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

Commit afaee2c4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix NPE when querying AmbientDisply through ExternalSeting"

parents ed31d718 d7d1e806
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;
    }
}