Merge "Do not schedule restarts if the system is shutting down" into nyc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
1f0151220e
@@ -1443,6 +1443,12 @@ public final class ActiveServices {
|
||||
boolean allowCancel) {
|
||||
boolean canceled = false;
|
||||
|
||||
if (mAm.isShuttingDownLocked()) {
|
||||
Slog.w(TAG, "Not scheduling restart of crashed service " + r.shortName
|
||||
+ " - system is shutting down");
|
||||
return false;
|
||||
}
|
||||
|
||||
ServiceMap smap = getServiceMap(r.userId);
|
||||
if (smap.mServicesByName.get(r.name) != r) {
|
||||
ServiceRecord cur = smap.mServicesByName.get(r.name);
|
||||
|
||||
@@ -11504,11 +11504,15 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
|
||||
// Actually is sleeping or shutting down or whatever else in the future
|
||||
// is an inactive state.
|
||||
public boolean isSleepingOrShuttingDown() {
|
||||
return isSleeping() || mShuttingDown;
|
||||
boolean isSleepingOrShuttingDownLocked() {
|
||||
return isSleepingLocked() || mShuttingDown;
|
||||
}
|
||||
|
||||
public boolean isSleeping() {
|
||||
boolean isShuttingDownLocked() {
|
||||
return mShuttingDown;
|
||||
}
|
||||
|
||||
boolean isSleepingLocked() {
|
||||
return mSleeping;
|
||||
}
|
||||
|
||||
@@ -12878,7 +12882,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
proc.notCachedSinceIdle = true;
|
||||
proc.initialIdlePss = 0;
|
||||
proc.nextPssTime = ProcessList.computeNextPssTime(proc.setProcState, true,
|
||||
mTestPssMode, isSleeping(), now);
|
||||
mTestPssMode, isSleepingLocked(), now);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19810,7 +19814,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
if (memLowered || now > (app.lastStateTime+ProcessList.PSS_ALL_INTERVAL)) {
|
||||
app.pssProcState = app.setProcState;
|
||||
app.nextPssTime = ProcessList.computeNextPssTime(app.curProcState, true,
|
||||
mTestPssMode, isSleeping(), now);
|
||||
mTestPssMode, isSleepingLocked(), now);
|
||||
mPendingPssProcesses.add(app);
|
||||
}
|
||||
}
|
||||
@@ -19858,7 +19862,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
}
|
||||
return !processingBroadcasts
|
||||
&& (isSleeping() || mStackSupervisor.allResumedActivitiesIdle());
|
||||
&& (isSleepingLocked() || mStackSupervisor.allResumedActivitiesIdle());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20149,7 +20153,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
app.lastStateTime = now;
|
||||
app.nextPssTime = ProcessList.computeNextPssTime(app.curProcState, true,
|
||||
mTestPssMode, isSleeping(), now);
|
||||
mTestPssMode, isSleepingLocked(), now);
|
||||
if (DEBUG_PSS) Slog.d(TAG_PSS, "Process state change from "
|
||||
+ ProcessList.makeProcStateString(app.setProcState) + " to "
|
||||
+ ProcessList.makeProcStateString(app.curProcState) + " next pss in "
|
||||
@@ -20160,7 +20164,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
mTestPssMode)))) {
|
||||
requestPssLocked(app, app.setProcState);
|
||||
app.nextPssTime = ProcessList.computeNextPssTime(app.curProcState, false,
|
||||
mTestPssMode, isSleeping(), now);
|
||||
mTestPssMode, isSleepingLocked(), now);
|
||||
} else if (false && DEBUG_PSS) Slog.d(TAG_PSS,
|
||||
"Not requesting PSS of " + app + ": next=" + (app.nextPssTime-now));
|
||||
}
|
||||
@@ -20686,7 +20690,7 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
}
|
||||
mLastMemoryLevel = memFactor;
|
||||
mLastNumProcesses = mLruProcesses.size();
|
||||
boolean allChanged = mProcessStats.setMemFactorLocked(memFactor, !isSleeping(), now);
|
||||
boolean allChanged = mProcessStats.setMemFactorLocked(memFactor, !isSleepingLocked(), now);
|
||||
final int trackerMemFactor = mProcessStats.getMemFactorLocked();
|
||||
if (memFactor != ProcessStats.ADJ_MEM_FACTOR_NORMAL) {
|
||||
if (mLowRamStartTime == 0) {
|
||||
|
||||
@@ -931,7 +931,7 @@ final class ActivityRecord {
|
||||
final ReferrerIntent rintent = new ReferrerIntent(intent, referrer);
|
||||
boolean unsent = true;
|
||||
if ((state == ActivityState.RESUMED
|
||||
|| (service.isSleeping() && task.stack != null
|
||||
|| (service.isSleepingLocked() && task.stack != null
|
||||
&& task.stack.topRunningActivityLocked() == this))
|
||||
&& app != null && app.thread != null) {
|
||||
try {
|
||||
|
||||
@@ -1075,7 +1075,7 @@ final class ActivityStack {
|
||||
if (mPausingActivity != null) {
|
||||
Slog.wtf(TAG, "Going to pause when pause is already pending for " + mPausingActivity
|
||||
+ " state=" + mPausingActivity.state);
|
||||
if (!mService.isSleeping()) {
|
||||
if (!mService.isSleepingLocked()) {
|
||||
// Avoid recursion among check for sleep and complete pause during sleeping.
|
||||
// Because activity will be paused immediately after resume, just let pause
|
||||
// be completed by the order of activity paused from clients.
|
||||
@@ -1139,7 +1139,7 @@ final class ActivityStack {
|
||||
|
||||
// If we are not going to sleep, we want to ensure the device is
|
||||
// awake until the next activity is started.
|
||||
if (!uiSleeping && !mService.isSleepingOrShuttingDown()) {
|
||||
if (!uiSleeping && !mService.isSleepingOrShuttingDownLocked()) {
|
||||
mStackSupervisor.acquireLaunchWakelock();
|
||||
}
|
||||
|
||||
@@ -1292,7 +1292,7 @@ final class ActivityStack {
|
||||
// We don't need to schedule another stop, we only need to let it happen.
|
||||
prev.state = ActivityState.STOPPING;
|
||||
} else if ((!prev.visible && !hasVisibleBehindActivity())
|
||||
|| mService.isSleepingOrShuttingDown()) {
|
||||
|| mService.isSleepingOrShuttingDownLocked()) {
|
||||
// If we were visible then resumeTopActivities will release resources before
|
||||
// stopping.
|
||||
addToStopping(prev, true /* immediate */);
|
||||
@@ -1310,7 +1310,7 @@ final class ActivityStack {
|
||||
|
||||
if (resumeNext) {
|
||||
final ActivityStack topStack = mStackSupervisor.getFocusedStack();
|
||||
if (!mService.isSleepingOrShuttingDown()) {
|
||||
if (!mService.isSleepingOrShuttingDownLocked()) {
|
||||
mStackSupervisor.resumeFocusedStackTopActivityLocked(topStack, prev, null);
|
||||
} else {
|
||||
mStackSupervisor.checkReadyForSleepLocked();
|
||||
@@ -1821,7 +1821,7 @@ final class ActivityStack {
|
||||
boolean behindFullscreenActivity) {
|
||||
|
||||
if (!okToShowLocked(r)
|
||||
|| (mService.isSleepingOrShuttingDown() && r.voiceSession == null)) {
|
||||
|| (mService.isSleepingOrShuttingDownLocked() && r.voiceSession == null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2196,7 +2196,7 @@ final class ActivityStack {
|
||||
|
||||
// If we are sleeping, and there is no resumed activity, and the top
|
||||
// activity is paused, well that is the state we want.
|
||||
if (mService.isSleepingOrShuttingDown()
|
||||
if (mService.isSleepingOrShuttingDownLocked()
|
||||
&& mLastPausedActivity == next
|
||||
&& mStackSupervisor.allPausedActivitiesComplete()) {
|
||||
// Make sure we have executed any pending transitions, since there
|
||||
@@ -2278,7 +2278,7 @@ final class ActivityStack {
|
||||
// If the most recent activity was noHistory but was only stopped rather
|
||||
// than stopped+finished because the device went to sleep, we need to make
|
||||
// sure to finish it as we're making a new activity topmost.
|
||||
if (mService.isSleeping() && mLastNoHistoryActivity != null &&
|
||||
if (mService.isSleepingLocked() && mLastNoHistoryActivity != null &&
|
||||
!mLastNoHistoryActivity.finishing) {
|
||||
if (DEBUG_STATES) Slog.d(TAG_STATES,
|
||||
"no-history finish of " + mLastNoHistoryActivity + " on new resume");
|
||||
@@ -3213,7 +3213,7 @@ final class ActivityStack {
|
||||
if ((r.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_HISTORY) != 0
|
||||
|| (r.info.flags&ActivityInfo.FLAG_NO_HISTORY) != 0) {
|
||||
if (!r.finishing) {
|
||||
if (!mService.isSleeping()) {
|
||||
if (!mService.isSleepingLocked()) {
|
||||
if (DEBUG_STATES) Slog.d(TAG_STATES, "no-history finish of " + r);
|
||||
if (requestFinishActivityLocked(r.appToken, Activity.RESULT_CANCELED, null,
|
||||
"stop-no-history", false)) {
|
||||
@@ -3245,7 +3245,7 @@ final class ActivityStack {
|
||||
EventLogTags.writeAmStopActivity(
|
||||
r.userId, System.identityHashCode(r), r.shortComponentName);
|
||||
r.app.thread.scheduleStopActivity(r.appToken, r.visible, r.configChangeFlags);
|
||||
if (mService.isSleepingOrShuttingDown()) {
|
||||
if (mService.isSleepingOrShuttingDownLocked()) {
|
||||
r.setSleeping(true);
|
||||
}
|
||||
Message msg = mHandler.obtainMessage(STOP_TIMEOUT_MSG, r);
|
||||
|
||||
@@ -2708,7 +2708,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
|
||||
void checkReadyForSleepLocked() {
|
||||
if (!mService.isSleepingOrShuttingDown()) {
|
||||
if (!mService.isSleepingOrShuttingDownLocked()) {
|
||||
// Do not care.
|
||||
return;
|
||||
}
|
||||
@@ -3048,7 +3048,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
mWindowManager.setAppVisibility(s.appToken, false);
|
||||
}
|
||||
}
|
||||
if ((!waitingVisible || mService.isSleepingOrShuttingDown()) && remove) {
|
||||
if ((!waitingVisible || mService.isSleepingOrShuttingDownLocked()) && remove) {
|
||||
if (DEBUG_STATES) Slog.v(TAG, "Ready to stop: " + s);
|
||||
if (stops == null) {
|
||||
stops = new ArrayList<>();
|
||||
@@ -3772,7 +3772,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
} break;
|
||||
case SLEEP_TIMEOUT_MSG: {
|
||||
synchronized (mService) {
|
||||
if (mService.isSleepingOrShuttingDown()) {
|
||||
if (mService.isSleepingOrShuttingDownLocked()) {
|
||||
Slog.w(TAG, "Sleep timeout! Sleeping now.");
|
||||
mSleepTimeout = true;
|
||||
checkReadyForSleepLocked();
|
||||
|
||||
Reference in New Issue
Block a user