Add support for "empty" server-side flag values
Add support to ServerFlags for a special escape string for empty arrays. Also adjust code to allow no entries in the "origin priorities" to help test what happens when auto time isn't supported (see the associated change in packages/apps/Settings/ Tested with: adb shell cmd dumpsys time_detector <Inspect the ConfigurationInternal> <View SettingsUI Date & Time screen> adb shell cmd device_config system_time time_detector_origin_priorities_override _[]_ adb shell cmd dumpsys time_detector <Inspect the ConfigurationInternal> <View SettingsUI Date & Time screen> Bug: 172891783 Test: See above Change-Id: I1e2573384055b2527f39b0134ace5f08019a3a40
This commit is contained in:
@@ -278,11 +278,19 @@ public final class ServerFlags {
|
||||
*/
|
||||
@NonNull
|
||||
public Optional<String[]> getOptionalStringArray(@DeviceConfigKey String key) {
|
||||
Optional<String> string = getOptionalString(key);
|
||||
if (!string.isPresent()) {
|
||||
Optional<String> optionalString = getOptionalString(key);
|
||||
if (!optionalString.isPresent()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
return Optional.of(string.get().split(","));
|
||||
|
||||
// DeviceConfig appears to have no way to specify an empty string, so we use "_[]_" as a
|
||||
// special value to mean a zero-length array.
|
||||
String value = optionalString.get();
|
||||
if ("_[]_".equals(value)) {
|
||||
return Optional.of(new String[0]);
|
||||
}
|
||||
|
||||
return Optional.of(value.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -334,7 +334,7 @@ final class ServiceConfigAccessorImpl implements ServiceConfigAccessor {
|
||||
}
|
||||
|
||||
int[] priorityInts = null;
|
||||
if (priorityStrings != null && priorityStrings.length > 0) {
|
||||
if (priorityStrings != null) {
|
||||
priorityInts = new int[priorityStrings.length];
|
||||
try {
|
||||
for (int i = 0; i < priorityInts.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user