From ce25a2bf68e13ea32ead7934d7c570a62e404fe2 Mon Sep 17 00:00:00 2001 From: vadimt Date: Fri, 11 Oct 2019 19:02:12 -0700 Subject: [PATCH] Adding tracing for a lab-only flake Bug: 142514365 Change-Id: I9c93ecabbcbad6d4683d595587831d8465e62ee8 --- .../quickstep/QuickstepTestInformationHandler.java | 8 ++++++++ .../android/quickstep/TouchInteractionService.java | 8 ++++++++ src/com/android/launcher3/LauncherModel.java | 5 +++++ .../launcher3/testing/TestInformationHandler.java | 6 ++++++ src/com/android/launcher3/testing/TestProtocol.java | 1 + src/com/android/launcher3/util/ActivityTracker.java | 12 ++++++++++++ 6 files changed, 40 insertions(+) diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java index daaa95b01b..ce533a699a 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -4,7 +4,10 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.Context; import android.os.Bundle; +import android.util.Log; +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherAppState; import com.android.launcher3.testing.TestInformationHandler; import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.uioverrides.states.OverviewState; @@ -109,6 +112,11 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { @Override protected boolean isLauncherInitialized() { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, + "isLauncherInitialized.TouchInteractionService.isInitialized=" + + TouchInteractionService.isInitialized()); + } return super.isLauncherInitialized() && TouchInteractionService.isInitialized(); } } 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 4b7ae6f426..a34638dae4 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/TouchInteractionService.java @@ -53,6 +53,8 @@ import androidx.annotation.UiThread; import androidx.annotation.WorkerThread; import com.android.launcher3.BaseDraggingActivity; +import com.android.launcher3.Launcher; +import com.android.launcher3.LauncherAppState; import com.android.launcher3.Utilities; import com.android.launcher3.allapps.DiscoveryBounce; import com.android.launcher3.config.FeatureFlags; @@ -131,6 +133,9 @@ public class TouchInteractionService extends Service implements .setProxy(proxy)); MAIN_EXECUTOR.execute(TouchInteractionService.this::initInputMonitor); MAIN_EXECUTOR.execute(() -> preloadOverview(true /* fromInit */)); + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS initialized"); + } sIsInitialized = true; } @@ -380,6 +385,9 @@ public class TouchInteractionService extends Service implements @Override public void onDestroy() { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS destroyed"); + } sIsInitialized = false; if (mDeviceState.isUserUnlocked()) { mInputConsumer.unregisterInputConsumer(); diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index bea25e07ee..b22d137b2f 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -53,6 +53,7 @@ import com.android.launcher3.model.UserLockStateChangedTask; import com.android.launcher3.pm.InstallSessionTracker; import com.android.launcher3.pm.PackageInstallInfo; import com.android.launcher3.shortcuts.DeepShortcutManager; +import com.android.launcher3.testing.TestProtocol; import com.android.launcher3.util.IntSparseArrayMap; import com.android.launcher3.util.ItemInfoMatcher; import com.android.launcher3.util.PackageUserKey; @@ -92,6 +93,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi private boolean mModelLoaded; public boolean isModelLoaded() { synchronized (mLock) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, + "isModelLoaded: " + mModelLoaded + ", " + mLoaderTask); + } return mModelLoaded && mLoaderTask == null; } } diff --git a/src/com/android/launcher3/testing/TestInformationHandler.java b/src/com/android/launcher3/testing/TestInformationHandler.java index 8296cf962b..d0e648ffc9 100644 --- a/src/com/android/launcher3/testing/TestInformationHandler.java +++ b/src/com/android/launcher3/testing/TestInformationHandler.java @@ -24,6 +24,7 @@ import android.graphics.Bitmap; import android.graphics.Color; import android.os.Bundle; import android.os.Debug; +import android.util.Log; import android.view.View; import com.android.launcher3.DeviceProfile; @@ -176,6 +177,11 @@ public class TestInformationHandler implements ResourceBasedOverride { } protected boolean isLauncherInitialized() { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, + "isLauncherInitialized " + Launcher.ACTIVITY_TRACKER.getCreatedActivity() + ", " + + LauncherAppState.getInstance(mContext).getModel().isModelLoaded()); + } return Launcher.ACTIVITY_TRACKER.getCreatedActivity() == null || LauncherAppState.getInstance(mContext).getModel().isModelLoaded(); } diff --git a/src/com/android/launcher3/testing/TestProtocol.java b/src/com/android/launcher3/testing/TestProtocol.java index 5110977ae4..faf0ff6c45 100644 --- a/src/com/android/launcher3/testing/TestProtocol.java +++ b/src/com/android/launcher3/testing/TestProtocol.java @@ -85,4 +85,5 @@ public final class TestProtocol { public static final String NO_DRAG_TO_WORKSPACE = "b/138729456"; public static final String APP_NOT_DISABLED = "b/139891609"; public static final String NO_CONTEXT_MENU = "b/141770616"; + public static final String LAUNCHER_DIDNT_INITIALIZE = "b/142514365"; } diff --git a/src/com/android/launcher3/util/ActivityTracker.java b/src/com/android/launcher3/util/ActivityTracker.java index e85a4e8058..b4f361f36c 100644 --- a/src/com/android/launcher3/util/ActivityTracker.java +++ b/src/com/android/launcher3/util/ActivityTracker.java @@ -20,10 +20,12 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; import android.content.Intent; import android.os.Bundle; import android.os.IBinder; +import android.util.Log; import androidx.annotation.Nullable; import com.android.launcher3.BaseActivity; +import com.android.launcher3.testing.TestProtocol; import java.lang.ref.WeakReference; @@ -43,7 +45,13 @@ public final class ActivityTracker implements Runnable { } public void onActivityDestroyed(T activity) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "onActivityDestroyed"); + } if (mCurrentActivity.get() == activity) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "onActivityDestroyed: clear"); + } mCurrentActivity.clear(); } } @@ -89,6 +97,10 @@ public final class ActivityTracker implements Runnable { } public boolean handleCreate(T activity) { + if (TestProtocol.sDebugTracing) { + Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, + "ActivityTracker.handleCreate " + mCurrentActivity.get() + " => " + activity); + } mCurrentActivity = new WeakReference<>(activity); return handleIntent(activity, activity.getIntent(), false, false); }