Provide a way to keep dreaming when undocking.

This change makes it possible to keep a device dreaming when it is
removed from its dock. But there should be no change to existing
functionality unless config_keepDreamingWhenUndocking is true.

Bug: 239090297
Test: Enable screen saver and set it to start when device is docked.
Dock device and wait for screen saver to appear. Remove device from dock
and verify that the screen saver ends (the existing behavior without
this change).

Change-Id: I345eb1d17ae88d893789dfcc160b4a9a664ba57f
This commit is contained in:
Will Leshner
2022-08-12 10:08:45 -07:00
committed by Will
parent 057f721740
commit bef0255273
4 changed files with 19 additions and 5 deletions

View File

@@ -550,6 +550,9 @@
<!-- If this is true, long press on power button will be available from the non-interactive state -->
<bool name="config_supportLongPressPowerWhenNonInteractive">false</bool>
<!-- If this is true, then keep dreaming when undocking. -->
<bool name="config_keepDreamingWhenUndocking">false</bool>
<!-- Auto-rotation behavior -->
<!-- If true, enables auto-rotation features using the accelerometer.

View File

@@ -1978,6 +1978,7 @@
<java-symbol type="bool" name="config_allowTheaterModeWakeFromLidSwitch" />
<java-symbol type="bool" name="config_allowTheaterModeWakeFromDock" />
<java-symbol type="bool" name="config_allowTheaterModeWakeFromWindowLayout" />
<java-symbol type="bool" name="config_keepDreamingWhenUndocking" />
<java-symbol type="bool" name="config_goToSleepOnButtonPressTheaterMode" />
<java-symbol type="bool" name="config_supportLongPressPowerWhenNonInteractive" />
<java-symbol type="bool" name="config_wimaxEnabled" />

View File

@@ -69,6 +69,7 @@ final class DockObserver extends SystemService {
private boolean mUpdatesStopped;
private final boolean mKeepDreamingWhenUndocking;
private final boolean mAllowTheaterModeWakeFromDock;
private final List<ExtconStateConfig> mExtconStateConfigs;
@@ -164,6 +165,8 @@ final class DockObserver extends SystemService {
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
mAllowTheaterModeWakeFromDock = context.getResources().getBoolean(
com.android.internal.R.bool.config_allowTheaterModeWakeFromDock);
mKeepDreamingWhenUndocking = context.getResources().getBoolean(
com.android.internal.R.bool.config_keepDreamingWhenUndocking);
mExtconStateConfigs = loadExtconStateConfigs(context);
@@ -216,10 +219,8 @@ final class DockObserver extends SystemService {
if (newState != mReportedDockState) {
mReportedDockState = newState;
if (mSystemReady) {
// Wake up immediately when docked or undocked except in theater mode.
if (mAllowTheaterModeWakeFromDock
|| Settings.Global.getInt(getContext().getContentResolver(),
Settings.Global.THEATER_MODE_ON, 0) == 0) {
// Wake up immediately when docked or undocked unless prohibited from doing so.
if (allowWakeFromDock()) {
mPowerManager.wakeUp(SystemClock.uptimeMillis(),
"android.server:DOCK");
}
@@ -228,6 +229,15 @@ final class DockObserver extends SystemService {
}
}
private boolean allowWakeFromDock() {
if (mKeepDreamingWhenUndocking) {
return false;
}
return (mAllowTheaterModeWakeFromDock
|| Settings.Global.getInt(getContext().getContentResolver(),
Settings.Global.THEATER_MODE_ON, 0) == 0);
}
private void updateLocked() {
mWakeLock.acquire();
mHandler.sendEmptyMessage(MSG_DOCK_STATE_CHANGED);

View File

@@ -1487,7 +1487,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
a.colorMode = ActivityInfo.COLOR_MODE_DEFAULT;
a.flags |= ActivityInfo.FLAG_EXCLUDE_FROM_RECENTS;
a.resizeMode = RESIZE_MODE_UNRESIZEABLE;
a.configChanges = ActivityInfo.CONFIG_ORIENTATION;
a.configChanges = 0xffffffff;
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchActivityType(ACTIVITY_TYPE_DREAM);