Mark mAutomaticBrightnessController @Nullable.
Check that AutomaticBrightnessController is not null before calling update() and resetShortTermModel().
Bug: 203737431
Test: manual: flashed build with automaticBrightnessController set to null and verified that no NPE is thrown.
Change-Id: Ie709d4bc7e6166eeb7e936bea79162f468c713f4
(cherry picked from commit 4d9cb42e21)
This commit is contained in:
@@ -378,6 +378,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
private float mInitialAutoBrightness;
|
private float mInitialAutoBrightness;
|
||||||
|
|
||||||
// The controller for the automatic brightness level.
|
// The controller for the automatic brightness level.
|
||||||
|
@Nullable
|
||||||
private AutomaticBrightnessController mAutomaticBrightnessController;
|
private AutomaticBrightnessController mAutomaticBrightnessController;
|
||||||
|
|
||||||
private Sensor mLightSensor;
|
private Sensor mLightSensor;
|
||||||
@@ -608,7 +609,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
mPendingRbcOnOrChanged = strengthChanged || justActivated;
|
mPendingRbcOnOrChanged = strengthChanged || justActivated;
|
||||||
|
|
||||||
// Reset model if strength changed OR rbc is turned off
|
// Reset model if strength changed OR rbc is turned off
|
||||||
if (strengthChanged || !justActivated && mAutomaticBrightnessController != null) {
|
if ((strengthChanged || !justActivated) && mAutomaticBrightnessController != null) {
|
||||||
mAutomaticBrightnessController.resetShortTermModel();
|
mAutomaticBrightnessController.resetShortTermModel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1567,7 +1568,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
|||||||
sendUpdatePowerStateLocked();
|
sendUpdatePowerStateLocked();
|
||||||
mHandler.post(mOnBrightnessChangeRunnable);
|
mHandler.post(mOnBrightnessChangeRunnable);
|
||||||
// TODO(b/192258832): Switch the HBMChangeCallback to a listener pattern.
|
// TODO(b/192258832): Switch the HBMChangeCallback to a listener pattern.
|
||||||
mAutomaticBrightnessController.update();
|
if (mAutomaticBrightnessController != null) {
|
||||||
|
mAutomaticBrightnessController.update();
|
||||||
|
}
|
||||||
}, mContext);
|
}, mContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user