Refactor CompoundString to use a string-format API matching ProtoLog

Flag: com.android.launcher3.enable_active_gesture_proto_log
Bug: 293182501
Test: checked TIS logs
Change-Id: I6728697f659ed3617169a41e524ab93a587b6e75
This commit is contained in:
Schneider Victor-Tulias
2024-09-21 11:22:10 -04:00
committed by Schneider Victor-tulias
parent e3dc1c5185
commit 688bc453cd
5 changed files with 286 additions and 409 deletions
@@ -1201,11 +1201,9 @@ public abstract class AbsSwipeUpHandler<
failureReason.append("STATE_START_NEW_TASK was never set");
} else {
TaskInfo taskInfo = appearedTaskTargets[0].taskInfo;
failureReason.append("Unexpected task appeared")
.append(" id=")
.append(taskInfo.taskId)
.append(" pkg=")
.append(taskInfo.baseIntent.getComponent().getPackageName());
failureReason.append("Unexpected task appeared id=%d, pkg=%s",
taskInfo.taskId,
taskInfo.baseIntent.getComponent().getPackageName());
}
return false;
}
@@ -2274,18 +2272,15 @@ public abstract class AbsSwipeUpHandler<
TaskView nextTask = mRecentsView == null ? null : mRecentsView.getNextPageTaskView();
if (nextTask != null) {
int[] taskIds = nextTask.getTaskIds();
ActiveGestureLog.CompoundString nextTaskLog = new ActiveGestureLog.CompoundString(
"Launching task: ");
ActiveGestureLog.CompoundString nextTaskLog =
ActiveGestureLog.CompoundString.newEmptyString();
for (TaskContainer container : nextTask.getTaskContainers()) {
if (container == null) {
continue;
}
nextTaskLog
.append("[id: ")
.append(container.getTask().key.id)
.append(", pkg: ")
.append(container.getTask().key.getPackageName())
.append("] | ");
nextTaskLog.append("[id: %d, pkg: %s] | ",
container.getTask().key.id,
container.getTask().key.getPackageName());
}
mGestureState.updateLastStartedTaskIds(taskIds);
boolean hasTaskPreviouslyAppeared = Arrays.stream(taskIds).anyMatch(
@@ -2294,7 +2289,7 @@ public abstract class AbsSwipeUpHandler<
if (!hasTaskPreviouslyAppeared) {
ActiveGestureLog.INSTANCE.trackEvent(EXPECTING_TASK_APPEARED);
}
ActiveGestureProtoLogProxy.logDynamicString(nextTaskLog.toString());
ActiveGestureProtoLogProxy.logStartNewTask(nextTaskLog);
nextTask.launchWithoutAnimation(true, success -> {
resultCallback.accept(success);
if (success) {
@@ -2375,8 +2370,8 @@ public abstract class AbsSwipeUpHandler<
ActiveGestureProtoLogProxy.logAbsSwipeUpHandlerOnTasksAppeared();
mStateCallback.setStateOnUiThread(STATE_GESTURE_CANCELLED | STATE_HANDLER_INVALIDATED);
};
ActiveGestureLog.CompoundString forceFinishReason = new ActiveGestureLog.CompoundString(
"Forcefully finishing recents animation: ");
ActiveGestureLog.CompoundString forceFinishReason =
ActiveGestureLog.CompoundString.newEmptyString();
if (!mStateCallback.hasStates(STATE_GESTURE_COMPLETED)
&& !hasStartedTaskBefore(appearedTaskTargets)) {
// This is a special case, if a task is started mid-gesture that wasn't a part of a
@@ -2390,10 +2385,10 @@ public abstract class AbsSwipeUpHandler<
return;
}
ActiveGestureLog.CompoundString handleTaskFailureReason =
new ActiveGestureLog.CompoundString("handleTaskAppeared check failed: ");
ActiveGestureLog.CompoundString.newEmptyString();
if (!handleTaskAppeared(appearedTaskTargets, handleTaskFailureReason)) {
forceFinishReason.append(handleTaskFailureReason);
ActiveGestureProtoLogProxy.logDynamicString(forceFinishReason.toString());
ActiveGestureProtoLogProxy.logHandleTaskAppearedFailed(forceFinishReason);
finishRecentsAnimationOnTasksAppeared(onFinishComplete);
return;
}
@@ -2402,7 +2397,7 @@ public abstract class AbsSwipeUpHandler<
.toArray(RemoteAnimationTarget[]::new);
if (taskTargets.length == 0) {
forceFinishReason.append("No appeared task matching started task id");
ActiveGestureProtoLogProxy.logDynamicString(forceFinishReason.toString());
ActiveGestureProtoLogProxy.logHandleTaskAppearedFailed(forceFinishReason);
finishRecentsAnimationOnTasksAppeared(onFinishComplete);
return;
}
@@ -2412,13 +2407,13 @@ public abstract class AbsSwipeUpHandler<
if (taskView == null || taskView.getTaskContainers().stream().noneMatch(
TaskContainer::getShouldShowSplashView)) {
forceFinishReason.append("Splash not needed");
ActiveGestureProtoLogProxy.logDynamicString(forceFinishReason.toString());
ActiveGestureProtoLogProxy.logHandleTaskAppearedFailed(forceFinishReason);
finishRecentsAnimationOnTasksAppeared(onFinishComplete);
return;
}
if (mContainer == null) {
forceFinishReason.append("Activity destroyed");
ActiveGestureProtoLogProxy.logDynamicString(forceFinishReason.toString());
ActiveGestureProtoLogProxy.logHandleTaskAppearedFailed(forceFinishReason);
finishRecentsAnimationOnTasksAppeared(onFinishComplete);
return;
}
@@ -911,7 +911,7 @@ public class TouchInteractionService extends Service {
SafeCloseable traceToken = TraceHelper.INSTANCE.allowIpcs("TIS.onInputEvent");
CompoundString reasonString = action == ACTION_DOWN
? new CompoundString("TIS.onMotionEvent: ") : CompoundString.NO_OP;
? CompoundString.newEmptyString() : CompoundString.NO_OP;
if (action == ACTION_DOWN || isHoverActionWithoutConsumer) {
mRotationTouchHelper.setOrientationTransformIfNeeded(event);
@@ -929,22 +929,22 @@ public class TouchInteractionService extends Service {
reasonString.append("in three button mode which supports Assistant gesture");
// Consume gesture event for Assistant (all other gestures should do nothing).
if (mDeviceState.canTriggerAssistantAction(event)) {
reasonString.append(" and event can trigger assistant action")
.append(", consuming gesture for assistant action");
reasonString.append(" and event can trigger assistant action, "
+ "consuming gesture for assistant action");
mGestureState =
createGestureState(mGestureState, getTrackpadGestureType(event));
mUncheckedConsumer = tryCreateAssistantInputConsumer(mGestureState, event);
} else {
reasonString.append(" but event cannot trigger Assistant")
.append(", consuming gesture as no-op");
reasonString.append(" but event cannot trigger Assistant, "
+ "consuming gesture as no-op");
mUncheckedConsumer = InputConsumer.NO_OP;
}
} else if ((!isOneHandedModeActive && isInSwipeUpTouchRegion)
|| isHoverActionWithoutConsumer || isOnBubbles) {
reasonString.append(!isOneHandedModeActive && isInSwipeUpTouchRegion
? "one handed mode is not active and event is in swipe up region"
: "isHoverActionWithoutConsumer == true")
.append(", creating new input consumer");
? "one handed mode is not active and event is in swipe up region, "
+ "creating new input consumer"
: "isHoverActionWithoutConsumer == true, creating new input consumer");
// Clone the previous gesture state since onConsumerAboutToBeSwitched might trigger
// onConsumerInactive and wipe the previous gesture state
GestureState prevGestureState = new GestureState(mGestureState);
@@ -957,18 +957,18 @@ public class TouchInteractionService extends Service {
} else if ((mDeviceState.isFullyGesturalNavMode() || isTrackpadMultiFingerSwipe(event))
&& mDeviceState.canTriggerAssistantAction(event)) {
reasonString.append(mDeviceState.isFullyGesturalNavMode()
? "using fully gestural nav"
: "event is a trackpad multi-finger swipe")
.append(" and event can trigger assistant action")
.append(", consuming gesture for assistant action");
? "using fully gestural nav and event can trigger assistant action, "
+ "consuming gesture for assistant action"
: "event is a trackpad multi-finger swipe and event can trigger assistant "
+ "action, consuming gesture for assistant action");
mGestureState = createGestureState(mGestureState, getTrackpadGestureType(event));
// Do not change mConsumer as if there is an ongoing QuickSwitch gesture, we
// should not interrupt it. QuickSwitch assumes that interruption can only
// happen if the next gesture is also quick switch.
mUncheckedConsumer = tryCreateAssistantInputConsumer(mGestureState, event);
} else if (mDeviceState.canTriggerOneHandedAction(event)) {
reasonString.append("event can trigger one-handed action")
.append(", consuming gesture for one-handed action");
reasonString.append("event can trigger one-handed action, "
+ "consuming gesture for one-handed action");
// Consume gesture event for triggering one handed feature.
mUncheckedConsumer = new OneHandedModeInputConsumer(this, mDeviceState,
InputConsumer.NO_OP, mInputMonitorCompat);
@@ -986,7 +986,7 @@ public class TouchInteractionService extends Service {
if (mUncheckedConsumer != InputConsumer.NO_OP) {
switch (action) {
case ACTION_DOWN:
ActiveGestureProtoLogProxy.logDynamicString(reasonString.toString());
ActiveGestureProtoLogProxy.logOnInputEventActionDown(reasonString);
// fall through
case ACTION_UP:
ActiveGestureProtoLogProxy.logOnInputEventActionUp(
@@ -1059,11 +1059,11 @@ public class TouchInteractionService extends Service {
MotionEvent motionEvent,
CompoundString reasonString) {
if (mDeviceState.isGestureBlockedTask(gestureState.getRunningTask())) {
reasonString.append(SUBSTRING_PREFIX)
.append("is gesture-blocked task, using base input consumer");
reasonString.append(
"%sis gesture-blocked task, using base input consumer", SUBSTRING_PREFIX);
return base;
} else {
reasonString.append(SUBSTRING_PREFIX).append("using AssistantInputConsumer");
reasonString.append("%susing AssistantInputConsumer", SUBSTRING_PREFIX);
return new AssistantInputConsumer(
this, gestureState, base, mInputMonitorCompat, mDeviceState, motionEvent);
}
@@ -1132,12 +1132,11 @@ public class TouchInteractionService extends Service {
// This handles apps launched in direct boot mode (e.g. dialer) as well as apps
// launched while device is locked even after exiting direct boot mode (e.g. camera).
consumer = createDeviceLockedInputConsumer(
newGestureState, reasonString.append(SUBSTRING_PREFIX)
.append("can start system gesture"));
newGestureState,
reasonString.append("%scan start system gesture", SUBSTRING_PREFIX));
} else {
consumer = getDefaultInputConsumer(
reasonString.append(SUBSTRING_PREFIX)
.append("cannot start system gesture"));
reasonString.append("%scannot start system gesture", SUBSTRING_PREFIX));
}
logInputConsumerSelectionReason(consumer, reasonString);
return consumer;
@@ -1149,13 +1148,12 @@ public class TouchInteractionService extends Service {
// a followup gesture and the first gesture started in a valid system state.
if (canStartSystemGesture || previousGestureState.isRecentsAnimationRunning()) {
reasonString = newCompoundString(canStartSystemGesture
? "can start system gesture" : "recents animation was running")
.append(", trying to use base consumer");
? "can start system gesture, trying to use base consumer"
: "recents animation was running, trying to use base consumer");
base = newBaseConsumer(previousGestureState, newGestureState, event, reasonString);
} else {
reasonString = newCompoundString(
"cannot start system gesture and recents animation was not running")
.append(", trying to use default input consumer");
reasonString = newCompoundString("cannot start system gesture and recents "
+ "animation was not running, trying to use default input consumer");
base = getDefaultInputConsumer(reasonString);
}
if (mDeviceState.isGesturalNavMode() || newGestureState.isTrackpadGesture()) {
@@ -1165,11 +1163,11 @@ public class TouchInteractionService extends Service {
String reasonPrefix =
"device is in gesture navigation mode or 3-button mode with a trackpad gesture";
if (mDeviceState.canTriggerAssistantAction(event)) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("gesture can trigger the assistant")
.append(", trying to use assistant input consumer");
reasonString.append("%s%s%sgesture can trigger the assistant, "
+ "trying to use assistant input consumer",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
base = tryCreateAssistantInputConsumer(base, newGestureState, event, reasonString);
}
@@ -1180,11 +1178,11 @@ public class TouchInteractionService extends Service {
&& !tac.isPhoneMode()
&& !tac.isInStashedLauncherState();
if (canStartSystemGesture && useTaskbarConsumer) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("TaskbarActivityContext != null, ")
.append("using TaskbarUnstashInputConsumer");
reasonString.append("%s%s%sTaskbarActivityContext != null, "
+ "using TaskbarUnstashInputConsumer",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
base = new TaskbarUnstashInputConsumer(this, base, mInputMonitorCompat, tac,
mOverviewCommandHelper, mGestureState);
}
@@ -1193,9 +1191,9 @@ public class TouchInteractionService extends Service {
// Create bubbles input consumer before NavHandleLongPressInputConsumer.
// This allows for nav handle to fall back to bubbles.
if (mDeviceState.isBubblesExpanded()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("bubbles expanded, trying to use default input consumer");
reasonString = newCompoundString(reasonPrefix).append(
"%sbubbles expanded, trying to use default input consumer",
SUBSTRING_PREFIX);
// Bubbles can handle home gesture itself.
base = getDefaultInputConsumer(reasonString);
}
@@ -1206,10 +1204,10 @@ public class TouchInteractionService extends Service {
if (canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()
&& navHandle.canNavHandleBeLongPressed()
&& !ignoreThreeFingerTrackpadForNavHandleLongPress(mGestureState)) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("Not running recents animation, ");
reasonString.append("%s%s%sNot running recents animation, ",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
if (tac != null && tac.getNavHandle().canNavHandleBeLongPressed()) {
reasonString.append("stashed handle is long-pressable, ");
}
@@ -1221,74 +1219,74 @@ public class TouchInteractionService extends Service {
if (!enableBubblesLongPressNavHandle()) {
// Continue overriding nav handle input consumer with bubbles
if (mDeviceState.isBubblesExpanded()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("bubbles expanded, trying to use default input consumer");
reasonString = newCompoundString(reasonPrefix).append(
"%sbubbles expanded, trying to use default input consumer",
SUBSTRING_PREFIX);
// Bubbles can handle home gesture itself.
base = getDefaultInputConsumer(reasonString);
}
}
if (mDeviceState.isSystemUiDialogShowing()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("system dialog is showing, using SysUiOverlayInputConsumer");
reasonString = newCompoundString(reasonPrefix).append(
"%ssystem dialog is showing, using SysUiOverlayInputConsumer",
SUBSTRING_PREFIX);
base = new SysUiOverlayInputConsumer(
getBaseContext(), mDeviceState, mInputMonitorCompat);
}
if (mGestureState.isTrackpadGesture()
&& canStartSystemGesture && !previousGestureState.isRecentsAnimationRunning()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("Trackpad 3-finger gesture, using TrackpadStatusBarInputConsumer");
reasonString = newCompoundString(reasonPrefix).append(
"%sTrackpad 3-finger gesture, using TrackpadStatusBarInputConsumer",
SUBSTRING_PREFIX);
base = new TrackpadStatusBarInputConsumer(getBaseContext(), base,
mInputMonitorCompat);
}
if (mDeviceState.isScreenPinningActive()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("screen pinning is active, using ScreenPinnedInputConsumer");
reasonString = newCompoundString(reasonPrefix).append(
"%sscreen pinning is active, using ScreenPinnedInputConsumer",
SUBSTRING_PREFIX);
// Note: we only allow accessibility to wrap this, and it replaces the previous
// base input consumer (which should be NO_OP anyway since topTaskLocked == true).
base = new ScreenPinnedInputConsumer(this, newGestureState);
}
if (mDeviceState.canTriggerOneHandedAction(event)) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("gesture can trigger one handed mode")
.append(", using OneHandedModeInputConsumer");
reasonString.append("%s%s%sgesture can trigger one handed mode, "
+ "using OneHandedModeInputConsumer",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
base = new OneHandedModeInputConsumer(
this, mDeviceState, base, mInputMonitorCompat);
}
if (mDeviceState.isAccessibilityMenuAvailable()) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("accessibility menu is available")
.append(", using AccessibilityInputConsumer");
reasonString.append(
"%s%s%saccessibility menu is available, using AccessibilityInputConsumer",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
base = new AccessibilityInputConsumer(
this, mDeviceState, mGestureState, base, mInputMonitorCompat);
}
} else {
String reasonPrefix = "device is not in gesture navigation mode";
if (mDeviceState.isScreenPinningActive()) {
reasonString = newCompoundString(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("screen pinning is active, trying to use default input consumer");
reasonString = newCompoundString(reasonPrefix).append(
"%sscreen pinning is active, trying to use default input consumer",
SUBSTRING_PREFIX);
base = getDefaultInputConsumer(reasonString);
}
if (mDeviceState.canTriggerOneHandedAction(event)) {
reasonString.append(NEWLINE_PREFIX)
.append(reasonPrefix)
.append(SUBSTRING_PREFIX)
.append("gesture can trigger one handed mode")
.append(", using OneHandedModeInputConsumer");
reasonString.append("%s%s%sgesture can trigger one handed mode, "
+ "using OneHandedModeInputConsumer",
NEWLINE_PREFIX,
reasonPrefix,
SUBSTRING_PREFIX);
base = new OneHandedModeInputConsumer(
this, mDeviceState, base, mInputMonitorCompat);
}
@@ -1298,7 +1296,7 @@ public class TouchInteractionService extends Service {
}
private CompoundString newCompoundString(String substring) {
return new CompoundString(NEWLINE_PREFIX).append(substring);
return new CompoundString("%s%s", NEWLINE_PREFIX, substring);
}
private boolean ignoreThreeFingerTrackpadForNavHandleLongPress(GestureState gestureState) {
@@ -1325,14 +1323,12 @@ public class TouchInteractionService extends Service {
CompoundString reasonString) {
if (mDeviceState.isKeyguardShowingOccluded()) {
// This handles apps showing over the lockscreen (e.g. camera)
return createDeviceLockedInputConsumer(
gestureState,
reasonString.append(SUBSTRING_PREFIX)
.append("keyguard is showing occluded")
.append(", trying to use device locked input consumer"));
return createDeviceLockedInputConsumer(gestureState, reasonString.append(
"%skeyguard is showing occluded, trying to use device locked input consumer",
SUBSTRING_PREFIX));
}
reasonString.append(SUBSTRING_PREFIX).append("keyguard is not showing occluded");
reasonString.append("%skeyguard is not showing occluded", SUBSTRING_PREFIX);
TopTaskTracker.CachedTaskInfo runningTask = gestureState.getRunningTask();
// Use overview input consumer for sharesheets on top of home.
@@ -1373,11 +1369,12 @@ public class TouchInteractionService extends Service {
gestureState,
event,
forceOverviewInputConsumer,
reasonString.append(SUBSTRING_PREFIX)
.append("is in live tile mode, trying to use overview input consumer"));
reasonString.append(
"%sis in live tile mode, trying to use overview input consumer",
SUBSTRING_PREFIX));
} else if (runningTask == null) {
return getDefaultInputConsumer(reasonString.append(SUBSTRING_PREFIX)
.append("running task == null"));
return getDefaultInputConsumer(reasonString.append(
"%srunning task == null", SUBSTRING_PREFIX));
} else if (previousGestureAnimatedToLauncher
|| launcherResumedThroughShellTransition
|| forceOverviewInputConsumer) {
@@ -1386,21 +1383,22 @@ public class TouchInteractionService extends Service {
gestureState,
event,
forceOverviewInputConsumer,
reasonString.append(SUBSTRING_PREFIX)
.append(previousGestureAnimatedToLauncher
? "previous gesture animated to launcher"
reasonString.append(previousGestureAnimatedToLauncher
? "%sprevious gesture animated to launcher, "
+ "trying to use overview input consumer"
: (launcherResumedThroughShellTransition
? "launcher resumed through a shell transition"
: "forceOverviewInputConsumer == true"))
.append(", trying to use overview input consumer"));
? "%slauncher resumed through a shell transition, "
+ "trying to use overview input consumer"
: "%sforceOverviewInputConsumer == true, "
+ "trying to use overview input consumer"),
SUBSTRING_PREFIX));
} else if (mDeviceState.isGestureBlockedTask(runningTask) || launcherChildActivityResumed) {
return getDefaultInputConsumer(reasonString.append(SUBSTRING_PREFIX)
.append(launcherChildActivityResumed
? "is launcher child-task, trying to use default input consumer"
: "is gesture-blocked task, trying to use default input consumer"));
return getDefaultInputConsumer(reasonString.append(launcherChildActivityResumed
? "%sis launcher child-task, trying to use default input consumer"
: "%sis gesture-blocked task, trying to use default input consumer",
SUBSTRING_PREFIX));
} else {
reasonString.append(SUBSTRING_PREFIX)
.append("using OtherActivityInputConsumer");
reasonString.append("%susing OtherActivityInputConsumer", SUBSTRING_PREFIX);
return createOtherActivityInputConsumer(gestureState, event);
}
}
@@ -1427,20 +1425,18 @@ public class TouchInteractionService extends Service {
GestureState gestureState, CompoundString reasonString) {
if ((mDeviceState.isFullyGesturalNavMode() || gestureState.isTrackpadGesture())
&& gestureState.getRunningTask() != null) {
reasonString.append(SUBSTRING_PREFIX)
.append("device is in gesture nav mode or 3-button mode with a trackpad")
.append(" gesture and running task != null")
.append(", using DeviceLockedInputConsumer");
reasonString.append("%sdevice is in gesture nav mode or 3-button mode with a trackpad "
+ "gesture and running task != null, using DeviceLockedInputConsumer",
SUBSTRING_PREFIX);
return new DeviceLockedInputConsumer(
this, mDeviceState, mTaskAnimationManager, gestureState, mInputMonitorCompat);
} else {
return getDefaultInputConsumer(reasonString
.append(SUBSTRING_PREFIX)
.append((mDeviceState.isFullyGesturalNavMode()
|| gestureState.isTrackpadGesture())
? "running task == null"
: "device is not in gesture nav mode and it's not a trackpad gesture")
.append(", trying to use default input consumer"));
return getDefaultInputConsumer(reasonString.append(
mDeviceState.isFullyGesturalNavMode() || gestureState.isTrackpadGesture()
? "%srunning task == null, trying to use default input consumer"
: "%sdevice is not in gesture nav mode and it's not a trackpad gesture,"
+ " trying to use default input consumer",
SUBSTRING_PREFIX));
}
}
@@ -1452,9 +1448,8 @@ public class TouchInteractionService extends Service {
CompoundString reasonString) {
RecentsViewContainer container = gestureState.getContainerInterface().getCreatedContainer();
if (container == null) {
return getDefaultInputConsumer(
reasonString.append(SUBSTRING_PREFIX)
.append("activity == null, trying to use default input consumer"));
return getDefaultInputConsumer(reasonString.append(
"%sactivity == null, trying to use default input consumer", SUBSTRING_PREFIX));
}
View rootview = container.getRootView();
@@ -1464,24 +1459,24 @@ public class TouchInteractionService extends Service {
|| mDeviceState.isPredictiveBackToHomeInProgress();
boolean isInLiveTileMode = gestureState.getContainerInterface().isInLiveTileMode();
reasonString.append(SUBSTRING_PREFIX)
.append(hasWindowFocus
? "activity has window focus"
: (isPreviousGestureAnimatingToLauncher
? "previous gesture is still animating to launcher"
: isInLiveTileMode
? "device is in live mode"
: "all overview focus conditions failed"));
reasonString.append(hasWindowFocus
? "%sactivity has window focus"
: (isPreviousGestureAnimatingToLauncher
? "%sprevious gesture is still animating to launcher"
: isInLiveTileMode
? "%sdevice is in live mode"
: "%sall overview focus conditions failed"), SUBSTRING_PREFIX);
if (hasWindowFocus
|| isPreviousGestureAnimatingToLauncher
|| isInLiveTileMode) {
reasonString.append(SUBSTRING_PREFIX)
.append("overview should have focus, using OverviewInputConsumer");
reasonString.append(
"%soverview should have focus, using OverviewInputConsumer", SUBSTRING_PREFIX);
return new OverviewInputConsumer(gestureState, container, mInputMonitorCompat,
false /* startingInActivityBounds */);
} else {
reasonString.append(SUBSTRING_PREFIX).append(
"overview shouldn't have focus, using OverviewWithoutFocusInputConsumer");
reasonString.append(
"%soverview shouldn't have focus, using OverviewWithoutFocusInputConsumer",
SUBSTRING_PREFIX);
final boolean disableHorizontalSwipe = mDeviceState.isInExclusionRegion(event);
return new OverviewWithoutFocusInputConsumer(container.asContext(), mDeviceState,
gestureState, mInputMonitorCompat, disableHorizontalSwipe);
@@ -1518,12 +1513,14 @@ public class TouchInteractionService extends Service {
*/
private @NonNull InputConsumer getDefaultInputConsumer(@NonNull CompoundString reasonString) {
if (mResetGestureInputConsumer != null) {
reasonString.append(SUBSTRING_PREFIX).append(
"mResetGestureInputConsumer initialized, using ResetGestureInputConsumer");
reasonString.append(
"%smResetGestureInputConsumer initialized, using ResetGestureInputConsumer",
SUBSTRING_PREFIX);
return mResetGestureInputConsumer;
} else {
reasonString.append(SUBSTRING_PREFIX).append(
"mResetGestureInputConsumer not initialized, using no-op input consumer");
reasonString.append(
"%smResetGestureInputConsumer not initialized, using no-op input consumer",
SUBSTRING_PREFIX);
// mResetGestureInputConsumer isn't initialized until onUserUnlocked(), so reset to
// NO_OP until then (we never want these to be null).
return InputConsumer.NO_OP;
@@ -98,10 +98,8 @@ public class MotionPauseDetector {
mSpeedFast = res.getDimension(R.dimen.motion_pause_detector_speed_fast);
mForcePauseTimeout = new Alarm();
mForcePauseTimeout.setOnAlarmListener(alarm -> {
ActiveGestureLog.CompoundString log =
new ActiveGestureLog.CompoundString("Force pause timeout after ")
.append(alarm.getLastSetTimeout())
.append("ms");
ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString(
"Force pause timeout after %dms", alarm.getLastSetTimeout());
addLogs(log);
updatePaused(true /* isPaused */, log);
});
@@ -124,9 +122,8 @@ public class MotionPauseDetector {
* @param disallowPause If true, we will not detect any pauses until this is set to false again.
*/
public void setDisallowPause(boolean disallowPause) {
ActiveGestureLog.CompoundString log =
new ActiveGestureLog.CompoundString("Set disallowPause=")
.append(disallowPause);
ActiveGestureLog.CompoundString log = new ActiveGestureLog.CompoundString(
"Set disallowPause=%b", disallowPause);
if (mDisallowPause != disallowPause) {
addLogs(log);
}
@@ -188,8 +185,8 @@ public class MotionPauseDetector {
speed < previousSpeed * getRapidDecelerationFactor();
isPaused = isRapidDeceleration && speed < mSpeedSomewhatFast;
isPausedReason = new ActiveGestureLog.CompoundString(
"Didn't have back to back slow speeds, checking for rapid ")
.append(" deceleration on first pause only");
"Didn't have back to back slow speeds, checking for rapid "
+ " deceleration on first pause only");
}
if (mMakePauseHarderToTrigger) {
if (speed < mSpeedSlow) {
@@ -198,8 +195,8 @@ public class MotionPauseDetector {
}
isPaused = time - mSlowStartTime >= HARDER_TRIGGER_TIMEOUT;
isPausedReason = new ActiveGestureLog.CompoundString(
"Maintained slow speed for sufficient duration when making")
.append(" pause harder to trigger");
"Maintained slow speed for sufficient duration when making"
+ " pause harder to trigger");
} else {
mSlowStartTime = 0;
isPaused = false;
@@ -215,17 +212,14 @@ public class MotionPauseDetector {
private void updatePaused(boolean isPaused, ActiveGestureLog.CompoundString reason) {
if (mDisallowPause) {
reason = new ActiveGestureLog.CompoundString(
"Disallow pause; otherwise, would have been ")
.append(isPaused)
.append(" due to reason:")
"Disallow pause; otherwise, would have been %b due to reason: ", isPaused)
.append(reason);
isPaused = false;
}
if (mIsPaused != isPaused) {
mIsPaused = isPaused;
addLogs(new ActiveGestureLog.CompoundString("onMotionPauseChanged triggered; paused=")
.append(mIsPaused)
.append(", reason=")
addLogs(new ActiveGestureLog.CompoundString(
"onMotionPauseChanged triggered; paused=%b, reason=", mIsPaused)
.append(reason));
boolean isFirstDetectedPause = !mHasEverBeenPaused && mIsPaused;
if (mIsPaused) {
@@ -245,14 +239,13 @@ public class MotionPauseDetector {
}
}
private void addLogs(ActiveGestureLog.CompoundString compoundString) {
ActiveGestureLog.CompoundString logString =
new ActiveGestureLog.CompoundString("MotionPauseDetector: ")
.append(compoundString);
private void addLogs(ActiveGestureLog.CompoundString event) {
if (Utilities.isRunningInTestHarness()) {
Log.d(TAG, logString.toString());
Log.d(TAG, new ActiveGestureLog.CompoundString("MotionPauseDetector: ")
.append(event)
.toString());
}
ActiveGestureProtoLogProxy.logMotionPauseDetectorEvent(logString.toString());
ActiveGestureProtoLogProxy.logMotionPauseDetectorEvent(event);
}
public void clear() {
@@ -21,6 +21,7 @@ import androidx.annotation.Nullable;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@@ -70,14 +71,6 @@ public class ActiveGestureLog {
addLog(event, null);
}
public void addLog(@NonNull String event, int extras) {
addLog(event, extras, null);
}
public void addLog(@NonNull String event, boolean extras) {
addLog(event, extras, null);
}
/**
* Adds a log to be printed at log-dump-time and track the associated event for error detection.
*
@@ -88,20 +81,6 @@ public class ActiveGestureLog {
addLog(new CompoundString(event), gestureEvent);
}
public void addLog(
@NonNull String event,
int extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
public void addLog(
@NonNull String event,
boolean extras,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
addLog(new CompoundString(event).append(": ").append(extras), gestureEvent);
}
public void addLog(@NonNull CompoundString compoundString) {
addLog(compoundString, null);
}
@@ -250,25 +229,27 @@ public class ActiveGestureLog {
/** A buildable string stored as an array for memory efficiency. */
public static class CompoundString {
public static final CompoundString NO_OP = new CompoundString();
public static final CompoundString NO_OP = new CompoundString(true);
private final List<String> mSubstrings;
private final List<Object> mArgs;
private final boolean mIsNoOp;
private CompoundString() {
this(null);
public static CompoundString newEmptyString() {
return new CompoundString(false);
}
public CompoundString(String substring) {
mIsNoOp = substring == null;
private CompoundString(boolean isNoOp) {
mIsNoOp = isNoOp;
mSubstrings = mIsNoOp ? null : new ArrayList<>();
mArgs = mIsNoOp ? null : new ArrayList<>();
}
if (!mIsNoOp) {
mSubstrings.add(substring);
}
public CompoundString(String substring, Object... args) {
this(substring == null);
append(substring, args);
}
public CompoundString append(CompoundString substring) {
@@ -281,76 +262,24 @@ public class ActiveGestureLog {
return this;
}
public CompoundString append(String substring) {
public CompoundString append(String substring, Object... args) {
if (mIsNoOp) {
return this;
}
mSubstrings.add(substring);
mArgs.addAll(Arrays.stream(args).toList());
return this;
}
public CompoundString append(int num) {
if (mIsNoOp) {
return this;
}
mArgs.add(num);
return append("%d");
}
public CompoundString append(long num) {
if (mIsNoOp) {
return this;
}
mArgs.add(num);
return append("%d");
}
public CompoundString append(float num) {
if (mIsNoOp) {
return this;
}
mArgs.add(num);
return append("%.2f");
}
public CompoundString append(double num) {
if (mIsNoOp) {
return this;
}
mArgs.add(num);
return append("%.2f");
}
public CompoundString append(boolean bool) {
if (mIsNoOp) {
return this;
}
mArgs.add(bool);
return append("%b");
}
private Object[] getArgs() {
return mArgs.toArray();
}
@Override
public String toString() {
return String.format(toUnformattedString(), getArgs());
}
private String toUnformattedString() {
if (mIsNoOp) return null;
StringBuilder sb = new StringBuilder();
for (String substring : mSubstrings) {
sb.append(substring);
}
return sb.toString();
return String.format(sb.toString(), mArgs.toArray());
}
@Override
@@ -360,10 +289,9 @@ public class ActiveGestureLog {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CompoundString)) {
if (!(obj instanceof CompoundString other)) {
return false;
}
CompoundString other = (CompoundString) obj;
return (mIsNoOp == other.mIsNoOp)
&& Objects.equals(mSubstrings, other.mSubstrings)
&& Objects.equals(mArgs, other.mArgs);
@@ -86,25 +86,20 @@ public class ActiveGestureProtoLogProxy {
ActiveGestureErrorDetector.GestureEvent.CANCEL_CURRENT_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.cancelCurrentAnimation");
}
public static void logAbsSwipeUpHandlerOnTasksAppeared() {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"AbsSwipeUpHandler.onTasksAppeared: ")
.append("force finish recents animation complete; clearing state callback."));
ActiveGestureLog.INSTANCE.addLog("AbsSwipeUpHandler.onTasksAppeared: "
+ "force finish recents animation complete; clearing state callback.");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"AbsSwipeUpHandler.onTasksAppeared: force finish recents animation complete; "
+ "clearing state callback.");
ProtoLog.d(ACTIVE_GESTURE_LOG, "AbsSwipeUpHandler.onTasksAppeared: "
+ "force finish recents animation complete; clearing state callback.");
}
public static void logFinishRecentsAnimationOnTasksAppeared() {
ActiveGestureLog.INSTANCE.addLog("finishRecentsAnimationOnTasksAppeared");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimationOnTasksAppeared");
}
public static void logRecentsAnimationCallbacksOnAnimationCancelled() {
@@ -113,7 +108,6 @@ public class ActiveGestureProtoLogProxy {
/* gestureEvent= */ ON_CANCEL_RECENTS_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationCanceled");
}
public static void logRecentsAnimationCallbacksOnTasksAppeared() {
@@ -121,7 +115,6 @@ public class ActiveGestureProtoLogProxy {
ActiveGestureErrorDetector.GestureEvent.TASK_APPEARED);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onTasksAppeared");
}
public static void logStartRecentsAnimation() {
@@ -130,21 +123,18 @@ public class ActiveGestureProtoLogProxy {
/* gestureEvent= */ START_RECENTS_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "TaskAnimationManager.startRecentsAnimation");
}
public static void logLaunchingSideTaskFailed() {
ActiveGestureLog.INSTANCE.addLog("Unable to launch side task (no recents)");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "Unable to launch side task (no recents)");
}
public static void logContinueRecentsAnimation() {
ActiveGestureLog.INSTANCE.addLog(/* event= */ "continueRecentsAnimation");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "continueRecentsAnimation");
}
public static void logCleanUpRecentsAnimationSkipped() {
@@ -152,46 +142,39 @@ public class ActiveGestureProtoLogProxy {
/* event= */ "cleanUpRecentsAnimation skipped due to wrong callbacks");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation skipped due to wrong callbacks");
}
public static void logCleanUpRecentsAnimation() {
ActiveGestureLog.INSTANCE.addLog(/* event= */ "cleanUpRecentsAnimation");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "cleanUpRecentsAnimation");
}
public static void logOnInputEventUserLocked() {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("TIS.onInputEvent: ")
.append("Cannot process input event: user is locked"));
ActiveGestureLog.INSTANCE.addLog(
"TIS.onInputEvent: Cannot process input event: user is locked");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TIS.onInputEvent: Cannot process input event: user is locked");
}
public static void logOnInputIgnoringFollowingEvents() {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("TIS.onMotionEvent: A new gesture has been ")
.append("started, but a previously-requested recents ")
.append("animation hasn't started. Ignoring all following ")
.append("motion events."),
ActiveGestureLog.INSTANCE.addLog("TIS.onMotionEvent: A new gesture has been started, "
+ "but a previously-requested recents animation hasn't started. "
+ "Ignoring all following motion events.",
RECENTS_ANIMATION_START_PENDING);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TIS.onMotionEvent: A new gesture has been started, but a "
+ "previously-requested recents animation hasn't started. "
+ "Ignoring all following motion events.");
ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: A new gesture has been started, "
+ "but a previously-requested recents animation hasn't started. "
+ "Ignoring all following motion events.");
}
public static void logOnInputEventThreeButtonNav() {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("TIS.onInputEvent: ")
.append("Cannot process input event: ")
.append("using 3-button nav and event is not a trackpad event"));
ActiveGestureLog.INSTANCE.addLog("TIS.onInputEvent: Cannot process input event: "
+ "using 3-button nav and event is not a trackpad event");
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TIS.onInputEvent: Cannot process input event: using 3-button nav and "
+ "event is not a trackpad event");
ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onInputEvent: Cannot process input event: "
+ "using 3-button nav and event is not a trackpad event");
}
public static void logPreloadRecentsAnimation() {
@@ -226,31 +209,23 @@ public class ActiveGestureProtoLogProxy {
}
public static void logInputConsumerBecameActive(@NonNull String consumerName) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(consumerName)
.append(" became active"));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"%s became active", consumerName));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "%s became active", consumerName);
}
public static void logTaskLaunchFailed(int launchedTaskId) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Launch failed, task (id=")
.append(launchedTaskId)
.append(") finished mid transition"));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Launch failed, task (id=%d) finished mid transition", launchedTaskId));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"Launch failed, task (id=%d) finished mid transition", launchedTaskId);
}
public static void logMotionPauseDetectorEvent(@NonNull String event) {
ActiveGestureLog.INSTANCE.addLog(event);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "MotionPauseDetector: %s", event);
}
public static void logOnPageEndTransition(int nextPageIndex) {
ActiveGestureLog.INSTANCE.addLog(
"onPageEndTransition: current page index updated", nextPageIndex);
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"onPageEndTransition: current page index updated: %d", nextPageIndex));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"onPageEndTransition: current page index updated: %d", nextPageIndex);
@@ -258,9 +233,8 @@ public class ActiveGestureProtoLogProxy {
public static void logQuickSwitchFromHomeFallback(int taskIndex) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Quick switch from home fallback case: The TaskView at index ")
.append(taskIndex)
.append(" is missing."),
"Quick switch from home fallback case: The TaskView at index %d is missing.",
taskIndex),
QUICK_SWITCH_FROM_HOME_FALLBACK);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
@@ -270,9 +244,8 @@ public class ActiveGestureProtoLogProxy {
public static void logQuickSwitchFromHomeFailed(int taskIndex) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Quick switch from home failed: TaskViews at indices ")
.append(taskIndex)
.append(" and 0 are missing."),
"Quick switch from home failed: TaskViews at indices %d and 0 are missing.",
taskIndex),
QUICK_SWITCH_FROM_HOME_FAILED);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
@@ -281,50 +254,44 @@ public class ActiveGestureProtoLogProxy {
}
public static void logFinishRecentsAnimation(boolean toRecents) {
ActiveGestureLog.INSTANCE.addLog(
/* event= */ "finishRecentsAnimation",
/* extras= */ toRecents,
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"finishRecentsAnimation: %b", toRecents),
/* gestureEvent= */ FINISH_RECENTS_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRecentsAnimation: %b", toRecents);
}
public static void logSetEndTarget(@NonNull String target) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("setEndTarget ")
.append(target),
/* gestureEvent= */ SET_END_TARGET);
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"setEndTarget %s", target), /* gestureEvent= */ SET_END_TARGET);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "setEndTarget %s", target);
}
public static void logStartHomeIntent(@NonNull String reason) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"OverviewComponentObserver.startHomeIntent: ").append(reason));
"OverviewComponentObserver.startHomeIntent: %s", reason));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "OverviewComponentObserver.startHomeIntent: %s", reason);
}
public static void logRunningTaskPackage(@NonNull String packageName) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Current running task package name=")
.append(packageName));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Current running task package name=%s", packageName));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "Current running task package name=%s", packageName);
}
public static void logSysuiStateFlags(@NonNull String stateFlags) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Current SystemUi state flags=")
.append(stateFlags));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Current SystemUi state flags=%s", stateFlags));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "Current SystemUi state flags=%s", stateFlags);
}
public static void logSetInputConsumer(@NonNull String consumerName, @NonNull String reason) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("setInputConsumer: ")
.append(consumerName)
.append(". reason(s):")
.append(reason));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"setInputConsumer: %s. reason(s):%s", consumerName, reason));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"setInputConsumer: %s. reason(s):%s", consumerName, reason);
@@ -332,12 +299,11 @@ public class ActiveGestureProtoLogProxy {
public static void logUpdateGestureStateRunningTask(
@NonNull String otherTaskPackage, @NonNull String runningTaskPackage) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Changing active task to ")
.append(otherTaskPackage)
.append(" because the previous task running on top of this one (")
.append(runningTaskPackage)
.append(") was excluded from recents"));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Changing active task to %s because the previous task running on top of this "
+ "one (%s) was excluded from recents",
otherTaskPackage,
runningTaskPackage));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"Changing active task to %s because the previous task running on top of this "
@@ -349,15 +315,8 @@ public class ActiveGestureProtoLogProxy {
public static void logOnInputEventActionUp(
int x, int y, int action, @NonNull String classification) {
String actionString = MotionEvent.actionToString(action);
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("onMotionEvent(")
.append(x)
.append(", ")
.append(y)
.append("): ")
.append(actionString)
.append(", ")
.append(classification),
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"onMotionEvent(%d, %d): %s, %s", x, y, actionString, classification),
/* gestureEvent= */ action == ACTION_DOWN
? MOTION_DOWN
: MOTION_UP);
@@ -368,13 +327,11 @@ public class ActiveGestureProtoLogProxy {
public static void logOnInputEventActionMove(
@NonNull String action, @NonNull String classification, int pointerCount) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("onMotionEvent: ")
.append(action)
.append(",")
.append(classification)
.append(", pointerCount: ")
.append(pointerCount),
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"onMotionEvent: %s, %s, pointerCount: %d",
action,
classification,
pointerCount),
MOTION_MOVE);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
@@ -383,23 +340,19 @@ public class ActiveGestureProtoLogProxy {
public static void logOnInputEventGenericAction(
@NonNull String action, @NonNull String classification) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("onMotionEvent: ")
.append(action)
.append(",")
.append(classification));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"onMotionEvent: %s, %s", action, classification));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "onMotionEvent: %s, %s", action, classification);
}
public static void logOnInputEventNavModeSwitched(
@NonNull String startNavMode, @NonNull String currentNavMode) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("TIS.onInputEvent: ")
.append("Navigation mode switched mid-gesture (")
.append(startNavMode)
.append(" -> ")
.append(currentNavMode)
.append("); cancelling gesture."),
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"TIS.onInputEvent: Navigation mode switched mid-gesture (%s -> %s); "
+ "cancelling gesture.",
startNavMode,
currentNavMode),
NAVIGATION_MODE_SWITCHED);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
@@ -410,84 +363,100 @@ public class ActiveGestureProtoLogProxy {
}
public static void logUnknownInputEvent(@NonNull String event) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString("TIS.onInputEvent: ")
.append("Cannot process input event: received unknown event ")
.append(event));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"TIS.onInputEvent: Cannot process input event: received unknown event %s", event));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TIS.onInputEvent: Cannot process input event: received unknown event %s", event);
}
public static void logFinishRunningRecentsAnimation(boolean toHome) {
ActiveGestureLog.INSTANCE.addLog(
/* event= */ "finishRunningRecentsAnimation", toHome);
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"finishRunningRecentsAnimation: %b", toHome));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "finishRunningRecentsAnimation: %b", toHome);
}
public static void logOnRecentsAnimationStartCancelled() {
ActiveGestureLog.INSTANCE.addLog(
/* event= */ "RecentsAnimationCallbacks.onAnimationStart (canceled)",
/* extras= */ 0,
ActiveGestureLog.INSTANCE.addLog("RecentsAnimationCallbacks.onAnimationStart (canceled): 0",
/* gestureEvent= */ ON_START_RECENTS_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "RecentsAnimationCallbacks.onAnimationStart (canceled): 0");
}
public static void logOnRecentsAnimationStart(int appCount) {
ActiveGestureLog.INSTANCE.addLog(
/* event= */ "RecentsAnimationCallbacks.onAnimationStart",
/* extras= */ appCount,
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"RecentsAnimationCallbacks.onAnimationStart (canceled): %d", appCount),
/* gestureEvent= */ ON_START_RECENTS_ANIMATION);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"RecentsAnimationCallbacks.onAnimationStart (canceled): %d", appCount);
}
public static void logStartRecentsAnimationCallback(@NonNull String callback) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"TaskAnimationManager.startRecentsAnimation(")
.append(callback)
.append("): ")
.append("Setting mRecentsAnimationStartPending = false"));
"TaskAnimationManager.startRecentsAnimation(%s): "
+ "Setting mRecentsAnimationStartPending = false",
callback));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TaskAnimationManager.startRecentsAnimation(%s): "
+ "Setting mRecentsAnimationStartPending = false",
callback);
}
public static void logSettingRecentsAnimationStartPending(boolean value) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"TaskAnimationManager.startRecentsAnimation: ")
.append("Setting mRecentsAnimationStartPending = ")
.append(value));
"TaskAnimationManager.startRecentsAnimation: "
+ "Setting mRecentsAnimationStartPending = %b",
value));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"TaskAnimationManager.startRecentsAnimation: "
+ "Setting mRecentsAnimationStartPending = %b",
value);
}
public static void logLaunchingSideTask(int taskId) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Launching side task id=")
.append(taskId));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Launching side task id=%d", taskId));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "Launching side task id=", taskId);
ProtoLog.d(ACTIVE_GESTURE_LOG, "Launching side task id=%d", taskId);
}
public static void logDynamicString(@NonNull String string) {
logDynamicString(string, null);
public static void logOnInputEventActionDown(@NonNull ActiveGestureLog.CompoundString reason) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"TIS.onMotionEvent: ").append(reason));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: %s", reason.toString());
}
public static void logStartNewTask(@NonNull ActiveGestureLog.CompoundString tasks) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Launching task: ").append(tasks));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "TIS.onMotionEvent: %s", tasks.toString());
}
public static void logMotionPauseDetectorEvent(@NonNull ActiveGestureLog.CompoundString event) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"MotionPauseDetector: ").append(event));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "MotionPauseDetector: %s", event.toString());
}
public static void logHandleTaskAppearedFailed(
@NonNull ActiveGestureLog.CompoundString reason) {
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"handleTaskAppeared check failed: ").append(reason));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "handleTaskAppeared check failed: %s", reason.toString());
}
/**
* This is for special cases where the string is purely dynamic and therefore has no format that
* can be extracted. Do not use in any other case.
*/
public static void logDynamicString(
@NonNull String string,
@Nullable ActiveGestureErrorDetector.GestureEvent gestureEvent) {
@@ -497,22 +466,19 @@ public class ActiveGestureProtoLogProxy {
}
public static void logOnSettledOnEndTarget(@NonNull String endTarget) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("onSettledOnEndTarget ")
.append(endTarget),
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"onSettledOnEndTarget %s", endTarget),
/* gestureEvent= */ ON_SETTLED_ON_END_TARGET);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG, "onSettledOnEndTarget %s", endTarget);
}
public static void logOnCalculateEndTarget(float velocityX, float velocityY, double angle) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("calculateEndTarget: velocities=(x=")
.append(velocityX)
.append("dp/ms, y=")
.append(velocityY)
.append("dp/ms), angle=")
.append(angle),
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"calculateEndTarget: velocities=(x=%fdp/ms, y=%fdp/ms), angle=%f",
velocityX,
velocityY,
angle),
velocityX == 0 && velocityY == 0 ? INVALID_VELOCITY_ON_SWIPE_UP : null);
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
@@ -523,12 +489,10 @@ public class ActiveGestureProtoLogProxy {
}
public static void logUnexpectedTaskAppeared(int taskId, @NonNull String packageName) {
ActiveGestureLog.INSTANCE.addLog(
new ActiveGestureLog.CompoundString("Forcefully finishing recents animation: ")
.append("Unexpected task appeared id=")
.append(taskId)
.append(" pkg=")
.append(packageName));
ActiveGestureLog.INSTANCE.addLog(new ActiveGestureLog.CompoundString(
"Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s",
taskId,
packageName));
if (!enableActiveGestureProtoLog()) return;
ProtoLog.d(ACTIVE_GESTURE_LOG,
"Forcefully finishing recents animation: Unexpected task appeared id=%d, pkg=%s",