Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8e57f861 authored by Chandru S's avatar Chandru S
Browse files

Add isPresent check before invoking optional.get()

Test: NA
Bug: 376799898
Flag: EXEMPT bugfix
Change-Id: Iccbbadc38f5f8134a2d0b6b67674c708f755d301
parent f41f24f5
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -469,9 +469,8 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
                    || posture >= mLightSensorOptional.length) {
                return;
            }

            final Sensor oldSensor = mLightSensorOptional[mDevicePosture].get();
            final Sensor newSensor = mLightSensorOptional[posture].get();
            Sensor oldSensor = mLightSensorOptional[mDevicePosture].orElse(null);
            Sensor newSensor = mLightSensorOptional[posture].orElse(null);
            if (Objects.equals(oldSensor, newSensor)) {
                mDevicePosture = posture;
                // uses the same sensor for the new posture