Loading core/java/android/hardware/display/DisplayManagerInternal.java +8 −2 Original line number Diff line number Diff line Loading @@ -504,6 +504,9 @@ public abstract class DisplayManagerInternal { public float dozeScreenBrightness; public int dozeScreenStateReason; // Override that makes display use normal brightness while dozing. public boolean useNormalBrightnessForDoze; public DisplayPowerRequest() { policy = POLICY_BRIGHT; useProximitySensor = false; Loading Loading @@ -537,6 +540,7 @@ public abstract class DisplayManagerInternal { dozeScreenBrightness = other.dozeScreenBrightness; dozeScreenState = other.dozeScreenState; dozeScreenStateReason = other.dozeScreenStateReason; useNormalBrightnessForDoze = other.useNormalBrightnessForDoze; } @Override Loading @@ -561,7 +565,8 @@ public abstract class DisplayManagerInternal { && boostScreenBrightness == other.boostScreenBrightness && floatEquals(dozeScreenBrightness, other.dozeScreenBrightness) && dozeScreenState == other.dozeScreenState && dozeScreenStateReason == other.dozeScreenStateReason; && dozeScreenStateReason == other.dozeScreenStateReason && useNormalBrightnessForDoze == other.useNormalBrightnessForDoze; } private boolean floatEquals(float f1, float f2) { Loading @@ -587,7 +592,8 @@ public abstract class DisplayManagerInternal { + ", dozeScreenBrightness=" + dozeScreenBrightness + ", dozeScreenState=" + Display.stateToString(dozeScreenState) + ", dozeScreenStateReason=" + Display.stateReasonToString(dozeScreenStateReason); + Display.stateReasonToString(dozeScreenStateReason) + ", useNormalBrightnessForDoze=" + useNormalBrightnessForDoze; } public static String policyToString(int policy) { Loading core/java/android/os/PowerManagerInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -145,10 +145,11 @@ public abstract class PowerManagerInternal { * @param screenBrightnessInt The overridden screen brightness between 1 and 255, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. Not used if * screenBrightnessFloat is provided (is not NaN). * @param useNormalBrightnessForDoze Whether use normal brightness while device is dozing. */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt); int screenBrightnessInt, boolean useNormalBrightnessForDoze); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading core/java/android/service/dreams/DreamService.java +36 −9 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package android.service.dreams; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.service.dreams.Flags.dreamHandlesBeingObscured; import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.service.dreams.Flags.startAndStopDozingInBackground; import android.annotation.FlaggedApi; Loading Loading @@ -272,6 +272,9 @@ public class DreamService extends Service implements Window.Callback { private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; // This variable being true means dozing device expecting normal(non-doze) brightness. private boolean mUseNormalBrightnessForDoze; private boolean mDebug = false; private ComponentName mDreamComponent; Loading Loading @@ -935,13 +938,14 @@ public class DreamService extends Service implements Window.Callback { if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); } else { mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); } } catch (RemoteException ex) { // system server died } Loading Loading @@ -1010,7 +1014,8 @@ public class DreamService extends Service implements Window.Callback { */ @UnsupportedAppUsage public void setDozeScreenState(int state) { setDozeScreenState(state, Display.STATE_REASON_UNKNOWN); setDozeScreenState(state, Display.STATE_REASON_UNKNOWN, /* useNormalBrightnessForDoze= */ false); } /** Loading Loading @@ -1048,20 +1053,42 @@ public class DreamService extends Service implements Window.Callback { * {@link Display#STATE_ON_SUSPEND}, {@link Display#STATE_OFF}, or {@link Display#STATE_UNKNOWN} * for the default behavior. * @param reason the reason for setting the specified screen state. * * @hide For use by system UI components only. * @param useNormalBrightnessForDoze False means the default case where doze brightness is * expected when device is dozing. True means display expects normal brightness for next doze * request. Noted: unlike {@link #setDozeScreenBrightness} that sets a real brightness value for * doze screen, this parameter only indicates whether the doze brightness is intended on next * doze screen. The actual brightness value will be computed by {@link DisplayManager} * internally. * @hide For use by System UI components only. */ @UnsupportedAppUsage public void setDozeScreenState(int state, @Display.StateReason int reason) { public void setDozeScreenState(int state, @Display.StateReason int reason, boolean useNormalBrightnessForDoze) { synchronized (this) { if (mDozeScreenState != state) { if (mDozeScreenState != state || mUseNormalBrightnessForDoze != useNormalBrightnessForDoze) { mDozeScreenState = state; mDozeScreenStateReason = reason; mUseNormalBrightnessForDoze = useNormalBrightnessForDoze; updateDoze(); } } } /** * Returns whether we want to use the normal brightness setting while in doze. This is useful * on devices like Wear; when we allow the user to interact with a device that remains in * doze (looking at time). * * @return a boolean that informs {@link DisplayManager} whether to adjust the display for the * interacting user e.g. brightening the display. * @hide For use by System UI components only. */ @UnsupportedAppUsage public boolean getUseNormalBrightnessForDoze() { return mUseNormalBrightnessForDoze; } /** * Gets the screen brightness to use while dozing. * Loading core/java/android/service/dreams/IDreamManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ interface IDreamManager { void finishSelf(in IBinder token, boolean immediate); /** @deprecated Please use startDozingOneway instead. */ void startDozing(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); int screenBrightnessInt, boolean useNormalBrightnessForDoze); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -54,6 +54,7 @@ interface IDreamManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDreamIsObscured(in boolean isObscured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); oneway void finishSelfOneway(in IBinder token, boolean immediate); } services/core/java/com/android/server/display/AutomaticBrightnessController.java +11 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.display; import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; import static com.android.server.display.BrightnessMappingStrategy.INVALID_LUX; import static com.android.server.display.config.DisplayBrightnessMappingConfig.autoBrightnessModeToString; Loading Loading @@ -241,6 +243,9 @@ public class AutomaticBrightnessController { private int mDisplayState = Display.STATE_UNKNOWN; // True if the normal brightness should be forced while device is dozing. private boolean mUseNormalBrightnessForDoze; // True if we are collecting a brightness adjustment sample, along with some data // for the initial state of the sample. private boolean mBrightnessAdjustmentSamplePending; Loading Loading @@ -442,11 +447,12 @@ public class AutomaticBrightnessController { public void configure(int state, @Nullable BrightnessConfiguration configuration, float brightness, boolean userChangedBrightness, float adjustment, boolean userChangedAutoBrightnessAdjustment, int displayPolicy, int displayState, boolean shouldResetShortTermModel) { boolean useNormalBrightnessForDoze, boolean shouldResetShortTermModel) { mState = state; boolean changed = setBrightnessConfiguration(configuration, shouldResetShortTermModel); changed |= setDisplayPolicy(displayPolicy); mDisplayState = displayState; mUseNormalBrightnessForDoze = useNormalBrightnessForDoze; if (userChangedAutoBrightnessAdjustment) { changed |= setAutoBrightnessAdjustment(adjustment); } Loading Loading @@ -1264,11 +1270,10 @@ public class AutomaticBrightnessController { } private boolean shouldApplyDozeScaleFactor() { // Apply the doze scale factor if the display is in doze. We shouldn't rely on the display // policy here - the screen might turn on while the policy is POLICY_DOZE and in this // situation, we shouldn't apply the doze scale factor. We also don't apply the doze scale // factor if we have a designated brightness curve for doze. return Display.isDozeState(mDisplayState) && getMode() != AUTO_BRIGHTNESS_MODE_DOZE; // We don't apply the doze scale factor if we have a designated brightness curve for doze. return (mDisplayManagerFlags.isNormalBrightnessForDozeParameterEnabled() ? !mUseNormalBrightnessForDoze && mDisplayPolicy == POLICY_DOZE : Display.isDozeState(mDisplayState)) && getMode() != AUTO_BRIGHTNESS_MODE_DOZE; } private class ShortTermModel { Loading Loading
core/java/android/hardware/display/DisplayManagerInternal.java +8 −2 Original line number Diff line number Diff line Loading @@ -504,6 +504,9 @@ public abstract class DisplayManagerInternal { public float dozeScreenBrightness; public int dozeScreenStateReason; // Override that makes display use normal brightness while dozing. public boolean useNormalBrightnessForDoze; public DisplayPowerRequest() { policy = POLICY_BRIGHT; useProximitySensor = false; Loading Loading @@ -537,6 +540,7 @@ public abstract class DisplayManagerInternal { dozeScreenBrightness = other.dozeScreenBrightness; dozeScreenState = other.dozeScreenState; dozeScreenStateReason = other.dozeScreenStateReason; useNormalBrightnessForDoze = other.useNormalBrightnessForDoze; } @Override Loading @@ -561,7 +565,8 @@ public abstract class DisplayManagerInternal { && boostScreenBrightness == other.boostScreenBrightness && floatEquals(dozeScreenBrightness, other.dozeScreenBrightness) && dozeScreenState == other.dozeScreenState && dozeScreenStateReason == other.dozeScreenStateReason; && dozeScreenStateReason == other.dozeScreenStateReason && useNormalBrightnessForDoze == other.useNormalBrightnessForDoze; } private boolean floatEquals(float f1, float f2) { Loading @@ -587,7 +592,8 @@ public abstract class DisplayManagerInternal { + ", dozeScreenBrightness=" + dozeScreenBrightness + ", dozeScreenState=" + Display.stateToString(dozeScreenState) + ", dozeScreenStateReason=" + Display.stateReasonToString(dozeScreenStateReason); + Display.stateReasonToString(dozeScreenStateReason) + ", useNormalBrightnessForDoze=" + useNormalBrightnessForDoze; } public static String policyToString(int policy) { Loading
core/java/android/os/PowerManagerInternal.java +2 −1 Original line number Diff line number Diff line Loading @@ -145,10 +145,11 @@ public abstract class PowerManagerInternal { * @param screenBrightnessInt The overridden screen brightness between 1 and 255, or * {@link PowerManager#BRIGHTNESS_DEFAULT} to disable the override. Not used if * screenBrightnessFloat is provided (is not NaN). * @param useNormalBrightnessForDoze Whether use normal brightness while device is dozing. */ public abstract void setDozeOverrideFromDreamManager( int screenState, @Display.StateReason int reason, float screenBrightnessFloat, int screenBrightnessInt); int screenBrightnessInt, boolean useNormalBrightnessForDoze); /** * Used by sidekick manager to tell the power manager if it shouldn't change the display state Loading
core/java/android/service/dreams/DreamService.java +36 −9 Original line number Diff line number Diff line Loading @@ -17,8 +17,8 @@ package android.service.dreams; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.service.dreams.Flags.dreamHandlesBeingObscured; import static android.service.dreams.Flags.dreamHandlesConfirmKeys; import static android.service.dreams.Flags.startAndStopDozingInBackground; import android.annotation.FlaggedApi; Loading Loading @@ -272,6 +272,9 @@ public class DreamService extends Service implements Window.Callback { private int mDozeScreenBrightness = PowerManager.BRIGHTNESS_DEFAULT; private float mDozeScreenBrightnessFloat = PowerManager.BRIGHTNESS_INVALID_FLOAT; // This variable being true means dozing device expecting normal(non-doze) brightness. private boolean mUseNormalBrightnessForDoze; private boolean mDebug = false; private ComponentName mDreamComponent; Loading Loading @@ -935,13 +938,14 @@ public class DreamService extends Service implements Window.Callback { if (startAndStopDozingInBackground()) { mDreamManager.startDozingOneway( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); } else { mDreamManager.startDozing( mDreamToken, mDozeScreenState, mDozeScreenStateReason, mDozeScreenBrightnessFloat, mDozeScreenBrightness); mDozeScreenBrightnessFloat, mDozeScreenBrightness, mUseNormalBrightnessForDoze); } } catch (RemoteException ex) { // system server died } Loading Loading @@ -1010,7 +1014,8 @@ public class DreamService extends Service implements Window.Callback { */ @UnsupportedAppUsage public void setDozeScreenState(int state) { setDozeScreenState(state, Display.STATE_REASON_UNKNOWN); setDozeScreenState(state, Display.STATE_REASON_UNKNOWN, /* useNormalBrightnessForDoze= */ false); } /** Loading Loading @@ -1048,20 +1053,42 @@ public class DreamService extends Service implements Window.Callback { * {@link Display#STATE_ON_SUSPEND}, {@link Display#STATE_OFF}, or {@link Display#STATE_UNKNOWN} * for the default behavior. * @param reason the reason for setting the specified screen state. * * @hide For use by system UI components only. * @param useNormalBrightnessForDoze False means the default case where doze brightness is * expected when device is dozing. True means display expects normal brightness for next doze * request. Noted: unlike {@link #setDozeScreenBrightness} that sets a real brightness value for * doze screen, this parameter only indicates whether the doze brightness is intended on next * doze screen. The actual brightness value will be computed by {@link DisplayManager} * internally. * @hide For use by System UI components only. */ @UnsupportedAppUsage public void setDozeScreenState(int state, @Display.StateReason int reason) { public void setDozeScreenState(int state, @Display.StateReason int reason, boolean useNormalBrightnessForDoze) { synchronized (this) { if (mDozeScreenState != state) { if (mDozeScreenState != state || mUseNormalBrightnessForDoze != useNormalBrightnessForDoze) { mDozeScreenState = state; mDozeScreenStateReason = reason; mUseNormalBrightnessForDoze = useNormalBrightnessForDoze; updateDoze(); } } } /** * Returns whether we want to use the normal brightness setting while in doze. This is useful * on devices like Wear; when we allow the user to interact with a device that remains in * doze (looking at time). * * @return a boolean that informs {@link DisplayManager} whether to adjust the display for the * interacting user e.g. brightening the display. * @hide For use by System UI components only. */ @UnsupportedAppUsage public boolean getUseNormalBrightnessForDoze() { return mUseNormalBrightnessForDoze; } /** * Gets the screen brightness to use while dozing. * Loading
core/java/android/service/dreams/IDreamManager.aidl +3 −2 Original line number Diff line number Diff line Loading @@ -43,7 +43,7 @@ interface IDreamManager { void finishSelf(in IBinder token, boolean immediate); /** @deprecated Please use startDozingOneway instead. */ void startDozing(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); int screenBrightnessInt, boolean useNormalBrightnessForDoze); void stopDozing(in IBinder token); void forceAmbientDisplayEnabled(boolean enabled); ComponentName[] getDreamComponentsForUser(int userId); Loading @@ -54,6 +54,7 @@ interface IDreamManager { @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.WRITE_DREAM_STATE)") oneway void setDreamIsObscured(in boolean isObscured); oneway void startDozingOneway(in IBinder token, int screenState, int reason, float screenBrightnessFloat, int screenBrightnessInt); float screenBrightnessFloat, int screenBrightnessInt, boolean useNormalBrightnessForDoze); oneway void finishSelfOneway(in IBinder token, boolean immediate); }
services/core/java/com/android/server/display/AutomaticBrightnessController.java +11 −6 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.server.display; import static android.hardware.display.DisplayManagerInternal.DisplayPowerRequest.POLICY_DOZE; import static com.android.server.display.BrightnessMappingStrategy.INVALID_LUX; import static com.android.server.display.config.DisplayBrightnessMappingConfig.autoBrightnessModeToString; Loading Loading @@ -241,6 +243,9 @@ public class AutomaticBrightnessController { private int mDisplayState = Display.STATE_UNKNOWN; // True if the normal brightness should be forced while device is dozing. private boolean mUseNormalBrightnessForDoze; // True if we are collecting a brightness adjustment sample, along with some data // for the initial state of the sample. private boolean mBrightnessAdjustmentSamplePending; Loading Loading @@ -442,11 +447,12 @@ public class AutomaticBrightnessController { public void configure(int state, @Nullable BrightnessConfiguration configuration, float brightness, boolean userChangedBrightness, float adjustment, boolean userChangedAutoBrightnessAdjustment, int displayPolicy, int displayState, boolean shouldResetShortTermModel) { boolean useNormalBrightnessForDoze, boolean shouldResetShortTermModel) { mState = state; boolean changed = setBrightnessConfiguration(configuration, shouldResetShortTermModel); changed |= setDisplayPolicy(displayPolicy); mDisplayState = displayState; mUseNormalBrightnessForDoze = useNormalBrightnessForDoze; if (userChangedAutoBrightnessAdjustment) { changed |= setAutoBrightnessAdjustment(adjustment); } Loading Loading @@ -1264,11 +1270,10 @@ public class AutomaticBrightnessController { } private boolean shouldApplyDozeScaleFactor() { // Apply the doze scale factor if the display is in doze. We shouldn't rely on the display // policy here - the screen might turn on while the policy is POLICY_DOZE and in this // situation, we shouldn't apply the doze scale factor. We also don't apply the doze scale // factor if we have a designated brightness curve for doze. return Display.isDozeState(mDisplayState) && getMode() != AUTO_BRIGHTNESS_MODE_DOZE; // We don't apply the doze scale factor if we have a designated brightness curve for doze. return (mDisplayManagerFlags.isNormalBrightnessForDozeParameterEnabled() ? !mUseNormalBrightnessForDoze && mDisplayPolicy == POLICY_DOZE : Display.isDozeState(mDisplayState)) && getMode() != AUTO_BRIGHTNESS_MODE_DOZE; } private class ShortTermModel { Loading