Add methods setFlag and resetAll in FeatureFlags in test mode. For the injection usecase, user will use the interface FeatureFlags in the code to control the flags. Add tests for test mode. Bug: 280833463 Test: Atest AconfigJavaHostTest --host Change-Id: Ib59ba35a9011a6400af42fc9c283d37193577997
45 lines
1.2 KiB
Plaintext
45 lines
1.2 KiB
Plaintext
package {package_name};
|
|
{{ if not is_test_mode }}
|
|
{{ if is_read_write- }}
|
|
import android.provider.DeviceConfig;
|
|
{{ endif }}
|
|
public final class FeatureFlagsImpl implements FeatureFlags \{
|
|
{{ for item in class_elements}}
|
|
@Override
|
|
public boolean {item.method_name}() \{
|
|
{{ -if item.is_read_write }}
|
|
return DeviceConfig.getBoolean(
|
|
"{item.device_config_namespace}",
|
|
"{item.device_config_flag}",
|
|
{item.default_value}
|
|
);
|
|
{{ else }}
|
|
return {item.default_value};
|
|
{{ endif- }}
|
|
}
|
|
{{ endfor- }}
|
|
}
|
|
{{ else }}
|
|
{#- Generate only stub if in test mode #}
|
|
public final class FeatureFlagsImpl implements FeatureFlags \{
|
|
{{ for item in class_elements}}
|
|
@Override
|
|
public boolean {item.method_name}() \{
|
|
throw new UnsupportedOperationException(
|
|
"Method is not implemented.");
|
|
}
|
|
{{ endfor- }}
|
|
@Override
|
|
public void setFlag(String flagName, boolean value) \{
|
|
throw new UnsupportedOperationException(
|
|
"Method is not implemented.");
|
|
}
|
|
|
|
@Override
|
|
public void resetAll() \{
|
|
throw new UnsupportedOperationException(
|
|
"Method is not implemented.");
|
|
}
|
|
}
|
|
{{ endif }}
|