diff options
author | 2022-05-04 12:28:59 +0000 | |
---|---|---|
committer | 2022-05-09 09:17:00 +0000 | |
commit | 22f34b376939e6600c2e50a6bd9619b4b577ee81 (patch) | |
tree | 3f0ca825119265f1d24ff0b9c9964915d8551883 | |
parent | 3ba842dfa15bb51d6579b0ac4dc92f6fbc23db23 (diff) |
Add support for max-target-s
Bug: 169748350
Test: make
Change-Id: I3d7c32b18bb6b64d69632f0799aa48672b8712d7
Merged-In: I3d7c32b18bb6b64d69632f0799aa48672b8712d7
-rw-r--r-- | libartbase/base/hiddenapi_flags.h | 6 | ||||
-rw-r--r-- | runtime/hidden_api_test.cc | 20 |
2 files changed, 25 insertions, 1 deletions
diff --git a/libartbase/base/hiddenapi_flags.h b/libartbase/base/hiddenapi_flags.h index 7415b934cc..9d0a18e78f 100644 --- a/libartbase/base/hiddenapi_flags.h +++ b/libartbase/base/hiddenapi_flags.h @@ -98,11 +98,12 @@ class ApiList { 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 @@ class ApiList { "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 @@ class ApiList { /* 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 @@ class ApiList { 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 f5cd15ef4f..e204c57b28 100644 --- a/runtime/hidden_api_test.cc +++ b/runtime/hidden_api_test.cc @@ -235,6 +235,7 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { 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); |