Merge "aconfig: add isOptimizationEnabled in FakeFeatureFlagsImpl" into main am: d09505cc62
Original change: https://android-review.googlesource.com/c/platform/build/+/2925520 Change-Id: I4c960a1d63569354de27682c4fbd0a18186253a2 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
4a29d17d3e
2 changed files with 96 additions and 1 deletions
|
@ -278,8 +278,11 @@ mod tests {
|
|||
package com.android.aconfig.test;
|
||||
// TODO(b/303773055): Remove the annotation after access issue is resolved.
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/** @hide */
|
||||
public class FakeFeatureFlagsImpl implements FeatureFlags {
|
||||
public FakeFeatureFlagsImpl() {
|
||||
|
@ -341,6 +344,13 @@ mod tests {
|
|||
entry.setValue(null);
|
||||
}
|
||||
}
|
||||
public boolean isFlagReadOnlyOptimized(String flagName) {
|
||||
if (mReadOnlyFlagsSet.contains(flagName) &&
|
||||
isOptimizationEnabled()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean getValue(String flagName) {
|
||||
Boolean value = this.mFlagMap.get(flagName);
|
||||
if (value == null) {
|
||||
|
@ -348,6 +358,10 @@ mod tests {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
private boolean isOptimizationEnabled() {
|
||||
return false;
|
||||
}
|
||||
private Map<String, Boolean> mFlagMap = new HashMap<>(
|
||||
Map.ofEntries(
|
||||
Map.entry(Flags.FLAG_DISABLED_RO, false),
|
||||
|
@ -361,6 +375,16 @@ mod tests {
|
|||
Map.entry(Flags.FLAG_ENABLED_RW, false)
|
||||
)
|
||||
);
|
||||
private Set<String> mReadOnlyFlagsSet = new HashSet<>(
|
||||
Arrays.asList(
|
||||
Flags.FLAG_DISABLED_RO,
|
||||
Flags.FLAG_ENABLED_FIXED_RO,
|
||||
Flags.FLAG_ENABLED_FIXED_RO_EXPORTED,
|
||||
Flags.FLAG_ENABLED_RO,
|
||||
Flags.FLAG_ENABLED_RO_EXPORTED,
|
||||
""
|
||||
)
|
||||
);
|
||||
}
|
||||
"#;
|
||||
|
||||
|
@ -644,8 +668,11 @@ mod tests {
|
|||
package com.android.aconfig.test;
|
||||
// TODO(b/303773055): Remove the annotation after access issue is resolved.
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/** @hide */
|
||||
public class FakeFeatureFlagsImpl implements FeatureFlags {
|
||||
public FakeFeatureFlagsImpl() {
|
||||
|
@ -677,6 +704,13 @@ mod tests {
|
|||
entry.setValue(null);
|
||||
}
|
||||
}
|
||||
public boolean isFlagReadOnlyOptimized(String flagName) {
|
||||
if (mReadOnlyFlagsSet.contains(flagName) &&
|
||||
isOptimizationEnabled()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean getValue(String flagName) {
|
||||
Boolean value = this.mFlagMap.get(flagName);
|
||||
if (value == null) {
|
||||
|
@ -684,6 +718,10 @@ mod tests {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
private boolean isOptimizationEnabled() {
|
||||
return false;
|
||||
}
|
||||
private Map<String, Boolean> mFlagMap = new HashMap<>(
|
||||
Map.ofEntries(
|
||||
Map.entry(Flags.FLAG_DISABLED_RW_EXPORTED, false),
|
||||
|
@ -691,6 +729,11 @@ mod tests {
|
|||
Map.entry(Flags.FLAG_ENABLED_RO_EXPORTED, false)
|
||||
)
|
||||
);
|
||||
private Set<String> mReadOnlyFlagsSet = new HashSet<>(
|
||||
Arrays.asList(
|
||||
""
|
||||
)
|
||||
);
|
||||
}
|
||||
"#;
|
||||
|
||||
|
@ -964,8 +1007,11 @@ mod tests {
|
|||
package com.android.aconfig.test;
|
||||
// TODO(b/303773055): Remove the annotation after access issue is resolved.
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
/** @hide */
|
||||
public class FakeFeatureFlagsImpl implements FeatureFlags {
|
||||
public FakeFeatureFlagsImpl() {
|
||||
|
@ -1012,6 +1058,13 @@ mod tests {
|
|||
entry.setValue(null);
|
||||
}
|
||||
}
|
||||
public boolean isFlagReadOnlyOptimized(String flagName) {
|
||||
if (mReadOnlyFlagsSet.contains(flagName) &&
|
||||
isOptimizationEnabled()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private boolean getValue(String flagName) {
|
||||
Boolean value = this.mFlagMap.get(flagName);
|
||||
if (value == null) {
|
||||
|
@ -1019,6 +1072,10 @@ mod tests {
|
|||
}
|
||||
return value;
|
||||
}
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
private boolean isOptimizationEnabled() {
|
||||
return false;
|
||||
}
|
||||
private Map<String, Boolean> mFlagMap = new HashMap<>(
|
||||
Map.ofEntries(
|
||||
Map.entry(Flags.FLAG_DISABLED_RO, false),
|
||||
|
@ -1029,6 +1086,17 @@ mod tests {
|
|||
Map.entry(Flags.FLAG_ENABLED_RW, false)
|
||||
)
|
||||
);
|
||||
private Set<String> mReadOnlyFlagsSet = new HashSet<>(
|
||||
Arrays.asList(
|
||||
Flags.FLAG_DISABLED_RO,
|
||||
Flags.FLAG_DISABLED_RW,
|
||||
Flags.FLAG_DISABLED_RW_IN_OTHER_NAMESPACE,
|
||||
Flags.FLAG_ENABLED_FIXED_RO,
|
||||
Flags.FLAG_ENABLED_RO,
|
||||
Flags.FLAG_ENABLED_RW,
|
||||
""
|
||||
)
|
||||
);
|
||||
}
|
||||
"#;
|
||||
let mut file_set = HashMap::from([
|
||||
|
|
|
@ -2,8 +2,11 @@ package {package_name};
|
|||
// TODO(b/303773055): Remove the annotation after access issue is resolved.
|
||||
import android.compat.annotation.UnsupportedAppUsage;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** @hide */
|
||||
public class FakeFeatureFlagsImpl implements FeatureFlags \{
|
||||
|
@ -31,6 +34,14 @@ public class FakeFeatureFlagsImpl implements FeatureFlags \{
|
|||
}
|
||||
}
|
||||
|
||||
public boolean isFlagReadOnlyOptimized(String flagName) \{
|
||||
if (mReadOnlyFlagsSet.contains(flagName) &&
|
||||
isOptimizationEnabled()) \{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean getValue(String flagName) \{
|
||||
Boolean value = this.mFlagMap.get(flagName);
|
||||
if (value == null) \{
|
||||
|
@ -39,12 +50,28 @@ public class FakeFeatureFlagsImpl implements FeatureFlags \{
|
|||
return value;
|
||||
}
|
||||
|
||||
@com.android.aconfig.annotations.AssumeTrueForR8
|
||||
private boolean isOptimizationEnabled() \{
|
||||
return false;
|
||||
}
|
||||
|
||||
private Map<String, Boolean> mFlagMap = new HashMap<>(
|
||||
Map.ofEntries(
|
||||
{{-for item in flag_elements}}
|
||||
{{ -for item in flag_elements }}
|
||||
Map.entry(Flags.FLAG_{item.flag_name_constant_suffix}, false)
|
||||
{{ -if not @last }},{{ endif }}
|
||||
{{ -endfor }}
|
||||
)
|
||||
);
|
||||
|
||||
private Set<String> mReadOnlyFlagsSet = new HashSet<>(
|
||||
Arrays.asList(
|
||||
{{ -for item in flag_elements }}
|
||||
{{ -if not item.is_read_write }}
|
||||
Flags.FLAG_{item.flag_name_constant_suffix},
|
||||
{{ -endif }}
|
||||
{{ -endfor }}
|
||||
""{# The empty string here is to resolve the ending comma #}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue