Loading services/core/java/com/android/server/display/AutomaticBrightnessController.java +4 −8 Original line number Diff line number Diff line Loading @@ -208,7 +208,6 @@ class AutomaticBrightnessController { private PackageManager mPackageManager; private Context mContext; private DisplayDeviceConfig mDisplayDeviceConfig; private final Injector mInjector; AutomaticBrightnessController(Callbacks callbacks, Looper looper, Loading @@ -217,14 +216,13 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, HysteresisLevels screenBrightnessThresholds, Context context, DisplayDeviceConfig displayDeviceConfig) { HysteresisLevels screenBrightnessThresholds, Context context) { this(new Injector(), callbacks, looper, sensorManager, lightSensor, mapper, lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounceConfig, darkeningLightDebounceConfig, resetAmbientLuxAfterWarmUpConfig, ambientBrightnessThresholds, screenBrightnessThresholds, context, displayDeviceConfig); ambientBrightnessThresholds, screenBrightnessThresholds, context ); } @VisibleForTesting Loading @@ -234,8 +232,7 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, HysteresisLevels screenBrightnessThresholds, Context context, DisplayDeviceConfig displayDeviceConfig) { HysteresisLevels screenBrightnessThresholds, Context context) { mInjector = injector; mContext = context; mCallbacks = callbacks; Loading @@ -257,7 +254,6 @@ class AutomaticBrightnessController { mScreenBrightnessThresholds = screenBrightnessThresholds; mShortTermModelValid = true; mShortTermModelAnchor = -1; mDisplayDeviceConfig = displayDeviceConfig; mHandler = new AutomaticBrightnessHandler(looper); mAmbientLightRingBuffer = new AmbientLightRingBuffer(mNormalLightSensorRate, mAmbientLightHorizon); Loading services/core/java/com/android/server/display/DisplayBlanker.java +1 −1 Original line number Diff line number Diff line Loading @@ -20,5 +20,5 @@ package com.android.server.display; * Interface used to update the actual display state. */ public interface DisplayBlanker { void requestDisplayState(int state, float brightness); void requestDisplayState(int displayId, int state, float brightness); } services/core/java/com/android/server/display/DisplayManagerService.java +3 −5 Original line number Diff line number Diff line Loading @@ -2382,7 +2382,7 @@ public final class DisplayManagerService extends SystemService { synchronized (mSyncRoot) { DisplayBlanker blanker = new DisplayBlanker() { @Override public void requestDisplayState(int state, float brightness) { public void requestDisplayState(int displayId, int state, float brightness) { // The order of operations is important for legacy reasons. if (state == Display.STATE_OFF) { requestGlobalDisplayStateInternal(state, brightness); Loading @@ -2395,11 +2395,9 @@ public final class DisplayManagerService extends SystemService { } } }; LogicalDisplay defaultDisplay = mLogicalDisplayMapper.getLocked(Display.DEFAULT_DISPLAY); DisplayDevice defaultDevice = defaultDisplay.getPrimaryDisplayDeviceLocked(); mDisplayPowerController = new DisplayPowerController( mContext, callbacks, handler, sensorManager, blanker, defaultDevice); mContext, callbacks, handler, sensorManager, blanker, Display.DEFAULT_DISPLAY); mSensorManager = sensorManager; } Loading services/core/java/com/android/server/display/DisplayPowerController.java +11 −12 Original line number Diff line number Diff line Loading @@ -163,8 +163,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // The display blanker. private final DisplayBlanker mBlanker; // The display device. private final DisplayDevice mDisplayDevice; // The ID of the LogicalDisplay tied to this DisplayPowerController. private final int mDisplayId; // Tracker for brightness changes. private final BrightnessTracker mBrightnessTracker; Loading Loading @@ -406,7 +406,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call */ public DisplayPowerController(Context context, DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager, DisplayBlanker blanker, DisplayDevice displayDevice) { SensorManager sensorManager, DisplayBlanker blanker, int displayId) { mHandler = new DisplayControllerHandler(handler.getLooper()); mBrightnessTracker = new BrightnessTracker(context, null); mSettingsObserver = new SettingsObserver(mHandler); Loading @@ -417,10 +417,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mBlanker = blanker; mContext = context; mBrightnessSynchronizer = new BrightnessSynchronizer(context); mDisplayDevice = displayDevice; mDisplayId = displayId; PowerManager pm = context.getSystemService(PowerManager.class); DisplayDeviceConfig displayDeviceConfig = mDisplayDevice.getDisplayDeviceConfig(); final Resources resources = context.getResources(); Loading Loading @@ -515,7 +514,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp, ambientBrightnessThresholds, screenBrightnessThresholds, context, displayDeviceConfig); screenBrightnessThresholds, context); } else { mUseSoftwareAutoBrightnessConfig = false; } Loading Loading @@ -684,7 +683,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Initialize the power state object for the default display. // In the future, we might manage multiple displays independently. mPowerState = new DisplayPowerState(mBlanker, mColorFadeEnabled ? new ColorFade(Display.DEFAULT_DISPLAY) : null); mColorFadeEnabled ? new ColorFade(mDisplayId) : null, mDisplayId); if (mColorFadeEnabled) { mColorFadeOnAnimator = ObjectAnimator.ofFloat( Loading Loading @@ -1153,7 +1152,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (ready && state != Display.STATE_OFF && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_ON) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_ON); mWindowManagerPolicy.screenTurnedOn(); mWindowManagerPolicy.screenTurnedOn(mDisplayId); } // Grab a wake lock if we have unfinished business. Loading Loading @@ -1277,7 +1276,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_OFF); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); mWindowManagerPolicy.screenTurningOff(mDisplayId, mPendingScreenOffUnblocker); unblockScreenOff(); } else if (mPendingScreenOffUnblocker != null) { // Abort doing the state change until screen off is unblocked. Loading Loading @@ -1309,14 +1308,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call && !mScreenOffBecauseOfProximity) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); unblockScreenOn(); mWindowManagerPolicy.screenTurnedOff(); mWindowManagerPolicy.screenTurnedOff(mDisplayId); } else if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_OFF) { // We told policy already that screen was turning off, but now we changed our minds. // Complete the full state transition on -> turningOff -> off. unblockScreenOff(); mWindowManagerPolicy.screenTurnedOff(); mWindowManagerPolicy.screenTurnedOff(mDisplayId); setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); } if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) { Loading @@ -1326,7 +1325,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } else { unblockScreenOn(); } mWindowManagerPolicy.screenTurningOn(mPendingScreenOnUnblocker); mWindowManagerPolicy.screenTurningOn(mDisplayId, mPendingScreenOnUnblocker); } // Return true if the screen isn't blocked. Loading services/core/java/com/android/server/display/DisplayPowerState.java +5 −3 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ final class DisplayPowerState { private final DisplayBlanker mBlanker; private final ColorFade mColorFade; private final PhotonicModulator mPhotonicModulator; private final int mDisplayId; private int mScreenState; private float mScreenBrightness; Loading @@ -71,13 +72,14 @@ final class DisplayPowerState { private Runnable mCleanListener; public DisplayPowerState(DisplayBlanker blanker, ColorFade colorFade) { public DisplayPowerState(DisplayBlanker blanker, ColorFade colorFade, int displayId) { mHandler = new Handler(true /*async*/); mChoreographer = Choreographer.getInstance(); mBlanker = blanker; mColorFade = colorFade; mPhotonicModulator = new PhotonicModulator(); mPhotonicModulator.start(); mDisplayId = displayId; // At boot time, we know that the screen is on and the electron beam // animation is not playing. We don't know the screen's brightness though, Loading Loading @@ -434,10 +436,10 @@ final class DisplayPowerState { // Apply pending change. if (DEBUG) { Slog.d(TAG, "Updating screen state: state=" Slog.d(TAG, "Updating screen state: id=" + mDisplayId + ", state=" + Display.stateToString(state) + ", backlight=" + brightnessState); } mBlanker.requestDisplayState(state, brightnessState); mBlanker.requestDisplayState(mDisplayId, state, brightnessState); } } } Loading Loading
services/core/java/com/android/server/display/AutomaticBrightnessController.java +4 −8 Original line number Diff line number Diff line Loading @@ -208,7 +208,6 @@ class AutomaticBrightnessController { private PackageManager mPackageManager; private Context mContext; private DisplayDeviceConfig mDisplayDeviceConfig; private final Injector mInjector; AutomaticBrightnessController(Callbacks callbacks, Looper looper, Loading @@ -217,14 +216,13 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, HysteresisLevels screenBrightnessThresholds, Context context, DisplayDeviceConfig displayDeviceConfig) { HysteresisLevels screenBrightnessThresholds, Context context) { this(new Injector(), callbacks, looper, sensorManager, lightSensor, mapper, lightSensorWarmUpTime, brightnessMin, brightnessMax, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounceConfig, darkeningLightDebounceConfig, resetAmbientLuxAfterWarmUpConfig, ambientBrightnessThresholds, screenBrightnessThresholds, context, displayDeviceConfig); ambientBrightnessThresholds, screenBrightnessThresholds, context ); } @VisibleForTesting Loading @@ -234,8 +232,7 @@ class AutomaticBrightnessController { float dozeScaleFactor, int lightSensorRate, int initialLightSensorRate, long brighteningLightDebounceConfig, long darkeningLightDebounceConfig, boolean resetAmbientLuxAfterWarmUpConfig, HysteresisLevels ambientBrightnessThresholds, HysteresisLevels screenBrightnessThresholds, Context context, DisplayDeviceConfig displayDeviceConfig) { HysteresisLevels screenBrightnessThresholds, Context context) { mInjector = injector; mContext = context; mCallbacks = callbacks; Loading @@ -257,7 +254,6 @@ class AutomaticBrightnessController { mScreenBrightnessThresholds = screenBrightnessThresholds; mShortTermModelValid = true; mShortTermModelAnchor = -1; mDisplayDeviceConfig = displayDeviceConfig; mHandler = new AutomaticBrightnessHandler(looper); mAmbientLightRingBuffer = new AmbientLightRingBuffer(mNormalLightSensorRate, mAmbientLightHorizon); Loading
services/core/java/com/android/server/display/DisplayBlanker.java +1 −1 Original line number Diff line number Diff line Loading @@ -20,5 +20,5 @@ package com.android.server.display; * Interface used to update the actual display state. */ public interface DisplayBlanker { void requestDisplayState(int state, float brightness); void requestDisplayState(int displayId, int state, float brightness); }
services/core/java/com/android/server/display/DisplayManagerService.java +3 −5 Original line number Diff line number Diff line Loading @@ -2382,7 +2382,7 @@ public final class DisplayManagerService extends SystemService { synchronized (mSyncRoot) { DisplayBlanker blanker = new DisplayBlanker() { @Override public void requestDisplayState(int state, float brightness) { public void requestDisplayState(int displayId, int state, float brightness) { // The order of operations is important for legacy reasons. if (state == Display.STATE_OFF) { requestGlobalDisplayStateInternal(state, brightness); Loading @@ -2395,11 +2395,9 @@ public final class DisplayManagerService extends SystemService { } } }; LogicalDisplay defaultDisplay = mLogicalDisplayMapper.getLocked(Display.DEFAULT_DISPLAY); DisplayDevice defaultDevice = defaultDisplay.getPrimaryDisplayDeviceLocked(); mDisplayPowerController = new DisplayPowerController( mContext, callbacks, handler, sensorManager, blanker, defaultDevice); mContext, callbacks, handler, sensorManager, blanker, Display.DEFAULT_DISPLAY); mSensorManager = sensorManager; } Loading
services/core/java/com/android/server/display/DisplayPowerController.java +11 −12 Original line number Diff line number Diff line Loading @@ -163,8 +163,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // The display blanker. private final DisplayBlanker mBlanker; // The display device. private final DisplayDevice mDisplayDevice; // The ID of the LogicalDisplay tied to this DisplayPowerController. private final int mDisplayId; // Tracker for brightness changes. private final BrightnessTracker mBrightnessTracker; Loading Loading @@ -406,7 +406,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call */ public DisplayPowerController(Context context, DisplayPowerCallbacks callbacks, Handler handler, SensorManager sensorManager, DisplayBlanker blanker, DisplayDevice displayDevice) { SensorManager sensorManager, DisplayBlanker blanker, int displayId) { mHandler = new DisplayControllerHandler(handler.getLooper()); mBrightnessTracker = new BrightnessTracker(context, null); mSettingsObserver = new SettingsObserver(mHandler); Loading @@ -417,10 +417,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mBlanker = blanker; mContext = context; mBrightnessSynchronizer = new BrightnessSynchronizer(context); mDisplayDevice = displayDevice; mDisplayId = displayId; PowerManager pm = context.getSystemService(PowerManager.class); DisplayDeviceConfig displayDeviceConfig = mDisplayDevice.getDisplayDeviceConfig(); final Resources resources = context.getResources(); Loading Loading @@ -515,7 +514,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call mScreenBrightnessRangeMaximum, dozeScaleFactor, lightSensorRate, initialLightSensorRate, brighteningLightDebounce, darkeningLightDebounce, autoBrightnessResetAmbientLuxAfterWarmUp, ambientBrightnessThresholds, screenBrightnessThresholds, context, displayDeviceConfig); screenBrightnessThresholds, context); } else { mUseSoftwareAutoBrightnessConfig = false; } Loading Loading @@ -684,7 +683,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call // Initialize the power state object for the default display. // In the future, we might manage multiple displays independently. mPowerState = new DisplayPowerState(mBlanker, mColorFadeEnabled ? new ColorFade(Display.DEFAULT_DISPLAY) : null); mColorFadeEnabled ? new ColorFade(mDisplayId) : null, mDisplayId); if (mColorFadeEnabled) { mColorFadeOnAnimator = ObjectAnimator.ofFloat( Loading Loading @@ -1153,7 +1152,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (ready && state != Display.STATE_OFF && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_ON) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_ON); mWindowManagerPolicy.screenTurnedOn(); mWindowManagerPolicy.screenTurnedOn(mDisplayId); } // Grab a wake lock if we have unfinished business. Loading Loading @@ -1277,7 +1276,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call if (mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_ON) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_TURNING_OFF); blockScreenOff(); mWindowManagerPolicy.screenTurningOff(mPendingScreenOffUnblocker); mWindowManagerPolicy.screenTurningOff(mDisplayId, mPendingScreenOffUnblocker); unblockScreenOff(); } else if (mPendingScreenOffUnblocker != null) { // Abort doing the state change until screen off is unblocked. Loading Loading @@ -1309,14 +1308,14 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call && !mScreenOffBecauseOfProximity) { setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); unblockScreenOn(); mWindowManagerPolicy.screenTurnedOff(); mWindowManagerPolicy.screenTurnedOff(mDisplayId); } else if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_TURNING_OFF) { // We told policy already that screen was turning off, but now we changed our minds. // Complete the full state transition on -> turningOff -> off. unblockScreenOff(); mWindowManagerPolicy.screenTurnedOff(); mWindowManagerPolicy.screenTurnedOff(mDisplayId); setReportedScreenState(REPORTED_TO_POLICY_SCREEN_OFF); } if (!isOff && mReportedScreenStateToPolicy == REPORTED_TO_POLICY_SCREEN_OFF) { Loading @@ -1326,7 +1325,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call } else { unblockScreenOn(); } mWindowManagerPolicy.screenTurningOn(mPendingScreenOnUnblocker); mWindowManagerPolicy.screenTurningOn(mDisplayId, mPendingScreenOnUnblocker); } // Return true if the screen isn't blocked. Loading
services/core/java/com/android/server/display/DisplayPowerState.java +5 −3 Original line number Diff line number Diff line Loading @@ -58,6 +58,7 @@ final class DisplayPowerState { private final DisplayBlanker mBlanker; private final ColorFade mColorFade; private final PhotonicModulator mPhotonicModulator; private final int mDisplayId; private int mScreenState; private float mScreenBrightness; Loading @@ -71,13 +72,14 @@ final class DisplayPowerState { private Runnable mCleanListener; public DisplayPowerState(DisplayBlanker blanker, ColorFade colorFade) { public DisplayPowerState(DisplayBlanker blanker, ColorFade colorFade, int displayId) { mHandler = new Handler(true /*async*/); mChoreographer = Choreographer.getInstance(); mBlanker = blanker; mColorFade = colorFade; mPhotonicModulator = new PhotonicModulator(); mPhotonicModulator.start(); mDisplayId = displayId; // At boot time, we know that the screen is on and the electron beam // animation is not playing. We don't know the screen's brightness though, Loading Loading @@ -434,10 +436,10 @@ final class DisplayPowerState { // Apply pending change. if (DEBUG) { Slog.d(TAG, "Updating screen state: state=" Slog.d(TAG, "Updating screen state: id=" + mDisplayId + ", state=" + Display.stateToString(state) + ", backlight=" + brightnessState); } mBlanker.requestDisplayState(state, brightnessState); mBlanker.requestDisplayState(mDisplayId, state, brightnessState); } } } Loading