aconfig: throw exception if reading from DeviceConfig fails

Reading value from DeviceConfig may fail if the provider is not ready.
Since DeciceConfig, and Settings class are static wrapper on top of
the provider, it won't cause the instance  initialization issue.
Thus when the issue happens it means the provider is not initialized.

Test: atest aconfig.test.java and manually make a change in the
framework and check the exception message
Bug: 299471646

Change-Id: Ic08d7a9cd32a8810a7274b6d93c249abccb50b9e
This commit is contained in:
Zhi Dou
2023-09-13 19:55:50 +00:00
parent 708dc5bf81
commit 73a34ce10a
3 changed files with 55 additions and 11 deletions

View File

@@ -12,7 +12,7 @@ public class FakeFeatureFlagsImpl implements FeatureFlags \{
{{ for item in class_elements}}
@Override
public boolean {item.method_name}() \{
return getFlag(Flags.FLAG_{item.flag_name_constant_suffix});
return getValue(Flags.FLAG_{item.flag_name_constant_suffix});
}
{{ endfor}}
public void setFlag(String flagName, boolean value) \{
@@ -28,7 +28,7 @@ public class FakeFeatureFlagsImpl implements FeatureFlags \{
}
}
private boolean getFlag(String flagName) \{
private boolean getValue(String flagName) \{
Boolean value = this.mFlagMap.get(flagName);
if (value == null) \{
throw new IllegalArgumentException(flagName + " is not set");