diff options
Diffstat (limited to 'services')
7 files changed, 40 insertions, 68 deletions
diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index a14d729..ddb6d1a 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -1689,7 +1689,7 @@ public final class ActivityManagerService extends ActivityManagerNative && proc.pid == pid) { num++; proc.lastPssTime = SystemClock.uptimeMillis(); - proc.baseProcessTracker.addPss(pss, tmp[0], true); + proc.baseProcessTracker.addPss(pss, tmp[0], true, proc.pkgList); if (DEBUG_PSS) Slog.d(TAG, "PSS of " + proc.toShortString() + ": " + pss + " lastPss=" + proc.lastPss + " state=" + ProcessList.makeProcStateString(procState)); @@ -2705,18 +2705,6 @@ public final class ActivityManagerService extends ActivityManagerNative return intent; } - String getHomePackageName() { - Intent intent = getHomeIntent(); - ActivityInfo aInfo = resolveActivityInfo(intent, STOCK_PM_FLAGS, mCurrentUserId); - if (aInfo != null) { - final String homePackageName = aInfo.applicationInfo.packageName; - if (!ResolverActivity.class.getName().equals(homePackageName)) { - return homePackageName; - } - } - return null; - } - boolean startHomeActivityLocked(int userId) { if (mHeadless) { // Added because none of the other calls to ensureBootCompleted seem to fire @@ -4278,7 +4266,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (proc.thread != null && proc.setAdj == oomAdj) { // Record this for posterity if the process has been stable. proc.baseProcessTracker.addPss(infos[i].getTotalPss(), - infos[i].getTotalUss(), false); + infos[i].getTotalUss(), false, proc.pkgList); } } } @@ -4305,7 +4293,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { if (proc.thread != null && proc.setAdj == oomAdj) { // Record this for posterity if the process has been stable. - proc.baseProcessTracker.addPss(pss[i], tmpUss[0], false); + proc.baseProcessTracker.addPss(pss[i], tmpUss[0], false, proc.pkgList); } } } @@ -6786,6 +6774,10 @@ public final class ActivityManagerService extends ActivityManagerNative // Kill the running processes. for (int i=0; i<procs.size(); i++) { ProcessRecord pr = procs.get(i); + if (pr == mHomeProcess) { + // Don't kill the home process along with tasks from the same package. + continue; + } if (pr.setSchedGroup == Process.THREAD_GROUP_BG_NONINTERACTIVE) { killUnneededProcessLocked(pr, "remove task"); } else { @@ -11748,7 +11740,7 @@ public final class ActivityManagerService extends ActivityManagerNative synchronized (this) { if (r.thread != null && oomAdj == r.getSetAdjWithServices()) { // Record this for posterity if the process has been stable. - r.baseProcessTracker.addPss(myTotalPss, myTotalUss, true); + r.baseProcessTracker.addPss(myTotalPss, myTotalUss, true, r.pkgList); } } @@ -11909,7 +11901,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (memInfo.getZramTotalSizeKb() != 0) { if (!isCompact) { pw.print(" ZRAM: "); pw.print(memInfo.getZramTotalSizeKb()); - pw.print(" kB used for "); + pw.print(" kB physical used for "); pw.print(memInfo.getSwapTotalSizeKb() - memInfo.getSwapFreeSizeKb()); pw.print(" kB in swap ("); diff --git a/services/java/com/android/server/am/ActivityRecord.java b/services/java/com/android/server/am/ActivityRecord.java index 4359895..2c0b83b 100644 --- a/services/java/com/android/server/am/ActivityRecord.java +++ b/services/java/com/android/server/am/ActivityRecord.java @@ -58,6 +58,7 @@ import java.util.HashSet; final class ActivityRecord { static final String TAG = ActivityManagerService.TAG; static final boolean DEBUG_SAVED_STATE = ActivityStackSupervisor.DEBUG_SAVED_STATE; + final public static String RECENTS_PACKAGE_NAME = "com.android.systemui.recent"; final ActivityManagerService service; // owner final IApplicationToken.Stub appToken; // window manager token @@ -443,25 +444,18 @@ final class ActivityRecord { noDisplay = ent != null && ent.array.getBoolean( com.android.internal.R.styleable.Window_windowNoDisplay, false); - // If we know the system has determined the component, then - // we can consider this to be a home activity... - String homePackageName = supervisor.getHomePackageName(); - if (homePackageName != null && homePackageName.equals(packageName)) { - mActivityType = HOME_ACTIVITY_TYPE; - } else if ((!_componentSpecified || _launchedFromUid == Process.myUid() + if ((!_componentSpecified || _launchedFromUid == Process.myUid() || _launchedFromUid == 0) && Intent.ACTION_MAIN.equals(_intent.getAction()) && _intent.hasCategory(Intent.CATEGORY_HOME) && _intent.getCategories().size() == 1 && _intent.getData() == null && _intent.getType() == null && - (intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0) { + (intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_TASK) != 0 && + isNotResolverActivity()) { // This sure looks like a home activity! mActivityType = HOME_ACTIVITY_TYPE; - if (isNotResolverActivity()) { - supervisor.setHomePackageName(userId, packageName); - } - } else if (realActivity.getClassName().contains("com.android.systemui.recent")) { + } else if (realActivity.getClassName().contains(RECENTS_PACKAGE_NAME)) { mActivityType = RECENTS_ACTIVITY_TYPE; } else { mActivityType = APPLICATION_ACTIVITY_TYPE; diff --git a/services/java/com/android/server/am/ActivityStackSupervisor.java b/services/java/com/android/server/am/ActivityStackSupervisor.java index bf91904..f718706 100644 --- a/services/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/java/com/android/server/am/ActivityStackSupervisor.java @@ -203,12 +203,6 @@ public final class ActivityStackSupervisor { */ final PowerManager.WakeLock mGoingToSleep; - /** - * The name of the current home activity for each user. - * TODO: Remove entries when user is deleted. - */ - final SparseArray<String> mHomePackageNames = new SparseArray<String>(); - public ActivityStackSupervisor(ActivityManagerService service, Context context, Looper looper) { mService = service; @@ -2285,11 +2279,6 @@ public final class ActivityStackSupervisor { boolean switchUserLocked(int userId, UserStartedState uss) { mCurrentUser = userId; - final String homePackageName = mService.getHomePackageName(); - if (homePackageName != null) { - setHomePackageName(mCurrentUser, homePackageName); - } - mStartingUsers.add(uss); boolean haveActivities = false; for (int stackNdx = mStacks.size() - 1; stackNdx >= 0; --stackNdx) { @@ -2391,12 +2380,6 @@ public final class ActivityStackSupervisor { pw.print(prefix); pw.print("mStackState="); pw.println(stackStateToString(mStackState)); pw.print(prefix); pw.println("mSleepTimeout: " + mSleepTimeout); pw.print(prefix); pw.println("mCurTaskId: " + mCurTaskId); - pw.print(prefix); pw.print("mHomePackageNames:"); - for (int i = 0; i < mHomePackageNames.size(); ++i) { - pw.print(" ("); pw.print(mHomePackageNames.keyAt(i)); pw.print(","); - pw.print(mHomePackageNames.valueAt(i)); pw.print(")"); - } - pw.println(); } ArrayList<ActivityRecord> getDumpActivitiesLocked(String name) { @@ -2653,14 +2636,4 @@ public final class ActivityStackSupervisor { } } } - - String getHomePackageName() { - return mHomePackageNames.get(mCurrentUser); - } - - void setHomePackageName(int userId, String homePackageName) { - if (DEBUG_SWITCH) Slog.d(TAG, "setHomePackageName: user=" + userId + " package=" - + homePackageName); - mHomePackageNames.put(userId, homePackageName); - } } diff --git a/services/java/com/android/server/am/ProcessStatsService.java b/services/java/com/android/server/am/ProcessStatsService.java index be08973..2c49bb9 100644 --- a/services/java/com/android/server/am/ProcessStatsService.java +++ b/services/java/com/android/server/am/ProcessStatsService.java @@ -61,7 +61,6 @@ public final class ProcessStatsService extends IProcessStats.Stub { static final String STATE_FILE_SUFFIX = ".bin"; // Suffix to use for state filenames. static final String STATE_FILE_CHECKIN_SUFFIX = ".ci"; // State files that have checked in. static long WRITE_PERIOD = 30*60*1000; // Write file every 30 minutes or so. - static long COMMIT_PERIOD = 3*60*60*1000; // Commit current stats every 3 hours. final ActivityManagerService mAm; final File mBaseDir; @@ -160,7 +159,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { public boolean shouldWriteNowLocked(long now) { if (now > (mLastWriteTime+WRITE_PERIOD)) { if (SystemClock.elapsedRealtime() - > (mProcessStats.mTimePeriodStartRealtime+COMMIT_PERIOD)) { + > (mProcessStats.mTimePeriodStartRealtime+ProcessStats.COMMIT_PERIOD)) { mCommitPending = true; } return true; @@ -358,7 +357,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { boolean sepScreenStates, int[] screenStates, boolean sepMemStates, int[] memStates, boolean sepProcStates, int[] procStates, long now, String reqPackage) { ArrayList<ProcessStats.ProcessState> procs = mProcessStats.collectProcessesLocked( - screenStates, memStates, procStates, now, reqPackage); + screenStates, memStates, procStates, procStates, now, reqPackage); if (procs.size() > 0) { if (header != null) { pw.println(header); @@ -457,7 +456,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { if (curTime < minTime) { // Need to add in older stats to reach desired time. ArrayList<String> files = getCommittedFiles(0, false, true); - if (files.size() > 0) { + if (files != null && files.size() > 0) { current.setDataPosition(0); ProcessStats stats = ProcessStats.CREATOR.createFromParcel(current); current.recycle(); @@ -520,7 +519,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { static private void dumpHelp(PrintWriter pw) { pw.println("Process stats (procstats) dump options:"); pw.println(" [--checkin|-c|--csv] [--csv-screen] [--csv-proc] [--csv-mem]"); - pw.println(" [--details] [--full-details] [--current] [--one-day]"); + pw.println(" [--details] [--full-details] [--current] [--hours]"); pw.println(" [--commit] [--reset] [--clear] [--write] [-h] [<package.name>]"); pw.println(" --checkin: perform a checkin: print and delete old committed states."); pw.println(" --c: print only state in checkin format."); @@ -532,7 +531,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { pw.println(" --details: dump all execution details, not just summary."); pw.println(" --full-details: dump only detail information, for all saved state."); pw.println(" --current: only dump current state."); - pw.println(" --one-day: dump stats aggregated across about one day."); + pw.println(" --hours: aggregate over about N last hours."); pw.println(" --commit: commit current stats to disk and reset to start new stats."); pw.println(" --reset: reset current stats, without committing."); pw.println(" --clear: clear all stats; does both --reset and deletes old stats."); @@ -562,7 +561,7 @@ public final class ProcessStatsService extends IProcessStats.Stub { boolean dumpDetails = false; boolean dumpFullDetails = false; boolean dumpAll = false; - boolean oneDay = false; + int aggregateHours = 0; String reqPackage = null; boolean csvSepScreenStats = false; int[] csvScreenStats = new int[] { ProcessStats.ADJ_SCREEN_OFF, ProcessStats.ADJ_SCREEN_ON}; @@ -632,8 +631,20 @@ public final class ProcessStatsService extends IProcessStats.Stub { dumpDetails = true; } else if ("--full-details".equals(arg)) { dumpFullDetails = true; - } else if ("--one-day".equals(arg)) { - oneDay = true; + } else if ("--hours".equals(arg)) { + i++; + if (i >= args.length) { + pw.println("Error: argument required for --hours"); + dumpHelp(pw); + return; + } + try { + aggregateHours = Integer.parseInt(args[i]); + } catch (NumberFormatException e) { + pw.println("Error: --hours argument not an int -- " + args[i]); + dumpHelp(pw); + return; + } } else if ("--current".equals(arg)) { currentOnly = true; } else if ("--commit".equals(arg)) { @@ -750,8 +761,9 @@ public final class ProcessStatsService extends IProcessStats.Stub { */ } return; - } else if (oneDay) { - ParcelFileDescriptor pfd = getStatsOverTime(24*60*60*1000); + } else if (aggregateHours != 0) { + ParcelFileDescriptor pfd = getStatsOverTime(aggregateHours*60*60*1000 + - (ProcessStats.COMMIT_PERIOD/2)); if (pfd == null) { pw.println("Unable to build stats!"); return; diff --git a/services/java/com/android/server/am/TaskRecord.java b/services/java/com/android/server/am/TaskRecord.java index 8a9324c..385253e 100644 --- a/services/java/com/android/server/am/TaskRecord.java +++ b/services/java/com/android/server/am/TaskRecord.java @@ -428,6 +428,7 @@ final class TaskRecord extends ThumbnailHolder { pw.print(prefix); pw.print("numActivities="); pw.print(numActivities); pw.print(" rootWasReset="); pw.print(rootWasReset); pw.print(" userId="); pw.print(userId); + pw.print(" mTaskType="); pw.print(mTaskType); pw.print(" numFullscreen="); pw.print(numFullscreen); pw.print(" mOnTopOfHome="); pw.println(mOnTopOfHome); } diff --git a/services/java/com/android/server/wm/DisplayContent.java b/services/java/com/android/server/wm/DisplayContent.java index beeb899..2798104 100644 --- a/services/java/com/android/server/wm/DisplayContent.java +++ b/services/java/com/android/server/wm/DisplayContent.java @@ -162,6 +162,7 @@ class DisplayContent { void moveStack(TaskStack stack, boolean toTop) { mStackHistory.remove(stack); mStackHistory.add(toTop ? mStackHistory.size() : 0, stack); + mService.moveStackWindowsLocked(stack); } public boolean isPrivate() { diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 680b44e..80c50cc 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -4715,7 +4715,7 @@ public class WindowManagerService extends IWindowManager.Stub } } - private void moveStackWindowsLocked(TaskStack stack) { + void moveStackWindowsLocked(TaskStack stack) { DisplayContent displayContent = stack.getDisplayContent(); // First remove all of the windows from the list. @@ -4782,7 +4782,6 @@ public class WindowManagerService extends IWindowManager.Stub } stack.moveTaskToTop(task); displayContent.moveStack(stack, true); - moveStackWindowsLocked(stack); } } finally { Binder.restoreCallingIdentity(origId); |