Demote top app scheduling group when unlocking am: bea0e67d0d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19465512 Change-Id: I7ac280ab3d9d5c60072f4d3e1625f5b11412fafe Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1556,14 +1556,22 @@ public class OomAdjuster {
|
|||||||
|
|
||||||
boolean foregroundActivities = false;
|
boolean foregroundActivities = false;
|
||||||
boolean hasVisibleActivities = false;
|
boolean hasVisibleActivities = false;
|
||||||
if (PROCESS_STATE_CUR_TOP == PROCESS_STATE_TOP && app == topApp) {
|
if (app == topApp && (PROCESS_STATE_CUR_TOP == PROCESS_STATE_TOP
|
||||||
|
|| PROCESS_STATE_CUR_TOP == PROCESS_STATE_IMPORTANT_FOREGROUND)) {
|
||||||
// The last app on the list is the foreground app.
|
// The last app on the list is the foreground app.
|
||||||
adj = ProcessList.FOREGROUND_APP_ADJ;
|
adj = ProcessList.FOREGROUND_APP_ADJ;
|
||||||
schedGroup = ProcessList.SCHED_GROUP_TOP_APP;
|
if (PROCESS_STATE_CUR_TOP == PROCESS_STATE_TOP) {
|
||||||
state.setAdjType("top-activity");
|
schedGroup = ProcessList.SCHED_GROUP_TOP_APP;
|
||||||
|
state.setAdjType("top-activity");
|
||||||
|
} else {
|
||||||
|
// Demote the scheduling group to avoid CPU contention if there is another more
|
||||||
|
// important process which also uses top-app, such as if SystemUI is animating.
|
||||||
|
schedGroup = ProcessList.SCHED_GROUP_DEFAULT;
|
||||||
|
state.setAdjType("intermediate-top-activity");
|
||||||
|
}
|
||||||
foregroundActivities = true;
|
foregroundActivities = true;
|
||||||
hasVisibleActivities = true;
|
hasVisibleActivities = true;
|
||||||
procState = PROCESS_STATE_CUR_TOP;
|
procState = PROCESS_STATE_TOP;
|
||||||
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
|
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
|
||||||
reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making top: " + app);
|
reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making top: " + app);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ import static android.provider.Settings.Global.HIDE_ERROR_DIALOGS;
|
|||||||
import static android.provider.Settings.System.FONT_SCALE;
|
import static android.provider.Settings.System.FONT_SCALE;
|
||||||
import static android.view.Display.DEFAULT_DISPLAY;
|
import static android.view.Display.DEFAULT_DISPLAY;
|
||||||
import static android.view.Display.INVALID_DISPLAY;
|
import static android.view.Display.INVALID_DISPLAY;
|
||||||
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT;
|
|
||||||
import static android.view.WindowManager.TRANSIT_WAKE;
|
import static android.view.WindowManager.TRANSIT_WAKE;
|
||||||
|
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT;
|
||||||
|
|
||||||
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
|
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_CONFIGURATION;
|
||||||
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
|
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS;
|
||||||
@@ -400,6 +400,13 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
/** The time at which the previous process was last visible. */
|
/** The time at which the previous process was last visible. */
|
||||||
private long mPreviousProcessVisibleTime;
|
private long mPreviousProcessVisibleTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* It can be true from keyguard-going-away to set-keyguard-shown. And getTopProcessState() will
|
||||||
|
* return {@link ActivityManager#PROCESS_STATE_IMPORTANT_FOREGROUND} to avoid top app from
|
||||||
|
* preempting CPU while keyguard is animating.
|
||||||
|
*/
|
||||||
|
private volatile boolean mDemoteTopAppDuringUnlocking;
|
||||||
|
|
||||||
/** List of intents that were used to start the most recent tasks. */
|
/** List of intents that were used to start the most recent tasks. */
|
||||||
private RecentTasks mRecentTasks;
|
private RecentTasks mRecentTasks;
|
||||||
/** State of external calls telling us if the device is awake or asleep. */
|
/** State of external calls telling us if the device is awake or asleep. */
|
||||||
@@ -2830,12 +2837,24 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
keyguardShowing);
|
keyguardShowing);
|
||||||
mH.sendMessage(msg);
|
mH.sendMessage(msg);
|
||||||
}
|
}
|
||||||
|
// Always reset the state regardless of keyguard-showing change, because that means the
|
||||||
|
// unlock is either completed or canceled.
|
||||||
|
if (mDemoteTopAppDuringUnlocking) {
|
||||||
|
mDemoteTopAppDuringUnlocking = false;
|
||||||
|
// The scheduling group of top process was demoted by unlocking, so recompute
|
||||||
|
// to restore its real top priority if possible.
|
||||||
|
if (mTopApp != null) {
|
||||||
|
mTopApp.scheduleUpdateOomAdj();
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
|
Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "setLockScreenShown");
|
||||||
mRootWindowContainer.forAllDisplays(displayContent -> {
|
mRootWindowContainer.forAllDisplays(displayContent -> {
|
||||||
mKeyguardController.setKeyguardShown(displayContent.getDisplayId(),
|
mKeyguardController.setKeyguardShown(displayContent.getDisplayId(),
|
||||||
keyguardShowing, aodShowing);
|
keyguardShowing, aodShowing);
|
||||||
});
|
});
|
||||||
} finally {
|
} finally {
|
||||||
|
Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
|
||||||
Binder.restoreCallingIdentity(ident);
|
Binder.restoreCallingIdentity(ident);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2862,6 +2881,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
// animation of system UI. Even if AOD is not enabled, it should be no harm.
|
// animation of system UI. Even if AOD is not enabled, it should be no harm.
|
||||||
final WindowProcessController proc;
|
final WindowProcessController proc;
|
||||||
synchronized (mGlobalLockWithoutBoost) {
|
synchronized (mGlobalLockWithoutBoost) {
|
||||||
|
mDemoteTopAppDuringUnlocking = false;
|
||||||
final WindowState notificationShade = mRootWindowContainer.getDefaultDisplay()
|
final WindowState notificationShade = mRootWindowContainer.getDefaultDisplay()
|
||||||
.getDisplayPolicy().getNotificationShade();
|
.getDisplayPolicy().getNotificationShade();
|
||||||
proc = notificationShade != null
|
proc = notificationShade != null
|
||||||
@@ -3399,8 +3419,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
try {
|
try {
|
||||||
synchronized (mGlobalLock) {
|
synchronized (mGlobalLock) {
|
||||||
// Keyguard asked us to clear the home task snapshot before going away, so do that.
|
// Keyguard asked us to clear the home task snapshot before going away, so do that.
|
||||||
if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT) != 0) {
|
if ((flags & KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT) != 0) {
|
||||||
mActivityClientController.invalidateHomeTaskSnapshot(null /* token */);
|
mActivityClientController.invalidateHomeTaskSnapshot(null /* token */);
|
||||||
|
} else if (mKeyguardShown) {
|
||||||
|
// Only set if it is not unlocking to launcher which may also animate.
|
||||||
|
mDemoteTopAppDuringUnlocking = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mRootWindowContainer.forAllDisplays(displayContent -> {
|
mRootWindowContainer.forAllDisplays(displayContent -> {
|
||||||
@@ -5595,12 +5618,17 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
|||||||
@HotPath(caller = HotPath.OOM_ADJUSTMENT)
|
@HotPath(caller = HotPath.OOM_ADJUSTMENT)
|
||||||
@Override
|
@Override
|
||||||
public int getTopProcessState() {
|
public int getTopProcessState() {
|
||||||
|
final int topState = mTopProcessState;
|
||||||
|
if (mDemoteTopAppDuringUnlocking && topState == ActivityManager.PROCESS_STATE_TOP) {
|
||||||
|
// The unlocking UI is more important, so defer the top state of app.
|
||||||
|
return ActivityManager.PROCESS_STATE_IMPORTANT_FOREGROUND;
|
||||||
|
}
|
||||||
if (mRetainPowerModeAndTopProcessState) {
|
if (mRetainPowerModeAndTopProcessState) {
|
||||||
// There is a launching app while device may be sleeping, force the top state so
|
// There is a launching app while device may be sleeping, force the top state so
|
||||||
// the launching process can have top-app scheduling group.
|
// the launching process can have top-app scheduling group.
|
||||||
return ActivityManager.PROCESS_STATE_TOP;
|
return ActivityManager.PROCESS_STATE_TOP;
|
||||||
}
|
}
|
||||||
return mTopProcessState;
|
return topState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@HotPath(caller = HotPath.PROCESS_CHANGE)
|
@HotPath(caller = HotPath.PROCESS_CHANGE)
|
||||||
|
|||||||
@@ -1126,6 +1126,13 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
|
|||||||
mAtm.mH.sendMessage(m);
|
mAtm.mH.sendMessage(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Refreshes oom adjustment and process state of this process. */
|
||||||
|
void scheduleUpdateOomAdj() {
|
||||||
|
mAtm.mH.sendMessage(PooledLambda.obtainMessage(WindowProcessListener::updateProcessInfo,
|
||||||
|
mListener, false /* updateServiceConnectionActivities */,
|
||||||
|
false /* activityChange */, true /* updateOomAdj */));
|
||||||
|
}
|
||||||
|
|
||||||
/** Makes the process have top state before oom-adj is computed from a posted message. */
|
/** Makes the process have top state before oom-adj is computed from a posted message. */
|
||||||
void addToPendingTop() {
|
void addToPendingTop() {
|
||||||
mAtm.mAmInternal.addPendingTopUid(mUid, mPid, mThread);
|
mAtm.mAmInternal.addPendingTopUid(mUid, mPid, mThread);
|
||||||
|
|||||||
Reference in New Issue
Block a user