1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.quickstep.util; 17 18 import static android.view.MotionEvent.ACTION_DOWN; 19 20 import static com.android.launcher3.Flags.enableActiveGestureProtoLog; 21 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.CANCEL_RECENTS_ANIMATION; 22 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.FINISH_RECENTS_ANIMATION; 23 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.INVALID_VELOCITY_ON_SWIPE_UP; 24 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.LAUNCHER_DESTROYED; 25 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_DOWN; 26 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_MOVE; 27 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.MOTION_UP; 28 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.NAVIGATION_MODE_SWITCHED; 29 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_CANCEL_RECENTS_ANIMATION; 30 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_FINISH_RECENTS_ANIMATION; 31 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_SETTLED_ON_END_TARGET; 32 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.ON_START_RECENTS_ANIMATION; 33 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.QUICK_SWITCH_FROM_HOME_FAILED; 34 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.QUICK_SWITCH_FROM_HOME_FALLBACK; 35 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.RECENTS_ANIMATION_START_PENDING; 36 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.RECENT_TASKS_MISSING; 37 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.SET_END_TARGET; 38 import static com.android.quickstep.util.ActiveGestureErrorDetector.GestureEvent.START_RECENTS_ANIMATION; 39 import static com.android.quickstep.util.QuickstepProtoLogGroup.ACTIVE_GESTURE_LOG; 40 import static com.android.quickstep.util.QuickstepProtoLogGroup.isProtoLogInitialized; 41 42 import android.graphics.Point; 43 import android.graphics.RectF; 44 import android.view.MotionEvent; 45 46 import androidx.annotation.NonNull; 47 import androidx.annotation.Nullable; 48 49 import com.android.internal.protolog.ProtoLog; 50 import com.android.internal.protolog.common.IProtoLogGroup; 51 52 /** 53 * Proxy class used for ActiveGestureLog ProtoLog support. 54 * <p> 55 * This file will have all of its static strings in the 56 * {@link ProtoLog#d(IProtoLogGroup, String, Object...)} calls replaced by dynamic code/strings. 57 * <p> 58 * When a new ActiveGestureLog entry needs to be added to the codebase (or and existing entry needs 59 * to be modified), add it here under a new unique method and make sure the ProtoLog entry matches 60 * to avoid confusion. 61 */ 62 public class ActiveGestureProtoLogProxy { 63 logLauncherDestroyed()64 public static void logLauncherDestroyed() { 65 ActiveGestureLog.INSTANCE.addLog("Launcher destroyed", LAUNCHER_DESTROYED); 66 if (isProtoLogInitialized()) return; 67 ProtoLog.d(ACTIVE_GESTURE_LOG, "Launcher destroyed"); 68 } 69 logAbsSwipeUpHandlerOnRecentsAnimationCanceled()70 public static void logAbsSwipeUpHandlerOnRecentsAnimationCanceled() { 71 ActiveGestureLog.INSTANCE.addLog( 72 /* event= */ "AbsSwipeUpHandler.onRecentsAnimationCanceled", 73 /* gestureEvent= */ CANCEL_RECENTS_ANIMATION); 74 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 75 ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onRecentsAnimationCanceled"); 76 } 77 logAbsSwipeUpHandlerOnRecentsAnimationFinished()78 public static void logAbsSwipeUpHandlerOnRecentsAnimationFinished() { 79 ActiveGestureLog.INSTANCE.addLog( 80 /* event= */ "RecentsAnimationCallbacks.onAnimationFinished", 81 ON_FINISH_RECENTS_ANIMATION); 82 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 83 ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onAnimationFinished"); 84 } 85 logAbsSwipeUpHandlerCancelCurrentAnimation()86 public static void logAbsSwipeUpHandlerCancelCurrentAnimation() { 87 ActiveGestureLog.INSTANCE.addLog( 88 "AbsSwipeUpHandler.cancelCurrentAnimation", 89 ActiveGestureErrorDetector.GestureEvent.CANCEL_CURRENT_ANIMATION); 90 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 91 ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.cancelCurrentAnimation"); 92 } 93 logAbsSwipeUpHandlerOnTasksAppeared()94 public static void logAbsSwipeUpHandlerOnTasksAppeared() { 95 ActiveGestureLog.INSTANCE.addLog("AbsSwipeUpHandler.onTasksAppeared: " 96 + "force finish recents animation complete; clearing state callback."); 97 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 98 ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onTasksAppeared: " 99 + "force finish recents animation complete; clearing state callback."); 100 } 101 logHandOffAnimation()102 public static void logHandOffAnimation() { 103 ActiveGestureLog.INSTANCE.addLog("AbsSwipeUpHandler.handOffAnimation"); 104 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 105 ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.handOffAnimation"); 106 } 107 logFinishRecentsAnimationOnTasksAppeared()108 public static void logFinishRecentsAnimationOnTasksAppeared() { 109 ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimationOnTasksAppeared"); 110 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 111 ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimationOnTasksAppeared"); 112 } 113 logRecentsAnimationCallbacksOnAnimationCancelled()114 public static void logRecentsAnimationCallbacksOnAnimationCancelled() { 115 ActiveGestureLog.INSTANCE.addLog( 116 /* event= */ "RecentsAnimationCallbacks.onAnimationCanceled", 117 /* gestureEvent= */ ON_CANCEL_RECENTS_ANIMATION); 118 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 119 ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationCanceled"); 120 } 121 logRecentsAnimationCallbacksOnTasksAppeared()122 public static void logRecentsAnimationCallbacksOnTasksAppeared() { 123 ActiveGestureLog.INSTANCE.addLog("RecentsAnimationCallbacks.onTasksAppeared", 124 ActiveGestureErrorDetector.GestureEvent.TASK_APPEARED); 125 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 126 ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onTasksAppeared"); 127 } 128 logStartRecentsAnimation()129 public static void logStartRecentsAnimation() { 130 ActiveGestureLog.INSTANCE.addLog( 131 /* event= */ "TaskAnimationManager.startRecentsAnimation", 132 /* gestureEvent= */ START_RECENTS_ANIMATION); 133 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 134 ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager.startRecentsAnimation"); 135 } 136 logLaunchingSideTaskFailed()137 public static void logLaunchingSideTaskFailed() { 138 ActiveGestureLog.INSTANCE.addLog("Unable to launch side task (no recents)"); 139 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 140 ProtoLog.d(ACTIVE_GESTURE_LOG, "Unable to launch side task (no recents)"); 141 } 142 logContinueRecentsAnimation()143 public static void logContinueRecentsAnimation() { 144 ActiveGestureLog.INSTANCE.addLog(/* event= */ "continueRecentsAnimation"); 145 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 146 ProtoLog.d(ACTIVE_GESTURE_LOG, "continueRecentsAnimation"); 147 } 148 logCleanUpRecentsAnimationSkipped()149 public static void logCleanUpRecentsAnimationSkipped() { 150 ActiveGestureLog.INSTANCE.addLog( 151 /* event= */ "cleanUpRecentsAnimation skipped due to wrong callbacks"); 152 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 153 ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation skipped due to wrong callbacks"); 154 } 155 logCleanUpRecentsAnimation()156 public static void logCleanUpRecentsAnimation() { 157 ActiveGestureLog.INSTANCE.addLog(/* event= */ "cleanUpRecentsAnimation"); 158 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 159 ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation"); 160 } 161 logOnInputEventUserLocked(int displayId)162 public static void logOnInputEventUserLocked(int displayId) { 163 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 164 "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked", 165 displayId)); 166 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 167 ProtoLog.d(ACTIVE_GESTURE_LOG, 168 "TIS.onInputEvent(displayId=%d): Cannot process input event: user is locked", 169 displayId); 170 } 171 logOnInputIgnoringFollowingEvents(int displayId)172 public static void logOnInputIgnoringFollowingEvents(int displayId) { 173 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 174 "TIS.onMotionEvent(displayId=%d): A new gesture has been started, " 175 + "but a previously-requested recents animation hasn't started. " 176 + "Ignoring all following motion events.", displayId), 177 RECENTS_ANIMATION_START_PENDING); 178 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 179 ProtoLog.d(ACTIVE_GESTURE_LOG, 180 "TIS.onMotionEvent(displayId=%d): A new gesture has been started, " 181 + "but a previously-requested recents animation hasn't started. " 182 + "Ignoring all following motion events.", displayId); 183 } 184 logOnInputEventThreeButtonNav(int displayId)185 public static void logOnInputEventThreeButtonNav(int displayId) { 186 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 187 "TIS.onInputEvent(displayId=%d): Cannot process input event: " 188 + "using 3-button nav and event is not a trackpad event", displayId)); 189 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 190 ProtoLog.d(ACTIVE_GESTURE_LOG, 191 "TIS.onInputEvent(displayId=%d): Cannot process input event: " 192 + "using 3-button nav and event is not a trackpad event", displayId); 193 } 194 logPreloadRecentsAnimation()195 public static void logPreloadRecentsAnimation() { 196 ActiveGestureLog.INSTANCE.addLog("preloadRecentsAnimation"); 197 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 198 ProtoLog.d(ACTIVE_GESTURE_LOG, "preloadRecentsAnimation"); 199 } 200 logRecentTasksMissing()201 public static void logRecentTasksMissing() { 202 ActiveGestureLog.INSTANCE.addLog("Null mRecentTasks", RECENT_TASKS_MISSING); 203 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 204 ProtoLog.d(ACTIVE_GESTURE_LOG, "Null mRecentTasks"); 205 } 206 logExecuteHomeCommand()207 public static void logExecuteHomeCommand() { 208 ActiveGestureLog.INSTANCE.addLog("OverviewCommandHelper.executeCommand(HOME)"); 209 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 210 ProtoLog.d(ACTIVE_GESTURE_LOG, "OverviewCommandHelper.executeCommand(HOME)"); 211 } 212 logFinishRecentsAnimationCallback()213 public static void logFinishRecentsAnimationCallback() { 214 ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimation-callback"); 215 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 216 ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimation-callback"); 217 } 218 logOnScrollerAnimationAborted()219 public static void logOnScrollerAnimationAborted() { 220 ActiveGestureLog.INSTANCE.addLog("scroller animation aborted", 221 ActiveGestureErrorDetector.GestureEvent.SCROLLER_ANIMATION_ABORTED); 222 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 223 ProtoLog.d(ACTIVE_GESTURE_LOG, "scroller animation aborted"); 224 } 225 logInputConsumerBecameActive(@onNull String consumerName)226 public static void logInputConsumerBecameActive(@NonNull String consumerName) { 227 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 228 "%s became active", consumerName)); 229 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 230 ProtoLog.d(ACTIVE_GESTURE_LOG, "%s became active", consumerName); 231 } 232 logTaskLaunchFailed(int launchedTaskId)233 public static void logTaskLaunchFailed(int launchedTaskId) { 234 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 235 "Launch failed, task (id=%d) finished mid transition", launchedTaskId)); 236 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 237 ProtoLog.d(ACTIVE_GESTURE_LOG, 238 "Launch failed, task (id=%d) finished mid transition", launchedTaskId); 239 } 240 logOnPageEndTransition(int nextPageIndex)241 public static void logOnPageEndTransition(int nextPageIndex) { 242 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 243 "onPageEndTransition: current page index updated: %d", nextPageIndex)); 244 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 245 ProtoLog.d(ACTIVE_GESTURE_LOG, 246 "onPageEndTransition: current page index updated: %d", nextPageIndex); 247 } 248 logQuickSwitchFromHomeFallback(int taskIndex)249 public static void logQuickSwitchFromHomeFallback(int taskIndex) { 250 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 251 "Quick switch from home fallback case: The TaskView at index %d is missing.", 252 taskIndex), 253 QUICK_SWITCH_FROM_HOME_FALLBACK); 254 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 255 ProtoLog.d(ACTIVE_GESTURE_LOG, 256 "Quick switch from home fallback case: The TaskView at index %d is missing.", 257 taskIndex); 258 } 259 logQuickSwitchFromHomeFailed(int taskIndex)260 public static void logQuickSwitchFromHomeFailed(int taskIndex) { 261 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 262 "Quick switch from home failed: TaskViews at indices %d and 0 are missing.", 263 taskIndex), 264 QUICK_SWITCH_FROM_HOME_FAILED); 265 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 266 ProtoLog.d(ACTIVE_GESTURE_LOG, 267 "Quick switch from home failed: TaskViews at indices %d and 0 are missing.", 268 taskIndex); 269 } 270 logFinishRecentsAnimation(boolean toRecents)271 public static void logFinishRecentsAnimation(boolean toRecents) { 272 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 273 "finishRecentsAnimation: %b", toRecents), 274 /* gestureEvent= */ FINISH_RECENTS_ANIMATION); 275 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 276 ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimation: %b", toRecents); 277 } 278 logSetEndTarget(@onNull String target)279 public static void logSetEndTarget(@NonNull String target) { 280 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 281 "setEndTarget %s", target), /* gestureEvent= */ SET_END_TARGET); 282 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 283 ProtoLog.d(ACTIVE_GESTURE_LOG, "setEndTarget %s", target); 284 } 285 logStartHomeIntent(@onNull String reason)286 public static void logStartHomeIntent(@NonNull String reason) { 287 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 288 "OverviewComponentObserver.startHomeIntent: %s", reason)); 289 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 290 ProtoLog.d(ACTIVE_GESTURE_LOG, "OverviewComponentObserver.startHomeIntent: %s", reason); 291 } 292 logRunningTaskPackage(@onNull String packageName)293 public static void logRunningTaskPackage(@NonNull String packageName) { 294 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 295 "Current running task package name=%s", packageName)); 296 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 297 ProtoLog.d(ACTIVE_GESTURE_LOG, "Current running task package name=%s", packageName); 298 } 299 logSysuiStateFlags(@onNull String stateFlags)300 public static void logSysuiStateFlags(@NonNull String stateFlags) { 301 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 302 "Current SystemUi state flags=%s", stateFlags)); 303 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 304 ProtoLog.d(ACTIVE_GESTURE_LOG, "Current SystemUi state flags=%s", stateFlags); 305 } 306 logSetInputConsumer(@onNull String consumerName, @NonNull String reason)307 public static void logSetInputConsumer(@NonNull String consumerName, @NonNull String reason) { 308 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 309 "setInputConsumer: %s. reason(s):%s", consumerName, reason)); 310 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 311 ProtoLog.d(ACTIVE_GESTURE_LOG, 312 "setInputConsumer: %s. reason(s):%s", consumerName, reason); 313 } 314 logUpdateGestureStateRunningTask( @onNull String otherTaskPackage, @NonNull String runningTaskPackage)315 public static void logUpdateGestureStateRunningTask( 316 @NonNull String otherTaskPackage, @NonNull String runningTaskPackage) { 317 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 318 "Changing active task to %s because the previous task running on top of this " 319 + "one (%s) was excluded from recents", 320 otherTaskPackage, 321 runningTaskPackage)); 322 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 323 ProtoLog.d(ACTIVE_GESTURE_LOG, 324 "Changing active task to %s because the previous task running on top of this " 325 + "one (%s) was excluded from recents", 326 otherTaskPackage, 327 runningTaskPackage); 328 } 329 logOnInputEventActionUp( int x, int y, int action, @NonNull String classification, int displayId)330 public static void logOnInputEventActionUp( 331 int x, int y, int action, @NonNull String classification, int displayId) { 332 String actionString = MotionEvent.actionToString(action); 333 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 334 "onMotionEvent(%d, %d): %s, %s, displayId=%d", 335 x, 336 y, 337 actionString, 338 classification, 339 displayId), 340 /* gestureEvent= */ action == ACTION_DOWN 341 ? MOTION_DOWN 342 : MOTION_UP); 343 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 344 ProtoLog.d(ACTIVE_GESTURE_LOG, 345 "onMotionEvent(%d, %d): %s, %s, displayId=%d", 346 x, 347 y, 348 actionString, 349 classification, 350 displayId); 351 } 352 logOnInputEventActionMove( @onNull String action, @NonNull String classification, int pointerCount, int displayId)353 public static void logOnInputEventActionMove( 354 @NonNull String action, 355 @NonNull String classification, 356 int pointerCount, 357 int displayId) { 358 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 359 "onMotionEvent: %s, %s, pointerCount: %d, displayId=%d", 360 action, 361 classification, 362 pointerCount, 363 displayId), 364 MOTION_MOVE); 365 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 366 ProtoLog.d(ACTIVE_GESTURE_LOG, 367 "onMotionEvent: %s, %s, pointerCount: %d, displayId=%d", 368 action, 369 classification, 370 pointerCount, 371 displayId); 372 } 373 logOnInputEventGenericAction( @onNull String action, @NonNull String classification, int displayId)374 public static void logOnInputEventGenericAction( 375 @NonNull String action, @NonNull String classification, int displayId) { 376 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 377 "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId)); 378 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 379 ProtoLog.d(ACTIVE_GESTURE_LOG, 380 "onMotionEvent: %s, %s, displayId=%d", action, classification, displayId); 381 } 382 logOnInputEventNavModeSwitched( int displayId, @NonNull String startNavMode, @NonNull String currentNavMode)383 public static void logOnInputEventNavModeSwitched( 384 int displayId, @NonNull String startNavMode, @NonNull String currentNavMode) { 385 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 386 "TIS.onInputEvent(displayId=%d): Navigation mode switched mid-gesture (%s -> %s); " 387 + "cancelling gesture.", 388 displayId, 389 startNavMode, 390 currentNavMode), 391 NAVIGATION_MODE_SWITCHED); 392 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 393 ProtoLog.d(ACTIVE_GESTURE_LOG, 394 "TIS.onInputEvent(displayId=%d): Navigation mode switched mid-gesture (%s -> %s); " 395 + "cancelling gesture.", 396 displayId, 397 startNavMode, 398 currentNavMode); 399 } 400 logUnknownInputEvent(int displayId, @NonNull String event)401 public static void logUnknownInputEvent(int displayId, @NonNull String event) { 402 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 403 "TIS.onInputEvent(displayId=%d): Cannot process input event: " 404 + "received unknown event %s", displayId, event)); 405 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 406 ProtoLog.d(ACTIVE_GESTURE_LOG, 407 "TIS.onInputEvent(displayId=%d): Cannot process input event: " 408 + "received unknown event %s", displayId, event); 409 } 410 logFinishRunningRecentsAnimation(boolean toHome)411 public static void logFinishRunningRecentsAnimation(boolean toHome) { 412 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 413 "finishRunningRecentsAnimation: %b", toHome)); 414 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 415 ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRunningRecentsAnimation: %b", toHome); 416 } 417 logOnRecentsAnimationStartCancelled()418 public static void logOnRecentsAnimationStartCancelled() { 419 ActiveGestureLog.INSTANCE.addLog("RecentsAnimationCallbacks.onAnimationStart (canceled): 0", 420 /* gestureEvent= */ ON_START_RECENTS_ANIMATION); 421 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 422 ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationStart (canceled): 0"); 423 } 424 logOnRecentsAnimationStart(int appCount)425 public static void logOnRecentsAnimationStart(int appCount) { 426 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 427 "RecentsAnimationCallbacks.onAnimationStart: %d", appCount), 428 /* gestureEvent= */ ON_START_RECENTS_ANIMATION); 429 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 430 ProtoLog.d(ACTIVE_GESTURE_LOG, 431 "RecentsAnimationCallbacks.onAnimationStart: %d", appCount); 432 } 433 logStartRecentsAnimationCallback(@onNull String callback)434 public static void logStartRecentsAnimationCallback(@NonNull String callback) { 435 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 436 "TaskAnimationManager.startRecentsAnimation(%s): " 437 + "Setting mRecentsAnimationStartPending = false", 438 callback)); 439 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 440 ProtoLog.d(ACTIVE_GESTURE_LOG, 441 "TaskAnimationManager.startRecentsAnimation(%s): " 442 + "Setting mRecentsAnimationStartPending = false", 443 callback); 444 } 445 logSettingRecentsAnimationStartPending(boolean value)446 public static void logSettingRecentsAnimationStartPending(boolean value) { 447 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 448 "TaskAnimationManager.startRecentsAnimation: " 449 + "Setting mRecentsAnimationStartPending = %b", 450 value)); 451 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 452 ProtoLog.d(ACTIVE_GESTURE_LOG, 453 "TaskAnimationManager.startRecentsAnimation: " 454 + "Setting mRecentsAnimationStartPending = %b", 455 value); 456 } 457 logLaunchingSideTask(int taskId)458 public static void logLaunchingSideTask(int taskId) { 459 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 460 "Launching side task id=%d", taskId)); 461 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 462 ProtoLog.d(ACTIVE_GESTURE_LOG, "Launching side task id=%d", taskId); 463 } 464 logOnInputEventActionDown( int displayId, @NonNull ActiveGestureLog.CompoundString reason)465 public static void logOnInputEventActionDown( 466 int displayId, @NonNull ActiveGestureLog.CompoundString reason) { 467 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 468 "TIS.onMotionEvent(displayId=%d): ", displayId).append(reason)); 469 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 470 ProtoLog.d(ACTIVE_GESTURE_LOG, 471 "TIS.onMotionEvent(displayId=%d): %s", displayId, reason.toString()); 472 } 473 logStartNewTask(@onNull ActiveGestureLog.CompoundString tasks)474 public static void logStartNewTask(@NonNull ActiveGestureLog.CompoundString tasks) { 475 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 476 "Launching task: ").append(tasks)); 477 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 478 ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: %s", tasks.toString()); 479 } 480 logMotionPauseDetectorEvent(@onNull ActiveGestureLog.CompoundString event)481 public static void logMotionPauseDetectorEvent(@NonNull ActiveGestureLog.CompoundString event) { 482 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 483 "MotionPauseDetector: ").append(event)); 484 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 485 ProtoLog.d(ACTIVE_GESTURE_LOG, "MotionPauseDetector: %s", event.toString()); 486 } 487 logHandleTaskAppearedFailed( @onNull ActiveGestureLog.CompoundString reason)488 public static void logHandleTaskAppearedFailed( 489 @NonNull ActiveGestureLog.CompoundString reason) { 490 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 491 "handleTaskAppeared check failed: ").append(reason)); 492 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 493 ProtoLog.d(ACTIVE_GESTURE_LOG, "handleTaskAppeared check failed: %s", reason.toString()); 494 } 495 496 /** 497 * This is for special cases where the string is purely dynamic and therefore has no format that 498 * can be extracted. Do not use in any other case. 499 */ logDynamicString( @onNull String string, @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent)500 public static void logDynamicString( 501 @NonNull String string, 502 @Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) { 503 ActiveGestureLog.INSTANCE.addLog(string, gestureEvent); 504 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 505 ProtoLog.d(ACTIVE_GESTURE_LOG, "%s", string); 506 } 507 logOnSettledOnEndTarget(@onNull String endTarget)508 public static void logOnSettledOnEndTarget(@NonNull String endTarget) { 509 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 510 "onSettledOnEndTarget %s", endTarget), 511 /* gestureEvent= */ ON_SETTLED_ON_END_TARGET); 512 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 513 ProtoLog.d(ACTIVE_GESTURE_LOG, "onSettledOnEndTarget %s", endTarget); 514 } 515 logOnCalculateEndTarget(float velocityX, float velocityY, double angle)516 public static void logOnCalculateEndTarget(float velocityX, float velocityY, double angle) { 517 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 518 "calculateEndTarget: velocities=(x=%fdp/ms, y=%fdp/ms), angle=%f", 519 velocityX, 520 velocityY, 521 angle), 522 velocityX == 0 && velocityY == 0 ? INVALID_VELOCITY_ON_SWIPE_UP : null); 523 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 524 ProtoLog.d(ACTIVE_GESTURE_LOG, 525 "calculateEndTarget: velocities=(x=%fdp/ms, y=%fdp/ms), angle=%f", 526 velocityX, 527 velocityY, 528 angle); 529 } 530 logUnexpectedTaskAppeared(int taskId, @NonNull String packageName)531 public static void logUnexpectedTaskAppeared(int taskId, @NonNull String packageName) { 532 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 533 "Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s", 534 taskId, 535 packageName)); 536 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 537 ProtoLog.d(ACTIVE_GESTURE_LOG, 538 "Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s", 539 taskId, 540 packageName); 541 } 542 logCreateTouchRegionForDisplay(int displayRotation, @NonNull Point displaySize, @NonNull RectF swipeRegion, @NonNull RectF ohmRegion, int gesturalHeight, int largerGesturalHeight, @NonNull String reason)543 public static void logCreateTouchRegionForDisplay(int displayRotation, 544 @NonNull Point displaySize, @NonNull RectF swipeRegion, @NonNull RectF ohmRegion, 545 int gesturalHeight, int largerGesturalHeight, @NonNull String reason) { 546 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 547 ProtoLog.d(ACTIVE_GESTURE_LOG, 548 "OrientationTouchTransformer.createRegionForDisplay: " 549 + "dispRot=%d, dispSize=%s, swipeRegion=%s, ohmRegion=%s, " 550 + "gesturalHeight=%d, largerGesturalHeight=%d, reason=%s", 551 displayRotation, displaySize.flattenToString(), swipeRegion.toShortString(), 552 ohmRegion.toShortString(), gesturalHeight, largerGesturalHeight, reason); 553 } 554 logOnTaskAnimationManagerNotAvailable(int displayId)555 public static void logOnTaskAnimationManagerNotAvailable(int displayId) { 556 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 557 "TaskAnimationManager not available for displayId=%d", 558 displayId)); 559 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 560 ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager not available for displayId=%d", 561 displayId); 562 } 563 logGestureStartSwipeHandler(@onNull String interactionHandler)564 public static void logGestureStartSwipeHandler(@NonNull String interactionHandler) { 565 ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString( 566 "OtherActivityInputConsumer.startTouchTrackingForWindowAnimation: " 567 + "interactionHandler=%s", interactionHandler)); 568 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 569 ProtoLog.d(ACTIVE_GESTURE_LOG, 570 "OtherActivityInputConsumer.startTouchTrackingForWindowAnimation: " 571 + "interactionHandler=%s", interactionHandler); 572 } 573 logQueuingForceFinishRecentsAnimation()574 public static void logQueuingForceFinishRecentsAnimation() { 575 ActiveGestureLog.INSTANCE.addLog("Launcher destroyed while mRecentsAnimationStartPending ==" 576 + " true, queuing a callback to clean the pending animation up on start", 577 /* gestureEvent= */ ON_START_RECENTS_ANIMATION); 578 if (!enableActiveGestureProtoLog() || !isProtoLogInitialized()) return; 579 ProtoLog.d(ACTIVE_GESTURE_LOG, "Launcher destroyed while mRecentsAnimationStartPending ==" 580 + " true, queuing a callback to clean the pending animation up on start"); 581 } 582 } 583