diff options
author | 2022-05-04 12:28:59 +0000 | |
---|---|---|
committer | 2022-05-09 09:17:00 +0000 | |
commit | 22f34b376939e6600c2e50a6bd9619b4b577ee81 (patch) | |
tree | 3f0ca825119265f1d24ff0b9c9964915d8551883 /runtime/hidden_api_test.cc | |
parent | 3ba842dfa15bb51d6579b0ac4dc92f6fbc23db23 (diff) |
Add support for max-target-s
Bug: 169748350
Test: make
Change-Id: I3d7c32b18bb6b64d69632f0799aa48672b8712d7
Merged-In: I3d7c32b18bb6b64d69632f0799aa48672b8712d7
Diffstat (limited to 'runtime/hidden_api_test.cc')
-rw-r--r-- | runtime/hidden_api_test.cc | 20 |
1 files changed, 20 insertions, 0 deletions
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); |