diff options
author | 2018-10-17 18:00:06 +0100 | |
---|---|---|
committer | 2018-11-14 16:49:40 +0000 | |
commit | f50ac103426588d9f7c014ef2d2b9c766f8dc25e (patch) | |
tree | bac6537c3cd63cc382e24d9b94f0eb64f18ab0a4 /runtime/interpreter/unstarted_runtime.cc | |
parent | b56e8353020acda1a8285daa11c69f57060cd015 (diff) |
Simplify hidden_api.h logic
Refactor GetMemberAction to return a boolean whether access to a class
member should be denied. This also moves StrictMode consumer
notification into hidden_api.cc and removes notifications for toasts.
Tests are changed accordingly.
Test: phone boots
Test: m test-art
Merged-In: I02902143de0ff91d402ba79c83f28226b1822a6f
Change-Id: I02902143de0ff91d402ba79c83f28226b1822a6f
(cherry picked from commit 51995f90adaa0e5047dee56d22f15e4225e70517)
Diffstat (limited to 'runtime/interpreter/unstarted_runtime.cc')
-rw-r--r-- | runtime/interpreter/unstarted_runtime.cc | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/runtime/interpreter/unstarted_runtime.cc b/runtime/interpreter/unstarted_runtime.cc index 9bc2179b63..e292a7612c 100644 --- a/runtime/interpreter/unstarted_runtime.cc +++ b/runtime/interpreter/unstarted_runtime.cc @@ -182,15 +182,16 @@ static mirror::String* GetClassName(Thread* self, ShadowFrame* shadow_frame, siz } template<typename T> -static ALWAYS_INLINE bool ShouldBlockAccessToMember(T* member, ShadowFrame* frame) +static ALWAYS_INLINE bool ShouldDenyAccessToMember(T* member, ShadowFrame* frame) REQUIRES_SHARED(Locks::mutator_lock_) { // All uses in this file are from reflection - constexpr hiddenapi::AccessMethod access_method = hiddenapi::kReflection; - return hiddenapi::GetMemberAction( + constexpr hiddenapi::AccessMethod access_method = hiddenapi::AccessMethod::kReflection; + return hiddenapi::ShouldDenyAccessToMember( member, - frame->GetMethod()->GetDeclaringClass()->GetClassLoader(), - frame->GetMethod()->GetDeclaringClass()->GetDexCache(), - access_method) == hiddenapi::kDeny; + [&]() REQUIRES_SHARED(Locks::mutator_lock_) { + return hiddenapi::AccessContext(frame->GetMethod()->GetDeclaringClass()); + }, + access_method); } void UnstartedRuntime::UnstartedClassForNameCommon(Thread* self, @@ -297,7 +298,7 @@ void UnstartedRuntime::UnstartedClassNewInstance( auto* cl = Runtime::Current()->GetClassLinker(); if (cl->EnsureInitialized(self, h_klass, true, true)) { ArtMethod* cons = h_klass->FindConstructor("()V", cl->GetImagePointerSize()); - if (cons != nullptr && ShouldBlockAccessToMember(cons, shadow_frame)) { + if (cons != nullptr && ShouldDenyAccessToMember(cons, shadow_frame)) { cons = nullptr; } if (cons != nullptr) { @@ -342,7 +343,7 @@ void UnstartedRuntime::UnstartedClassGetDeclaredField( } } } - if (found != nullptr && ShouldBlockAccessToMember(found, shadow_frame)) { + if (found != nullptr && ShouldDenyAccessToMember(found, shadow_frame)) { found = nullptr; } if (found == nullptr) { @@ -407,7 +408,7 @@ void UnstartedRuntime::UnstartedClassGetDeclaredMethod( self, klass, name, args); } } - if (method != nullptr && ShouldBlockAccessToMember(method->GetArtMethod(), shadow_frame)) { + if (method != nullptr && ShouldDenyAccessToMember(method->GetArtMethod(), shadow_frame)) { method = nullptr; } result->SetL(method); @@ -445,7 +446,7 @@ void UnstartedRuntime::UnstartedClassGetDeclaredConstructor( } } if (constructor != nullptr && - ShouldBlockAccessToMember(constructor->GetArtMethod(), shadow_frame)) { + ShouldDenyAccessToMember(constructor->GetArtMethod(), shadow_frame)) { constructor = nullptr; } result->SetL(constructor); |