Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d67619d4 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Use foreground sched group for process showing UI while dozing" into main

parents 9b4cb637 f5a6c03f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1829,7 +1829,7 @@ public class OomAdjuster {
                    // screen on or animating, promote UI
                    state.setCurProcState(ActivityManager.PROCESS_STATE_PERSISTENT_UI);
                    state.setCurrentSchedulingGroup(SCHED_GROUP_TOP_APP);
                } else {
                } else if (!app.getWindowProcessController().isShowingUiWhileDozing()) {
                    // screen off, restrict UI scheduling
                    state.setCurProcState(PROCESS_STATE_BOUND_FOREGROUND_SERVICE);
                    state.setCurrentSchedulingGroup(SCHED_GROUP_RESTRICTED);
+2 −0
Original line number Diff line number Diff line
@@ -414,6 +414,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
    boolean mHasCompanionDeviceSetupFeature;
    /** The process of the top most activity. */
    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
     * from the one they are currently in.
+20 −0
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.util.ArraySet;
import android.util.PrintWriterPrinter;
@@ -781,6 +782,12 @@ public class DisplayPolicy {
            if (!mDisplayContent.isDefaultDisplay) {
                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(
                    mAwake /* waiting */);
        }
@@ -826,12 +833,24 @@ public class DisplayPolicy {
    }

    public void screenTurnedOn(ScreenOnListener screenOnListener) {
        WindowProcessController visibleDozeUiProcess = null;
        synchronized (mLock) {
            mScreenOnEarly = true;
            mScreenOnFully = false;
            mKeyguardDrawComplete = false;
            mWindowManagerDrawComplete = false;
            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);
        }
    }

@@ -842,6 +861,7 @@ public class DisplayPolicy {
            mKeyguardDrawComplete = false;
            mWindowManagerDrawComplete = false;
            mScreenOnListener = null;
            mService.mAtmService.mVisibleDozeUiProcess = null;
        }
    }

+5 −0
Original line number Diff line number Diff line
@@ -1863,6 +1863,11 @@ public class WindowProcessController extends ConfigurationContainer<Configuratio
        return this == mAtm.mHomeProcess;
    }

    @HotPath(caller = HotPath.OOM_ADJUSTMENT)
    public boolean isShowingUiWhileDozing() {
        return this == mAtm.mVisibleDozeUiProcess;
    }

    @HotPath(caller = HotPath.OOM_ADJUSTMENT)
    public boolean isPreviousProcess() {
        return this == mAtm.mPreviousProcess;
+20 −0
Original line number Diff line number Diff line
@@ -274,6 +274,26 @@ public class DisplayPolicyTests extends WindowTestsBase {
        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)
    public void testMainAppWindowDisallowFitSystemWindowTypes() {
        final DisplayPolicy policy = mDisplayContent.getDisplayPolicy();