Add support for max-target-s
Bug: 169748350
Test: m
Change-Id: Ifdd7b7a71e96fa6ba628acea0f9ad7996673c7bc
diff --git a/libartbase/base/hiddenapi_flags.h b/libartbase/base/hiddenapi_flags.h
index 7415b93..9d0a18e 100644
--- a/libartbase/base/hiddenapi_flags.h
+++ b/libartbase/base/hiddenapi_flags.h
@@ -98,11 +98,12 @@
kMaxTargetP = 4,
kMaxTargetQ = 5,
kMaxTargetR = 6,
+ kMaxTargetS = 7,
// Special values
kInvalid = (static_cast<uint32_t>(-1) & kValueBitMask),
kMin = kSdk,
- kMax = kMaxTargetR,
+ kMax = kMaxTargetS,
};
// Additional bit flags after the first kValueBitSize bits in dex flags.
@@ -139,6 +140,7 @@
"max-target-p",
"max-target-q",
"max-target-r",
+ "max-target-s",
};
// A magic marker used by tests to mimic a hiddenapi list which doesn't exist
@@ -160,6 +162,7 @@
/* max-target-p */ SdkVersion::kP,
/* max-target-q */ SdkVersion::kQ,
/* max-target-r */ SdkVersion::kR,
+ /* max-target-s */ SdkVersion::kS,
};
explicit ApiList(Value val, uint32_t domain_apis = 0u)
@@ -204,6 +207,7 @@
static ApiList MaxTargetP() { return ApiList(Value::kMaxTargetP); }
static ApiList MaxTargetQ() { return ApiList(Value::kMaxTargetQ); }
static ApiList MaxTargetR() { return ApiList(Value::kMaxTargetR); }
+ static ApiList MaxTargetS() { return ApiList(Value::kMaxTargetS); }
static ApiList CorePlatformApi() { return ApiList(DomainApi::kCorePlatformApi); }
static ApiList TestApi() { return ApiList(DomainApi::kTestApi); }
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc
index f5cd15e..e204c57 100644
--- a/runtime/hidden_api_test.cc
+++ b/runtime/hidden_api_test.cc
@@ -235,6 +235,7 @@
runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kJustWarn);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), false);
@@ -248,6 +249,7 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), false);
@@ -261,6 +263,7 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), false);
@@ -269,6 +272,8 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetO()), true);
@@ -281,6 +286,7 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), true);
@@ -294,6 +300,7 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), true);
@@ -307,6 +314,19 @@
SetChangeIdState(kHideMaxtargetsdkQHiddenApis, true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), true);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), true);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), true);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetO()), true);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blocked()), true);
+
+ runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled);
+ runtime_->SetTargetSdkVersion(
+ static_cast<uint32_t>(hiddenapi::ApiList::MaxTargetS().GetMaxAllowedSdkVersion()) + 1);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Sdk()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Unsupported()), false);
+ ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetS()), true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetR()), true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetQ()), true);
ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::MaxTargetP()), true);