summaryrefslogtreecommitdiffstats
path: root/libartbase
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2018-11-30 10:01:02 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2018-11-30 10:01:02 +0000
commita3a57d35ba82aef59db44b947f6ed6d058cf0817 (patch)
treee7690f4c797c389ab81df0ef94752c5cd1ceeb20 /libartbase
parent1ee723b683307c804c5ddf2ad7d699f5abfc362a (diff)
parente701de908bf5cb9375f15a3dbd113206aa582e7e (diff)
downloadart-a3a57d35ba82aef59db44b947f6ed6d058cf0817.tar.gz
art-a3a57d35ba82aef59db44b947f6ed6d058cf0817.tar.bz2
art-a3a57d35ba82aef59db44b947f6ed6d058cf0817.zip
Merge changes from topic "hiddenapi-csv"
* changes: Support CSV hiddenapi flags in class2greylist hiddenapi: Convert API lists to a flags CSV file
Diffstat (limited to 'libartbase')
-rw-r--r--libartbase/base/hiddenapi_flags.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/libartbase/base/hiddenapi_flags.h b/libartbase/base/hiddenapi_flags.h
index 8e7269cc60..9ea01d7f3b 100644
--- a/libartbase/base/hiddenapi_flags.h
+++ b/libartbase/base/hiddenapi_flags.h
@@ -58,6 +58,8 @@ class ApiList {
"greylist-max-o",
};
+ static constexpr const char* kInvalidName = "invalid";
+
static constexpr SdkVersion kMaxSdkVersions[] {
/* whitelist */ SdkVersion::kMax,
/* greylist */ SdkVersion::kMax,
@@ -70,7 +72,7 @@ class ApiList {
explicit ApiList(Value value) : value_(value) {}
- const Value value_;
+ Value value_;
public:
static ApiList Whitelist() { return ApiList(Value::kWhitelist); }
@@ -87,6 +89,14 @@ class ApiList {
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 @@ class ApiList {
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()]; }