diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 849db28e20..fcda19542c 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -424,6 +424,7 @@ public class Launcher extends StatefulActivity @Override @TargetApi(Build.VERSION_CODES.S) protected void onCreate(Bundle savedInstanceState) { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onCreate 1"); mStartupLatencyLogger = createStartupLatencyLogger( sIsNewProcess ? LockedUserState.get(this).isUserUnlockedAtLauncherStartup() @@ -582,6 +583,7 @@ public class Launcher extends StatefulActivity } setTitle(R.string.home_screen); mStartupLatencyLogger.logEnd(LAUNCHER_LATENCY_STARTUP_ACTIVITY_ON_CREATE); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onCreate 2"); } /** @@ -1056,6 +1058,7 @@ public class Launcher extends StatefulActivity @Override protected void onStop() { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStop 1"); super.onStop(); if (mDeferOverlayCallbacks) { checkIfOverlayStillDeferred(); @@ -1067,10 +1070,12 @@ public class Launcher extends StatefulActivity mAppWidgetHolder.setActivityStarted(false); NotificationListener.removeNotificationsChangedListener(getPopupDataProvider()); FloatingIconView.resetIconLoadResult(); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStop 2"); } @Override protected void onStart() { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStart 1"); TraceHelper.INSTANCE.beginSection(ON_START_EVT); super.onStart(); if (!mDeferOverlayCallbacks) { @@ -1079,6 +1084,7 @@ public class Launcher extends StatefulActivity mAppWidgetHolder.setActivityStarted(true); TraceHelper.INSTANCE.endSection(); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onStart 2"); } @Override @@ -1249,6 +1255,7 @@ public class Launcher extends StatefulActivity @Override protected void onResume() { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onResume 1"); TraceHelper.INSTANCE.beginSection(ON_RESUME_EVT); super.onResume(); @@ -1260,10 +1267,12 @@ public class Launcher extends StatefulActivity DragView.removeAllViews(this); TraceHelper.INSTANCE.endSection(); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onResume 2"); } @Override protected void onPause() { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onPause 1"); // Ensure that items added to Launcher are queued until Launcher returns ItemInstallQueue.INSTANCE.get(this).pauseModelPush(FLAG_ACTIVITY_PAUSED); @@ -1276,6 +1285,7 @@ public class Launcher extends StatefulActivity mOverlayManager.onActivityPaused(this); } mAppWidgetHolder.setActivityResumed(false); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onPause 2"); } /** @@ -1740,6 +1750,8 @@ public class Launcher extends StatefulActivity @Override protected void onSaveInstanceState(Bundle outState) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onSaveInstanceState 1"); outState.putIntArray(RUNTIME_STATE_CURRENT_SCREEN_IDS, mWorkspace.getCurrentPageScreenIds().getArray().toArray()); outState.putInt(RUNTIME_STATE, mStateManager.getState().ordinal); @@ -1771,10 +1783,13 @@ public class Launcher extends StatefulActivity super.onSaveInstanceState(outState); mOverlayManager.onActivitySaveInstanceState(this, outState); + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onSaveInstanceState 2"); } @Override public void onDestroy() { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onDestroy 1"); super.onDestroy(); ACTIVITY_TRACKER.onActivityDestroyed(this); @@ -1797,6 +1812,7 @@ public class Launcher extends StatefulActivity LauncherAppState.getIDP(this).removeOnChangeListener(this); mOverlayManager.onActivityDestroyed(this); + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, "Launcher.onDestroy 2"); } public LauncherAccessibilityDelegate getAccessibilityDelegate() { diff --git a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java index 4073517b5e..75cee2f7dc 100644 --- a/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java +++ b/tests/shared/com/android/launcher3/testing/shared/TestProtocol.java @@ -157,6 +157,7 @@ public final class TestProtocol { public static final String TWO_TASKBAR_LONG_CLICKS = "b/262282528"; public static final String FLAKY_ACTIVITY_COUNT = "b/260260325"; public static final String ICON_MISSING = "b/282963545"; + public static final String ACTIVITY_LIFECYCLE_RULE = "b/289161193"; public static final String REQUEST_EMULATE_DISPLAY = "emulate-display"; public static final String REQUEST_STOP_EMULATE_DISPLAY = "stop-emulate-display"; diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java index 435649b8eb..b05ebf8182 100644 --- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java +++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java @@ -21,6 +21,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import android.platform.test.annotations.PlatinumTest; +import android.platform.test.rule.ScreenRecordRule; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; @@ -53,7 +54,9 @@ public class AddWidgetTest extends AbstractLauncherUiTest { @PlatinumTest(focusArea = "launcher") @Test @PortraitLandscape + @ScreenRecordRule.ScreenRecord // b/289161193 public void testDragIcon() throws Throwable { + mLauncher.enableDebugTracing(); // b/289161193 new FavoriteItemsTransaction(mTargetContext).commitAndLoadHome(mLauncher); waitForLauncherCondition("Workspace didn't finish loading", l -> !l.isWorkspaceLoading()); @@ -79,6 +82,7 @@ public class AddWidgetTest extends AbstractLauncherUiTest { DEFAULT_UI_TIMEOUT); assertNotNull("Widget not found on the workspace", widget); widget.launch(getAppPackageName()); + mLauncher.disableDebugTracing(); // b/289161193 } /** diff --git a/tests/src/com/android/launcher3/util/rule/SimpleActivityRule.java b/tests/src/com/android/launcher3/util/rule/SimpleActivityRule.java index 2eedec30b6..b5d819318c 100644 --- a/tests/src/com/android/launcher3/util/rule/SimpleActivityRule.java +++ b/tests/src/com/android/launcher3/util/rule/SimpleActivityRule.java @@ -22,6 +22,8 @@ import android.os.Bundle; import androidx.test.InstrumentationRegistry; +import com.android.launcher3.testing.shared.TestProtocol; + import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; @@ -71,33 +73,57 @@ public class SimpleActivityRule implements TestRule { @Override public void onActivityCreated(Activity activity, Bundle bundle) { if (activity != null && mClass.isInstance(activity)) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityCreated"); mActivity = (T) activity; } } @Override public void onActivityStarted(Activity activity) { + if (activity == mActivity) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityStarted"); + } } @Override public void onActivityResumed(Activity activity) { + if (activity == mActivity) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityResumed"); + } } @Override public void onActivityPaused(Activity activity) { + if (activity == mActivity) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityPaused"); + } } @Override public void onActivityStopped(Activity activity) { + if (activity == mActivity) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onAcgtivityStopped"); + } } @Override public void onActivitySaveInstanceState(Activity activity, Bundle bundle) { + if (activity == mActivity) { + TestProtocol.testLogD(TestProtocol.ACTIVITY_LIFECYCLE_RULE, + "MyStatement.onActivitySaveInstanceState"); + } } @Override public void onActivityDestroyed(Activity activity) { if (activity == mActivity) { + TestProtocol.testLogD( + TestProtocol.ACTIVITY_LIFECYCLE_RULE, "MyStatement.onActivityDestroyed"); mActivity = null; } }