diff options
Diffstat (limited to 'services/java/com')
8 files changed, 149 insertions, 105 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 498bdfc..851cb33 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -2450,6 +2450,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { int defaultVal = (SystemProperties.get("ro.tether.denied").equals("true") ? 0 : 1); boolean tetherEnabledInSettings = (Settings.Secure.getInt(mContext.getContentResolver(), Settings.Secure.TETHER_SUPPORTED, defaultVal) != 0); + // Short term disabling of Tethering if DUN is required. + // TODO - fix multi-connection tethering using policy-base routing + int[] upstreamConnTypes = mTethering.getUpstreamIfaceTypes(); + for (int i : upstreamConnTypes) { + if (i == ConnectivityManager.TYPE_MOBILE_DUN) return false; + } return tetherEnabledInSettings && mTetheringConfigValid; } diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java index fdae4bd..1b0addf 100644 --- a/services/java/com/android/server/PowerManagerService.java +++ b/services/java/com/android/server/PowerManagerService.java @@ -2198,25 +2198,21 @@ public class PowerManagerService extends IPowerManager.Stub } public void run() { - if (mAnimateScreenLights) { - synchronized (mLocks) { + synchronized (mLocks) { + // we're turning off + final boolean turningOff = animating && targetValue == Power.BRIGHTNESS_OFF; + if (mAnimateScreenLights || !turningOff) { long now = SystemClock.uptimeMillis(); boolean more = mScreenBrightness.stepLocked(); if (more) { mScreenOffHandler.postAtTime(this, now+(1000/60)); } - } - } else { - synchronized (mLocks) { - // we're turning off - final boolean animate = animating && targetValue == Power.BRIGHTNESS_OFF; - if (animate) { - // It's pretty scary to hold mLocks for this long, and we should - // redesign this, but it works for now. - nativeStartSurfaceFlingerAnimation( - mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR - ? 0 : mAnimationSetting); - } + } else { + // It's pretty scary to hold mLocks for this long, and we should + // redesign this, but it works for now. + nativeStartSurfaceFlingerAnimation( + mScreenOffReason == WindowManagerPolicy.OFF_BECAUSE_OF_PROX_SENSOR + ? 0 : mAnimationSetting); mScreenBrightness.jumpToTargetLocked(); } } diff --git a/services/java/com/android/server/Watchdog.java b/services/java/com/android/server/Watchdog.java index 2d3ac00..728fb26 100644 --- a/services/java/com/android/server/Watchdog.java +++ b/services/java/com/android/server/Watchdog.java @@ -451,7 +451,8 @@ public class Watchdog extends Thread { Thread dropboxThread = new Thread("watchdogWriteToDropbox") { public void run() { mActivity.addErrorToDropBox( - "watchdog", null, null, null, name, null, stack, null); + "watchdog", null, "system_server", null, null, + name, null, stack, null); } }; dropboxThread.start(); diff --git a/services/java/com/android/server/am/ActivityManagerService.java b/services/java/com/android/server/am/ActivityManagerService.java index 0d6f405..04bbc11 100644 --- a/services/java/com/android/server/am/ActivityManagerService.java +++ b/services/java/com/android/server/am/ActivityManagerService.java @@ -721,6 +721,13 @@ public final class ActivityManagerService extends ActivityManagerNative int mLruSeq = 0; /** + * Keep track of the number of service processes we last found, to + * determine on the next iteration which should be B services. + */ + int mNumServiceProcs = 0; + int mNewNumServiceProcs = 0; + + /** * System monitoring: number of processes that died since the last * N procs were started. */ @@ -2978,7 +2985,8 @@ public final class ActivityManagerService extends ActivityManagerNative Process.sendSignal(app.pid, Process.SIGNAL_QUIT); } - addErrorToDropBox("anr", app, activity, parent, annotation, cpuInfo, tracesFile, null); + addErrorToDropBox("anr", app, app.processName, activity, parent, annotation, + cpuInfo, tracesFile, null); if (mController != null) { try { @@ -3122,7 +3130,7 @@ public final class ActivityManagerService extends ActivityManagerNative return; } killPackageProcessesLocked(packageName, pkgUid, - ProcessList.SECONDARY_SERVER_ADJ, false, true, true, false); + ProcessList.SERVICE_ADJ, false, true, true, false); } } finally { Binder.restoreCallingIdentity(callingId); @@ -4921,7 +4929,7 @@ public final class ActivityManagerService extends ActivityManagerNative outInfo.lowMemory = outInfo.availMem < (homeAppMem + ((hiddenAppMem-homeAppMem)/2)); outInfo.hiddenAppThreshold = hiddenAppMem; outInfo.secondaryServerThreshold = mProcessList.getMemLevel( - ProcessList.SECONDARY_SERVER_ADJ); + ProcessList.SERVICE_ADJ); outInfo.visibleAppThreshold = mProcessList.getMemLevel( ProcessList.VISIBLE_APP_ADJ); outInfo.foregroundAppThreshold = mProcessList.getMemLevel( @@ -6112,7 +6120,7 @@ public final class ActivityManagerService extends ActivityManagerNative if ((info.flags&(ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) == (ApplicationInfo.FLAG_SYSTEM|ApplicationInfo.FLAG_PERSISTENT)) { app.persistent = true; - app.maxAdj = ProcessList.CORE_SERVER_ADJ; + app.maxAdj = ProcessList.PERSISTENT_PROC_ADJ; } if (app.thread == null && mPersistentStartingProcesses.indexOf(app) < 0) { mPersistentStartingProcesses.add(app); @@ -6510,14 +6518,15 @@ public final class ActivityManagerService extends ActivityManagerNative // If the worst oom_adj is somewhere in the hidden proc LRU range, // then constrain it so we will kill all hidden procs. - if (worstType < ProcessList.EMPTY_APP_ADJ && worstType > ProcessList.HIDDEN_APP_MIN_ADJ) { + if (worstType < ProcessList.HIDDEN_APP_MAX_ADJ + && worstType > ProcessList.HIDDEN_APP_MIN_ADJ) { worstType = ProcessList.HIDDEN_APP_MIN_ADJ; } // If this is not a secure call, don't let it kill processes that // are important. - if (!secure && worstType < ProcessList.SECONDARY_SERVER_ADJ) { - worstType = ProcessList.SECONDARY_SERVER_ADJ; + if (!secure && worstType < ProcessList.SERVICE_ADJ) { + worstType = ProcessList.SERVICE_ADJ; } Slog.w(TAG, "Killing processes " + reason + " at adjustment " + worstType); @@ -7082,16 +7091,18 @@ public final class ActivityManagerService extends ActivityManagerNative */ public void handleApplicationCrash(IBinder app, ApplicationErrorReport.CrashInfo crashInfo) { ProcessRecord r = findAppProcess(app, "Crash"); + final String processName = app == null ? "system_server" + : (r == null ? "unknown" : r.processName); EventLog.writeEvent(EventLogTags.AM_CRASH, Binder.getCallingPid(), - app == null ? "system" : (r == null ? "unknown" : r.processName), + processName, r == null ? -1 : r.info.flags, crashInfo.exceptionClassName, crashInfo.exceptionMessage, crashInfo.throwFileName, crashInfo.throwLineNumber); - addErrorToDropBox("crash", r, null, null, null, null, null, crashInfo); + addErrorToDropBox("crash", r, processName, null, null, null, null, null, crashInfo); crashApplication(r, crashInfo); } @@ -7164,6 +7175,7 @@ public final class ActivityManagerService extends ActivityManagerNative final boolean isSystemApp = process == null || (process.info.flags & (ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)) != 0; + final String processName = process == null ? "unknown" : process.processName; final String dropboxTag = isSystemApp ? "system_app_strictmode" : "data_app_strictmode"; final DropBoxManager dbox = (DropBoxManager) mContext.getSystemService(Context.DROPBOX_SERVICE); @@ -7176,7 +7188,7 @@ public final class ActivityManagerService extends ActivityManagerNative final StringBuilder sb = isSystemApp ? mStrictModeBuffer : new StringBuilder(1024); synchronized (sb) { bufferWasEmpty = sb.length() == 0; - appendDropBoxProcessHeaders(process, sb); + appendDropBoxProcessHeaders(process, processName, sb); sb.append("Build: ").append(Build.FINGERPRINT).append("\n"); sb.append("System-App: ").append(isSystemApp).append("\n"); sb.append("Uptime-Millis: ").append(info.violationUptimeMillis).append("\n"); @@ -7278,13 +7290,15 @@ public final class ActivityManagerService extends ActivityManagerNative public boolean handleApplicationWtf(IBinder app, String tag, ApplicationErrorReport.CrashInfo crashInfo) { ProcessRecord r = findAppProcess(app, "WTF"); + final String processName = app == null ? "system_server" + : (r == null ? "unknown" : r.processName); EventLog.writeEvent(EventLogTags.AM_WTF, Binder.getCallingPid(), - app == null ? "system" : (r == null ? "unknown" : r.processName), + processName, r == null ? -1 : r.info.flags, tag, crashInfo.exceptionMessage); - addErrorToDropBox("wtf", r, null, null, tag, null, null, crashInfo); + addErrorToDropBox("wtf", r, processName, null, null, tag, null, null, crashInfo); if (r != null && r.pid != Process.myPid() && Settings.Secure.getInt(mContext.getContentResolver(), @@ -7327,7 +7341,8 @@ public final class ActivityManagerService extends ActivityManagerNative * Utility function for addErrorToDropBox and handleStrictModeViolation's logging * to append various headers to the dropbox log text. */ - private void appendDropBoxProcessHeaders(ProcessRecord process, StringBuilder sb) { + private void appendDropBoxProcessHeaders(ProcessRecord process, String processName, + StringBuilder sb) { // Watchdog thread ends up invoking this function (with // a null ProcessRecord) to add the stack file to dropbox. // Do not acquire a lock on this (am) in such cases, as it @@ -7335,18 +7350,14 @@ public final class ActivityManagerService extends ActivityManagerNative // is invoked due to unavailability of lock on am and it // would prevent watchdog from killing system_server. if (process == null) { - sb.append("Process: system_server\n"); + sb.append("Process: ").append(processName).append("\n"); return; } // Note: ProcessRecord 'process' is guarded by the service // instance. (notably process.pkgList, which could otherwise change // concurrently during execution of this method) synchronized (this) { - if (process.pid == MY_PID) { - sb.append("Process: system_server\n"); - } else { - sb.append("Process: ").append(process.processName).append("\n"); - } + sb.append("Process: ").append(processName).append("\n"); int flags = process.info.flags; IPackageManager pm = AppGlobals.getPackageManager(); sb.append("Flags: 0x").append(Integer.toString(flags, 16)).append("\n"); @@ -7390,7 +7401,8 @@ public final class ActivityManagerService extends ActivityManagerNative * @param crashInfo giving an application stack trace, null if absent */ public void addErrorToDropBox(String eventType, - ProcessRecord process, ActivityRecord activity, ActivityRecord parent, String subject, + ProcessRecord process, String processName, ActivityRecord activity, + ActivityRecord parent, String subject, final String report, final File logFile, final ApplicationErrorReport.CrashInfo crashInfo) { // NOTE -- this must never acquire the ActivityManagerService lock, @@ -7404,7 +7416,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (dbox == null || !dbox.isTagEnabled(dropboxTag)) return; final StringBuilder sb = new StringBuilder(1024); - appendDropBoxProcessHeaders(process, sb); + appendDropBoxProcessHeaders(process, processName, sb); if (activity != null) { sb.append("Activity: ").append(activity.shortComponentName).append("\n"); } @@ -7653,19 +7665,19 @@ public final class ActivityManagerService extends ActivityManagerNative } static int oomAdjToImportance(int adj, ActivityManager.RunningAppProcessInfo currApp) { - if (adj >= ProcessList.EMPTY_APP_ADJ) { - return ActivityManager.RunningAppProcessInfo.IMPORTANCE_EMPTY; - } else if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { + if (adj >= ProcessList.HIDDEN_APP_MIN_ADJ) { if (currApp != null) { currApp.lru = adj - ProcessList.HIDDEN_APP_MIN_ADJ + 1; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; + } else if (adj >= ProcessList.SERVICE_B_ADJ) { + return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HOME_APP_ADJ) { if (currApp != null) { currApp.lru = 0; } return ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND; - } else if (adj >= ProcessList.SECONDARY_SERVER_ADJ) { + } else if (adj >= ProcessList.SERVICE_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_SERVICE; } else if (adj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { return ActivityManager.RunningAppProcessInfo.IMPORTANCE_CANT_SAVE_STATE; @@ -8154,6 +8166,8 @@ public final class ActivityManagerService extends ActivityManagerNative pw.println(" mGoingToSleep=" + mMainStack.mGoingToSleep); pw.println(" mLaunchingActivity=" + mMainStack.mLaunchingActivity); pw.println(" mAdjSeq=" + mAdjSeq + " mLruSeq=" + mLruSeq); + pw.println(" mNumServiceProcs=" + mNumServiceProcs + + " mNewNumServiceProcs=" + mNewNumServiceProcs); } return true; @@ -8190,16 +8204,17 @@ public final class ActivityManagerService extends ActivityManagerNative needSep = true; pw.println(" OOM levels:"); pw.print(" SYSTEM_ADJ: "); pw.println(ProcessList.SYSTEM_ADJ); - pw.print(" CORE_SERVER_ADJ: "); pw.println(ProcessList.CORE_SERVER_ADJ); + pw.print(" PERSISTENT_PROC_ADJ: "); pw.println(ProcessList.PERSISTENT_PROC_ADJ); pw.print(" FOREGROUND_APP_ADJ: "); pw.println(ProcessList.FOREGROUND_APP_ADJ); pw.print(" VISIBLE_APP_ADJ: "); pw.println(ProcessList.VISIBLE_APP_ADJ); pw.print(" PERCEPTIBLE_APP_ADJ: "); pw.println(ProcessList.PERCEPTIBLE_APP_ADJ); pw.print(" HEAVY_WEIGHT_APP_ADJ: "); pw.println(ProcessList.HEAVY_WEIGHT_APP_ADJ); pw.print(" BACKUP_APP_ADJ: "); pw.println(ProcessList.BACKUP_APP_ADJ); - pw.print(" SECONDARY_SERVER_ADJ: "); pw.println(ProcessList.SECONDARY_SERVER_ADJ); + pw.print(" SERVICE_ADJ: "); pw.println(ProcessList.SERVICE_ADJ); pw.print(" HOME_APP_ADJ: "); pw.println(ProcessList.HOME_APP_ADJ); + pw.print(" SERVICE_B_ADJ: "); pw.println(ProcessList.SERVICE_B_ADJ); pw.print(" HIDDEN_APP_MIN_ADJ: "); pw.println(ProcessList.HIDDEN_APP_MIN_ADJ); - pw.print(" EMPTY_APP_ADJ: "); pw.println(ProcessList.EMPTY_APP_ADJ); + pw.print(" HIDDEN_APP_MAX_ADJ: "); pw.println(ProcessList.HIDDEN_APP_MAX_ADJ); if (needSep) pw.println(" "); needSep = true; @@ -8990,14 +9005,14 @@ public final class ActivityManagerService extends ActivityManagerNative for (int i=N; i>=0; i--) { ProcessRecord r = list.get(i).first; String oomAdj; - if (r.setAdj >= ProcessList.EMPTY_APP_ADJ) { - oomAdj = buildOomTag("empty", null, r.setAdj, ProcessList.EMPTY_APP_ADJ); - } else if (r.setAdj >= ProcessList.HIDDEN_APP_MIN_ADJ) { + if (r.setAdj >= ProcessList.HIDDEN_APP_MIN_ADJ) { oomAdj = buildOomTag("bak", " ", r.setAdj, ProcessList.HIDDEN_APP_MIN_ADJ); + } else if (r.setAdj >= ProcessList.SERVICE_B_ADJ) { + oomAdj = buildOomTag("svcb ", null, r.setAdj, ProcessList.SERVICE_B_ADJ); } else if (r.setAdj >= ProcessList.HOME_APP_ADJ) { oomAdj = buildOomTag("home ", null, r.setAdj, ProcessList.HOME_APP_ADJ); - } else if (r.setAdj >= ProcessList.SECONDARY_SERVER_ADJ) { - oomAdj = buildOomTag("svc", " ", r.setAdj, ProcessList.SECONDARY_SERVER_ADJ); + } else if (r.setAdj >= ProcessList.SERVICE_ADJ) { + oomAdj = buildOomTag("svc ", null, r.setAdj, ProcessList.SERVICE_ADJ); } else if (r.setAdj >= ProcessList.BACKUP_APP_ADJ) { oomAdj = buildOomTag("bckup", null, r.setAdj, ProcessList.BACKUP_APP_ADJ); } else if (r.setAdj >= ProcessList.HEAVY_WEIGHT_APP_ADJ) { @@ -9008,8 +9023,8 @@ public final class ActivityManagerService extends ActivityManagerNative oomAdj = buildOomTag("vis ", null, r.setAdj, ProcessList.VISIBLE_APP_ADJ); } else if (r.setAdj >= ProcessList.FOREGROUND_APP_ADJ) { oomAdj = buildOomTag("fore ", null, r.setAdj, ProcessList.FOREGROUND_APP_ADJ); - } else if (r.setAdj >= ProcessList.CORE_SERVER_ADJ) { - oomAdj = buildOomTag("core ", null, r.setAdj, ProcessList.CORE_SERVER_ADJ); + } else if (r.setAdj >= ProcessList.PERSISTENT_PROC_ADJ) { + oomAdj = buildOomTag("pers ", null, r.setAdj, ProcessList.PERSISTENT_PROC_ADJ); } else if (r.setAdj >= ProcessList.SYSTEM_ADJ) { oomAdj = buildOomTag("sys ", null, r.setAdj, ProcessList.SYSTEM_ADJ); } else { @@ -9269,14 +9284,15 @@ public final class ActivityManagerService extends ActivityManagerNative long[] miscPss = new long[Debug.MemoryInfo.NUM_OTHER_STATS]; final int[] oomAdj = new int[] { - ProcessList.SYSTEM_ADJ, ProcessList.CORE_SERVER_ADJ, ProcessList.FOREGROUND_APP_ADJ, + ProcessList.SYSTEM_ADJ, ProcessList.PERSISTENT_PROC_ADJ, ProcessList.FOREGROUND_APP_ADJ, ProcessList.VISIBLE_APP_ADJ, ProcessList.PERCEPTIBLE_APP_ADJ, ProcessList.HEAVY_WEIGHT_APP_ADJ, - ProcessList.BACKUP_APP_ADJ, ProcessList.SECONDARY_SERVER_ADJ, ProcessList.HOME_APP_ADJ, ProcessList.EMPTY_APP_ADJ + ProcessList.BACKUP_APP_ADJ, ProcessList.SERVICE_ADJ, ProcessList.HOME_APP_ADJ, + ProcessList.SERVICE_B_ADJ, ProcessList.HIDDEN_APP_MAX_ADJ }; final String[] oomLabel = new String[] { "System", "Persistent", "Foreground", "Visible", "Perceptible", "Heavy Weight", - "Backup", "Services", "Home", "Background" + "Backup", "A Services", "Home", "B Services", "Background" }; long oomPss[] = new long[oomLabel.length]; ArrayList<MemItem>[] oomProcs = (ArrayList<MemItem>[])new ArrayList[oomLabel.length]; @@ -12931,7 +12947,7 @@ public final class ActivityManagerService extends ActivityManagerNative // ========================================================= private final int computeOomAdjLocked(ProcessRecord app, int hiddenAdj, - ProcessRecord TOP_APP, boolean recursed) { + ProcessRecord TOP_APP, boolean recursed, boolean doingAll) { if (mAdjSeq == app.adjSeq) { // This adjustment has already been computed. If we are calling // from the top, we may have already computed our adjustment with @@ -12946,7 +12962,7 @@ public final class ActivityManagerService extends ActivityManagerNative if (app.thread == null) { app.adjSeq = mAdjSeq; app.curSchedGroup = Process.THREAD_GROUP_BG_NONINTERACTIVE; - return (app.curAdj=ProcessList.EMPTY_APP_ADJ); + return (app.curAdj=ProcessList.HIDDEN_APP_MAX_ADJ); } app.adjTypeCode = ActivityManager.RunningAppProcessInfo.REASON_UNKNOWN; @@ -13130,7 +13146,7 @@ public final class ActivityManagerService extends ActivityManagerNative // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help // debug and understand what is going on. - if (adj > ProcessList.SECONDARY_SERVER_ADJ) { + if (adj > ProcessList.SERVICE_ADJ) { app.adjType = "started-bg-ui-services"; } } else { @@ -13138,8 +13154,8 @@ public final class ActivityManagerService extends ActivityManagerNative // This service has seen some activity within // recent memory, so we will keep its process ahead // of the background processes. - if (adj > ProcessList.SECONDARY_SERVER_ADJ) { - adj = ProcessList.SECONDARY_SERVER_ADJ; + if (adj > ProcessList.SERVICE_ADJ) { + adj = ProcessList.SERVICE_ADJ; app.adjType = "started-services"; app.hidden = false; } @@ -13147,7 +13163,7 @@ public final class ActivityManagerService extends ActivityManagerNative // If we have let the service slide into the background // state, still have some text describing what it is doing // even though the service no longer has an impact. - if (adj > ProcessList.SECONDARY_SERVER_ADJ) { + if (adj > ProcessList.SERVICE_ADJ) { app.adjType = "started-bg-services"; } } @@ -13181,7 +13197,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } clientAdj = computeOomAdjLocked( - client, myHiddenAdj, TOP_APP, true); + client, myHiddenAdj, TOP_APP, true, doingAll); String adjType = null; if ((cr.flags&Context.BIND_ALLOW_OOM_MANAGEMENT) != 0) { // Not doing bind OOM management, so treat @@ -13311,7 +13327,7 @@ public final class ActivityManagerService extends ActivityManagerNative } } int clientAdj = computeOomAdjLocked( - client, myHiddenAdj, TOP_APP, true); + client, myHiddenAdj, TOP_APP, true, doingAll); if (adj > clientAdj) { if (app.hasShownUi && app != mHomeProcess && clientAdj > ProcessList.PERCEPTIBLE_APP_ADJ) { @@ -13382,11 +13398,23 @@ public final class ActivityManagerService extends ActivityManagerNative adj = ProcessList.PERCEPTIBLE_APP_ADJ; } else if (adj < ProcessList.HIDDEN_APP_MIN_ADJ) { adj = ProcessList.HIDDEN_APP_MIN_ADJ; - } else if (adj < ProcessList.EMPTY_APP_ADJ) { + } else if (adj < ProcessList.HIDDEN_APP_MAX_ADJ) { adj++; } } + if (adj == ProcessList.SERVICE_ADJ) { + if (doingAll) { + app.serviceb = mNewNumServiceProcs > (mNumServiceProcs/3); + mNewNumServiceProcs++; + } + if (app.serviceb) { + adj = ProcessList.SERVICE_B_ADJ; + } + } else { + app.serviceb = false; + } + app.curAdj = adj; app.curSchedGroup = schedGroup; @@ -13627,7 +13655,7 @@ public final class ActivityManagerService extends ActivityManagerNative } private final boolean updateOomAdjLocked( - ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP) { + ProcessRecord app, int hiddenAdj, ProcessRecord TOP_APP, boolean doingAll) { app.hiddenAdj = hiddenAdj; if (app.thread == null) { @@ -13638,7 +13666,7 @@ public final class ActivityManagerService extends ActivityManagerNative boolean success = true; - computeOomAdjLocked(app, hiddenAdj, TOP_APP, false); + computeOomAdjLocked(app, hiddenAdj, TOP_APP, false, doingAll); if (app.curRawAdj != app.setRawAdj) { if (false) { @@ -13672,11 +13700,12 @@ public final class ActivityManagerService extends ActivityManagerNative app.setRawAdj = app.curRawAdj; } + if (app.curAdj != app.setAdj) { if (Process.setOomAdj(app.pid, app.curAdj)) { - if (DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v( - TAG, "Set app " + app.processName + - " oom adj to " + app.curAdj + " because " + app.adjType); + if (true || DEBUG_SWITCH || DEBUG_OOM_ADJ) Slog.v( + TAG, "Set " + app.pid + " " + app.processName + + " adj " + app.curAdj + ": " + app.adjType); app.setAdj = app.curAdj; } else { success = false; @@ -13740,7 +13769,7 @@ public final class ActivityManagerService extends ActivityManagerNative mAdjSeq++; - boolean success = updateOomAdjLocked(app, app.hiddenAdj, TOP_APP); + boolean success = updateOomAdjLocked(app, app.hiddenAdj, TOP_APP, false); final boolean nowHidden = app.curAdj >= ProcessList.HIDDEN_APP_MIN_ADJ && app.curAdj <= ProcessList.HIDDEN_APP_MAX_ADJ; if (nowHidden != wasHidden) { @@ -13762,6 +13791,7 @@ public final class ActivityManagerService extends ActivityManagerNative } mAdjSeq++; + mNewNumServiceProcs = 0; // Let's determine how many processes we have running vs. // how many slots we have for background processes; we may want @@ -13782,8 +13812,8 @@ public final class ActivityManagerService extends ActivityManagerNative i--; ProcessRecord app = mLruProcesses.get(i); //Slog.i(TAG, "OOM " + app + ": cur hidden=" + curHiddenAdj); - updateOomAdjLocked(app, curHiddenAdj, TOP_APP); - if (curHiddenAdj < ProcessList.EMPTY_APP_ADJ + updateOomAdjLocked(app, curHiddenAdj, TOP_APP, true); + if (curHiddenAdj < ProcessList.HIDDEN_APP_MAX_ADJ && app.curAdj == curHiddenAdj) { step++; if (step >= factor) { @@ -13810,6 +13840,8 @@ public final class ActivityManagerService extends ActivityManagerNative } } + mNumServiceProcs = mNewNumServiceProcs; + // Now determine the memory trimming level of background processes. // Unfortunately we need to start at the back of the list to do this // properly. We only do this if the number of background apps we diff --git a/services/java/com/android/server/am/ProcessList.java b/services/java/com/android/server/am/ProcessList.java index 131255f..f368a70 100644 --- a/services/java/com/android/server/am/ProcessList.java +++ b/services/java/com/android/server/am/ProcessList.java @@ -16,7 +16,6 @@ package com.android.server.am; -import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; @@ -24,7 +23,6 @@ import com.android.internal.util.MemInfoReader; import com.android.server.wm.WindowManagerService; import android.graphics.Point; -import android.os.StrictMode; import android.util.Slog; /** @@ -37,27 +35,23 @@ class ProcessList { // OOM adjustments for processes in various states: - // This is a process without anything currently running in it. Definitely - // the first to go! Value set in system/rootdir/init.rc on startup. - // This value is initalized in the constructor, careful when refering to - // this static variable externally. - static final int EMPTY_APP_ADJ = 15; - // This is a process only hosting activities that are not visible, - // so it can be killed without any disruption. Value set in - // system/rootdir/init.rc on startup. + // so it can be killed without any disruption. static final int HIDDEN_APP_MAX_ADJ = 15; - static int HIDDEN_APP_MIN_ADJ = 7; + static int HIDDEN_APP_MIN_ADJ = 8; + + // The B list of SERVICE_ADJ -- these are the old and decrepit + // services that aren't as shiny and interesting as the ones in the A list. + static final int SERVICE_B_ADJ = 7; // This is a process holding the home application -- we want to try // avoiding killing it, even if it would normally be in the background, // because the user interacts with it so much. static final int HOME_APP_ADJ = 6; - // This is a process holding a secondary server -- killing it will not - // have much of an impact as far as the user is concerned. Value set in - // system/rootdir/init.rc on startup. - static final int SECONDARY_SERVER_ADJ = 5; + // This is a process holding an application service -- killing it will not + // have much of an impact as far as the user is concerned. + static final int SERVICE_ADJ = 5; // This is a process currently hosting a backup operation. Killing it // is not entirely fatal but is generally a bad idea. @@ -70,22 +64,20 @@ class ProcessList { // This is a process only hosting components that are perceptible to the // user, and we really want to avoid killing them, but they are not - // immediately visible. An example is background music playback. Value set in - // system/rootdir/init.rc on startup. + // immediately visible. An example is background music playback. static final int PERCEPTIBLE_APP_ADJ = 2; // This is a process only hosting activities that are visible to the - // user, so we'd prefer they don't disappear. Value set in - // system/rootdir/init.rc on startup. + // user, so we'd prefer they don't disappear. static final int VISIBLE_APP_ADJ = 1; // This is the process running the current foreground app. We'd really - // rather not kill it! Value set in system/rootdir/init.rc on startup. + // rather not kill it! static final int FOREGROUND_APP_ADJ = 0; - // This is a process running a core server, such as telephony. Definitely + // This is a system persistent process, such as telephony. Definitely // don't want to kill it, but doing so is not completely fatal. - static final int CORE_SERVER_ADJ = -12; + static final int PERSISTENT_PROC_ADJ = -12; // The system process runs at the default adjustment. static final int SYSTEM_ADJ = -16; @@ -115,7 +107,7 @@ class ProcessList { // can't give it a different value for every possible kind of process. private final int[] mOomAdj = new int[] { FOREGROUND_APP_ADJ, VISIBLE_APP_ADJ, PERCEPTIBLE_APP_ADJ, - BACKUP_APP_ADJ, HIDDEN_APP_MIN_ADJ, EMPTY_APP_ADJ + BACKUP_APP_ADJ, HIDDEN_APP_MIN_ADJ, HIDDEN_APP_MAX_ADJ }; // These are the low-end OOM level limits. This is appropriate for an // HVGA or smaller phone with less than 512MB. Values are in KB. diff --git a/services/java/com/android/server/am/ProcessRecord.java b/services/java/com/android/server/am/ProcessRecord.java index 9392bb4..72292be 100644 --- a/services/java/com/android/server/am/ProcessRecord.java +++ b/services/java/com/android/server/am/ProcessRecord.java @@ -63,6 +63,7 @@ class ProcessRecord { int curSchedGroup; // Currently desired scheduling class int setSchedGroup; // Last set to background scheduling class int trimMemoryLevel; // Last selected memory trimming level + boolean serviceb; // Process currently is on the service B list boolean keeping; // Actively running code so don't kill due to that? boolean setIsForeground; // Running foreground UI when last set? boolean foregroundServices; // Running any services that are foreground? @@ -179,6 +180,7 @@ class ProcessRecord { pw.print(prefix); pw.print("lastActivityTime="); TimeUtils.formatDuration(lastActivityTime, now, pw); pw.print(" lruWeight="); pw.print(lruWeight); + pw.print(" serviceb="); pw.print(serviceb); pw.print(" keeping="); pw.print(keeping); pw.print(" hidden="); pw.print(hidden); pw.print(" empty="); pw.println(empty); @@ -271,7 +273,7 @@ class ProcessRecord { processName = _processName; pkgList.add(_info.packageName); thread = _thread; - maxAdj = ProcessList.EMPTY_APP_ADJ; + maxAdj = ProcessList.HIDDEN_APP_MAX_ADJ; hiddenAdj = ProcessList.HIDDEN_APP_MIN_ADJ; curRawAdj = setRawAdj = -100; curAdj = setAdj = -100; diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java index 792ef70..08797dd 100644 --- a/services/java/com/android/server/wm/WindowManagerService.java +++ b/services/java/com/android/server/wm/WindowManagerService.java @@ -1836,7 +1836,8 @@ public class WindowManagerService extends IWindowManager.Stub rawChanged = true; } - if (rawChanged) { + if (rawChanged && (wallpaperWin.getAttrs().privateFlags & + WindowManager.LayoutParams.PRIVATE_FLAG_WANTS_OFFSET_NOTIFICATIONS) != 0) { try { if (DEBUG_WALLPAPER) Slog.v(TAG, "Report new wp offset " + wallpaperWin + " x=" + wallpaperWin.mWallpaperX @@ -1886,12 +1887,10 @@ public class WindowManagerService extends IWindowManager.Stub } } - boolean updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) { + void updateWallpaperOffsetLocked(WindowState changingTarget, boolean sync) { final int dw = mAppDisplayWidth; final int dh = mAppDisplayHeight; - boolean changed = false; - WindowState target = mWallpaperTarget; if (target != null) { if (target.mWallpaperX >= 0) { @@ -1916,14 +1915,31 @@ public class WindowManagerService extends IWindowManager.Stub WindowState wallpaper = token.windows.get(curWallpaperIndex); if (updateWallpaperOffsetLocked(wallpaper, dw, dh, sync)) { wallpaper.computeShownFrameLocked(); - changed = true; + // No need to lay out the windows - we can just set the wallpaper position + // directly. + if (wallpaper.mSurfaceX != wallpaper.mShownFrame.left + || wallpaper.mSurfaceY != wallpaper.mShownFrame.top) { + Surface.openTransaction(); + try { + if (SHOW_TRANSACTIONS) logSurface(wallpaper, + "POS " + wallpaper.mShownFrame.left + + ", " + wallpaper.mShownFrame.top, null); + wallpaper.mSurfaceX = wallpaper.mShownFrame.left; + wallpaper.mSurfaceY = wallpaper.mShownFrame.top; + wallpaper.mSurface.setPosition(wallpaper.mShownFrame.left, + wallpaper.mShownFrame.top); + } catch (RuntimeException e) { + Slog.w(TAG, "Error positioning surface of " + wallpaper + + " pos=(" + wallpaper.mShownFrame.left + + "," + wallpaper.mShownFrame.top + ")", e); + } + Surface.closeTransaction(); + } // We only want to be synchronous with one wallpaper. sync = false; } } } - - return changed; } void updateWallpaperVisibilityLocked() { @@ -2436,9 +2452,7 @@ public class WindowManagerService extends IWindowManager.Stub window.mWallpaperY = y; window.mWallpaperXStep = xStep; window.mWallpaperYStep = yStep; - if (updateWallpaperOffsetLocked(window, true)) { - performLayoutAndPlaceSurfacesLocked(); - } + updateWallpaperOffsetLocked(window, true); } } diff --git a/services/java/com/android/server/wm/WindowState.java b/services/java/com/android/server/wm/WindowState.java index f442003..23ec2d9 100644 --- a/services/java/com/android/server/wm/WindowState.java +++ b/services/java/com/android/server/wm/WindowState.java @@ -612,7 +612,8 @@ final class WindowState implements WindowManagerPolicy.WindowState { if (mSurface == null) { mReportDestroySurface = false; mSurfacePendingDestroy = false; - Slog.i(WindowManagerService.TAG, "createSurface " + this + ": DRAW NOW PENDING"); + if (WindowManagerService.DEBUG_ORIENTATION) Slog.i(WindowManagerService.TAG, + "createSurface " + this + ": DRAW NOW PENDING"); mDrawPending = true; mCommitDrawPending = false; mReadyToShow = false; |