summaryrefslogtreecommitdiff
path: root/runtime/hidden_api_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/hidden_api_test.cc')
-rw-r--r--runtime/hidden_api_test.cc20
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);