diff options
author | 2024-08-26 01:27:07 +0000 | |
---|---|---|
committer | 2024-08-26 01:27:07 +0000 | |
commit | 4cc6b39fa5fe44f5b4c71b1447b49b84d745ec6d (patch) | |
tree | 7842f533eeb78414528df4207db0a097947fe860 | |
parent | 2df19e5a6c61942a67630b5ba1b5ccabb6dab895 (diff) | |
parent | f7f5fa1e2f2cca799e5428437c13bce2113ccc88 (diff) |
Merge "Apply power mode when unlocking" into main
-rw-r--r-- | services/core/java/com/android/server/wm/ActivityTaskManagerService.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 2d8e3dbb2461..0f108c5ed5d7 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -3617,6 +3617,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { final long token = Binder.clearCallingIdentity(); try { synchronized (mGlobalLock) { + boolean isPowerModePreApplied = false; + if (mPowerModeReasons == 0) { + startPowerMode(POWER_MODE_REASON_START_ACTIVITY); + isPowerModePreApplied = true; + } // Keyguard asked us to clear the home task snapshot before going away, so do that. if ((flags & KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT) != 0) { mActivityClientController.invalidateHomeTaskSnapshot(null /* token */); @@ -3625,9 +3630,19 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mDemoteTopAppReasons |= DEMOTE_TOP_REASON_DURING_UNLOCKING; } - mRootWindowContainer.forAllDisplays(displayContent -> { - mKeyguardController.keyguardGoingAway(displayContent.getDisplayId(), flags); - }); + boolean foundResumed = false; + for (int i = mRootWindowContainer.getChildCount() - 1; i >= 0; i--) { + final DisplayContent dc = mRootWindowContainer.getChildAt(i); + final boolean wasNoResumed = dc.mFocusedApp == null + || !dc.mFocusedApp.isState(RESUMED); + mKeyguardController.keyguardGoingAway(dc.mDisplayId, flags); + if (wasNoResumed && dc.mFocusedApp != null && dc.mFocusedApp.isState(RESUMED)) { + foundResumed = true; + } + } + if (isPowerModePreApplied && !foundResumed) { + endPowerMode(POWER_MODE_REASON_START_ACTIVITY); + } } WallpaperManagerInternal wallpaperManagerInternal = getWallpaperManagerInternal(); if (wallpaperManagerInternal != null) { |