Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +0 −15 Original line number Original line Diff line number Diff line Loading @@ -507,7 +507,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private boolean mPendingKeyguardOccluded; private boolean mPendingKeyguardOccluded; private boolean mKeyguardOccludedChanged; private boolean mKeyguardOccludedChanged; private ActivityTaskManagerInternal.SleepTokenAcquirer mScreenOffSleepTokenAcquirer; Intent mHomeIntent; Intent mHomeIntent; Intent mCarDockIntent; Intent mCarDockIntent; Intent mDeskDockIntent; Intent mDeskDockIntent; Loading Loading @@ -1623,9 +1622,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { new AccessibilityShortcutController(mContext, new Handler(), mCurrentUserId); new AccessibilityShortcutController(mContext, new Handler(), mCurrentUserId); mLogger = new MetricsLogger(); mLogger = new MetricsLogger(); mScreenOffSleepTokenAcquirer = mActivityTaskManagerInternal .createSleepTokenAcquirer("ScreenOff"); Resources res = mContext.getResources(); Resources res = mContext.getResources(); mWakeOnDpadKeyPress = mWakeOnDpadKeyPress = res.getBoolean(com.android.internal.R.bool.config_wakeOnDpadKeyPress); res.getBoolean(com.android.internal.R.bool.config_wakeOnDpadKeyPress); Loading Loading @@ -4385,7 +4381,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (DEBUG_WAKEUP) Slog.i(TAG, "Display" + displayId + " turned off..."); if (DEBUG_WAKEUP) Slog.i(TAG, "Display" + displayId + " turned off..."); if (displayId == DEFAULT_DISPLAY) { if (displayId == DEFAULT_DISPLAY) { updateScreenOffSleepToken(true); mRequestedOrSleepingDefaultDisplay = false; mRequestedOrSleepingDefaultDisplay = false; mDefaultDisplayPolicy.screenTurnedOff(); mDefaultDisplayPolicy.screenTurnedOff(); synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -4418,7 +4413,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (displayId == DEFAULT_DISPLAY) { if (displayId == DEFAULT_DISPLAY) { Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */); 0 /* cookie */); updateScreenOffSleepToken(false); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mBootAnimationDismissable = false; mBootAnimationDismissable = false; Loading Loading @@ -4933,15 +4927,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } // TODO (multidisplay): Support multiple displays in WindowManagerPolicy. private void updateScreenOffSleepToken(boolean acquire) { if (acquire) { mScreenOffSleepTokenAcquirer.acquire(DEFAULT_DISPLAY); } else { mScreenOffSleepTokenAcquirer.release(DEFAULT_DISPLAY); } } /** {@inheritDoc} */ /** {@inheritDoc} */ @Override @Override public void enableScreenAfterBoot() { public void enableScreenAfterBoot() { Loading services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +0 −29 Original line number Original line Diff line number Diff line Loading @@ -123,35 +123,6 @@ public abstract class ActivityTaskManagerInternal { void onKeyguardStateChanged(boolean isShowing); void onKeyguardStateChanged(boolean isShowing); } } /** * Sleep tokens cause the activity manager to put the top activity to sleep. * They are used by components such as dreams that may hide and block interaction * with underlying activities. * The Acquirer provides an interface that encapsulates the underlying work, so the user does * not need to handle the token by him/herself. */ public interface SleepTokenAcquirer { /** * Acquires a sleep token. * @param displayId The display to apply to. */ void acquire(int displayId); /** * Releases the sleep token. * @param displayId The display to apply to. */ void release(int displayId); } /** * Creates a sleep token acquirer for the specified display with the specified tag. * * @param tag A string identifying the purpose (eg. "Dream"). */ public abstract SleepTokenAcquirer createSleepTokenAcquirer(@NonNull String tag); /** /** * Returns home activity for the specified user. * Returns home activity for the specified user. * * Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -4533,17 +4533,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { reason); reason); } } final class SleepTokenAcquirerImpl implements ActivityTaskManagerInternal.SleepTokenAcquirer { /** * Sleep tokens cause the activity manager to put the top activity to sleep. * They are used by components such as dreams that may hide and block interaction * with underlying activities. */ final class SleepTokenAcquirer { private final String mTag; private final String mTag; private final SparseArray<RootWindowContainer.SleepToken> mSleepTokens = private final SparseArray<RootWindowContainer.SleepToken> mSleepTokens = new SparseArray<>(); new SparseArray<>(); SleepTokenAcquirerImpl(@NonNull String tag) { SleepTokenAcquirer(@NonNull String tag) { mTag = tag; mTag = tag; } } @Override /** public void acquire(int displayId) { * Acquires a sleep token. * @param displayId The display to apply to. */ void acquire(int displayId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { if (!mSleepTokens.contains(displayId)) { if (!mSleepTokens.contains(displayId)) { mSleepTokens.append(displayId, mSleepTokens.append(displayId, Loading @@ -4553,8 +4561,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } } } @Override /** public void release(int displayId) { * Releases the sleep token. * @param displayId The display to apply to. */ void release(int displayId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { final RootWindowContainer.SleepToken token = mSleepTokens.get(displayId); final RootWindowContainer.SleepToken token = mSleepTokens.get(displayId); if (token != null) { if (token != null) { Loading Loading @@ -5231,12 +5242,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } final class LocalService extends ActivityTaskManagerInternal { final class LocalService extends ActivityTaskManagerInternal { @Override public SleepTokenAcquirer createSleepTokenAcquirer(@NonNull String tag) { Objects.requireNonNull(tag); return new SleepTokenAcquirerImpl(tag); } @Override @Override public ComponentName getHomeActivityForUser(int userId) { public ComponentName getHomeActivityForUser(int userId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { Loading services/core/java/com/android/server/wm/DisplayContent.java +11 −3 Original line number Original line Diff line number Diff line Loading @@ -685,7 +685,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp /** All tokens used to put activities on this root task to sleep (including mOffToken) */ /** All tokens used to put activities on this root task to sleep (including mOffToken) */ final ArrayList<RootWindowContainer.SleepToken> mAllSleepTokens = new ArrayList<>(); final ArrayList<RootWindowContainer.SleepToken> mAllSleepTokens = new ArrayList<>(); /** The token acquirer to put root tasks on the display to sleep */ /** The token acquirer to put root tasks on the display to sleep */ private final ActivityTaskManagerInternal.SleepTokenAcquirer mOffTokenAcquirer; private final ActivityTaskManagerService.SleepTokenAcquirer mOffTokenAcquirer; private boolean mSleeping; private boolean mSleeping; Loading Loading @@ -5549,6 +5549,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mMetricsLogger; return mMetricsLogger; } } void acquireScreenOffToken(boolean acquire) { if (acquire) { mOffTokenAcquirer.acquire(mDisplayId); } else { mOffTokenAcquirer.release(mDisplayId); } } void onDisplayChanged() { void onDisplayChanged() { mDisplay.getRealSize(mTmpDisplaySize); mDisplay.getRealSize(mTmpDisplaySize); setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y); setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y); Loading @@ -5559,9 +5567,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (displayId != DEFAULT_DISPLAY) { if (displayId != DEFAULT_DISPLAY) { final int displayState = mDisplay.getState(); final int displayState = mDisplay.getState(); if (displayState == Display.STATE_OFF) { if (displayState == Display.STATE_OFF) { mOffTokenAcquirer.acquire(mDisplayId); acquireScreenOffToken(true /* acquire */); } else if (displayState == Display.STATE_ON) { } else if (displayState == Display.STATE_ON) { mOffTokenAcquirer.release(mDisplayId); acquireScreenOffToken(false /* acquire */); } } ProtoLog.v(WM_DEBUG_LAYER_MIRRORING, ProtoLog.v(WM_DEBUG_LAYER_MIRRORING, "Display %d state is now (%d), so update layer mirroring?", "Display %d state is now (%d), so update layer mirroring?", Loading services/core/java/com/android/server/wm/DisplayPolicy.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -778,6 +778,10 @@ public class DisplayPolicy { public void setAwake(boolean awake) { public void setAwake(boolean awake) { mAwake = awake; mAwake = awake; // The screen off token for non-default display is controlled by DisplayContent. if (mDisplayContent.isDefaultDisplay) { mDisplayContent.acquireScreenOffToken(!awake); } } } public boolean isAwake() { public boolean isAwake() { Loading Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +0 −15 Original line number Original line Diff line number Diff line Loading @@ -507,7 +507,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { private boolean mPendingKeyguardOccluded; private boolean mPendingKeyguardOccluded; private boolean mKeyguardOccludedChanged; private boolean mKeyguardOccludedChanged; private ActivityTaskManagerInternal.SleepTokenAcquirer mScreenOffSleepTokenAcquirer; Intent mHomeIntent; Intent mHomeIntent; Intent mCarDockIntent; Intent mCarDockIntent; Intent mDeskDockIntent; Intent mDeskDockIntent; Loading Loading @@ -1623,9 +1622,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { new AccessibilityShortcutController(mContext, new Handler(), mCurrentUserId); new AccessibilityShortcutController(mContext, new Handler(), mCurrentUserId); mLogger = new MetricsLogger(); mLogger = new MetricsLogger(); mScreenOffSleepTokenAcquirer = mActivityTaskManagerInternal .createSleepTokenAcquirer("ScreenOff"); Resources res = mContext.getResources(); Resources res = mContext.getResources(); mWakeOnDpadKeyPress = mWakeOnDpadKeyPress = res.getBoolean(com.android.internal.R.bool.config_wakeOnDpadKeyPress); res.getBoolean(com.android.internal.R.bool.config_wakeOnDpadKeyPress); Loading Loading @@ -4385,7 +4381,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (DEBUG_WAKEUP) Slog.i(TAG, "Display" + displayId + " turned off..."); if (DEBUG_WAKEUP) Slog.i(TAG, "Display" + displayId + " turned off..."); if (displayId == DEFAULT_DISPLAY) { if (displayId == DEFAULT_DISPLAY) { updateScreenOffSleepToken(true); mRequestedOrSleepingDefaultDisplay = false; mRequestedOrSleepingDefaultDisplay = false; mDefaultDisplayPolicy.screenTurnedOff(); mDefaultDisplayPolicy.screenTurnedOff(); synchronized (mLock) { synchronized (mLock) { Loading Loading @@ -4418,7 +4413,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { if (displayId == DEFAULT_DISPLAY) { if (displayId == DEFAULT_DISPLAY) { Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "screenTurningOn", 0 /* cookie */); 0 /* cookie */); updateScreenOffSleepToken(false); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mDefaultDisplayPolicy.screenTurnedOn(screenOnListener); mBootAnimationDismissable = false; mBootAnimationDismissable = false; Loading Loading @@ -4933,15 +4927,6 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } } } // TODO (multidisplay): Support multiple displays in WindowManagerPolicy. private void updateScreenOffSleepToken(boolean acquire) { if (acquire) { mScreenOffSleepTokenAcquirer.acquire(DEFAULT_DISPLAY); } else { mScreenOffSleepTokenAcquirer.release(DEFAULT_DISPLAY); } } /** {@inheritDoc} */ /** {@inheritDoc} */ @Override @Override public void enableScreenAfterBoot() { public void enableScreenAfterBoot() { Loading
services/core/java/com/android/server/wm/ActivityTaskManagerInternal.java +0 −29 Original line number Original line Diff line number Diff line Loading @@ -123,35 +123,6 @@ public abstract class ActivityTaskManagerInternal { void onKeyguardStateChanged(boolean isShowing); void onKeyguardStateChanged(boolean isShowing); } } /** * Sleep tokens cause the activity manager to put the top activity to sleep. * They are used by components such as dreams that may hide and block interaction * with underlying activities. * The Acquirer provides an interface that encapsulates the underlying work, so the user does * not need to handle the token by him/herself. */ public interface SleepTokenAcquirer { /** * Acquires a sleep token. * @param displayId The display to apply to. */ void acquire(int displayId); /** * Releases the sleep token. * @param displayId The display to apply to. */ void release(int displayId); } /** * Creates a sleep token acquirer for the specified display with the specified tag. * * @param tag A string identifying the purpose (eg. "Dream"). */ public abstract SleepTokenAcquirer createSleepTokenAcquirer(@NonNull String tag); /** /** * Returns home activity for the specified user. * Returns home activity for the specified user. * * Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +17 −12 Original line number Original line Diff line number Diff line Loading @@ -4533,17 +4533,25 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { reason); reason); } } final class SleepTokenAcquirerImpl implements ActivityTaskManagerInternal.SleepTokenAcquirer { /** * Sleep tokens cause the activity manager to put the top activity to sleep. * They are used by components such as dreams that may hide and block interaction * with underlying activities. */ final class SleepTokenAcquirer { private final String mTag; private final String mTag; private final SparseArray<RootWindowContainer.SleepToken> mSleepTokens = private final SparseArray<RootWindowContainer.SleepToken> mSleepTokens = new SparseArray<>(); new SparseArray<>(); SleepTokenAcquirerImpl(@NonNull String tag) { SleepTokenAcquirer(@NonNull String tag) { mTag = tag; mTag = tag; } } @Override /** public void acquire(int displayId) { * Acquires a sleep token. * @param displayId The display to apply to. */ void acquire(int displayId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { if (!mSleepTokens.contains(displayId)) { if (!mSleepTokens.contains(displayId)) { mSleepTokens.append(displayId, mSleepTokens.append(displayId, Loading @@ -4553,8 +4561,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } } } @Override /** public void release(int displayId) { * Releases the sleep token. * @param displayId The display to apply to. */ void release(int displayId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { final RootWindowContainer.SleepToken token = mSleepTokens.get(displayId); final RootWindowContainer.SleepToken token = mSleepTokens.get(displayId); if (token != null) { if (token != null) { Loading Loading @@ -5231,12 +5242,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } } final class LocalService extends ActivityTaskManagerInternal { final class LocalService extends ActivityTaskManagerInternal { @Override public SleepTokenAcquirer createSleepTokenAcquirer(@NonNull String tag) { Objects.requireNonNull(tag); return new SleepTokenAcquirerImpl(tag); } @Override @Override public ComponentName getHomeActivityForUser(int userId) { public ComponentName getHomeActivityForUser(int userId) { synchronized (mGlobalLock) { synchronized (mGlobalLock) { Loading
services/core/java/com/android/server/wm/DisplayContent.java +11 −3 Original line number Original line Diff line number Diff line Loading @@ -685,7 +685,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp /** All tokens used to put activities on this root task to sleep (including mOffToken) */ /** All tokens used to put activities on this root task to sleep (including mOffToken) */ final ArrayList<RootWindowContainer.SleepToken> mAllSleepTokens = new ArrayList<>(); final ArrayList<RootWindowContainer.SleepToken> mAllSleepTokens = new ArrayList<>(); /** The token acquirer to put root tasks on the display to sleep */ /** The token acquirer to put root tasks on the display to sleep */ private final ActivityTaskManagerInternal.SleepTokenAcquirer mOffTokenAcquirer; private final ActivityTaskManagerService.SleepTokenAcquirer mOffTokenAcquirer; private boolean mSleeping; private boolean mSleeping; Loading Loading @@ -5549,6 +5549,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mMetricsLogger; return mMetricsLogger; } } void acquireScreenOffToken(boolean acquire) { if (acquire) { mOffTokenAcquirer.acquire(mDisplayId); } else { mOffTokenAcquirer.release(mDisplayId); } } void onDisplayChanged() { void onDisplayChanged() { mDisplay.getRealSize(mTmpDisplaySize); mDisplay.getRealSize(mTmpDisplaySize); setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y); setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y); Loading @@ -5559,9 +5567,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (displayId != DEFAULT_DISPLAY) { if (displayId != DEFAULT_DISPLAY) { final int displayState = mDisplay.getState(); final int displayState = mDisplay.getState(); if (displayState == Display.STATE_OFF) { if (displayState == Display.STATE_OFF) { mOffTokenAcquirer.acquire(mDisplayId); acquireScreenOffToken(true /* acquire */); } else if (displayState == Display.STATE_ON) { } else if (displayState == Display.STATE_ON) { mOffTokenAcquirer.release(mDisplayId); acquireScreenOffToken(false /* acquire */); } } ProtoLog.v(WM_DEBUG_LAYER_MIRRORING, ProtoLog.v(WM_DEBUG_LAYER_MIRRORING, "Display %d state is now (%d), so update layer mirroring?", "Display %d state is now (%d), so update layer mirroring?", Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -778,6 +778,10 @@ public class DisplayPolicy { public void setAwake(boolean awake) { public void setAwake(boolean awake) { mAwake = awake; mAwake = awake; // The screen off token for non-default display is controlled by DisplayContent. if (mDisplayContent.isDefaultDisplay) { mDisplayContent.acquireScreenOffToken(!awake); } } } public boolean isAwake() { public boolean isAwake() { Loading