Merge changes I4bf1d3ba,I33605054 am: 7734879e69
am: e911b7cf7c
am: 45842104d2
Original change: https://android-review.googlesource.com/c/platform/build/+/2643057 Change-Id: I2eb9f781050cb95871928e308ef35ea3967ead6d Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -233,8 +233,9 @@ mod tests {
|
|||||||
let expected_featureflagsimpl_content = r#"
|
let expected_featureflagsimpl_content = r#"
|
||||||
package com.android.aconfig.test;
|
package com.android.aconfig.test;
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
public final class FeatureFlagsImpl implements FeatureFlags {
|
public final class FeatureFlagsImpl implements FeatureFlags {
|
||||||
@Override
|
@Override
|
||||||
public boolean disabledRo() {
|
public boolean disabledRo() {
|
||||||
@@ -258,6 +259,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
this.mFlagMap.put(flagName, value);
|
this.mFlagMap.put(flagName, value);
|
||||||
}
|
}
|
||||||
|
public void resetAll() {
|
||||||
|
for (Map.Entry entry : mFlagMap.entrySet()) {
|
||||||
|
entry.setValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
private boolean getFlag(String flagName) {
|
private boolean getFlag(String flagName) {
|
||||||
Boolean value = this.mFlagMap.get(flagName);
|
Boolean value = this.mFlagMap.get(flagName);
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package {package_name};
|
package {package_name};
|
||||||
|
|
||||||
public interface FeatureFlags \{
|
public interface FeatureFlags \{
|
||||||
{{ for item in class_elements}}
|
{{ for item in class_elements}}
|
||||||
boolean {item.method_name}();
|
boolean {item.method_name}();
|
||||||
{{ endfor }}
|
{{ endfor }}
|
||||||
}
|
}
|
@@ -2,15 +2,16 @@ package {package_name};
|
|||||||
{{ -if is_test_mode }}
|
{{ -if is_test_mode }}
|
||||||
import static java.util.stream.Collectors.toMap;
|
import static java.util.stream.Collectors.toMap;
|
||||||
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
{{ else}}
|
{{ else}}
|
||||||
{{ if is_read_write- }}
|
{{ if is_read_write- }}
|
||||||
import android.provider.DeviceConfig;
|
import android.provider.DeviceConfig;
|
||||||
{{ -endif- }}
|
{{ -endif- }}
|
||||||
{{ endif }}
|
{{ endif }}
|
||||||
public final class FeatureFlagsImpl implements FeatureFlags \{
|
public final class FeatureFlagsImpl implements FeatureFlags \{
|
||||||
{{ for item in class_elements}}
|
{{ for item in class_elements}}
|
||||||
@Override
|
@Override
|
||||||
public boolean {item.method_name}() \{
|
public boolean {item.method_name}() \{
|
||||||
{{ -if not is_test_mode- }}
|
{{ -if not is_test_mode- }}
|
||||||
@@ -20,16 +21,15 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
|||||||
"{item.device_config_flag}",
|
"{item.device_config_flag}",
|
||||||
{item.default_value}
|
{item.default_value}
|
||||||
);
|
);
|
||||||
{{ else }}
|
{{ -else }}
|
||||||
return {item.default_value};
|
return {item.default_value};
|
||||||
{{ -endif- }}
|
{{ -endif- }}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
return getFlag(Flags.FLAG_{item.flag_name_constant_suffix});
|
return getFlag(Flags.FLAG_{item.flag_name_constant_suffix});
|
||||||
{{ -endif }}
|
{{ -endif }}
|
||||||
}
|
}
|
||||||
{{ endfor }}
|
{{ endfor- }}
|
||||||
|
{{ if is_test_mode }}
|
||||||
{{ if is_test_mode- }}
|
|
||||||
public void setFlag(String flagName, boolean value) \{
|
public void setFlag(String flagName, boolean value) \{
|
||||||
if (!this.mFlagMap.containsKey(flagName)) \{
|
if (!this.mFlagMap.containsKey(flagName)) \{
|
||||||
throw new IllegalArgumentException("no such flag" + flagName);
|
throw new IllegalArgumentException("no such flag" + flagName);
|
||||||
@@ -37,6 +37,12 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
|||||||
this.mFlagMap.put(flagName, value);
|
this.mFlagMap.put(flagName, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetAll() \{
|
||||||
|
for (Map.Entry entry : mFlagMap.entrySet()) \{
|
||||||
|
entry.setValue(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean getFlag(String flagName) \{
|
private boolean getFlag(String flagName) \{
|
||||||
Boolean value = this.mFlagMap.get(flagName);
|
Boolean value = this.mFlagMap.get(flagName);
|
||||||
if (value == null) \{
|
if (value == null) \{
|
||||||
@@ -55,7 +61,5 @@ public final class FeatureFlagsImpl implements FeatureFlags \{
|
|||||||
(map, elem) -> map.put(elem, null),
|
(map, elem) -> map.put(elem, null),
|
||||||
HashMap::putAll
|
HashMap::putAll
|
||||||
);
|
);
|
||||||
{{ -endif }}
|
{{ -endif }}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,15 +1,15 @@
|
|||||||
package {package_name};
|
package {package_name};
|
||||||
|
|
||||||
public final class Flags \{
|
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}";
|
public static final String FLAG_{item.flag_name_constant_suffix} = "{item.device_config_flag}";
|
||||||
{{- endfor }}
|
{{- endfor }}
|
||||||
{{ for item in class_elements}}
|
{{ for item in class_elements}}
|
||||||
public static boolean {item.method_name}() \{
|
public static boolean {item.method_name}() \{
|
||||||
return FEATURE_FLAGS.{item.method_name}();
|
return FEATURE_FLAGS.{item.method_name}();
|
||||||
}
|
}
|
||||||
{{ endfor }}
|
{{ endfor }}
|
||||||
{{ if is_test_mode }}
|
{{ -if is_test_mode }}
|
||||||
public static void setFeatureFlagsImpl(FeatureFlags featureFlags) \{
|
public static void setFeatureFlagsImpl(FeatureFlags featureFlags) \{
|
||||||
Flags.FEATURE_FLAGS = featureFlags;
|
Flags.FEATURE_FLAGS = featureFlags;
|
||||||
}
|
}
|
||||||
@@ -17,8 +17,7 @@ public final class Flags \{
|
|||||||
public static void unsetFeatureFlagsImpl() \{
|
public static void unsetFeatureFlagsImpl() \{
|
||||||
Flags.FEATURE_FLAGS = null;
|
Flags.FEATURE_FLAGS = null;
|
||||||
}
|
}
|
||||||
{{ -endif}}
|
{{ endif}}
|
||||||
|
|
||||||
private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }};
|
private static FeatureFlags FEATURE_FLAGS{{ -if not is_test_mode }} = new FeatureFlagsImpl(){{ -endif- }};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user