fixed build
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.android.wm.shell;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
/** @hide */
|
||||
public class FakeFeatureFlagsImpl extends CustomFeatureFlags {
|
||||
private final Map<String, Boolean> mFlagMap = new HashMap<>();
|
||||
private final FeatureFlags mDefaults;
|
||||
|
||||
public FakeFeatureFlagsImpl() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
public FakeFeatureFlagsImpl(FeatureFlags defaults) {
|
||||
super(null);
|
||||
mDefaults = defaults;
|
||||
// Initialize the map with null values
|
||||
for (String flagName : getFlagNames()) {
|
||||
mFlagMap.put(flagName, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean getValue(String flagName, Predicate<FeatureFlags> getter) {
|
||||
Boolean value = this.mFlagMap.get(flagName);
|
||||
if (value != null) {
|
||||
return value;
|
||||
}
|
||||
if (mDefaults != null) {
|
||||
return getter.test(mDefaults);
|
||||
}
|
||||
throw new IllegalArgumentException(flagName + " is not set");
|
||||
}
|
||||
|
||||
public void setFlag(String flagName, boolean value) {
|
||||
if (!this.mFlagMap.containsKey(flagName)) {
|
||||
throw new IllegalArgumentException("no such flag " + flagName);
|
||||
}
|
||||
this.mFlagMap.put(flagName, value);
|
||||
}
|
||||
|
||||
public void resetAll() {
|
||||
for (Map.Entry entry : mFlagMap.entrySet()) {
|
||||
entry.setValue(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user