From 82e201f03d7da6fdaa562bbaad92153a56c2f598 Mon Sep 17 00:00:00 2001 From: Tim Murray Date: Wed, 11 Jan 2017 09:52:38 -0800 Subject: [PATCH] add additional logging to ActiityManagerService add logging to help debugging issues with attachApplication/attachApplicationLocked. bug 34193533 Tests: boots and starts apps Change-Id: I6ef46dd92e893b71c164bfb28eeba1835dddffee --- .../android/server/am/ActivityManagerService.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index b68af438bf18c..fb39393b7874d 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -6455,6 +6455,7 @@ public final class ActivityManagerService extends ActivityManagerNative // the pid if we are running in multiple processes, or just pull the // next app record if we are emulating process with anonymous threads. ProcessRecord app; + long startTime = SystemClock.uptimeMillis(); if (pid != MY_PID && pid >= 0) { synchronized (mPidsSelfLocked) { app = mPidsSelfLocked.get(pid); @@ -6531,6 +6532,8 @@ public final class ActivityManagerService extends ActivityManagerNative mHandler.sendMessageDelayed(msg, CONTENT_PROVIDER_PUBLISH_TIMEOUT); } + checkTime(startTime, "attachApplicationLocked: before bindApplication"); + if (!normalMode) { Slog.i(TAG, "Launching preboot mode app: " + app); } @@ -6589,7 +6592,8 @@ public final class ActivityManagerService extends ActivityManagerNative profileFd = profileFd.dup(); } ProfilerInfo profilerInfo = profileFile == null ? null - : new ProfilerInfo(profileFile, profileFd, samplingInterval, profileAutoStop); + : new ProfilerInfo(profileFile, profileFd, samplingInterval, profileAutoStop); + checkTime(startTime, "attachApplicationLocked: immediately before bindApplication"); thread.bindApplication(processName, appInfo, providers, app.instrumentationClass, profilerInfo, app.instrumentationArguments, app.instrumentationWatcher, app.instrumentationUiAutomationConnection, testMode, @@ -6597,8 +6601,10 @@ public final class ActivityManagerService extends ActivityManagerNative isRestrictedBackupMode || !normalMode, app.persistent, new Configuration(mConfiguration), app.compat, getCommonServicesLocked(app.isolated), - mCoreSettingsObserver.getCoreSettingsLocked()); + mCoreSettingsObserver.getCoreSettingsLocked()); + checkTime(startTime, "attachApplicationLocked: immediately after bindApplication"); updateLruProcessLocked(app, false, null); + checkTime(startTime, "attachApplicationLocked: after updateLruProcessLocked"); app.lastRequestedGc = app.lastLowMemory = SystemClock.uptimeMillis(); } catch (Exception e) { // todo: Yikes! What should we do? For now we will try to @@ -6637,6 +6643,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (!badApp) { try { didSomething |= mServices.attachApplicationLocked(app, processName); + checkTime(startTime, "attachApplicationLocked: after mServices.attachApplicationLocked"); } catch (Exception e) { Slog.wtf(TAG, "Exception thrown starting services in " + app, e); badApp = true; @@ -6647,6 +6654,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (!badApp && isPendingBroadcastProcessLocked(pid)) { try { didSomething |= sendPendingBroadcastsLocked(app); + checkTime(startTime, "attachApplicationLocked: after sendPendingBroadcastsLocked"); } catch (Exception e) { // If the app died trying to launch the receiver we declare it 'bad' Slog.wtf(TAG, "Exception thrown dispatching broadcasts in " + app, e); @@ -6678,6 +6686,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (!didSomething) { updateOomAdjLocked(); + checkTime(startTime, "attachApplicationLocked: after updateOomAdjLocked"); } return true;