Tracing for another "Launcher didn't initialize" failure

This simply restored logging used for one of earlier investigations

Bug: 148313079
Change-Id: Idafed13208dc5610d577986fc487d1d44bc0ef5e
This commit is contained in:
vadimt
2020-01-27 17:44:44 -08:00
parent ce67572ec8
commit c8b09709ff
7 changed files with 67 additions and 1 deletions

View File

@@ -111,6 +111,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();
}
}

View File

@@ -135,6 +135,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
TouchInteractionService.this.initInputMonitor();
preloadOverview(true /* fromInit */);
});
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS initialized");
}
sIsInitialized = true;
}
@@ -392,6 +395,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
@Override
public void onDestroy() {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "TIS destroyed");
}
sIsInitialized = false;
if (mDeviceState.isUserUnlocked()) {
mInputConsumer.unregisterInputConsumer();

View File

@@ -56,6 +56,7 @@ import com.android.launcher3.pm.InstallSessionTracker;
import com.android.launcher3.pm.PackageInstallInfo;
import com.android.launcher3.pm.UserCache;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.IntSparseArrayMap;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.launcher3.util.LooperExecutor;
@@ -96,6 +97,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;
}
}
@@ -368,6 +373,9 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
public boolean stopLoader() {
synchronized (mLock) {
LoaderTask oldTask = mLoaderTask;
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE, "LauncherModel.stopLoader");
}
mLoaderTask = null;
if (oldTask != null) {
oldTask.stopLocked();
@@ -381,6 +389,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
synchronized (mLock) {
stopLoader();
mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, mBgDataModel, results);
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LauncherModel.startLoaderForResults " + mLoaderTask);
}
// Always post the loader task, instead of running directly (even on same thread) so
// that we exit any nested synchronized blocks
@@ -482,6 +494,10 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
public void close() {
synchronized (mLock) {
// If we are still the last one to be scheduled, remove ourselves.
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LauncherModel.close " + mLoaderTask + ", " + mTask);
}
if (mLoaderTask == mTask) {
mLoaderTask = null;
}

View File

@@ -76,6 +76,7 @@ import com.android.launcher3.qsb.QsbContainerView;
import com.android.launcher3.shortcuts.ShortcutKey;
import com.android.launcher3.shortcuts.ShortcutRequest;
import com.android.launcher3.shortcuts.ShortcutRequest.QueryResult;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.IOUtils;
import com.android.launcher3.util.LooperIdleLock;
@@ -168,15 +169,32 @@ public class LoaderTask implements Runnable {
}
public void run() {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LoaderTask1 " + this);
}
synchronized (this) {
// Skip fast if we are already stopped.
if (mStopped) {
return;
}
}
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LoaderTask2 " + this);
}
Object traceToken = TraceHelper.INSTANCE.beginSection(TAG);
TimingLogger logger = new TimingLogger(TAG, "run");
TimingLogger logger = TestProtocol.sDebugTracing ?
new TimingLogger(TAG, "run") {
@Override
public void addSplit(String splitLabel) {
super.addSplit(splitLabel);
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LoaderTask.addSplit " + splitLabel);
}
}
: new TimingLogger(TAG, "run");
try (LauncherModel.LoaderTransaction transaction = mApp.getModel().beginLoader(this)) {
List<ShortcutInfo> allShortcuts = new ArrayList<>();
loadWorkspace(allShortcuts);
@@ -260,6 +278,10 @@ public class LoaderTask implements Runnable {
updateHandler.finish();
logger.addSplit("finish icon update");
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.LAUNCHER_DIDNT_INITIALIZE,
"LoaderTask3 " + this);
}
transaction.commit();
} catch (CancellationException e) {
// Loader stopped, ignore

View File

@@ -25,6 +25,7 @@ import android.graphics.Color;
import android.os.Bundle;
import android.os.Debug;
import android.system.Os;
import android.util.Log;
import android.view.View;
import androidx.annotation.Keep;
@@ -190,6 +191,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();
}

View File

@@ -89,4 +89,5 @@ public final class TestProtocol {
public static final String NO_BACKGROUND_TO_OVERVIEW_TAG = "b/138251824";
public static final String APP_NOT_DISABLED = "b/139891609";
public static final String LAUNCHER_DIDNT_INITIALIZE = "b/148313079";
}

View File

@@ -45,7 +45,13 @@ public final class ActivityTracker<T extends BaseActivity> 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();
}
}
@@ -110,6 +116,10 @@ public final class ActivityTracker<T extends BaseActivity> 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);
}