Fix NPE when querying AmbientDisply through ExternalSeting
Bug: 110403709 Test: manual Change-Id: I5c037b010e296cbd011f8c141932e6befd341c99
This commit is contained in:
@@ -68,7 +68,7 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mConfig.pulseOnNotificationEnabled(MY_USER);
|
return getAmbientConfig().pulseOnNotificationEnabled(MY_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -79,14 +79,20 @@ public class AmbientDisplayNotificationsPreferenceController extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (mConfig == null) {
|
return getAmbientConfig().pulseOnNotificationAvailable()
|
||||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
|
||||||
return mConfig.pulseOnNotificationAvailable() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSliceable() {
|
public boolean isSliceable() {
|
||||||
return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
|
return TextUtils.equals(getPreferenceKey(), "ambient_display_notification");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||||
|
if (mConfig == null) {
|
||||||
|
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mConfig;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,17 +62,13 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (mAmbientConfig == null) {
|
|
||||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No hardware support for Pickup Gesture
|
// No hardware support for Pickup Gesture
|
||||||
if (!mAmbientConfig.dozePulsePickupSensorAvailable()) {
|
if (!getAmbientConfig().dozePulsePickupSensorAvailable()) {
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't change Pickup Gesture when AOD is enabled.
|
// Can't change Pickup Gesture when AOD is enabled.
|
||||||
if (!mAmbientConfig.ambientDisplayAvailable()) {
|
if (!getAmbientConfig().ambientDisplayAvailable()) {
|
||||||
return DISABLED_DEPENDENT_SETTING;
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +87,7 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mAmbientConfig.pulseOnPickupEnabled(mUserId);
|
return getAmbientConfig().pulseOnPickupEnabled(mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -112,6 +108,14 @@ public class PickupGesturePreferenceController extends GesturePreferenceControll
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
boolean pulseOnPickupCanBeModified() {
|
boolean pulseOnPickupCanBeModified() {
|
||||||
return mAmbientConfig.pulseOnPickupCanBeModified(mUserId);
|
return getAmbientConfig().pulseOnPickupCanBeModified(mUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||||
|
if (mAmbientConfig == null) {
|
||||||
|
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mAmbientConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user