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:
commit
e911b7cf7c
4 changed files with 29 additions and 20 deletions
|
@ -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) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package {package_name};
|
||||
|
||||
public interface FeatureFlags \{
|
||||
{{ for item in class_elements}}
|
||||
{{ for item in class_elements}}
|
||||
boolean {item.method_name}();
|
||||
{{ endfor }}
|
||||
{{ endfor }}
|
||||
}
|
|
@ -2,15 +2,16 @@ 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;
|
||||
{{ -endif- }}
|
||||
{{ endif }}
|
||||
public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||
{{ for item in class_elements}}
|
||||
{{ for item in class_elements}}
|
||||
@Override
|
||||
public boolean {item.method_name}() \{
|
||||
{{ -if not is_test_mode- }}
|
||||
|
@ -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) \{
|
||||
|
@ -55,7 +61,5 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
|||
(map, elem) -> map.put(elem, null),
|
||||
HashMap::putAll
|
||||
);
|
||||
{{ -endif }}
|
||||
{{ -endif }}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package {package_name};
|
||||
|
||||
public final class Flags \{
|
||||
{{- for item in class_elements}}
|
||||
{{- for item in class_elements}}
|
||||
public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";
|
||||
{{- endfor }}
|
||||
{{ for item in class_elements}}
|
||||
{{- endfor }}
|
||||
{{ for item in class_elements}}
|
||||
public static boolean {item.method_name}() \{
|
||||
return FEATURE_FLAGS.{item.method_name}();
|
||||
}
|
||||
{{ endfor }}
|
||||
{{ if is_test_mode }}
|
||||
{{ endfor }}
|
||||
{{ -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- }};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue