Simplify InlineSwitchPayloads and generalize get/set method

InlineSwitchPayload now assumes that all switches will be
stored as 1 or 0, which simplifies the code.

Moves Availability into ResultPayload, so that custom
payloads can be created to set/get values which are more
complicated than stotring ints (like bluetooth or DnD),
and give more expressive reasons when unavailable.

Bug: 62022517
Test: make RunSettingsRoboTests
Change-Id: I87e6fc041bfd398e7daf6e6e479d502930d36f0f
This commit is contained in:
Matthew Fritze
2017-05-23 09:42:33 -07:00
parent 63b013ea60
commit 2b1a88da3d
13 changed files with 378 additions and 190 deletions

View File

@@ -57,6 +57,37 @@ public class ResultPayload implements Parcelable {
int SAVED_QUERY = 3;
}
/**
* Enumerates the possible values for the Availability of a setting.
*/
@IntDef({Availability.AVAILABLE,
Availability.DISABLED_DEPENDENCY,
Availability.DISABLED_UNSUPPORTED,
Availability.RESOURCE_CONTENTION})
@Retention(RetentionPolicy.SOURCE)
public @interface Availability {
/**
* The setting is available.
*/
int AVAILABLE = 0;
/**
* The setting has a dependency which is currently disabled, blocking access.
*/
int DISABLED_DEPENDENCY = 1;
/**
* The setting is not supported by the device.
*/
int DISABLED_UNSUPPORTED = 2;
/**
* The setting you are trying to change is being used by another application and cannot
* be changed until it is released by said application.
*/
int RESOURCE_CONTENTION = 3;
}
@IntDef({SettingsSource.UNKNOWN, SettingsSource.SYSTEM, SettingsSource.SECURE,
SettingsSource.GLOBAL})
@Retention(RetentionPolicy.SOURCE)