diff options
author | Fan Zhang <zhfan@google.com> | 2018-07-09 16:45:22 -0700 |
---|---|---|
committer | Fan Zhang <zhfan@google.com> | 2018-07-09 17:35:35 -0700 |
commit | d7d1e8063aa692e09850a4b79f4903048b3380cc (patch) | |
tree | 8c55bdfb398c7657d117f6968d912f6835b961a0 | |
parent | 416a11855ecc7ed4c04b5fd555b9c9c669d09289 (diff) | |
download | packages_apps_Settings-d7d1e8063aa692e09850a4b79f4903048b3380cc.tar.gz packages_apps_Settings-d7d1e8063aa692e09850a4b79f4903048b3380cc.tar.bz2 packages_apps_Settings-d7d1e8063aa692e09850a4b79f4903048b3380cc.zip |
Fix NPE when querying AmbientDisply through ExternalSeting
Bug: 110403709
Test: manual
Change-Id: I5c037b010e296cbd011f8c141932e6befd341c99
-rw-r--r-- | src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java | 16 | ||||
-rw-r--r-- | src/com/android/settings/gestures/PickupGesturePreferenceController.java | 20 |
2 files changed, 23 insertions, 13 deletions
diff --git a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java index cae5671510..b3c182252f 100644 --- a/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java +++ b/src/com/android/settings/display/AmbientDisplayNotificationsPreferenceController.java @@ -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; + } } diff --git a/src/com/android/settings/gestures/PickupGesturePreferenceController.java b/src/com/android/settings/gestures/PickupGesturePreferenceController.java index 430361c170..53a4447cbe 100644 --- a/src/com/android/settings/gestures/PickupGesturePreferenceController.java +++ b/src/com/android/settings/gestures/PickupGesturePreferenceController.java @@ -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; } } |