diff options
author | 2018-11-01 09:55:09 +0000 | |
---|---|---|
committer | 2018-11-29 16:42:14 +0000 | |
commit | 80d16289df2ec243737063e4f9d092ac3a7cbb10 (patch) | |
tree | 65ee57a867a58f5ddaf42747bf49fef987c57356 /runtime/hidden_api_test.cc | |
parent | e701de908bf5cb9375f15a3dbd113206aa582e7e (diff) |
hiddenapi: Introduce greylist-max-p
Add a new hiddenapi::ApiList constant for a greylist only accessible to
apps targeting SDK version < Q.
The patch also removes SdkVersion::kP_MR1 which is invalid.
Test: m, phone boots
Test: m test-art
Test: atest art/tools/class2greylist/test
Change-Id: I48f3d1a4703166168fd8e0d1c3337aa2957b66ce
Diffstat (limited to 'runtime/hidden_api_test.cc')
-rw-r--r-- | runtime/hidden_api_test.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/runtime/hidden_api_test.cc b/runtime/hidden_api_test.cc index 520dc6d935..595f0779e2 100644 --- a/runtime/hidden_api_test.cc +++ b/runtime/hidden_api_test.cc @@ -103,12 +103,14 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kDisabled); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), false); runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kJustWarn); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), false); @@ -117,6 +119,7 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { static_cast<uint32_t>(hiddenapi::ApiList::GreylistMaxO().GetMaxAllowedSdkVersion())); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); @@ -125,6 +128,16 @@ TEST_F(HiddenApiTest, CheckGetActionFromRuntimeFlags) { static_cast<uint32_t>(hiddenapi::ApiList::GreylistMaxO().GetMaxAllowedSdkVersion()) + 1); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), true); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); + + runtime_->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled); + runtime_->SetTargetSdkVersion( + static_cast<uint32_t>(hiddenapi::ApiList::GreylistMaxP().GetMaxAllowedSdkVersion()) + 1); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Whitelist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Greylist()), false); + ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxP()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::GreylistMaxO()), true); ASSERT_EQ(ShouldDenyAccess(hiddenapi::ApiList::Blacklist()), true); } |