summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Mathew Inwood <mathewi@google.com> 2018-05-18 08:32:57 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-05-18 08:32:57 +0000
commit9c422cc4ef2f1825c60a43a1e8d770f270b076e7 (patch)
tree2b042a36c2ad0f0a26ba9739e52a4888a7902ce0
parent80a7c29b29c50c1c6cf40093a4552dacd4c5d638 (diff)
parent9b5ddff6f74073a2b45669eff8379ed796dbf488 (diff)
Merge "Hidden API: only log what we deny."
-rw-r--r--runtime/hidden_api.cc8
-rw-r--r--test/674-hiddenapi/src-ex/ChildClass.java8
2 files changed, 9 insertions, 7 deletions
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index ee518ae1ea..e41d1d3eb9 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -40,7 +40,7 @@ namespace hiddenapi {
// Note that when flipping this flag, you must also update the expectations of test 674-hiddenapi
// as it affects whether or not we warn for light grey APIs that have been added to the exemptions
// list.
-static constexpr bool kLogAllAccesses = true;
+static constexpr bool kLogAllAccesses = false;
static inline std::ostream& operator<<(std::ostream& os, AccessMethod value) {
switch (value) {
@@ -219,7 +219,8 @@ Action GetMemberActionImpl(T* member,
// - for non-debuggable apps, there is no distinction between light grey & whitelisted APIs.
// - we want to avoid the overhead of checking for exemptions for light greylisted APIs whenever
// possible.
- if (kLogAllAccesses || action == kDeny || runtime->IsJavaDebuggable()) {
+ const bool shouldWarn = kLogAllAccesses || runtime->IsJavaDebuggable();
+ if (shouldWarn || action == kDeny) {
if (member_signature.IsExempted(runtime->GetHiddenApiExemptions())) {
action = kAllow;
// Avoid re-examining the exemption list next time.
@@ -260,7 +261,8 @@ Action GetMemberActionImpl(T* member,
MaybeWhitelistMember(runtime, member);
// If this action requires a UI warning, set the appropriate flag.
- if (action == kAllowButWarnAndToast || runtime->ShouldAlwaysSetHiddenApiWarningFlag()) {
+ if (shouldWarn &&
+ (action == kAllowButWarnAndToast || runtime->ShouldAlwaysSetHiddenApiWarningFlag())) {
runtime->SetPendingHiddenApiWarning(true);
}
}
diff --git a/test/674-hiddenapi/src-ex/ChildClass.java b/test/674-hiddenapi/src-ex/ChildClass.java
index 0349e8fe46..d5966cde36 100644
--- a/test/674-hiddenapi/src-ex/ChildClass.java
+++ b/test/674-hiddenapi/src-ex/ChildClass.java
@@ -91,12 +91,12 @@ public class ChildClass {
// Run meaningful combinations of access flags.
for (Hiddenness hiddenness : Hiddenness.values()) {
final Behaviour expected;
- if (isSameBoot || hiddenness == Hiddenness.Whitelist || everythingWhitelisted) {
+ // Warnings are now disabled whenever access is granted, even for
+ // greylisted APIs. This is the behaviour for release builds.
+ if (isSameBoot || hiddenness != Hiddenness.Blacklist || everythingWhitelisted) {
expected = Behaviour.Granted;
- } else if (hiddenness == Hiddenness.Blacklist) {
- expected = Behaviour.Denied;
} else {
- expected = Behaviour.Warning;
+ expected = Behaviour.Denied;
}
for (boolean isStatic : booleanValues) {