diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java index b0cb35a55c..e62f571736 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -142,7 +142,7 @@ public class TouchInteractionService extends Service implements PluginListener ActiveGestureLog.INSTANCE.addLog("startQuickstep"); } if (mInputMonitor != null) { - TestLogging.recordEvent("pilferPointers"); + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "pilferPointers"); 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 6bfc3fd6b9..823b254d80 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 @@ -23,6 +23,7 @@ import com.android.launcher3.BaseActivity; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.logging.StatsLogUtils; import com.android.launcher3.testing.TestLogging; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; import com.android.quickstep.GestureState; @@ -64,7 +65,7 @@ public class OverviewWithoutFocusInputConsumer implements InputConsumer { private void onInterceptTouch() { if (mInputMonitor != null) { - TestLogging.recordEvent("pilferPointers"); + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "pilferPointers"); mInputMonitor.pilferPointers(); } } diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java index 294bb7b564..8b7ce10b2b 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/TaskView.java @@ -58,6 +58,7 @@ import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.popup.SystemShortcut; import com.android.launcher3.testing.TestLogging; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Direction; import com.android.launcher3.userevent.nano.LauncherLogProto.Action.Touch; @@ -334,9 +335,8 @@ public class TaskView extends FrameLayout implements PageCallbacks, Reusable { Consumer resultCallback, Handler resultCallbackHandler) { if (mTask != null) { final ActivityOptions opts; - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - TestLogging.recordEvent("startActivityFromRecentsAsync:" + mTask); - } + TestLogging.recordEvent( + TestProtocol.SEQUENCE_MAIN, "startActivityFromRecentsAsync", mTask); if (animate) { opts = mActivity.getActivityLaunchOptions(this); if (freezeTaskList) { diff --git a/src/com/android/launcher3/BaseActivity.java b/src/com/android/launcher3/BaseActivity.java index f3c5191bbe..217a41c083 100644 --- a/src/com/android/launcher3/BaseActivity.java +++ b/src/com/android/launcher3/BaseActivity.java @@ -42,6 +42,7 @@ import com.android.launcher3.logging.StatsLogUtils.LogStateProvider; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.logging.UserEventDispatcher.UserEventDelegate; import com.android.launcher3.testing.TestLogging; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.util.SystemUiController; import com.android.launcher3.util.ViewCache; @@ -330,9 +331,7 @@ public abstract class BaseActivity extends Activity return; } try { - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - TestLogging.recordEvent("start: shortcut: " + packageName); - } + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: shortcut", packageName); getSystemService(LauncherApps.class).startShortcut(packageName, id, sourceBounds, startActivityOptions, user); } catch (SecurityException | IllegalStateException e) { diff --git a/src/com/android/launcher3/BaseDraggingActivity.java b/src/com/android/launcher3/BaseDraggingActivity.java index 0d9126b133..9f3b48f78c 100644 --- a/src/com/android/launcher3/BaseDraggingActivity.java +++ b/src/com/android/launcher3/BaseDraggingActivity.java @@ -39,6 +39,7 @@ import androidx.annotation.Nullable; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.model.AppLaunchTracker; import com.android.launcher3.testing.TestLogging; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.touch.ItemClickHandler; import com.android.launcher3.uioverrides.WallpaperColorInfo; import com.android.launcher3.util.DefaultDisplay; @@ -169,9 +170,7 @@ public abstract class BaseDraggingActivity extends BaseActivity startShortcutIntentSafely(intent, optsBundle, item, sourceContainer); } else if (user == null || user.equals(Process.myUserHandle())) { // Could be launching some bookkeeping activity - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - TestLogging.recordEvent("start: activity: " + intent); - } + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "start: activity", intent); startActivity(intent, optsBundle); AppLaunchTracker.INSTANCE.get(this).onStartApp(intent.getComponent(), Process.myUserHandle(), sourceContainer); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 89c3b93aa0..397a38bbe3 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1789,17 +1789,13 @@ public class Launcher extends BaseDraggingActivity implements LauncherExterns, @Override public boolean dispatchKeyEvent(KeyEvent event) { - if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - TestLogging.recordEvent("Key event: " + event); - } + TestLogging.recordEvent(TestProtocol.SEQUENCE_MAIN, "Key event", event); return (event.getKeyCode() == KeyEvent.KEYCODE_HOME) || super.dispatchKeyEvent(event); } @Override public boolean dispatchTouchEvent(MotionEvent ev) { - if (Utilities.IS_RUNNING_IN_TEST_HARNESS && ev.getAction() != MotionEvent.ACTION_MOVE) { - TestLogging.recordEvent("Touch event: " + ev); - } + TestLogging.recordMotionEvent(TestProtocol.SEQUENCE_MAIN, "Touch event", ev); return super.dispatchTouchEvent(ev); } diff --git a/src/com/android/launcher3/testing/TestLogging.java b/src/com/android/launcher3/testing/TestLogging.java index fd066c1ce1..d522d81665 100644 --- a/src/com/android/launcher3/testing/TestLogging.java +++ b/src/com/android/launcher3/testing/TestLogging.java @@ -17,13 +17,30 @@ package com.android.launcher3.testing; import android.util.Log; +import android.view.MotionEvent; import com.android.launcher3.Utilities; public final class TestLogging { - public static void recordEvent(String event) { + private static void recordEventSlow(String sequence, String event) { + Log.d(TestProtocol.TAPL_EVENTS_TAG, sequence + " / " + event); + } + + public static void recordEvent(String sequence, String event) { if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { - Log.d(TestProtocol.TAPL_EVENTS_TAG, event); + recordEventSlow(sequence, event); + } + } + + public static void recordEvent(String sequence, String message, Object parameter) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS) { + recordEventSlow(sequence, message + ": " + parameter); + } + } + + public static void recordMotionEvent(String sequence, String message, MotionEvent event) { + if (Utilities.IS_RUNNING_IN_TEST_HARNESS && event.getAction() != MotionEvent.ACTION_MOVE) { + recordEventSlow(sequence, message + ": " + event); } } } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 7aa51405e5..f995c61ac9 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -33,6 +33,8 @@ public final class TestProtocol { public static final int BACKGROUND_APP_STATE_ORDINAL = 6; public static final int HINT_STATE_ORDINAL = 7; public static final String TAPL_EVENTS_TAG = "TaplEvents"; + public static final String SEQUENCE_MAIN = "Main"; + public static final String SEQUENCE_TIS = "TIS"; public static String stateOrdinalToString(int ordinal) { switch (ordinal) { diff --git a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java index afb50e06f3..468f54c0d9 100644 --- a/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java +++ b/tests/tapl/com/android/launcher3/tapl/AddToHomeScreenPrompt.java @@ -21,6 +21,8 @@ import static java.util.regex.Pattern.CASE_INSENSITIVE; import androidx.test.uiautomator.By; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.testing.TestProtocol; + import java.util.regex.Pattern; public class AddToHomeScreenPrompt { @@ -38,6 +40,13 @@ public class AddToHomeScreenPrompt { public void addAutomatically() { try (LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) { + if (mLauncher.getNavigationModel() + != LauncherInstrumentation.NavigationModel.THREE_BUTTON) { + mLauncher.expectEvent( + TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_DOWN_TIS); + mLauncher.expectEvent( + TestProtocol.SEQUENCE_TIS, LauncherInstrumentation.EVENT_TOUCH_UP_TIS); + } mLauncher.waitForObjectInContainer( mWidgetCell.getParent().getParent().getParent().getParent(), By.text(ADD_AUTOMATICALLY)).click(); diff --git a/tests/tapl/com/android/launcher3/tapl/AppIcon.java b/tests/tapl/com/android/launcher3/tapl/AppIcon.java index 3f814fd1eb..8932291f94 100644 --- a/tests/tapl/com/android/launcher3/tapl/AppIcon.java +++ b/tests/tapl/com/android/launcher3/tapl/AppIcon.java @@ -22,6 +22,8 @@ import androidx.test.uiautomator.By; import androidx.test.uiautomator.BySelector; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.testing.TestProtocol; + import java.util.regex.Pattern; /** @@ -56,6 +58,6 @@ public final class AppIcon extends Launchable { @Override protected void expectActivityStartEvents() { - mLauncher.expectEvent(START_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_EVENT); } } diff --git a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java index fadfd9ff38..f8dd89c60c 100644 --- a/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java +++ b/tests/tapl/com/android/launcher3/tapl/AppIconMenuItem.java @@ -18,6 +18,8 @@ package com.android.launcher3.tapl; import androidx.test.uiautomator.UiObject2; +import com.android.launcher3.testing.TestProtocol; + import java.util.regex.Pattern; /** @@ -45,6 +47,6 @@ public class AppIconMenuItem extends Launchable { @Override protected void expectActivityStartEvents() { - mLauncher.expectEvent(START_SHORTCUT_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, START_SHORTCUT_EVENT); } } diff --git a/tests/tapl/com/android/launcher3/tapl/Background.java b/tests/tapl/com/android/launcher3/tapl/Background.java index 9f29a1a826..2acab97454 100644 --- a/tests/tapl/com/android/launcher3/tapl/Background.java +++ b/tests/tapl/com/android/launcher3/tapl/Background.java @@ -131,7 +131,7 @@ public class Background extends LauncherInstrumentation.VisibleContainer { } case THREE_BUTTON: - mLauncher.expectEvent(SQUARE_BUTTON_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState( () -> mLauncher.waitForSystemUiObject("recent_apps").click(), OVERVIEW_STATE_ORDINAL); @@ -195,14 +195,14 @@ public class Background extends LauncherInstrumentation.VisibleContainer { case THREE_BUTTON: // Double press the recents button. UiObject2 recentsButton = mLauncher.waitForSystemUiObject("recent_apps"); - mLauncher.expectEvent(SQUARE_BUTTON_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); mLauncher.runToState(() -> recentsButton.click(), OVERVIEW_STATE_ORDINAL); mLauncher.getOverview(); - mLauncher.expectEvent(SQUARE_BUTTON_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, SQUARE_BUTTON_EVENT); recentsButton.click(); break; } - mLauncher.expectEvent(TASK_START_EVENT); + mLauncher.expectEvent(TestProtocol.SEQUENCE_MAIN, TASK_START_EVENT); } protected String getSwipeHeightRequestName() { diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java index c8f22c2a42..abd0f24a38 100644 --- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java +++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java @@ -76,8 +76,10 @@ import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Deque; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import java.util.concurrent.TimeoutException; import java.util.function.Consumer; import java.util.function.Function; @@ -102,13 +104,17 @@ public final class LauncherInstrumentation { static final Pattern EVENT_LOG_ENTRY = Pattern.compile( "(?