Support key without default value for carrier config subset retrieval APIs
This CL implements carrier config subset retrieval APIs that was just
introduced to support config keys without default values.
For historical reasons, some AOSP public or OEMs/carriers private
carrier config keys didn't provide default values. When retrieving
configs with such key, the current implementation return empty
bundle which may break those user cases.
The right behavior is that keys without default values will be filtered
out, but other valid keys/values will be kept as is in the returned
bundle.
Bug: 244087782
Test: atest CarrirConfigManagerTest
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:b49e90f219d701d3bfb3a35b4d74669e2c3b64b5)
Merged-In: I62ee536357f78caa8e95df2e4bf4a34f6bb845e5
Change-Id: Ie89a11b66a6b5aaa41332475eafe7250e25e1650
diff --git a/src/com/android/phone/CarrierConfigLoader.java b/src/com/android/phone/CarrierConfigLoader.java
index 8409ff8..051d676 100644
--- a/src/com/android/phone/CarrierConfigLoader.java
+++ b/src/com/android/phone/CarrierConfigLoader.java
@@ -1362,17 +1362,18 @@
}
for (String key : keys) {
Objects.requireNonNull(key, "Config key must be non-null");
- // TODO(b/261776046): validate provided key which may has no default value.
- // For now, return empty bundle if any required key is not supported
- if (!allConfigs.containsKey(key)) {
- return new PersistableBundle();
- }
}
PersistableBundle configSubset = new PersistableBundle(
keys.length + CONFIG_SUBSET_METADATA_KEYS.length);
for (String carrierConfigKey : keys) {
Object value = allConfigs.get(carrierConfigKey);
+ if (value == null) {
+ // Filter out keys without values.
+ // In history, many AOSP or OEMs/carriers private configs didn't provide default
+ // values. We have to continue supporting them for now. See b/261776046 for details.
+ continue;
+ }
// Config value itself could be PersistableBundle which requires different API to put
if (value instanceof PersistableBundle) {
configSubset.putPersistableBundle(carrierConfigKey, (PersistableBundle) value);