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

Commit d7d1e806 authored by Fan Zhang's avatar Fan Zhang
Browse files

Fix NPE when querying AmbientDisply through ExternalSeting

Bug: 110403709
Test: manual
Change-Id: I5c037b010e296cbd011f8c141932e6befd341c99
parent 416a1185
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ public class AmbientDisplayNotificationsPreferenceController extends

    @Override
    public boolean isChecked() {
        return mConfig.pulseOnNotificationEnabled(MY_USER);
        return getAmbientConfig().pulseOnNotificationEnabled(MY_USER);
    }

    @Override
@@ -79,14 +79,20 @@ public class AmbientDisplayNotificationsPreferenceController extends

    @Override
    public int getAvailabilityStatus() {
        if (mConfig == null) {
            mConfig = new AmbientDisplayConfiguration(mContext);
        }
        return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
        return getAmbientConfig().pulseOnNotificationAvailable()
                ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
    }

    @Override
    public boolean isSliceable() {
        return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
    }

    private AmbientDisplayConfiguration getAmbientConfig() {
        if (mConfig == null) {
            mConfig = new AmbientDisplayConfiguration(mContext);
        }

        return mConfig;
    }
}
+12 −8
Original line number Diff line number Diff line
@@ -62,17 +62,13 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll

    @Override
    public int getAvailabilityStatus() {
        if (mAmbientConfig == null) {
            mAmbientConfig = new AmbientDisplayConfiguration(mContext);
        }

        // No hardware support for Pickup Gesture
        if (!mAmbientConfig.dozePulsePickupSensorAvailable()) {
        if (!getAmbientConfig().dozePulsePickupSensorAvailable()) {
            return UNSUPPORTED_ON_DEVICE;
        }

        // Can't change Pickup Gesture when AOD is enabled.
        if (!mAmbientConfig.ambientDisplayAvailable()) {
        if (!getAmbientConfig().ambientDisplayAvailable()) {
            return DISABLED_DEPENDENT_SETTING;
        }

@@ -91,7 +87,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll

    @Override
    public boolean isChecked() {
        return mAmbientConfig.pulseOnPickupEnabled(mUserId);
        return getAmbientConfig().pulseOnPickupEnabled(mUserId);
    }

    @Override
@@ -112,6 +108,14 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll

    @VisibleForTesting
    boolean pulseOnPickupCanBeModified() {
        return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
        return getAmbientConfig().pulseOnPickupCanBeModified(mUserId);
    }

    private AmbientDisplayConfiguration getAmbientConfig() {
        if (mAmbientConfig == null) {
            mAmbientConfig = new AmbientDisplayConfiguration(mContext);
        }

        return mAmbientConfig;
    }
}