From 629c87283fd8ceedae75f6d51326474526d00879 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 1 Oct 2019 12:59:11 -0700 Subject: [PATCH] 3/ Move touch interaction log to its own class Bug: 141886704 Change-Id: I5f27faf83ccacc2d2eb2914f15e860d07628c37c --- .../android/quickstep/BaseSwipeUpHandler.java | 4 +- .../quickstep/TouchInteractionService.java | 23 +++-------- .../WindowTransformSwipeHandler.java | 12 +++--- .../DeviceLockedInputConsumer.java | 2 +- .../OtherActivityInputConsumer.java | 8 ++-- .../inputconsumers/OverviewInputConsumer.java | 4 +- .../OverviewWithoutFocusInputConsumer.java | 4 +- .../quickstep/util/ActiveGestureLog.java | 39 +++++++++++++++++++ 8 files changed, 62 insertions(+), 34 deletions(-) create mode 100644 quickstep/recents_ui_overrides/src/com/android/quickstep/util/ActiveGestureLog.java diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java index 770857ba43..5d7d2ff6d8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandler.java @@ -25,7 +25,6 @@ import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TI import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.launcher3.views.FloatingIconView.SHAPE_PROGRESS_DURATION; -import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import android.animation.Animator; import android.annotation.TargetApi; @@ -60,6 +59,7 @@ import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.inputconsumers.InputConsumer; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.ActivityInitListener; import com.android.quickstep.util.AppWindowAnimationHelper; import com.android.quickstep.util.AppWindowAnimationHelper.TransformParams; @@ -253,7 +253,7 @@ public abstract class BaseSwipeUpHandler { public class TouchInteractionService extends Service implements NavigationModeChangeListener { - /** - * NOTE: This value should be kept same as - * ActivityTaskManagerService#INTENT_EXTRA_LOG_TRACE_ID in platform - */ - public static final String INTENT_EXTRA_LOG_TRACE_ID = "INTENT_EXTRA_LOG_TRACE_ID"; - - - public static final EventLogArray TOUCH_INTERACTION_LOG = - new EventLogArray("touch_interaction_log", 40); - private static final String TAG = "TouchInteractionService"; private static final String KEY_BACK_NOTIFICATION_COUNT = "backNotificationCount"; @@ -403,14 +393,14 @@ public class TouchInteractionService extends Service implements MotionEvent event = (MotionEvent) ev; if (event.getAction() == ACTION_DOWN) { - mLogId = TOUCH_INTERACTION_LOG.generateAndSetLogId(); + mLogId = ActiveGestureLog.INSTANCE.generateAndSetLogId(); sSwipeSharedState.setLogTraceId(mLogId); if (mDeviceState.isInSwipeUpTouchRegion(event)) { boolean useSharedState = mConsumer.useSharedSwipeState(); mConsumer.onConsumerAboutToBeSwitched(); mConsumer = newConsumer(useSharedState, event); - TOUCH_INTERACTION_LOG.addLog("setInputConsumer", mConsumer.getType()); + ActiveGestureLog.INSTANCE.addLog("setInputConsumer", mConsumer.getType()); mUncheckedConsumer = mConsumer; } else if (mDeviceState.isUserUnlocked() && mMode == Mode.NO_BUTTON && mDeviceState.canTriggerAssistantAction(event)) { @@ -426,7 +416,7 @@ public class TouchInteractionService extends Service implements } } - TOUCH_INTERACTION_LOG.addLog("onMotionEvent", event.getActionMasked()); + ActiveGestureLog.INSTANCE.addLog("onMotionEvent", event.getActionMasked()); mUncheckedConsumer.onMotionEvent(event); DejankBinderTracker.disallowBinderTrackingInTests(); } @@ -683,8 +673,7 @@ public class TouchInteractionService extends Service implements pw.println(" ENABLE_QUICKSTEP_LIVE_TILE=" + ENABLE_QUICKSTEP_LIVE_TILE.get()); pw.println(" ENABLE_HINTS_IN_OVERVIEW=" + ENABLE_HINTS_IN_OVERVIEW.get()); pw.println(" FAKE_LANDSCAPE_UI=" + FAKE_LANDSCAPE_UI.get()); - TOUCH_INTERACTION_LOG.dump("", pw); - + ActiveGestureLog.INSTANCE.dump("", pw); } } @@ -696,7 +685,7 @@ public class TouchInteractionService extends Service implements private void onCommand(PrintWriter pw, ArgList args) { switch (args.nextArg()) { case "clear-touch-log": - TOUCH_INTERACTION_LOG.clear(); + ActiveGestureLog.INSTANCE.clear(); break; } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index 5cf987ad6c..b0628e55df 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -29,7 +29,6 @@ import static com.android.launcher3.util.SystemUiController.UI_STATE_OVERVIEW; import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.HIDE; import static com.android.quickstep.ActivityControlHelper.AnimationFactory.ShelfAnimState.PEEK; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; -import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.HOME; import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.LAST_TASK; import static com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget.NEW_TASK; @@ -78,6 +77,7 @@ import com.android.quickstep.ActivityControlHelper.HomeAnimationFactory; import com.android.quickstep.SysUINavigationMode.Mode; import com.android.quickstep.inputconsumers.InputConsumer; import com.android.quickstep.inputconsumers.OverviewInputConsumer; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.AppWindowAnimationHelper.TargetAlphaProvider; import com.android.quickstep.util.RectFSpringAnim; import com.android.quickstep.util.RecentsAnimationTargets; @@ -609,7 +609,7 @@ public class WindowTransformSwipeHandler @Override public void onRecentsAnimationStart(RecentsAnimationTargets targetSet) { super.onRecentsAnimationStart(targetSet); - TOUCH_INTERACTION_LOG.addLog("startRecentsAnimationCallback", targetSet.apps.length); + ActiveGestureLog.INSTANCE.addLog("startRecentsAnimationCallback", targetSet.apps.length); setStateOnUiThread(STATE_APP_CONTROLLER_RECEIVED); mPassedOverviewThreshold = false; @@ -620,7 +620,7 @@ public class WindowTransformSwipeHandler mRecentsAnimationWrapper.setController(null); mActivityInitListener.unregister(); setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED); - TOUCH_INTERACTION_LOG.addLog("cancelRecentsAnimation"); + ActiveGestureLog.INSTANCE.addLog("cancelRecentsAnimation"); } @Override @@ -1019,7 +1019,7 @@ public class WindowTransformSwipeHandler @UiThread private void resumeLastTask() { mRecentsAnimationWrapper.finish(false /* toRecents */, null); - TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", false); + ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", false); doLogGesture(LAST_TASK); reset(); } @@ -1164,7 +1164,7 @@ public class WindowTransformSwipeHandler () -> setStateOnUiThread(STATE_CURRENT_TASK_FINISHED)); } } - TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", true); + ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); } private void finishCurrentTransitionToHome() { @@ -1173,7 +1173,7 @@ public class WindowTransformSwipeHandler () -> setStateOnUiThread(STATE_CURRENT_TASK_FINISHED), true /* sendUserLeaveHint */); } - TOUCH_INTERACTION_LOG.addLog("finishRecentsAnimation", true); + ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation", true); doLogGesture(HOME); } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java index ba2d6d133c..25b4fe4f15 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/DeviceLockedInputConsumer.java @@ -22,9 +22,9 @@ import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.Utilities.squaredTouchSlop; import static com.android.quickstep.MultiStateCallback.DEBUG_STATES; -import static com.android.quickstep.TouchInteractionService.INTENT_EXTRA_LOG_TRACE_ID; import static com.android.quickstep.TouchInteractionService.startRecentsActivityAsync; import static com.android.quickstep.WindowTransformSwipeHandler.MIN_PROGRESS_FOR_OVERVIEW; +import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; import android.content.ComponentName; import android.content.Context; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java index 6776e84d27..3e66d7b1a4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OtherActivityInputConsumer.java @@ -27,9 +27,8 @@ import static com.android.launcher3.Utilities.EDGE_NAV_BAR; import static com.android.launcher3.Utilities.squaredHypot; import static com.android.launcher3.util.RaceConditionTracker.ENTER; import static com.android.launcher3.util.RaceConditionTracker.EXIT; -import static com.android.quickstep.TouchInteractionService.INTENT_EXTRA_LOG_TRACE_ID; -import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.quickstep.TouchInteractionService.startRecentsActivityAsync; +import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.annotation.TargetApi; @@ -58,6 +57,7 @@ import com.android.quickstep.RecentsAnimationDeviceState; import com.android.quickstep.SwipeSharedState; import com.android.quickstep.SysUINavigationMode; import com.android.quickstep.SysUINavigationMode.Mode; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.CachedEventDispatcher; import com.android.quickstep.util.MotionPauseDetector; import com.android.quickstep.util.NavBarPosition; @@ -311,7 +311,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC } private void notifyGestureStarted() { - TOUCH_INTERACTION_LOG.addLog("startQuickstep"); + ActiveGestureLog.INSTANCE.addLog("startQuickstep"); if (mInteractionHandler == null) { return; } @@ -327,7 +327,7 @@ public class OtherActivityInputConsumer extends ContextWrapper implements InputC private void startTouchTrackingForWindowAnimation( long touchTimeMs, boolean isLikelyToStartNewTask) { - TOUCH_INTERACTION_LOG.addLog("startRecentsAnimation"); + ActiveGestureLog.INSTANCE.addLog("startRecentsAnimation"); RecentsAnimationCallbacks listenerSet = mSwipeSharedState.getActiveListener(); final BaseSwipeUpHandler handler = mHandlerFactory.newHandler(mRunningTask, touchTimeMs, diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java index 4857d00260..74e457c686 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewInputConsumer.java @@ -16,7 +16,6 @@ package com.android.quickstep.inputconsumers; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; -import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.view.KeyEvent; @@ -28,6 +27,7 @@ import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.Utilities; import com.android.launcher3.views.BaseDragLayer; import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.util.ActiveGestureLog; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputMonitorCompat; @@ -102,7 +102,7 @@ public class OverviewInputConsumer mActivityControlHelper.closeOverlay(); ActivityManagerWrapper.getInstance() .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); - TOUCH_INTERACTION_LOG.addLog("startQuickstep"); + ActiveGestureLog.INSTANCE.addLog("startQuickstep"); } if (mInputMonitor != null) { mInputMonitor.pilferPointers(); diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java index e11d492331..03e0ae77e5 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/inputconsumers/OverviewWithoutFocusInputConsumer.java @@ -21,7 +21,6 @@ import static android.view.MotionEvent.ACTION_MOVE; import static android.view.MotionEvent.ACTION_UP; import static com.android.launcher3.Utilities.squaredHypot; -import static com.android.quickstep.TouchInteractionService.TOUCH_INTERACTION_LOG; import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS; import android.content.Context; @@ -37,6 +36,7 @@ import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.quickstep.ActivityControlHelper; +import com.android.quickstep.util.ActiveGestureLog; import com.android.quickstep.util.NavBarPosition; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputMonitorCompat; @@ -151,7 +151,7 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer { mActivityControlHelper.closeOverlay(); ActivityManagerWrapper.getInstance() .closeSystemWindows(CLOSE_SYSTEM_WINDOWS_REASON_RECENTS); - TOUCH_INTERACTION_LOG.addLog("startQuickstep"); + ActiveGestureLog.INSTANCE.addLog("startQuickstep"); BaseActivity activity = BaseDraggingActivity.fromContext(mContext); int pageIndex = -1; // This number doesn't reflect workspace page index. // It only indicates that launcher client screen was shown. diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ActiveGestureLog.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ActiveGestureLog.java new file mode 100644 index 0000000000..9a3bb760f1 --- /dev/null +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/util/ActiveGestureLog.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.quickstep.util; + +import android.content.Context; + +import com.android.launcher3.logging.EventLogArray; +import com.android.launcher3.util.MainThreadInitializedObject; + +/** + * A log to keep track of the active gesture. + */ +public class ActiveGestureLog extends EventLogArray { + + public static final ActiveGestureLog INSTANCE = new ActiveGestureLog(); + + /** + * NOTE: This value should be kept same as + * ActivityTaskManagerService#INTENT_EXTRA_LOG_TRACE_ID in platform + */ + public static final String INTENT_EXTRA_LOG_TRACE_ID = "INTENT_EXTRA_LOG_TRACE_ID"; + + public ActiveGestureLog() { + super("touch_interaction_log", 40); + } +}