hiddenapi: Convert API lists to a flags CSV file
Access flags for hiddenapi have been managed as a series of test files,
one file per flag. This requries too many changes every time a flag is
changed or a new flag is introduced. Change `hiddenapi` and `veridex`
to expect flags as a CSV file in the format:
<api signature>,<flag1>,...,<flagN>
Test: m, phone boots
Test: m test-art
Test: m appcompat
Change-Id: Iffa64b36ffc5524779d5f57c3c6f0c0e84bfc606
diff --git a/libartbase/base/hiddenapi_flags.h b/libartbase/base/hiddenapi_flags.h
index 8e7269c..9ea01d7 100644
--- a/libartbase/base/hiddenapi_flags.h
+++ b/libartbase/base/hiddenapi_flags.h
@@ -58,6 +58,8 @@
"greylist-max-o",
};
+ static constexpr const char* kInvalidName = "invalid";
+
static constexpr SdkVersion kMaxSdkVersions[] {
/* whitelist */ SdkVersion::kMax,
/* greylist */ SdkVersion::kMax,
@@ -70,7 +72,7 @@
explicit ApiList(Value value) : value_(value) {}
- const Value value_;
+ Value value_;
public:
static ApiList Whitelist() { return ApiList(Value::kWhitelist); }
@@ -87,6 +89,14 @@
return Invalid();
}
+ // Decodes ApiList from its integer value.
+ static ApiList FromIntValue(IntValueType int_value) {
+ if (MinValue().GetIntValue() <= int_value && int_value <= MaxValue().GetIntValue()) {
+ return ApiList(static_cast<Value>(int_value));
+ }
+ return Invalid();
+ }
+
// Returns the ApiList with a given name.
static ApiList FromName(const std::string& str) {
for (IntValueType i = MinValue().GetIntValue(); i <= MaxValue().GetIntValue(); i++) {
@@ -108,7 +118,7 @@
return static_cast<IntValueType>(value_);
}
- const char* GetName() const { return kNames[GetIntValue()]; }
+ const char* GetName() const { return IsValid() ? kNames[GetIntValue()]: kInvalidName; }
SdkVersion GetMaxAllowedSdkVersion() const { return kMaxSdkVersions[GetIntValue()]; }