summaryrefslogtreecommitdiff
path: root/runtime/hidden_api.h
diff options
context:
space:
mode:
author Mathieu Chartier <mathieuc@google.com> 2018-04-06 20:11:28 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2018-04-06 20:11:28 +0000
commitfaa7b29f1e0c311e42ab5a265cb1b17036ca5a10 (patch)
tree2d47cb8b1c10df002a602009724a026b136b3c9d /runtime/hidden_api.h
parentd7d9f00b9e87e491f2fc0631ed64ad1acde9c744 (diff)
parentf5f1f80aa6c1c10c61b6723bbc52d5aec2eba2b9 (diff)
Merge changes from topic "hidden_api_cp"
* changes: Revert^2 "hidden_api: Call back into libcore on hidden api detection"" Revert "hidden_api: Call back into libcore on hidden api detection" hidden_api: Call back into libcore on hidden api detection
Diffstat (limited to 'runtime/hidden_api.h')
-rw-r--r--runtime/hidden_api.h46
1 files changed, 26 insertions, 20 deletions
diff --git a/runtime/hidden_api.h b/runtime/hidden_api.h
index cc6c146f00..ffdeacbfff 100644
--- a/runtime/hidden_api.h
+++ b/runtime/hidden_api.h
@@ -58,7 +58,7 @@ enum AccessMethod {
kLinking,
};
-inline Action GetMemberAction(uint32_t access_flags) {
+inline Action GetActionFromAccessFlags(uint32_t access_flags) {
EnforcementPolicy policy = Runtime::Current()->GetHiddenApiEnforcementPolicy();
if (policy == EnforcementPolicy::kNoChecks) {
// Exit early. Nothing to enforce.
@@ -108,9 +108,7 @@ class MemberSignature {
};
template<typename T>
-bool ShouldBlockAccessToMemberImpl(T* member,
- Action action,
- AccessMethod access_method)
+Action GetMemberActionImpl(T* member, Action action, AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_);
// Returns true if the caller is either loaded by the boot strap class loader or comes from
@@ -138,28 +136,28 @@ inline bool IsCallerInPlatformDex(ObjPtr<mirror::ClassLoader> caller_class_loade
// return true if the caller is located in the platform.
// This function might print warnings into the log if the member is hidden.
template<typename T>
-inline bool ShouldBlockAccessToMember(T* member,
- Thread* self,
- std::function<bool(Thread*)> fn_caller_in_platform,
- AccessMethod access_method)
+inline Action GetMemberAction(T* member,
+ Thread* self,
+ std::function<bool(Thread*)> fn_caller_in_platform,
+ AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_) {
DCHECK(member != nullptr);
- Action action = GetMemberAction(member->GetAccessFlags());
+ Action action = GetActionFromAccessFlags(member->GetAccessFlags());
if (action == kAllow) {
// Nothing to do.
- return false;
+ return action;
}
// Member is hidden. Invoke `fn_caller_in_platform` and find the origin of the access.
// This can be *very* expensive. Save it for last.
if (fn_caller_in_platform(self)) {
// Caller in the platform. Exit.
- return false;
+ return kAllow;
}
// Member is hidden and caller is not in the platform.
- return detail::ShouldBlockAccessToMemberImpl(member, action, access_method);
+ return detail::GetMemberActionImpl(member, action, access_method);
}
inline bool IsCallerInPlatformDex(ObjPtr<mirror::Class> caller)
@@ -172,18 +170,26 @@ inline bool IsCallerInPlatformDex(ObjPtr<mirror::Class> caller)
// `caller_class_loader`.
// This function might print warnings into the log if the member is hidden.
template<typename T>
-inline bool ShouldBlockAccessToMember(T* member,
- ObjPtr<mirror::ClassLoader> caller_class_loader,
- ObjPtr<mirror::DexCache> caller_dex_cache,
- AccessMethod access_method)
+inline Action GetMemberAction(T* member,
+ ObjPtr<mirror::ClassLoader> caller_class_loader,
+ ObjPtr<mirror::DexCache> caller_dex_cache,
+ AccessMethod access_method)
REQUIRES_SHARED(Locks::mutator_lock_) {
bool caller_in_platform = detail::IsCallerInPlatformDex(caller_class_loader, caller_dex_cache);
- return ShouldBlockAccessToMember(member,
- /* thread */ nullptr,
- [caller_in_platform] (Thread*) { return caller_in_platform; },
- access_method);
+ return GetMemberAction(member,
+ /* thread */ nullptr,
+ [caller_in_platform] (Thread*) { return caller_in_platform; },
+ access_method);
}
+// Calls back into managed code to notify VMRuntime.nonSdkApiUsageConsumer that
+// |member| was accessed. This is usually called when an API is on the black,
+// dark grey or light grey lists. Given that the callback can execute arbitrary
+// code, a call to this method can result in thread suspension.
+template<typename T> void NotifyHiddenApiListener(T* member)
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
+
} // namespace hiddenapi
} // namespace art