Establish permanently unavailable settings

Distinguish between settings which are permanently unavailable on
the device, and temporarily unavailable. This enables us to restrict
which setting slices are exposed in onSliceGetDescendants.

The primary changes in this CL are renaming:
"DISABLED_UNSUPPORTED" -> "UNSUPPORTED_ON_DEVICE"
to be more clear the the setting will cannot be accessed on the device, and,
adding a new enum to encapsulate settings which are currently unavailable, but
could be enabled in the future.

Also remove UNAVAILABLE_UNKNOWN. Devs should never need this enum.

Bug: 78910582
Fixes: 79245656
Test: robotests
Change-Id: I42c2cedab66be2d76999795f46470a079cc1ec71
Merged-In: I58821a6cfd6134b3b351657b6edf5f74ead00643
This commit is contained in:
Matthew Fritze
2018-05-03 16:46:51 -07:00
parent 9a1d318b37
commit bd376296cd
90 changed files with 155 additions and 176 deletions

View File

@@ -49,8 +49,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
* {@link #isSupported()}.
*/
@Retention(RetentionPolicy.SOURCE)
@IntDef({AVAILABLE, DISABLED_UNSUPPORTED, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
UNAVAILABLE_UNKNOWN})
@IntDef({AVAILABLE, UNSUPPORTED_ON_DEVICE, DISABLED_FOR_USER, DISABLED_DEPENDENT_SETTING,
CONDITIONALLY_UNAVAILABLE})
public @interface AvailabilityStatus {
}
@@ -60,12 +60,20 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
public static final int AVAILABLE = 0;
/**
* The setting is not supported by the device.
* A generic catch for settings which are currently unavailable, but may become available in
* the future. You should use {@link #DISABLED_FOR_USER} or {@link #DISABLED_DEPENDENT_SETTING}
* if they describe the condition more accurately.
*/
public static final int CONDITIONALLY_UNAVAILABLE = 1;
/**
* The setting is not, and will not supported by this device.
* <p>
* There is no guarantee that the setting page exists, and any links to the Setting should take
* you to the home page of Settings.
*/
public static final int DISABLED_UNSUPPORTED = 1;
public static final int UNSUPPORTED_ON_DEVICE = 2;
/**
* The setting cannot be changed by the current user.
@@ -73,7 +81,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
* Links to the Setting should take you to the page of the Setting, even if it cannot be
* changed.
*/
public static final int DISABLED_FOR_USER = 2;
public static final int DISABLED_FOR_USER = 3;
/**
* The setting has a dependency in the Settings App which is currently blocking access.
@@ -90,15 +98,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
* Links to the Setting should take you to the page of the Setting, even if it cannot be
* changed.
*/
public static final int DISABLED_DEPENDENT_SETTING = 3;
public static final int DISABLED_DEPENDENT_SETTING = 4;
/**
* A catch-all case for internal errors and inexplicable unavailability.
* <p>
* There is no guarantee that the setting page exists, and any links to the Setting should take
* you to the home page of Settings.
*/
public static final int UNAVAILABLE_UNKNOWN = 4;
protected final String mPreferenceKey;
@@ -181,8 +182,8 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
@Override
public final boolean isAvailable() {
final int availabilityStatus = getAvailabilityStatus();
return (availabilityStatus == AVAILABLE) ||
(availabilityStatus == DISABLED_DEPENDENT_SETTING);
return (availabilityStatus == AVAILABLE
|| availabilityStatus == DISABLED_DEPENDENT_SETTING);
}
/**
@@ -193,7 +194,7 @@ public abstract class BasePreferenceController extends AbstractPreferenceControl
* Note that a return value of {@code true} does not mean that the setting is available.
*/
public final boolean isSupported() {
return getAvailabilityStatus() != DISABLED_UNSUPPORTED;
return getAvailabilityStatus() != UNSUPPORTED_ON_DEVICE;
}
/**