From 09efc1604936c234b65a5d278f5ea63da29b17cd Mon Sep 17 00:00:00 2001 From: satayev Date: Mon, 22 Feb 2021 17:24:57 +0000 Subject: Revert "Remove obsolete TestApiEnforcementPolicy." This reverts commit d8b153b7c2026f45db97a7fd5804957becc5cfdf. Reason for revert: cts tests on -user builds is broken Change-Id: I7528fb6d1606f08d2398bc4cbb27519424cf1b51 --- runtime/hidden_api_test.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'runtime/hidden_api_test.cc') 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(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); -- cgit v1.2.3-59-g8ed1b