summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/am
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2014-09-03 01:09:21 +0000
committerDianne Hackborn <hackbod@google.com>2014-09-03 01:09:21 +0000
commit1257e82b94f2de290f78955ea9ed507ed098b9a5 (patch)
treea032e245f1885cd86522e47698b999549d7908cc /services/core/java/com/android/server/am
parent36927a3600520686495cba4f3fc19e1445f8a64c (diff)
downloadframeworks_base-1257e82b94f2de290f78955ea9ed507ed098b9a5.zip
frameworks_base-1257e82b94f2de290f78955ea9ed507ed098b9a5.tar.gz
frameworks_base-1257e82b94f2de290f78955ea9ed507ed098b9a5.tar.bz2
Revert "And yet more logging for slow execution."
This reverts commit 113390ac113083884b6f498424b3f6afa2df4ebc. Change-Id: I16fdb08f83ad31c10d943862bae639f622542339
Diffstat (limited to 'services/core/java/com/android/server/am')
-rwxr-xr-xservices/core/java/com/android/server/am/ActivityManagerService.java56
1 files changed, 19 insertions, 37 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 3770dc2..389369f 100755
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -1107,7 +1107,12 @@ 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
/**
@@ -2898,11 +2903,9 @@ 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;
@@ -2924,17 +2927,14 @@ 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,7 +2970,6 @@ 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) {
@@ -2982,11 +2981,9 @@ 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
@@ -3003,7 +3000,6 @@ 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;
}
@@ -3019,14 +3015,11 @@ 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);
}
@@ -3034,9 +3027,7 @@ 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;
@@ -3046,12 +3037,10 @@ 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) {
@@ -3077,7 +3066,6 @@ 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
@@ -3121,18 +3109,14 @@ 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,
@@ -3143,7 +3127,6 @@ 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 ");
@@ -3181,7 +3164,6 @@ 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) {
@@ -3191,7 +3173,6 @@ 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);
@@ -10296,13 +10277,13 @@ public final class ActivityManagerService extends ActivityManagerNative
if (r == null) {
return false;
}
- if (r.changeWindowTranslucency(true)) {
- mWindowManager.setAppFullscreen(token, true);
+ final boolean translucentChanged = r.changeWindowTranslucency(true);
+ if (translucentChanged) {
r.task.stack.releaseBackgroundResources();
mStackSupervisor.ensureActivitiesVisibleLocked(null, 0);
- return true;
}
- return false;
+ mWindowManager.setAppFullscreen(token, true);
+ return translucentChanged;
}
} finally {
Binder.restoreCallingIdentity(origId);
@@ -10323,15 +10304,13 @@ public final class ActivityManagerService extends ActivityManagerNative
ActivityRecord under = r.task.mActivities.get(index - 1);
under.returningOptions = options;
}
- if (r.changeWindowTranslucency(false)) {
+ final boolean translucentChanged = r.changeWindowTranslucency(false);
+ if (translucentChanged) {
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);
@@ -17961,6 +17940,7 @@ 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));
@@ -18028,6 +18008,7 @@ 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
@@ -18395,7 +18376,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) {
+ if (mCurrentUserId == userId && mTargetUserId == UserHandle.USER_NULL) {
return ActivityManager.USER_OP_IS_CURRENT;
}
@@ -18535,12 +18516,13 @@ public final class ActivityManagerService extends ActivityManagerNative
throw new SecurityException(msg);
}
synchronized (this) {
- return getUserManagerLocked().getUserInfo(mCurrentUserId);
+ int userId = mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId;
+ return getUserManagerLocked().getUserInfo(userId);
}
}
int getCurrentUserIdLocked() {
- return mCurrentUserId;
+ return mTargetUserId != UserHandle.USER_NULL ? mTargetUserId : mCurrentUserId;
}
@Override