summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/am
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-09-02 22:49:37 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-02 22:49:38 +0000
commit526b642290eb81674d7772f85ced967c19714b68 (patch)
treedf25171a72f0e394ec838b7f6d1aea6ea217c24b /services/core/java/com/android/server/am
parentca2f20deaae0a3488cf1f7a4051a6833a15da4d9 (diff)
parent36927a3600520686495cba4f3fc19e1445f8a64c (diff)
downloadframeworks_base-526b642290eb81674d7772f85ced967c19714b68.zip
frameworks_base-526b642290eb81674d7772f85ced967c19714b68.tar.gz
frameworks_base-526b642290eb81674d7772f85ced967c19714b68.tar.bz2
Merge "And yet more logging for slow execution." into lmp-dev
Diffstat (limited to 'services/core/java/com/android/server/am')
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java56
1 files changed, 37 insertions, 19 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 389369f..3770dc2 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1107,12 +1107,7 @@ public final class ActivityManagerService extends ActivityManagerNative
final ActivityThread mSystemThread;
- // Holds the current foreground user's id
int mCurrentUserId = 0;
- // Holds the target user's id during a user switch
- int mTargetUserId = UserHandle.USER_NULL;
- // If there are multiple profiles for the current user, their ids are here
- // Currently only the primary user can have managed profiles
int[] mCurrentProfileIds = new int[] {UserHandle.USER_OWNER}; // Accessed by ActivityStack
/**
@@ -2903,9 +2898,11 @@ public final class ActivityManagerService extends ActivityManagerNative
boolean knownToBeDead, int intentFlags, String hostingType, ComponentName hostingName,
boolean allowWhileBooting, boolean isolated, int isolatedUid, boolean keepIfLarge,
String abiOverride, String entryPoint, String[] entryPointArgs, Runnable crashHandler) {
+ long startTime = SystemClock.elapsedRealtime();
ProcessRecord app;
if (!isolated) {
app = getProcessRecordLocked(processName, info.uid, keepIfLarge);
+ checkTime(startTime, "startProcess: after getProcessRecord");
} else {
// If this is an isolated process, it can't re-use an existing process.
app = null;
@@ -2927,14 +2924,17 @@ public final class ActivityManagerService extends ActivityManagerNative
if (DEBUG_PROCESSES) Slog.v(TAG, "App already running: " + app);
// If this is a new package in the process, add the package to the list
app.addPackage(info.packageName, info.versionCode, mProcessStats);
+ checkTime(startTime, "startProcess: done, added package to proc");
return app;
}
// An application record is attached to a previous process,
// clean it up now.
if (DEBUG_PROCESSES || DEBUG_CLEANUP) Slog.v(TAG, "App died: " + app);
+ checkTime(startTime, "startProcess: bad proc running, killing");
Process.killProcessGroup(app.info.uid, app.pid);
handleAppDiedLocked(app, true, true);
+ checkTime(startTime, "startProcess: done killing old proc");
}
String hostingNameStr = hostingName != null
@@ -2970,6 +2970,7 @@ public final class ActivityManagerService extends ActivityManagerNative
}
if (app == null) {
+ checkTime(startTime, "startProcess: creating new process record");
app = newProcessRecordLocked(info, processName, isolated, isolatedUid);
app.crashHandler = crashHandler;
if (app == null) {
@@ -2981,9 +2982,11 @@ public final class ActivityManagerService extends ActivityManagerNative
if (isolated) {
mIsolatedProcesses.put(app.uid, app);
}
+ checkTime(startTime, "startProcess: done creating new process record");
} else {
// If this is a new package in the process, add the package to the list
app.addPackage(info.packageName, info.versionCode, mProcessStats);
+ checkTime(startTime, "startProcess: added package to existing proc");
}
// If the system is not ready yet, then hold off on starting this
@@ -3000,6 +3003,7 @@ public final class ActivityManagerService extends ActivityManagerNative
startProcessLocked(
app, hostingType, hostingNameStr, abiOverride, entryPoint, entryPointArgs);
+ checkTime(startTime, "startProcess: done starting proc!");
return (app.pid != 0) ? app : null;
}
@@ -3015,11 +3019,14 @@ public final class ActivityManagerService extends ActivityManagerNative
private final void startProcessLocked(ProcessRecord app, String hostingType,
String hostingNameStr, String abiOverride, String entryPoint, String[] entryPointArgs) {
+ long startTime = SystemClock.elapsedRealtime();
if (app.pid > 0 && app.pid != MY_PID) {
+ checkTime(startTime, "startProcess: removing from pids map");
synchronized (mPidsSelfLocked) {
mPidsSelfLocked.remove(app.pid);
mHandler.removeMessages(PROC_START_TIMEOUT_MSG, app);
}
+ checkTime(startTime, "startProcess: done removing from pids map");
app.setPid(0);
}
@@ -3027,7 +3034,9 @@ public final class ActivityManagerService extends ActivityManagerNative
"startProcessLocked removing on hold: " + app);
mProcessesOnHold.remove(app);
+ checkTime(startTime, "startProcess: starting to update cpu stats");
updateCpuStats();
+ checkTime(startTime, "startProcess: done updating cpu stats");
try {
int uid = app.uid;
@@ -3037,10 +3046,12 @@ public final class ActivityManagerService extends ActivityManagerNative
if (!app.isolated) {
int[] permGids = null;
try {
+ checkTime(startTime, "startProcess: getting gids from package manager");
final PackageManager pm = mContext.getPackageManager();
permGids = pm.getPackageGids(app.info.packageName);
if (Environment.isExternalStorageEmulated()) {
+ checkTime(startTime, "startProcess: checking external storage perm");
if (pm.checkPermission(
android.Manifest.permission.ACCESS_ALL_EXTERNAL_STORAGE,
app.info.packageName) == PERMISSION_GRANTED) {
@@ -3066,6 +3077,7 @@ public final class ActivityManagerService extends ActivityManagerNative
gids[0] = UserHandle.getSharedAppGid(UserHandle.getAppId(uid));
gids[1] = UserHandle.getUserGid(UserHandle.getUserId(uid));
}
+ checkTime(startTime, "startProcess: building args");
if (mFactoryTest != FactoryTest.FACTORY_TEST_OFF) {
if (mFactoryTest == FactoryTest.FACTORY_TEST_LOW_LEVEL
&& mTopComponent != null
@@ -3109,14 +3121,18 @@ public final class ActivityManagerService extends ActivityManagerNative
// the PID of the new process, or else throw a RuntimeException.
boolean isActivityProcess = (entryPoint == null);
if (entryPoint == null) entryPoint = "android.app.ActivityThread";
+ checkTime(startTime, "startProcess: asking zygote to start proc");
Process.ProcessStartResult startResult = Process.start(entryPoint,
app.processName, uid, uid, gids, debugFlags, mountExternal,
app.info.targetSdkVersion, app.info.seinfo, requiredAbi, entryPointArgs);
+ checkTime(startTime, "startProcess: returned from zygote!");
+ checkTime(startTime, "startProcess: noting battery stats update");
if (app.isolated) {
mBatteryStatsService.addIsolatedUid(app.uid, app.info.uid);
}
mBatteryStatsService.noteProcessStart(app.processName, app.info.uid);
+ checkTime(startTime, "startProcess: done updating battery stats");
EventLog.writeEvent(EventLogTags.AM_PROC_START,
UserHandle.getUserId(uid), startResult.pid, uid,
@@ -3127,6 +3143,7 @@ public final class ActivityManagerService extends ActivityManagerNative
Watchdog.getInstance().processStarted(app.processName, startResult.pid);
}
+ checkTime(startTime, "startProcess: building log message");
StringBuilder buf = mStringBuilder;
buf.setLength(0);
buf.append("Start proc ");
@@ -3164,6 +3181,7 @@ public final class ActivityManagerService extends ActivityManagerNative
app.usingWrapper = startResult.usingWrapper;
app.removed = false;
app.killedByAm = false;
+ checkTime(startTime, "startProcess: starting to update pids map");
synchronized (mPidsSelfLocked) {
this.mPidsSelfLocked.put(startResult.pid, app);
if (isActivityProcess) {
@@ -3173,6 +3191,7 @@ public final class ActivityManagerService extends ActivityManagerNative
? PROC_START_TIMEOUT_WITH_WRAPPER : PROC_START_TIMEOUT);
}
}
+ checkTime(startTime, "startProcess: done updating pids map");
} catch (RuntimeException e) {
// XXX do better error recovery.
app.setPid(0);
@@ -10277,13 +10296,13 @@ public final class ActivityManagerService extends ActivityManagerNative
if (r == null) {
return false;
}
- final boolean translucentChanged = r.changeWindowTranslucency(true);
- if (translucentChanged) {
+ if (r.changeWindowTranslucency(true)) {
+ mWindowManager.setAppFullscreen(token, true);
r.task.stack.releaseBackgroundResources();
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
+ return true;
}
- mWindowManager.setAppFullscreen(token, true);
- return translucentChanged;
+ return false;
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -10304,13 +10323,15 @@ public final class ActivityManagerService extends ActivityManagerNative
ActivityRecord under = r.task.mActivities.get(index - 1);
under.returningOptions = options;
}
- final boolean translucentChanged = r.changeWindowTranslucency(false);
- if (translucentChanged) {
+ if (r.changeWindowTranslucency(false)) {
r.task.stack.convertToTranslucent(r);
+ mWindowManager.setAppFullscreen(token, false);
+ mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
+ return true;
+ } else {
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
+ return false;
}
- mWindowManager.setAppFullscreen(token, false);
- return translucentChanged;
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -17940,7 +17961,6 @@ public final class ActivityManagerService extends ActivityManagerNative
return false;
}
userName = userInfo.name;
- mTargetUserId = userId;
}
mHandler.removeMessages(START_USER_SWITCH_MSG);
mHandler.sendMessage(mHandler.obtainMessage(START_USER_SWITCH_MSG, userId, 0, userName));
@@ -18008,7 +18028,6 @@ public final class ActivityManagerService extends ActivityManagerNative
if (foreground) {
mCurrentUserId = userId;
- mTargetUserId = UserHandle.USER_NULL; // reset, mCurrentUserId has caught up
updateCurrentProfileIdsLocked();
mWindowManager.setCurrentUser(userId, mCurrentProfileIds);
// Once the internal notion of the active user has switched, we lock the device
@@ -18376,7 +18395,7 @@ public final class ActivityManagerService extends ActivityManagerNative
private int stopUserLocked(final int userId, final IStopUserCallback callback) {
if (DEBUG_MU) Slog.i(TAG_MU, "stopUserLocked userId=" + userId);
- if (mCurrentUserId == userId && mTargetUserId == UserHandle.USER_NULL) {
+ if (mCurrentUserId == userId) {
return ActivityManager.USER_OP_IS_CURRENT;
}
@@ -18516,13 +18535,12 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
synchronized (this) {
- int userId = mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId;
- return getUserManagerLocked().getUserInfo(userId);
+ return getUserManagerLocked().getUserInfo(mCurrentUserId);
}
}
int getCurrentUserIdLocked() {
- return mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId;
+ return mCurrentUserId;
}
@Override