Loading services/core/java/com/android/server/am/ActiveServices.java +1 −1 Original line number Diff line number Diff line Loading @@ -8835,7 +8835,7 @@ public final class ActiveServices { if (uidRecord != null) { for (int i = uidRecord.getNumOfProcs() - 1; i >= 0; i--) { final ProcessRecord pr = uidRecord.getProcessRecordByIndex(i); if (pr != null && pr.mState.hasOverlayUi()) { if (pr != null && pr.mState.getHasOverlayUi()) { ret = REASON_SYSTEM_ALERT_WINDOW_PERMISSION; break; } Loading services/core/java/com/android/server/am/ActivityManagerService.java +4 −3 Original line number Diff line number Diff line Loading @@ -6696,7 +6696,7 @@ public class ActivityManagerService extends IActivityManager.Stub // that here (pre-V versions will be checked in the conditional below) // Starting Android V, only allow the app to schedule a user-initiated job // if it's granted the permission and currently showing an overlay window if (pr != null && pr.mState.hasOverlayUi()) { if (pr != null && pr.mState.getHasOverlayUi()) { return true; } } Loading Loading @@ -16792,7 +16792,8 @@ public class ActivityManagerService extends IActivityManager.Stub continue; } if (app.isRemoved() || (app.userId == userId && app.mState.hasForegroundActivities())) { || (app.userId == userId && app.mState.getHasForegroundActivities())) { procs.add(app); } } Loading Loading @@ -17098,7 +17099,7 @@ public class ActivityManagerService extends IActivityManager.Stub final ProcessRecord pr = (ProcessRecord) wpc.mOwner; if (ActivityManager.isProcStateBackground(pr.mState.getSetProcState()) && !pr.mReceivers.isReceivingBroadcast() && !pr.mState.hasStartedServices()) { && !pr.mState.getHasStartedServices()) { pr.killLocked("remove task", ApplicationExitInfo.REASON_USER_REQUESTED, ApplicationExitInfo.SUBREASON_REMOVE_TASK, true); } else { services/core/java/com/android/server/am/AppProfiler.java +2 −2 Original line number Diff line number Diff line Loading @@ -1402,8 +1402,8 @@ public class AppProfiler { final ProcessProfileRecord profile = app.mProfile; final IApplicationThread thread; final ProcessStateRecord state = app.mState; if (state.hasProcStateChanged()) { state.setProcStateChanged(false); if (state.getHasProcStateChanged()) { state.setHasProcStateChanged(false); } int procState = app.mState.getCurProcState(); if (((procState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND Loading services/core/java/com/android/server/am/OomAdjuster.java +13 −13 Original line number Diff line number Diff line Loading @@ -970,14 +970,14 @@ public abstract class OomAdjuster { state.setCurAdj(nextPreviousAppAdj); nextPreviousAppAdj = Math.min(nextPreviousAppAdj + 1, PREVIOUS_APP_MAX_ADJ); } else if (!app.isKilledByAm() && app.getThread() != null && (curAdj >= UNKNOWN_ADJ || (state.hasShownUi() && curAdj >= CACHED_APP_MIN_ADJ))) { || (state.getHasShownUi() && curAdj >= CACHED_APP_MIN_ADJ))) { final ProcessServiceRecord psr = app.mServices; int targetAdj = CACHED_APP_MIN_ADJ; if (opt != null && opt.isFreezeExempt()) { // BIND_WAIVE_PRIORITY and the like get oom_adj 900 targetAdj += 0; } else if (state.hasShownUi() && uiTargetAdj < uiTierMaxAdj) { } else if (state.getHasShownUi() && uiTargetAdj < uiTierMaxAdj) { // The most recent UI-showing apps get [910, 910 + ui tier size). targetAdj += uiTargetAdj++; } else if ((state.getSetAdj() >= CACHED_APP_MIN_ADJ) Loading Loading @@ -1886,7 +1886,7 @@ public abstract class OomAdjuster { // restrictions on screen off if (state.getCurProcState() >= PROCESS_STATE_BOUND_FOREGROUND_SERVICE && !isDeviceFullyAwake() && !state.shouldScheduleLikeTopApp()) { && !state.getScheduleLikeTopApp()) { if (schedGroup > SCHED_GROUP_RESTRICTED) { schedGroup = SCHED_GROUP_RESTRICTED; } Loading Loading @@ -2105,7 +2105,7 @@ public abstract class OomAdjuster { final int curSchedGroup = state.getCurrentSchedulingGroup(); if (app.getWaitingToKill() != null && !app.mReceivers.isReceivingBroadcast() && ActivityManager.isProcStateBackground(state.getCurProcState()) && !state.hasStartedServices()) { && !state.getHasStartedServices()) { app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED, ApplicationExitInfo.SUBREASON_REMOVE_TASK, true); success = false; Loading Loading @@ -2183,8 +2183,8 @@ public abstract class OomAdjuster { } } } if (state.hasRepForegroundActivities() != state.hasForegroundActivities()) { state.setRepForegroundActivities(state.hasForegroundActivities()); if (state.getHasRepForegroundActivities() != state.getHasForegroundActivities()) { state.setRepForegroundActivities(state.getHasForegroundActivities()); changes |= ActivityManagerService.ProcessChangeItem.CHANGE_ACTIVITIES; } Loading Loading @@ -2252,9 +2252,9 @@ public abstract class OomAdjuster { mService.mProcessStats.getMemFactorLocked()); } } else { state.setProcStateChanged(true); state.setHasProcStateChanged(true); } } else if (state.hasReportedInteraction()) { } else if (state.getHasReportedInteraction()) { final boolean fgsInteractionChangeEnabled = state.getCachedCompatChange( CACHED_COMPAT_CHANGE_USE_SHORT_FGS_USAGE_INTERACTION_TIME); final long interactionThreshold = fgsInteractionChangeEnabled Loading Loading @@ -2298,11 +2298,11 @@ public abstract class OomAdjuster { if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Changes in " + app + ": " + changes); mProcessList.enqueueProcessChangeItemLocked(app.getPid(), app.info.uid, changes, state.hasRepForegroundActivities()); changes, state.getHasRepForegroundActivities()); if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Enqueued process change item for " + app.toShortString() + ": changes=" + changes + " foreground=" + state.hasRepForegroundActivities() + " foreground=" + state.getHasRepForegroundActivities() + " type=" + state.getAdjType() + " source=" + state.getAdjSource() + " target=" + state.getAdjTarget()); } Loading Loading @@ -2346,7 +2346,7 @@ public abstract class OomAdjuster { final int prevAdj = state.getCurRawAdj(); // If the process has been marked as foreground, it is starting as the top app (with // Zygote#START_AS_TOP_APP_ARG), so boost the thread priority of its default UI thread. if (state.hasForegroundActivities()) { if (state.getHasForegroundActivities()) { try { // The priority must be the same as how does {@link #applyOomAdjLSP} set for // {@link SCHED_GROUP_TOP_APP}. We don't check render thread because it Loading Loading @@ -2430,7 +2430,7 @@ public abstract class OomAdjuster { ? mConstants.USAGE_STATS_INTERACTION_INTERVAL_POST_S : mConstants.USAGE_STATS_INTERACTION_INTERVAL_PRE_S; if (isInteraction && (!state.hasReportedInteraction() && (!state.getHasReportedInteraction() || (nowElapsed - state.getInteractionEventTime()) > interactionThreshold)) { state.setInteractionEventTime(nowElapsed); String[] packages = app.getPackageList(); Loading @@ -2441,7 +2441,7 @@ public abstract class OomAdjuster { } } } state.setReportedInteraction(isInteraction); state.setHasReportedInteraction(isInteraction); if (!isInteraction) { state.setInteractionEventTime(0); } Loading services/core/java/com/android/server/am/OomAdjusterImpl.java +7 −7 Original line number Diff line number Diff line Loading @@ -1046,7 +1046,7 @@ public class OomAdjusterImpl extends OomAdjuster { // Need to check shouldScheduleLikeTopApp otherwise, there will be too many recompute which // leads to OOM. return !(cr.hasFlag(Context.BIND_SCHEDULE_LIKE_TOP_APP) && !host.mState.shouldScheduleLikeTopApp()); && !host.mState.getScheduleLikeTopApp()); } private static boolean isSandboxAttributedConnection(ConnectionRecord cr, ProcessRecord host) { Loading Loading @@ -1222,7 +1222,7 @@ public class OomAdjusterImpl extends OomAdjuster { state.setSystemNoUi(false); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); state.setAdjType("pers-top-activity"); } else if (state.hasTopUi()) { } else if (state.getHasTopUi()) { // sched group/proc state adjustment is below state.setSystemNoUi(false); state.setAdjType("pers-top-ui"); Loading Loading @@ -1401,7 +1401,7 @@ public class OomAdjusterImpl extends OomAdjuster { // short-fgs can't start FGS from the background. newProcState = PROCESS_STATE_FOREGROUND_SERVICE; } else if (state.hasOverlayUi()) { } else if (state.getHasOverlayUi()) { adjType = "has-overlay-ui"; newAdj = PERCEPTIBLE_APP_ADJ; newProcState = PROCESS_STATE_IMPORTANT_FOREGROUND; Loading Loading @@ -1610,7 +1610,7 @@ public class OomAdjusterImpl extends OomAdjuster { "Raise procstate to started service: " + app); } } if (!s.mKeepWarming && state.hasShownUi() && !isHomeProcess(app)) { if (!s.mKeepWarming && state.getHasShownUi() && !isHomeProcess(app)) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help Loading Loading @@ -1952,7 +1952,7 @@ public class OomAdjusterImpl extends OomAdjuster { } // Not doing bind OOM management, so treat // this guy more like a started service. if (state.hasShownUi() && !isHomeProcess(app)) { if (state.getHasShownUi() && !isHomeProcess(app)) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help Loading Loading @@ -1988,7 +1988,7 @@ public class OomAdjusterImpl extends OomAdjuster { // is less important than a state that can be actively running, then we don't // care about the binding as much as we care about letting this process get into // the LRU list to be killed and restarted if needed for memory. if (state.hasShownUi() && !isHomeProcess(app) if (state.getHasShownUi() && !isHomeProcess(app) && clientAdj > CACHING_UI_SERVICE_CLIENT_ADJ_THRESHOLD) { if (adj >= CACHED_APP_MIN_ADJ) { adjType = "cch-bound-ui-services"; Loading Loading @@ -2352,7 +2352,7 @@ public class OomAdjusterImpl extends OomAdjuster { String adjType = null; if (adj > clientAdj) { if (state.hasShownUi() && !isHomeProcess(app) if (state.getHasShownUi() && !isHomeProcess(app) && clientAdj > PERCEPTIBLE_APP_ADJ) { adjType = "cch-ui-provider"; } else { Loading Loading
services/core/java/com/android/server/am/ActiveServices.java +1 −1 Original line number Diff line number Diff line Loading @@ -8835,7 +8835,7 @@ public final class ActiveServices { if (uidRecord != null) { for (int i = uidRecord.getNumOfProcs() - 1; i >= 0; i--) { final ProcessRecord pr = uidRecord.getProcessRecordByIndex(i); if (pr != null && pr.mState.hasOverlayUi()) { if (pr != null && pr.mState.getHasOverlayUi()) { ret = REASON_SYSTEM_ALERT_WINDOW_PERMISSION; break; } Loading
services/core/java/com/android/server/am/ActivityManagerService.java +4 −3 Original line number Diff line number Diff line Loading @@ -6696,7 +6696,7 @@ public class ActivityManagerService extends IActivityManager.Stub // that here (pre-V versions will be checked in the conditional below) // Starting Android V, only allow the app to schedule a user-initiated job // if it's granted the permission and currently showing an overlay window if (pr != null && pr.mState.hasOverlayUi()) { if (pr != null && pr.mState.getHasOverlayUi()) { return true; } } Loading Loading @@ -16792,7 +16792,8 @@ public class ActivityManagerService extends IActivityManager.Stub continue; } if (app.isRemoved() || (app.userId == userId && app.mState.hasForegroundActivities())) { || (app.userId == userId && app.mState.getHasForegroundActivities())) { procs.add(app); } } Loading Loading @@ -17098,7 +17099,7 @@ public class ActivityManagerService extends IActivityManager.Stub final ProcessRecord pr = (ProcessRecord) wpc.mOwner; if (ActivityManager.isProcStateBackground(pr.mState.getSetProcState()) && !pr.mReceivers.isReceivingBroadcast() && !pr.mState.hasStartedServices()) { && !pr.mState.getHasStartedServices()) { pr.killLocked("remove task", ApplicationExitInfo.REASON_USER_REQUESTED, ApplicationExitInfo.SUBREASON_REMOVE_TASK, true); } else {
services/core/java/com/android/server/am/AppProfiler.java +2 −2 Original line number Diff line number Diff line Loading @@ -1402,8 +1402,8 @@ public class AppProfiler { final ProcessProfileRecord profile = app.mProfile; final IApplicationThread thread; final ProcessStateRecord state = app.mState; if (state.hasProcStateChanged()) { state.setProcStateChanged(false); if (state.getHasProcStateChanged()) { state.setHasProcStateChanged(false); } int procState = app.mState.getCurProcState(); if (((procState >= ActivityManager.PROCESS_STATE_IMPORTANT_BACKGROUND Loading
services/core/java/com/android/server/am/OomAdjuster.java +13 −13 Original line number Diff line number Diff line Loading @@ -970,14 +970,14 @@ public abstract class OomAdjuster { state.setCurAdj(nextPreviousAppAdj); nextPreviousAppAdj = Math.min(nextPreviousAppAdj + 1, PREVIOUS_APP_MAX_ADJ); } else if (!app.isKilledByAm() && app.getThread() != null && (curAdj >= UNKNOWN_ADJ || (state.hasShownUi() && curAdj >= CACHED_APP_MIN_ADJ))) { || (state.getHasShownUi() && curAdj >= CACHED_APP_MIN_ADJ))) { final ProcessServiceRecord psr = app.mServices; int targetAdj = CACHED_APP_MIN_ADJ; if (opt != null && opt.isFreezeExempt()) { // BIND_WAIVE_PRIORITY and the like get oom_adj 900 targetAdj += 0; } else if (state.hasShownUi() && uiTargetAdj < uiTierMaxAdj) { } else if (state.getHasShownUi() && uiTargetAdj < uiTierMaxAdj) { // The most recent UI-showing apps get [910, 910 + ui tier size). targetAdj += uiTargetAdj++; } else if ((state.getSetAdj() >= CACHED_APP_MIN_ADJ) Loading Loading @@ -1886,7 +1886,7 @@ public abstract class OomAdjuster { // restrictions on screen off if (state.getCurProcState() >= PROCESS_STATE_BOUND_FOREGROUND_SERVICE && !isDeviceFullyAwake() && !state.shouldScheduleLikeTopApp()) { && !state.getScheduleLikeTopApp()) { if (schedGroup > SCHED_GROUP_RESTRICTED) { schedGroup = SCHED_GROUP_RESTRICTED; } Loading Loading @@ -2105,7 +2105,7 @@ public abstract class OomAdjuster { final int curSchedGroup = state.getCurrentSchedulingGroup(); if (app.getWaitingToKill() != null && !app.mReceivers.isReceivingBroadcast() && ActivityManager.isProcStateBackground(state.getCurProcState()) && !state.hasStartedServices()) { && !state.getHasStartedServices()) { app.killLocked(app.getWaitingToKill(), ApplicationExitInfo.REASON_USER_REQUESTED, ApplicationExitInfo.SUBREASON_REMOVE_TASK, true); success = false; Loading Loading @@ -2183,8 +2183,8 @@ public abstract class OomAdjuster { } } } if (state.hasRepForegroundActivities() != state.hasForegroundActivities()) { state.setRepForegroundActivities(state.hasForegroundActivities()); if (state.getHasRepForegroundActivities() != state.getHasForegroundActivities()) { state.setRepForegroundActivities(state.getHasForegroundActivities()); changes |= ActivityManagerService.ProcessChangeItem.CHANGE_ACTIVITIES; } Loading Loading @@ -2252,9 +2252,9 @@ public abstract class OomAdjuster { mService.mProcessStats.getMemFactorLocked()); } } else { state.setProcStateChanged(true); state.setHasProcStateChanged(true); } } else if (state.hasReportedInteraction()) { } else if (state.getHasReportedInteraction()) { final boolean fgsInteractionChangeEnabled = state.getCachedCompatChange( CACHED_COMPAT_CHANGE_USE_SHORT_FGS_USAGE_INTERACTION_TIME); final long interactionThreshold = fgsInteractionChangeEnabled Loading Loading @@ -2298,11 +2298,11 @@ public abstract class OomAdjuster { if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Changes in " + app + ": " + changes); mProcessList.enqueueProcessChangeItemLocked(app.getPid(), app.info.uid, changes, state.hasRepForegroundActivities()); changes, state.getHasRepForegroundActivities()); if (DEBUG_PROCESS_OBSERVERS) Slog.i(TAG_PROCESS_OBSERVERS, "Enqueued process change item for " + app.toShortString() + ": changes=" + changes + " foreground=" + state.hasRepForegroundActivities() + " foreground=" + state.getHasRepForegroundActivities() + " type=" + state.getAdjType() + " source=" + state.getAdjSource() + " target=" + state.getAdjTarget()); } Loading Loading @@ -2346,7 +2346,7 @@ public abstract class OomAdjuster { final int prevAdj = state.getCurRawAdj(); // If the process has been marked as foreground, it is starting as the top app (with // Zygote#START_AS_TOP_APP_ARG), so boost the thread priority of its default UI thread. if (state.hasForegroundActivities()) { if (state.getHasForegroundActivities()) { try { // The priority must be the same as how does {@link #applyOomAdjLSP} set for // {@link SCHED_GROUP_TOP_APP}. We don't check render thread because it Loading Loading @@ -2430,7 +2430,7 @@ public abstract class OomAdjuster { ? mConstants.USAGE_STATS_INTERACTION_INTERVAL_POST_S : mConstants.USAGE_STATS_INTERACTION_INTERVAL_PRE_S; if (isInteraction && (!state.hasReportedInteraction() && (!state.getHasReportedInteraction() || (nowElapsed - state.getInteractionEventTime()) > interactionThreshold)) { state.setInteractionEventTime(nowElapsed); String[] packages = app.getPackageList(); Loading @@ -2441,7 +2441,7 @@ public abstract class OomAdjuster { } } } state.setReportedInteraction(isInteraction); state.setHasReportedInteraction(isInteraction); if (!isInteraction) { state.setInteractionEventTime(0); } Loading
services/core/java/com/android/server/am/OomAdjusterImpl.java +7 −7 Original line number Diff line number Diff line Loading @@ -1046,7 +1046,7 @@ public class OomAdjusterImpl extends OomAdjuster { // Need to check shouldScheduleLikeTopApp otherwise, there will be too many recompute which // leads to OOM. return !(cr.hasFlag(Context.BIND_SCHEDULE_LIKE_TOP_APP) && !host.mState.shouldScheduleLikeTopApp()); && !host.mState.getScheduleLikeTopApp()); } private static boolean isSandboxAttributedConnection(ConnectionRecord cr, ProcessRecord host) { Loading Loading @@ -1222,7 +1222,7 @@ public class OomAdjusterImpl extends OomAdjuster { state.setSystemNoUi(false); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); state.setAdjType("pers-top-activity"); } else if (state.hasTopUi()) { } else if (state.getHasTopUi()) { // sched group/proc state adjustment is below state.setSystemNoUi(false); state.setAdjType("pers-top-ui"); Loading Loading @@ -1401,7 +1401,7 @@ public class OomAdjusterImpl extends OomAdjuster { // short-fgs can't start FGS from the background. newProcState = PROCESS_STATE_FOREGROUND_SERVICE; } else if (state.hasOverlayUi()) { } else if (state.getHasOverlayUi()) { adjType = "has-overlay-ui"; newAdj = PERCEPTIBLE_APP_ADJ; newProcState = PROCESS_STATE_IMPORTANT_FOREGROUND; Loading Loading @@ -1610,7 +1610,7 @@ public class OomAdjusterImpl extends OomAdjuster { "Raise procstate to started service: " + app); } } if (!s.mKeepWarming && state.hasShownUi() && !isHomeProcess(app)) { if (!s.mKeepWarming && state.getHasShownUi() && !isHomeProcess(app)) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help Loading Loading @@ -1952,7 +1952,7 @@ public class OomAdjusterImpl extends OomAdjuster { } // Not doing bind OOM management, so treat // this guy more like a started service. if (state.hasShownUi() && !isHomeProcess(app)) { if (state.getHasShownUi() && !isHomeProcess(app)) { // If this process has shown some UI, let it immediately // go to the LRU list because it may be pretty heavy with // UI stuff. We'll tag it with a label just to help Loading Loading @@ -1988,7 +1988,7 @@ public class OomAdjusterImpl extends OomAdjuster { // is less important than a state that can be actively running, then we don't // care about the binding as much as we care about letting this process get into // the LRU list to be killed and restarted if needed for memory. if (state.hasShownUi() && !isHomeProcess(app) if (state.getHasShownUi() && !isHomeProcess(app) && clientAdj > CACHING_UI_SERVICE_CLIENT_ADJ_THRESHOLD) { if (adj >= CACHED_APP_MIN_ADJ) { adjType = "cch-bound-ui-services"; Loading Loading @@ -2352,7 +2352,7 @@ public class OomAdjusterImpl extends OomAdjuster { String adjType = null; if (adj > clientAdj) { if (state.hasShownUi() && !isHomeProcess(app) if (state.getHasShownUi() && !isHomeProcess(app) && clientAdj > PERCEPTIBLE_APP_ADJ) { adjType = "cch-ui-provider"; } else { Loading