Fix screen not turning off on power button press.
If Bedtime is active and the "Keep the screen dark" option is enabled, then the device shouldn't dream and tapping power button should turn the screen off but didn't. This change fixes that issue. Bug: 284857728 Test: Manually by enabling bedtime and the "keep screen dark" option and then tapping power button to verify the screen turns off. Also, if bedtime is disabled (or "keep screen dark" is disabled), then power button should continue to start dreaming. Change-Id: I5db541c5c2e52c58d773822bb7404704516cbb28
This commit is contained in:
@@ -126,6 +126,7 @@ public final class DreamManagerService extends SystemService {
|
||||
private final boolean mDreamsActivatedOnChargeByDefault;
|
||||
private final boolean mDreamsActivatedOnDockByDefault;
|
||||
private final boolean mKeepDreamingWhenUnpluggingDefault;
|
||||
private final boolean mDreamsDisabledByAmbientModeSuppressionConfig;
|
||||
|
||||
private final CopyOnWriteArrayList<DreamManagerInternal.DreamManagerStateListener>
|
||||
mDreamManagerStateListeners = new CopyOnWriteArrayList<>();
|
||||
@@ -239,6 +240,9 @@ public final class DreamManagerService extends SystemService {
|
||||
mSettingsObserver = new SettingsObserver(mHandler);
|
||||
mKeepDreamingWhenUnpluggingDefault = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_keepDreamingWhenUnplugging);
|
||||
mDreamsDisabledByAmbientModeSuppressionConfig = mContext.getResources().getBoolean(
|
||||
com.android.internal.R.bool.config_dreamsDisabledByAmbientModeSuppressionConfig);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -406,6 +410,13 @@ public final class DreamManagerService extends SystemService {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (mDreamsDisabledByAmbientModeSuppressionConfig
|
||||
&& mPowerManagerInternal.isAmbientDisplaySuppressed()) {
|
||||
// Don't dream if Bedtime (or something else) is suppressing ambient.
|
||||
Slog.i(TAG, "Can't start dreaming because ambient is suppressed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((mWhenToDream & DREAM_ON_CHARGE) == DREAM_ON_CHARGE) {
|
||||
return mIsCharging;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user