Loading services/core/java/com/android/server/display/brightness/BrightnessReason.java +6 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ public final class BrightnessReason { public static final int MODIFIER_THROTTLED = 0x8; public static final int MODIFIER_MIN_LUX = 0x10; public static final int MODIFIER_MIN_USER_SET_LOWER_BOUND = 0x20; public static final int MODIFIER_STYLUS_UNDER_USE = 0x40; public static final int MODIFIER_MASK = MODIFIER_DIMMED | MODIFIER_LOW_POWER | MODIFIER_HDR | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND; | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND | MODIFIER_STYLUS_UNDER_USE; // ADJUSTMENT_* // These things can happen at any point, even if the main brightness reason doesn't Loading Loading @@ -158,6 +160,9 @@ public final class BrightnessReason { if ((mModifier & MODIFIER_MIN_USER_SET_LOWER_BOUND) != 0) { sb.append(" user_min_pref"); } if ((mModifier & MODIFIER_STYLUS_UNDER_USE) != 0) { sb.append(" stylus_under_use"); } int strlen = sb.length(); if (sb.charAt(strlen - 1) == '[') { sb.setLength(strlen - 2); Loading services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java +14 −3 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ public final class DisplayBrightnessController { @VisibleForTesting AutomaticBrightnessController mAutomaticBrightnessController; // True if the stylus is being used private boolean mIsStylusBeingUsed; /** * The constructor of DisplayBrightnessController. */ Loading Loading @@ -460,6 +463,8 @@ public final class DisplayBrightnessController { writer.println(" mScreenBrightnessDefault=" + mScreenBrightnessDefault); writer.println(" mPersistBrightnessNitsForDefaultDisplay=" + mPersistBrightnessNitsForDefaultDisplay); writer.println(" mIsStylusBeingUsed=" + mIsStylusBeingUsed); synchronized (mLock) { writer.println(" mPendingScreenBrightness=" + mPendingScreenBrightness); writer.println(" mCurrentScreenBrightness=" + mCurrentScreenBrightness); Loading Loading @@ -505,7 +510,12 @@ public final class DisplayBrightnessController { * Notifies if the stylus is currently being used or not. */ public void setStylusBeingUsed(boolean isEnabled) { // Todo(b/369977976) - Disable the auto-brightness strategy mIsStylusBeingUsed = isEnabled; } @VisibleForTesting boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @VisibleForTesting Loading Loading @@ -626,13 +636,14 @@ public final class DisplayBrightnessController { lastUserSetScreenBrightness = mLastUserSetScreenBrightness; } return new StrategySelectionRequest(displayPowerRequest, targetDisplayState, lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession); lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession, mIsStylusBeingUsed); } private StrategyExecutionRequest constructStrategyExecutionRequest( DisplayManagerInternal.DisplayPowerRequest displayPowerRequest) { float currentScreenBrightness = getCurrentBrightness(); return new StrategyExecutionRequest(displayPowerRequest, currentScreenBrightness, mUserSetScreenBrightnessUpdated); mUserSetScreenBrightnessUpdated, mIsStylusBeingUsed); } } services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java +2 −1 Original line number Diff line number Diff line Loading @@ -306,7 +306,8 @@ public class DisplayBrightnessStrategySelector { strategySelectionRequest.getDisplayPowerRequest().useNormalBrightnessForDoze, strategySelectionRequest.getLastUserSetScreenBrightness(), strategySelectionRequest.isUserSetBrightnessChanged()); return mAutomaticBrightnessStrategy1.isAutoBrightnessValid(); return !strategySelectionRequest.isStylusBeingUsed() && mAutomaticBrightnessStrategy1.isAutoBrightnessValid(); } private StrategySelectionNotifyRequest constructStrategySelectionNotifyRequest( Loading services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java +12 −3 Original line number Diff line number Diff line Loading @@ -32,11 +32,15 @@ public final class StrategyExecutionRequest { // Represents if the user set screen brightness was changed or not. private boolean mUserSetBrightnessChanged; private boolean mIsStylusBeingUsed; public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, float currentScreenBrightness, boolean userSetBrightnessChanged) { float currentScreenBrightness, boolean userSetBrightnessChanged, boolean isStylusBeingUsed) { mDisplayPowerRequest = displayPowerRequest; mCurrentScreenBrightness = currentScreenBrightness; mUserSetBrightnessChanged = userSetBrightnessChanged; mIsStylusBeingUsed = isStylusBeingUsed; } public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { Loading @@ -51,6 +55,10 @@ public final class StrategyExecutionRequest { return mUserSetBrightnessChanged; } public boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @Override public boolean equals(Object obj) { if (!(obj instanceof StrategyExecutionRequest)) { Loading @@ -59,12 +67,13 @@ public final class StrategyExecutionRequest { StrategyExecutionRequest other = (StrategyExecutionRequest) obj; return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest()) && mCurrentScreenBrightness == other.getCurrentScreenBrightness() && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged(); && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged() && mIsStylusBeingUsed == other.isStylusBeingUsed(); } @Override public int hashCode() { return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness, mUserSetBrightnessChanged); mUserSetBrightnessChanged, mIsStylusBeingUsed); } } services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java +13 −3 Original line number Diff line number Diff line Loading @@ -40,15 +40,19 @@ public final class StrategySelectionRequest { private DisplayManagerInternal.DisplayOffloadSession mDisplayOffloadSession; private boolean mIsStylusBeingUsed; public StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, int targetDisplayState, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged, DisplayManagerInternal.DisplayOffloadSession displayOffloadSession) { DisplayManagerInternal.DisplayOffloadSession displayOffloadSession, boolean isStylusBeingUsed) { mDisplayPowerRequest = displayPowerRequest; mTargetDisplayState = targetDisplayState; mLastUserSetScreenBrightness = lastUserSetScreenBrightness; mUserSetBrightnessChanged = userSetBrightnessChanged; mDisplayOffloadSession = displayOffloadSession; mIsStylusBeingUsed = isStylusBeingUsed; } public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { Loading @@ -72,6 +76,10 @@ public final class StrategySelectionRequest { return mDisplayOffloadSession; } public boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @Override public boolean equals(Object obj) { if (!(obj instanceof StrategySelectionRequest)) { Loading @@ -82,12 +90,14 @@ public final class StrategySelectionRequest { && mTargetDisplayState == other.getTargetDisplayState() && mLastUserSetScreenBrightness == other.getLastUserSetScreenBrightness() && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged() && mDisplayOffloadSession.equals(other.getDisplayOffloadSession()); && mDisplayOffloadSession.equals(other.getDisplayOffloadSession()) && mIsStylusBeingUsed == other.isStylusBeingUsed(); } @Override public int hashCode() { return Objects.hash(mDisplayPowerRequest, mTargetDisplayState, mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession); mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession, mIsStylusBeingUsed); } } Loading
services/core/java/com/android/server/display/brightness/BrightnessReason.java +6 −1 Original line number Diff line number Diff line Loading @@ -50,8 +50,10 @@ public final class BrightnessReason { public static final int MODIFIER_THROTTLED = 0x8; public static final int MODIFIER_MIN_LUX = 0x10; public static final int MODIFIER_MIN_USER_SET_LOWER_BOUND = 0x20; public static final int MODIFIER_STYLUS_UNDER_USE = 0x40; public static final int MODIFIER_MASK = MODIFIER_DIMMED | MODIFIER_LOW_POWER | MODIFIER_HDR | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND; | MODIFIER_THROTTLED | MODIFIER_MIN_LUX | MODIFIER_MIN_USER_SET_LOWER_BOUND | MODIFIER_STYLUS_UNDER_USE; // ADJUSTMENT_* // These things can happen at any point, even if the main brightness reason doesn't Loading Loading @@ -158,6 +160,9 @@ public final class BrightnessReason { if ((mModifier & MODIFIER_MIN_USER_SET_LOWER_BOUND) != 0) { sb.append(" user_min_pref"); } if ((mModifier & MODIFIER_STYLUS_UNDER_USE) != 0) { sb.append(" stylus_under_use"); } int strlen = sb.length(); if (sb.charAt(strlen - 1) == '[') { sb.setLength(strlen - 2); Loading
services/core/java/com/android/server/display/brightness/DisplayBrightnessController.java +14 −3 Original line number Diff line number Diff line Loading @@ -110,6 +110,9 @@ public final class DisplayBrightnessController { @VisibleForTesting AutomaticBrightnessController mAutomaticBrightnessController; // True if the stylus is being used private boolean mIsStylusBeingUsed; /** * The constructor of DisplayBrightnessController. */ Loading Loading @@ -460,6 +463,8 @@ public final class DisplayBrightnessController { writer.println(" mScreenBrightnessDefault=" + mScreenBrightnessDefault); writer.println(" mPersistBrightnessNitsForDefaultDisplay=" + mPersistBrightnessNitsForDefaultDisplay); writer.println(" mIsStylusBeingUsed=" + mIsStylusBeingUsed); synchronized (mLock) { writer.println(" mPendingScreenBrightness=" + mPendingScreenBrightness); writer.println(" mCurrentScreenBrightness=" + mCurrentScreenBrightness); Loading Loading @@ -505,7 +510,12 @@ public final class DisplayBrightnessController { * Notifies if the stylus is currently being used or not. */ public void setStylusBeingUsed(boolean isEnabled) { // Todo(b/369977976) - Disable the auto-brightness strategy mIsStylusBeingUsed = isEnabled; } @VisibleForTesting boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @VisibleForTesting Loading Loading @@ -626,13 +636,14 @@ public final class DisplayBrightnessController { lastUserSetScreenBrightness = mLastUserSetScreenBrightness; } return new StrategySelectionRequest(displayPowerRequest, targetDisplayState, lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession); lastUserSetScreenBrightness, userSetBrightnessChanged, displayOffloadSession, mIsStylusBeingUsed); } private StrategyExecutionRequest constructStrategyExecutionRequest( DisplayManagerInternal.DisplayPowerRequest displayPowerRequest) { float currentScreenBrightness = getCurrentBrightness(); return new StrategyExecutionRequest(displayPowerRequest, currentScreenBrightness, mUserSetScreenBrightnessUpdated); mUserSetScreenBrightnessUpdated, mIsStylusBeingUsed); } }
services/core/java/com/android/server/display/brightness/DisplayBrightnessStrategySelector.java +2 −1 Original line number Diff line number Diff line Loading @@ -306,7 +306,8 @@ public class DisplayBrightnessStrategySelector { strategySelectionRequest.getDisplayPowerRequest().useNormalBrightnessForDoze, strategySelectionRequest.getLastUserSetScreenBrightness(), strategySelectionRequest.isUserSetBrightnessChanged()); return mAutomaticBrightnessStrategy1.isAutoBrightnessValid(); return !strategySelectionRequest.isStylusBeingUsed() && mAutomaticBrightnessStrategy1.isAutoBrightnessValid(); } private StrategySelectionNotifyRequest constructStrategySelectionNotifyRequest( Loading
services/core/java/com/android/server/display/brightness/StrategyExecutionRequest.java +12 −3 Original line number Diff line number Diff line Loading @@ -32,11 +32,15 @@ public final class StrategyExecutionRequest { // Represents if the user set screen brightness was changed or not. private boolean mUserSetBrightnessChanged; private boolean mIsStylusBeingUsed; public StrategyExecutionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, float currentScreenBrightness, boolean userSetBrightnessChanged) { float currentScreenBrightness, boolean userSetBrightnessChanged, boolean isStylusBeingUsed) { mDisplayPowerRequest = displayPowerRequest; mCurrentScreenBrightness = currentScreenBrightness; mUserSetBrightnessChanged = userSetBrightnessChanged; mIsStylusBeingUsed = isStylusBeingUsed; } public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { Loading @@ -51,6 +55,10 @@ public final class StrategyExecutionRequest { return mUserSetBrightnessChanged; } public boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @Override public boolean equals(Object obj) { if (!(obj instanceof StrategyExecutionRequest)) { Loading @@ -59,12 +67,13 @@ public final class StrategyExecutionRequest { StrategyExecutionRequest other = (StrategyExecutionRequest) obj; return Objects.equals(mDisplayPowerRequest, other.getDisplayPowerRequest()) && mCurrentScreenBrightness == other.getCurrentScreenBrightness() && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged(); && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged() && mIsStylusBeingUsed == other.isStylusBeingUsed(); } @Override public int hashCode() { return Objects.hash(mDisplayPowerRequest, mCurrentScreenBrightness, mUserSetBrightnessChanged); mUserSetBrightnessChanged, mIsStylusBeingUsed); } }
services/core/java/com/android/server/display/brightness/StrategySelectionRequest.java +13 −3 Original line number Diff line number Diff line Loading @@ -40,15 +40,19 @@ public final class StrategySelectionRequest { private DisplayManagerInternal.DisplayOffloadSession mDisplayOffloadSession; private boolean mIsStylusBeingUsed; public StrategySelectionRequest(DisplayManagerInternal.DisplayPowerRequest displayPowerRequest, int targetDisplayState, float lastUserSetScreenBrightness, boolean userSetBrightnessChanged, DisplayManagerInternal.DisplayOffloadSession displayOffloadSession) { DisplayManagerInternal.DisplayOffloadSession displayOffloadSession, boolean isStylusBeingUsed) { mDisplayPowerRequest = displayPowerRequest; mTargetDisplayState = targetDisplayState; mLastUserSetScreenBrightness = lastUserSetScreenBrightness; mUserSetBrightnessChanged = userSetBrightnessChanged; mDisplayOffloadSession = displayOffloadSession; mIsStylusBeingUsed = isStylusBeingUsed; } public DisplayManagerInternal.DisplayPowerRequest getDisplayPowerRequest() { Loading @@ -72,6 +76,10 @@ public final class StrategySelectionRequest { return mDisplayOffloadSession; } public boolean isStylusBeingUsed() { return mIsStylusBeingUsed; } @Override public boolean equals(Object obj) { if (!(obj instanceof StrategySelectionRequest)) { Loading @@ -82,12 +90,14 @@ public final class StrategySelectionRequest { && mTargetDisplayState == other.getTargetDisplayState() && mLastUserSetScreenBrightness == other.getLastUserSetScreenBrightness() && mUserSetBrightnessChanged == other.isUserSetBrightnessChanged() && mDisplayOffloadSession.equals(other.getDisplayOffloadSession()); && mDisplayOffloadSession.equals(other.getDisplayOffloadSession()) && mIsStylusBeingUsed == other.isStylusBeingUsed(); } @Override public int hashCode() { return Objects.hash(mDisplayPowerRequest, mTargetDisplayState, mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession); mLastUserSetScreenBrightness, mUserSetBrightnessChanged, mDisplayOffloadSession, mIsStylusBeingUsed); } }