Merge "Fix NPE when querying AmbientDisply through ExternalSeting"
This commit is contained in:
committed by
Android (Google) Code Review
commit
0da46d618e
@@ -43,10 +43,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (mConfig == null) {
|
return isAvailable(getConfig()) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
||||||
mConfig = new AmbientDisplayConfiguration(mContext);
|
|
||||||
}
|
|
||||||
return isAvailable(mConfig) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -56,7 +53,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mConfig.alwaysOnEnabled(MY_USER);
|
return getConfig().alwaysOnEnabled(MY_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -82,15 +79,14 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isAlwaysOnEnabled(AmbientDisplayConfiguration config) {
|
|
||||||
return config.alwaysOnEnabled(MY_USER);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isAvailable(AmbientDisplayConfiguration config) {
|
public static boolean isAvailable(AmbientDisplayConfiguration config) {
|
||||||
return config.alwaysOnAvailableForUser(MY_USER);
|
return config.alwaysOnAvailableForUser(MY_USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean accessibilityInversionEnabled(AmbientDisplayConfiguration config) {
|
private AmbientDisplayConfiguration getConfig() {
|
||||||
return config.accessibilityInversionEnabled(MY_USER);
|
if (mConfig == null) {
|
||||||
|
mConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
|
}
|
||||||
|
return mConfig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,7 +35,6 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
private final int OFF = 0;
|
private final int OFF = 0;
|
||||||
|
|
||||||
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
|
private static final String PREF_KEY_VIDEO = "gesture_double_tap_screen_video";
|
||||||
private final String mDoubleTapScreenPrefKey;
|
|
||||||
|
|
||||||
private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
|
private final String SECURE_KEY = DOZE_PULSE_ON_DOUBLE_TAP;
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
public DoubleTapScreenPreferenceController(Context context, String key) {
|
public DoubleTapScreenPreferenceController(Context context, String key) {
|
||||||
super(context, key);
|
super(context, key);
|
||||||
mUserId = UserHandle.myUserId();
|
mUserId = UserHandle.myUserId();
|
||||||
mDoubleTapScreenPrefKey = key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DoubleTapScreenPreferenceController setConfig(AmbientDisplayConfiguration config) {
|
public DoubleTapScreenPreferenceController setConfig(AmbientDisplayConfiguration config) {
|
||||||
@@ -67,17 +65,13 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAvailabilityStatus() {
|
public int getAvailabilityStatus() {
|
||||||
if (mAmbientConfig == null) {
|
|
||||||
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No hardware support for Double Tap
|
// No hardware support for Double Tap
|
||||||
if (!mAmbientConfig.doubleTapSensorAvailable()) {
|
if (!getAmbientConfig().doubleTapSensorAvailable()) {
|
||||||
return UNSUPPORTED_ON_DEVICE;
|
return UNSUPPORTED_ON_DEVICE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Can't change Double Tap when AOD is enabled.
|
// Can't change Double Tap when AOD is enabled.
|
||||||
if (!mAmbientConfig.ambientDisplayAvailable()) {
|
if (!getAmbientConfig().ambientDisplayAvailable()) {
|
||||||
return DISABLED_DEPENDENT_SETTING;
|
return DISABLED_DEPENDENT_SETTING;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,11 +96,18 @@ public class DoubleTapScreenPreferenceController extends GesturePreferenceContro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isChecked() {
|
public boolean isChecked() {
|
||||||
return mAmbientConfig.pulseOnDoubleTapEnabled(mUserId);
|
return getAmbientConfig().pulseOnDoubleTapEnabled(mUserId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean canHandleClicks() {
|
protected boolean canHandleClicks() {
|
||||||
return !mAmbientConfig.alwaysOnEnabled(mUserId);
|
return !getAmbientConfig().alwaysOnEnabled(mUserId);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private AmbientDisplayConfiguration getAmbientConfig() {
|
||||||
|
if (mAmbientConfig == null) {
|
||||||
|
mAmbientConfig = new AmbientDisplayConfiguration(mContext);
|
||||||
|
}
|
||||||
|
return mAmbientConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user