Merge changes I4bf1d3ba,I33605054 am: 7734879e69

Original change: https://android-review.googlesource.com/c/platform/build/+/2643057

Change-Id: I59851f958affe18fe8a9a90a9515f60d33b8d238
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Zhi Dou 2023-06-30 14:13:44 +00:00 committed by Automerger Merge Worker
commit e911b7cf7c
4 changed files with 29 additions and 20 deletions

View file

@ -233,8 +233,9 @@ mod tests {
let expected_featureflagsimpl_content = r#"
package com.android.aconfig.test;
import static java.util.stream.Collectors.toMap;
import java.util.stream.Stream;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
public final class FeatureFlagsImpl implements FeatureFlags {
@Override
public boolean disabledRo() {
@ -258,6 +259,11 @@ mod tests {
}
this.mFlagMap.put(flagName, value);
}
public void resetAll() {
for (Map.Entry entry : mFlagMap.entrySet()) {
entry.setValue(null);
}
}
private boolean getFlag(String flagName) {
Boolean value = this.mFlagMap.get(flagName);
if (value == null) {

View file

@ -2,8 +2,9 @@ package {package_name};
{{ -if is_test_mode }}
import static java.util.stream.Collectors.toMap;
import java.util.stream.Stream;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Stream;
{{ else}}
{{ if is_read_write- }}
import android.provider.DeviceConfig;
@ -20,16 +21,15 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
"{item.device_config_flag}",
{item.default_value}
);
{{ else }}
{{ -else }}
return {item.default_value};
{{ -endif- }}
{{ else }}
return getFlag(Flags.FLAG_{item.flag_name_constant_suffix});
{{ -endif }}
}
{{ endfor }}
{{ if is_test_mode- }}
{{ endfor- }}
{{ if is_test_mode }}
public void setFlag(String flagName, boolean value) \{
if (!this.mFlagMap.containsKey(flagName)) \{
throw new IllegalArgumentException("no such flag" + flagName);
@ -37,6 +37,12 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
this.mFlagMap.put(flagName, value);
}
public void resetAll() \{
for (Map.Entry entry : mFlagMap.entrySet()) \{
entry.setValue(null);
}
}
private boolean getFlag(String flagName) \{
Boolean value = this.mFlagMap.get(flagName);
if (value == null) \{
@ -57,5 +63,3 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
);
{{ -endif }}
}

View file

@ -9,7 +9,7 @@ public final class Flags \{
return FEATURE_FLAGS.{item.method_name}();
}
{{ endfor }}
{{ if is_test_mode }}
{{ -if is_test_mode }}
public static void setFeatureFlagsImpl(FeatureFlags featureFlags) \{
Flags.FEATURE_FLAGS = featureFlags;
}
@ -17,8 +17,7 @@ public final class Flags \{
public static void unsetFeatureFlagsImpl() \{
Flags.FEATURE_FLAGS = null;
}
{{ -endif}}
{{ endif}}
private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }};
}