diff options
author | 2021-02-22 17:24:57 +0000 | |
---|---|---|
committer | 2021-02-23 02:48:40 +0000 | |
commit | 09efc1604936c234b65a5d278f5ea63da29b17cd (patch) | |
tree | e0b34882e0af2f7fe364645b8b3c2a8c802bc6d5 /runtime/hidden_api_test.cc | |
parent | d83edf3d155c49a578851da4f0407affa03b2325 (diff) |
Revert "Remove obsolete TestApiEnforcementPolicy."
This reverts commit d8b153b7c2026f45db97a7fd5804957becc5cfdf.
Reason for revert: cts tests on -user builds is broken
Change-Id: I7528fb6d1606f08d2398bc4cbb27519424cf1b51
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 9c278fd720..cfdba4552e 100644 --- a/runtime/hidden_api_test.cc +++ b/runtime/hidden_api_test.cc @@ -216,6 +216,7 @@ TEST_F(HiddenApiTest, CheckTestApiEnforcement) { static_cast<uint32_t>(hiddenapi::ApiList::MaxTargetR().GetMaxAllowedSdkVersion()) + 1); // Default case where all TestApis are treated like non-TestApi. + runtime_->SetTestApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled); setChangeIdState(kAllowTestApiAccess, false); ASSERT_EQ( ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Sdk()), false); @@ -233,6 +234,25 @@ TEST_F(HiddenApiTest, CheckTestApiEnforcement) { ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Blocked()), true); // A case where we want to allow access to TestApis. + runtime_->SetTestApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kDisabled); + setChangeIdState(kAllowTestApiAccess, false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Sdk()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Unsupported()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::MaxTargetR()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::MaxTargetQ()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::MaxTargetP()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::MaxTargetO()), false); + ASSERT_EQ( + ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Blocked()), false); + + // A second case where we want to allow access to TestApis. + runtime_->SetTestApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled); setChangeIdState(kAllowTestApiAccess, true); ASSERT_EQ( ShouldDenyAccess(hiddenapi::ApiList::TestApi() | hiddenapi::ApiList::Sdk()), false); |