Stop the screen off brightness sensor controller
Bug: 264343121 Test: atest ScreenOffBrightnessSensorControllerTest Change-Id: Ib51e1812acdd503f348b2034514c97d5acbe7e4e
This commit is contained in:
@@ -860,6 +860,10 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mAutomaticBrightnessController.stop();
|
||||
}
|
||||
|
||||
if (mScreenOffBrightnessSensorController != null) {
|
||||
mScreenOffBrightnessSensorController.stop();
|
||||
}
|
||||
|
||||
if (mBrightnessSetting != null) {
|
||||
mBrightnessSetting.unregisterListener(mBrightnessSettingListener);
|
||||
}
|
||||
@@ -1104,6 +1108,9 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
|
||||
mBrightnessEventRingBuffer =
|
||||
new RingBuffer<>(BrightnessEvent.class, RINGBUFFER_MAX);
|
||||
|
||||
if (mScreenOffBrightnessSensorController != null) {
|
||||
mScreenOffBrightnessSensorController.stop();
|
||||
}
|
||||
loadScreenOffBrightnessSensor();
|
||||
int[] sensorValueToLux = mDisplayDeviceConfig.getScreenOffBrightnessSensorValueToLux();
|
||||
if (mScreenOffBrightnessSensor != null && sensorValueToLux != null) {
|
||||
|
||||
@@ -92,6 +92,10 @@ public class ScreenOffBrightnessSensorController implements SensorEventListener
|
||||
}
|
||||
}
|
||||
|
||||
void stop() {
|
||||
setLightSensorEnabled(false);
|
||||
}
|
||||
|
||||
float getAutomaticScreenBrightness() {
|
||||
if (mLastSensorValue < 0 || mLastSensorValue >= mSensorValueToLux.length
|
||||
|| (!mRegistered
|
||||
|
||||
@@ -35,6 +35,7 @@ import androidx.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.android.server.testutils.OffsettableClock;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@@ -73,6 +74,15 @@ public class ScreenOffBrightnessSensorControllerTest {
|
||||
);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (mController != null) {
|
||||
// Stop the update Brightness loop.
|
||||
mController.stop();
|
||||
mController = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrightness() throws Exception {
|
||||
when(mSensorManager.registerListener(any(SensorEventListener.class), eq(mLightSensor),
|
||||
|
||||
Reference in New Issue
Block a user