Loading services/core/java/com/android/server/am/OomAdjuster.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1829,7 +1829,7 @@ public class OomAdjuster { // screen on or animating, promote UI // screen on or animating, promote UI state.setCurProcState(ActivityManager.PROCESS_STATE_PERSISTENT_UI); state.setCurProcState(ActivityManager.PROCESS_STATE_PERSISTENT_UI); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); } else { } else if (!app.getWindowProcessController().isShowingUiWhileDozing()) { // screen off, restrict UI scheduling // screen off, restrict UI scheduling state.setCurProcState(PROCESS_STATE_BOUND_FOREGROUND_SERVICE); state.setCurProcState(PROCESS_STATE_BOUND_FOREGROUND_SERVICE); state.setCurrentSchedulingGroup(SCHED_GROUP_RESTRICTED); state.setCurrentSchedulingGroup(SCHED_GROUP_RESTRICTED); Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -414,6 +414,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { boolean mHasCompanionDeviceSetupFeature; boolean mHasCompanionDeviceSetupFeature; /** The process of the top most activity. */ /** The process of the top most activity. */ volatile WindowProcessController mTopApp; volatile WindowProcessController mTopApp; /** The process showing UI while the device is dozing. */ volatile WindowProcessController mVisibleDozeUiProcess; /** /** * This is the process holding the activity the user last visited that is in a different process * This is the process holding the activity the user last visited that is in a different process * from the one they are currently in. * from the one they are currently in. Loading services/core/java/com/android/server/wm/DisplayPolicy.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,7 @@ import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.UserHandle; import android.util.ArraySet; import android.util.ArraySet; import android.util.PrintWriterPrinter; import android.util.PrintWriterPrinter; Loading Loading @@ -781,6 +782,12 @@ public class DisplayPolicy { if (!mDisplayContent.isDefaultDisplay) { if (!mDisplayContent.isDefaultDisplay) { return; return; } } if (awake) { mService.mAtmService.mVisibleDozeUiProcess = null; } else if (mScreenOnFully && mNotificationShade != null) { // Screen is still on, so it may be showing an always-on UI. mService.mAtmService.mVisibleDozeUiProcess = mNotificationShade.getProcess(); } mService.mAtmService.mKeyguardController.updateDeferTransitionForAod( mService.mAtmService.mKeyguardController.updateDeferTransitionForAod( mAwake /* waiting */); mAwake /* waiting */); } } Loading Loading @@ -826,12 +833,24 @@ public class DisplayPolicy { } } public void screenTurnedOn(ScreenOnListener screenOnListener) { public void screenTurnedOn(ScreenOnListener screenOnListener) { WindowProcessController visibleDozeUiProcess = null; synchronized (mLock) { synchronized (mLock) { mScreenOnEarly = true; mScreenOnEarly = true; mScreenOnFully = false; mScreenOnFully = false; mKeyguardDrawComplete = false; mKeyguardDrawComplete = false; mWindowManagerDrawComplete = false; mWindowManagerDrawComplete = false; mScreenOnListener = screenOnListener; mScreenOnListener = screenOnListener; if (!mAwake && mNotificationShade != null) { // The screen is turned on without awake state. It is usually triggered by an // adding notification, so make the UI process have a higher priority. visibleDozeUiProcess = mNotificationShade.getProcess(); mService.mAtmService.mVisibleDozeUiProcess = visibleDozeUiProcess; } } // The method calls AM directly, so invoke it outside the lock. if (visibleDozeUiProcess != null) { Trace.instant(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurnedOnWhileDozing"); mService.mAtmService.setProcessAnimatingWhileDozing(visibleDozeUiProcess); } } } } Loading @@ -842,6 +861,7 @@ public class DisplayPolicy { mKeyguardDrawComplete = false; mKeyguardDrawComplete = false; mWindowManagerDrawComplete = false; mWindowManagerDrawComplete = false; mScreenOnListener = null; mScreenOnListener = null; mService.mAtmService.mVisibleDozeUiProcess = null; } } } } Loading services/core/java/com/android/server/wm/WindowProcessController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -1863,6 +1863,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return this == mAtm.mHomeProcess; return this == mAtm.mHomeProcess; } } @HotPath(caller = HotPath.OOM_ADJUSTMENT) public boolean isShowingUiWhileDozing() { return this == mAtm.mVisibleDozeUiProcess; } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @HotPath(caller = HotPath.OOM_ADJUSTMENT) public boolean isPreviousProcess() { public boolean isPreviousProcess() { return this == mAtm.mPreviousProcess; return this == mAtm.mPreviousProcess; Loading services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -274,6 +274,26 @@ public class DisplayPolicyTests extends WindowTestsBase { assertEquals(mAppWindow, policy.getTopFullscreenOpaqueWindow()); assertEquals(mAppWindow, policy.getTopFullscreenOpaqueWindow()); } } @SetupWindows(addWindows = W_NOTIFICATION_SHADE) @Test public void testVisibleProcessWhileDozing() { final WindowProcessController wpc = mNotificationShadeWindow.getProcess(); final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); policy.addWindowLw(mNotificationShadeWindow, mNotificationShadeWindow.mAttrs); policy.screenTurnedOff(); policy.setAwake(false); policy.screenTurnedOn(null /* screenOnListener */); assertTrue(wpc.isShowingUiWhileDozing()); policy.screenTurnedOff(); assertFalse(wpc.isShowingUiWhileDozing()); policy.screenTurnedOn(null /* screenOnListener */); assertTrue(wpc.isShowingUiWhileDozing()); policy.setAwake(true); assertFalse(wpc.isShowingUiWhileDozing()); } @Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class) public void testMainAppWindowDisallowFitSystemWindowTypes() { public void testMainAppWindowDisallowFitSystemWindowTypes() { final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); Loading Loading
services/core/java/com/android/server/am/OomAdjuster.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1829,7 +1829,7 @@ public class OomAdjuster { // screen on or animating, promote UI // screen on or animating, promote UI state.setCurProcState(ActivityManager.PROCESS_STATE_PERSISTENT_UI); state.setCurProcState(ActivityManager.PROCESS_STATE_PERSISTENT_UI); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP); } else { } else if (!app.getWindowProcessController().isShowingUiWhileDozing()) { // screen off, restrict UI scheduling // screen off, restrict UI scheduling state.setCurProcState(PROCESS_STATE_BOUND_FOREGROUND_SERVICE); state.setCurProcState(PROCESS_STATE_BOUND_FOREGROUND_SERVICE); state.setCurrentSchedulingGroup(SCHED_GROUP_RESTRICTED); state.setCurrentSchedulingGroup(SCHED_GROUP_RESTRICTED); Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -414,6 +414,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { boolean mHasCompanionDeviceSetupFeature; boolean mHasCompanionDeviceSetupFeature; /** The process of the top most activity. */ /** The process of the top most activity. */ volatile WindowProcessController mTopApp; volatile WindowProcessController mTopApp; /** The process showing UI while the device is dozing. */ volatile WindowProcessController mVisibleDozeUiProcess; /** /** * This is the process holding the activity the user last visited that is in a different process * This is the process holding the activity the user last visited that is in a different process * from the one they are currently in. * from the one they are currently in. Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -99,6 +99,7 @@ import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.SystemClock; import android.os.SystemClock; import android.os.SystemProperties; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; import android.os.UserHandle; import android.util.ArraySet; import android.util.ArraySet; import android.util.PrintWriterPrinter; import android.util.PrintWriterPrinter; Loading Loading @@ -781,6 +782,12 @@ public class DisplayPolicy { if (!mDisplayContent.isDefaultDisplay) { if (!mDisplayContent.isDefaultDisplay) { return; return; } } if (awake) { mService.mAtmService.mVisibleDozeUiProcess = null; } else if (mScreenOnFully && mNotificationShade != null) { // Screen is still on, so it may be showing an always-on UI. mService.mAtmService.mVisibleDozeUiProcess = mNotificationShade.getProcess(); } mService.mAtmService.mKeyguardController.updateDeferTransitionForAod( mService.mAtmService.mKeyguardController.updateDeferTransitionForAod( mAwake /* waiting */); mAwake /* waiting */); } } Loading Loading @@ -826,12 +833,24 @@ public class DisplayPolicy { } } public void screenTurnedOn(ScreenOnListener screenOnListener) { public void screenTurnedOn(ScreenOnListener screenOnListener) { WindowProcessController visibleDozeUiProcess = null; synchronized (mLock) { synchronized (mLock) { mScreenOnEarly = true; mScreenOnEarly = true; mScreenOnFully = false; mScreenOnFully = false; mKeyguardDrawComplete = false; mKeyguardDrawComplete = false; mWindowManagerDrawComplete = false; mWindowManagerDrawComplete = false; mScreenOnListener = screenOnListener; mScreenOnListener = screenOnListener; if (!mAwake && mNotificationShade != null) { // The screen is turned on without awake state. It is usually triggered by an // adding notification, so make the UI process have a higher priority. visibleDozeUiProcess = mNotificationShade.getProcess(); mService.mAtmService.mVisibleDozeUiProcess = visibleDozeUiProcess; } } // The method calls AM directly, so invoke it outside the lock. if (visibleDozeUiProcess != null) { Trace.instant(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurnedOnWhileDozing"); mService.mAtmService.setProcessAnimatingWhileDozing(visibleDozeUiProcess); } } } } Loading @@ -842,6 +861,7 @@ public class DisplayPolicy { mKeyguardDrawComplete = false; mKeyguardDrawComplete = false; mWindowManagerDrawComplete = false; mWindowManagerDrawComplete = false; mScreenOnListener = null; mScreenOnListener = null; mService.mAtmService.mVisibleDozeUiProcess = null; } } } } Loading
services/core/java/com/android/server/wm/WindowProcessController.java +5 −0 Original line number Original line Diff line number Diff line Loading @@ -1863,6 +1863,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio return this == mAtm.mHomeProcess; return this == mAtm.mHomeProcess; } } @HotPath(caller = HotPath.OOM_ADJUSTMENT) public boolean isShowingUiWhileDozing() { return this == mAtm.mVisibleDozeUiProcess; } @HotPath(caller = HotPath.OOM_ADJUSTMENT) @HotPath(caller = HotPath.OOM_ADJUSTMENT) public boolean isPreviousProcess() { public boolean isPreviousProcess() { return this == mAtm.mPreviousProcess; return this == mAtm.mPreviousProcess; Loading
services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +20 −0 Original line number Original line Diff line number Diff line Loading @@ -274,6 +274,26 @@ public class DisplayPolicyTests extends WindowTestsBase { assertEquals(mAppWindow, policy.getTopFullscreenOpaqueWindow()); assertEquals(mAppWindow, policy.getTopFullscreenOpaqueWindow()); } } @SetupWindows(addWindows = W_NOTIFICATION_SHADE) @Test public void testVisibleProcessWhileDozing() { final WindowProcessController wpc = mNotificationShadeWindow.getProcess(); final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); policy.addWindowLw(mNotificationShadeWindow, mNotificationShadeWindow.mAttrs); policy.screenTurnedOff(); policy.setAwake(false); policy.screenTurnedOn(null /* screenOnListener */); assertTrue(wpc.isShowingUiWhileDozing()); policy.screenTurnedOff(); assertFalse(wpc.isShowingUiWhileDozing()); policy.screenTurnedOn(null /* screenOnListener */); assertTrue(wpc.isShowingUiWhileDozing()); policy.setAwake(true); assertFalse(wpc.isShowingUiWhileDozing()); } @Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class) public void testMainAppWindowDisallowFitSystemWindowTypes() { public void testMainAppWindowDisallowFitSystemWindowTypes() { final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); final DisplayPolicy policy = mDisplayContent.getDisplayPolicy(); Loading