blob: e0939ddbdbd9948915d9eecf0d53f93847b1178e [file] [log] [blame]
Andreas Gampe80f5fe52018-03-28 16:23:24 -07001/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "hidden_api.h"
18
Narayan Kamathe453a8d2018-04-03 15:23:46 +010019#include <nativehelper/scoped_local_ref.h>
20
David Brazdil85865692018-10-30 17:26:20 +000021#include "art_field-inl.h"
22#include "art_method-inl.h"
Andreas Gampe80f5fe52018-03-28 16:23:24 -070023#include "base/dumpable.h"
David Brazdil1a658632018-12-01 17:54:26 +000024#include "class_root.h"
David Brazdil85865692018-10-30 17:26:20 +000025#include "dex/class_accessor-inl.h"
David Brazdil1a658632018-12-01 17:54:26 +000026#include "dex/dex_file_loader.h"
27#include "mirror/class_ext.h"
David Brazdil85865692018-10-30 17:26:20 +000028#include "scoped_thread_state_change.h"
29#include "thread-inl.h"
Narayan Kamathe453a8d2018-04-03 15:23:46 +010030#include "well_known_classes.h"
Andreas Gampe80f5fe52018-03-28 16:23:24 -070031
Nicolas Geoffray8a229072018-05-10 16:34:14 +010032#ifdef ART_TARGET_ANDROID
33#include <metricslogger/metrics_logger.h>
Mathew Inwood2d4d62f2018-04-12 13:56:37 +010034using android::metricslogger::ComplexEventLogger;
35using android::metricslogger::ACTION_HIDDEN_API_ACCESSED;
36using android::metricslogger::FIELD_HIDDEN_API_ACCESS_METHOD;
37using android::metricslogger::FIELD_HIDDEN_API_ACCESS_DENIED;
38using android::metricslogger::FIELD_HIDDEN_API_SIGNATURE;
Nicolas Geoffray8a229072018-05-10 16:34:14 +010039#endif
Mathew Inwood2d4d62f2018-04-12 13:56:37 +010040
Andreas Gampe80f5fe52018-03-28 16:23:24 -070041namespace art {
42namespace hiddenapi {
43
Mathew Inwood27199e62018-04-11 16:08:21 +010044// Set to true if we should always print a warning in logcat for all hidden API accesses, not just
45// dark grey and black. This can be set to true for developer preview / beta builds, but should be
46// false for public release builds.
Mathew Inwood6d6012e2018-04-12 15:43:11 +010047// Note that when flipping this flag, you must also update the expectations of test 674-hiddenapi
48// as it affects whether or not we warn for light grey APIs that have been added to the exemptions
49// list.
Mathew Inwood015a7ec2018-05-16 11:18:10 +010050static constexpr bool kLogAllAccesses = false;
Mathew Inwood27199e62018-04-11 16:08:21 +010051
Andreas Gampe80f5fe52018-03-28 16:23:24 -070052static inline std::ostream& operator<<(std::ostream& os, AccessMethod value) {
53 switch (value) {
David Brazdilf50ac102018-10-17 18:00:06 +010054 case AccessMethod::kNone:
David Brazdil54a99cf2018-04-05 16:57:32 +010055 LOG(FATAL) << "Internal access to hidden API should not be logged";
56 UNREACHABLE();
David Brazdilf50ac102018-10-17 18:00:06 +010057 case AccessMethod::kReflection:
Andreas Gampe80f5fe52018-03-28 16:23:24 -070058 os << "reflection";
59 break;
David Brazdilf50ac102018-10-17 18:00:06 +010060 case AccessMethod::kJNI:
Andreas Gampe80f5fe52018-03-28 16:23:24 -070061 os << "JNI";
62 break;
David Brazdilf50ac102018-10-17 18:00:06 +010063 case AccessMethod::kLinking:
Andreas Gampe80f5fe52018-03-28 16:23:24 -070064 os << "linking";
65 break;
66 }
67 return os;
68}
69
Andreas Gampe80f5fe52018-03-28 16:23:24 -070070namespace detail {
71
David Brazdilf50ac102018-10-17 18:00:06 +010072// Do not change the values of items in this enum, as they are written to the
73// event log for offline analysis. Any changes will interfere with that analysis.
74enum AccessContextFlags {
75 // Accessed member is a field if this bit is set, else a method
76 kMemberIsField = 1 << 0,
77 // Indicates if access was denied to the member, instead of just printing a warning.
78 kAccessDenied = 1 << 1,
79};
80
Andreas Gampe80f5fe52018-03-28 16:23:24 -070081MemberSignature::MemberSignature(ArtField* field) {
Mathew Inwood73ddda42018-04-03 15:32:32 +010082 class_name_ = field->GetDeclaringClass()->GetDescriptor(&tmp_);
83 member_name_ = field->GetName();
84 type_signature_ = field->GetTypeDescriptor();
85 type_ = kField;
Andreas Gampe80f5fe52018-03-28 16:23:24 -070086}
87
88MemberSignature::MemberSignature(ArtMethod* method) {
David Brazdil73a64f62018-05-02 16:53:06 +010089 // If this is a proxy method, print the signature of the interface method.
90 method = method->GetInterfaceMethodIfProxy(
91 Runtime::Current()->GetClassLinker()->GetImagePointerSize());
92
Mathew Inwood73ddda42018-04-03 15:32:32 +010093 class_name_ = method->GetDeclaringClass()->GetDescriptor(&tmp_);
94 member_name_ = method->GetName();
95 type_signature_ = method->GetSignature().ToString();
96 type_ = kMethod;
97}
98
David Brazdil1a658632018-12-01 17:54:26 +000099MemberSignature::MemberSignature(const ClassAccessor::Field& field) {
100 const DexFile& dex_file = field.GetDexFile();
101 const DexFile::FieldId& field_id = dex_file.GetFieldId(field.GetIndex());
102 class_name_ = dex_file.GetFieldDeclaringClassDescriptor(field_id);
103 member_name_ = dex_file.GetFieldName(field_id);
104 type_signature_ = dex_file.GetFieldTypeDescriptor(field_id);
105 type_ = kField;
106}
107
108MemberSignature::MemberSignature(const ClassAccessor::Method& method) {
109 const DexFile& dex_file = method.GetDexFile();
110 const DexFile::MethodId& method_id = dex_file.GetMethodId(method.GetIndex());
111 class_name_ = dex_file.GetMethodDeclaringClassDescriptor(method_id);
112 member_name_ = dex_file.GetMethodName(method_id);
113 type_signature_ = dex_file.GetMethodSignature(method_id).ToString();
114 type_ = kMethod;
115}
116
Mathew Inwood73ddda42018-04-03 15:32:32 +0100117inline std::vector<const char*> MemberSignature::GetSignatureParts() const {
118 if (type_ == kField) {
119 return { class_name_.c_str(), "->", member_name_.c_str(), ":", type_signature_.c_str() };
120 } else {
121 DCHECK_EQ(type_, kMethod);
122 return { class_name_.c_str(), "->", member_name_.c_str(), type_signature_.c_str() };
123 }
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700124}
125
126bool MemberSignature::DoesPrefixMatch(const std::string& prefix) const {
127 size_t pos = 0;
Mathew Inwood73ddda42018-04-03 15:32:32 +0100128 for (const char* part : GetSignatureParts()) {
129 size_t count = std::min(prefix.length() - pos, strlen(part));
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700130 if (prefix.compare(pos, count, part, 0, count) == 0) {
131 pos += count;
132 } else {
133 return false;
134 }
135 }
136 // We have a complete match if all parts match (we exit the loop without
137 // returning) AND we've matched the whole prefix.
138 return pos == prefix.length();
139}
140
141bool MemberSignature::IsExempted(const std::vector<std::string>& exemptions) {
142 for (const std::string& exemption : exemptions) {
143 if (DoesPrefixMatch(exemption)) {
144 return true;
145 }
146 }
147 return false;
148}
149
150void MemberSignature::Dump(std::ostream& os) const {
Mathew Inwood73ddda42018-04-03 15:32:32 +0100151 for (const char* part : GetSignatureParts()) {
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700152 os << part;
153 }
154}
155
David Brazdil47cd2722018-10-23 12:50:02 +0100156void MemberSignature::WarnAboutAccess(AccessMethod access_method, hiddenapi::ApiList list) {
Mathew Inwood73ddda42018-04-03 15:32:32 +0100157 LOG(WARNING) << "Accessing hidden " << (type_ == kField ? "field " : "method ")
158 << Dumpable<MemberSignature>(*this) << " (" << list << ", " << access_method << ")";
159}
David Brazdilf50ac102018-10-17 18:00:06 +0100160
David Brazdil1a658632018-12-01 17:54:26 +0000161bool MemberSignature::Equals(const MemberSignature& other) {
162 return type_ == other.type_ &&
163 class_name_ == other.class_name_ &&
164 member_name_ == other.member_name_ &&
165 type_signature_ == other.type_signature_;
166}
167
168bool MemberSignature::MemberNameAndTypeMatch(const MemberSignature& other) {
169 return member_name_ == other.member_name_ && type_signature_ == other.type_signature_;
170}
171
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100172#ifdef ART_TARGET_ANDROID
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100173// Convert an AccessMethod enum to a value for logging from the proto enum.
174// This method may look odd (the enum values are current the same), but it
175// prevents coupling the internal enum to the proto enum (which should never
176// be changed) so that we are free to change the internal one if necessary in
177// future.
178inline static int32_t GetEnumValueForLog(AccessMethod access_method) {
179 switch (access_method) {
David Brazdilf50ac102018-10-17 18:00:06 +0100180 case AccessMethod::kNone:
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100181 return android::metricslogger::ACCESS_METHOD_NONE;
David Brazdilf50ac102018-10-17 18:00:06 +0100182 case AccessMethod::kReflection:
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100183 return android::metricslogger::ACCESS_METHOD_REFLECTION;
David Brazdilf50ac102018-10-17 18:00:06 +0100184 case AccessMethod::kJNI:
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100185 return android::metricslogger::ACCESS_METHOD_JNI;
David Brazdilf50ac102018-10-17 18:00:06 +0100186 case AccessMethod::kLinking:
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100187 return android::metricslogger::ACCESS_METHOD_LINKING;
188 default:
189 DCHECK(false);
190 }
191}
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100192#endif
Mathew Inwood73ddda42018-04-03 15:32:32 +0100193
David Brazdilf50ac102018-10-17 18:00:06 +0100194void MemberSignature::LogAccessToEventLog(AccessMethod access_method, bool access_denied) {
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100195#ifdef ART_TARGET_ANDROID
David Brazdilf50ac102018-10-17 18:00:06 +0100196 if (access_method == AccessMethod::kLinking || access_method == AccessMethod::kNone) {
Mathew Inwood73ddda42018-04-03 15:32:32 +0100197 // Linking warnings come from static analysis/compilation of the bytecode
198 // and can contain false positives (i.e. code that is never run). We choose
199 // not to log these in the event log.
Mathew Inwoodf59ca612018-05-03 11:30:01 +0100200 // None does not correspond to actual access, so should also be ignored.
Mathew Inwood73ddda42018-04-03 15:32:32 +0100201 return;
202 }
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100203 ComplexEventLogger log_maker(ACTION_HIDDEN_API_ACCESSED);
204 log_maker.AddTaggedData(FIELD_HIDDEN_API_ACCESS_METHOD, GetEnumValueForLog(access_method));
David Brazdilf50ac102018-10-17 18:00:06 +0100205 if (access_denied) {
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100206 log_maker.AddTaggedData(FIELD_HIDDEN_API_ACCESS_DENIED, 1);
Mathew Inwood73ddda42018-04-03 15:32:32 +0100207 }
Mathew Inwood5bcef172018-05-01 14:40:12 +0100208 const std::string& package_name = Runtime::Current()->GetProcessPackageName();
209 if (!package_name.empty()) {
210 log_maker.SetPackageName(package_name);
211 }
Mathew Inwood2d4d62f2018-04-12 13:56:37 +0100212 std::ostringstream signature_str;
213 Dump(signature_str);
214 log_maker.AddTaggedData(FIELD_HIDDEN_API_SIGNATURE, signature_str.str());
215 log_maker.Record();
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100216#else
217 UNUSED(access_method);
David Brazdilf50ac102018-10-17 18:00:06 +0100218 UNUSED(access_denied);
Nicolas Geoffray8a229072018-05-10 16:34:14 +0100219#endif
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700220}
221
David Brazdilf50ac102018-10-17 18:00:06 +0100222void MemberSignature::NotifyHiddenApiListener(AccessMethod access_method) {
223 if (access_method != AccessMethod::kReflection && access_method != AccessMethod::kJNI) {
224 // We can only up-call into Java during reflection and JNI down-calls.
225 return;
226 }
227
228 Runtime* runtime = Runtime::Current();
229 if (!runtime->IsAotCompiler()) {
230 ScopedObjectAccessUnchecked soa(Thread::Current());
231
232 ScopedLocalRef<jobject> consumer_object(soa.Env(),
233 soa.Env()->GetStaticObjectField(
234 WellKnownClasses::dalvik_system_VMRuntime,
235 WellKnownClasses::dalvik_system_VMRuntime_nonSdkApiUsageConsumer));
236 // If the consumer is non-null, we call back to it to let it know that we
237 // have encountered an API that's in one of our lists.
238 if (consumer_object != nullptr) {
239 std::ostringstream member_signature_str;
240 Dump(member_signature_str);
241
242 ScopedLocalRef<jobject> signature_str(
243 soa.Env(),
244 soa.Env()->NewStringUTF(member_signature_str.str().c_str()));
245
246 // Call through to Consumer.accept(String memberSignature);
247 soa.Env()->CallVoidMethod(consumer_object.get(),
248 WellKnownClasses::java_util_function_Consumer_accept,
249 signature_str.get());
250 }
251 }
252}
253
David Brazdil85865692018-10-30 17:26:20 +0000254static ALWAYS_INLINE bool CanUpdateRuntimeFlags(ArtField*) {
David Brazdil8a6b2f32018-04-26 16:52:11 +0100255 return true;
256}
257
David Brazdil85865692018-10-30 17:26:20 +0000258static ALWAYS_INLINE bool CanUpdateRuntimeFlags(ArtMethod* method) {
David Brazdil8a6b2f32018-04-26 16:52:11 +0100259 return !method->IsIntrinsic();
260}
261
262template<typename T>
263static ALWAYS_INLINE void MaybeWhitelistMember(Runtime* runtime, T* member)
264 REQUIRES_SHARED(Locks::mutator_lock_) {
David Brazdil85865692018-10-30 17:26:20 +0000265 if (CanUpdateRuntimeFlags(member) && runtime->ShouldDedupeHiddenApiWarnings()) {
266 member->SetAccessFlags(member->GetAccessFlags() | kAccPublicApi);
David Brazdil8a6b2f32018-04-26 16:52:11 +0100267 }
268}
269
David Brazdil85865692018-10-30 17:26:20 +0000270static constexpr uint32_t kNoDexFlags = 0u;
271static constexpr uint32_t kInvalidDexFlags = static_cast<uint32_t>(-1);
272
David Brazdil1a658632018-12-01 17:54:26 +0000273static ALWAYS_INLINE uint32_t GetMemberDexIndex(ArtField* field) {
274 return field->GetDexFieldIndex();
David Brazdil85865692018-10-30 17:26:20 +0000275}
276
David Brazdil1a658632018-12-01 17:54:26 +0000277static ALWAYS_INLINE uint32_t GetMemberDexIndex(ArtMethod* method)
278 REQUIRES_SHARED(Locks::mutator_lock_) {
279 // Use the non-obsolete method to avoid DexFile mismatch between
280 // the method index and the declaring class.
281 return method->GetNonObsoleteMethod()->GetDexMethodIndex();
282}
David Brazdil85865692018-10-30 17:26:20 +0000283
David Brazdil1a658632018-12-01 17:54:26 +0000284static void VisitMembers(const DexFile& dex_file,
285 const DexFile::ClassDef& class_def,
286 const std::function<void(const ClassAccessor::Field&)>& fn_visit) {
287 ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true);
288 accessor.VisitFields(fn_visit, fn_visit);
289}
290
291static void VisitMembers(const DexFile& dex_file,
292 const DexFile::ClassDef& class_def,
293 const std::function<void(const ClassAccessor::Method&)>& fn_visit) {
294 ClassAccessor accessor(dex_file, class_def, /* parse_hiddenapi_class_data= */ true);
295 accessor.VisitMethods(fn_visit, fn_visit);
296}
297
298template<typename T>
299uint32_t GetDexFlags(T* member) REQUIRES_SHARED(Locks::mutator_lock_) {
300 static_assert(std::is_same<T, ArtField>::value || std::is_same<T, ArtMethod>::value);
301 using AccessorType = typename std::conditional<std::is_same<T, ArtField>::value,
302 ClassAccessor::Field, ClassAccessor::Method>::type;
303
304 ObjPtr<mirror::Class> declaring_class = member->GetDeclaringClass();
305 if (declaring_class.IsNull()) {
David Brazdil85865692018-10-30 17:26:20 +0000306 return kNoDexFlags;
307 }
308
309 uint32_t flags = kInvalidDexFlags;
David Brazdildcfa89b2018-10-31 11:04:10 +0000310 DCHECK(!AreValidDexFlags(flags));
David Brazdil85865692018-10-30 17:26:20 +0000311
David Brazdil1a658632018-12-01 17:54:26 +0000312 // Check if the declaring class has ClassExt allocated. If it does, check if
313 // the pre-JVMTI redefine dex file has been set to determine if the declaring
314 // class has been JVMTI-redefined.
315 ObjPtr<mirror::ClassExt> ext(declaring_class->GetExtData());
316 const DexFile* original_dex = ext.IsNull() ? nullptr : ext->GetPreRedefineDexFile();
317 if (LIKELY(original_dex == nullptr)) {
318 // Class is not redefined. Find the class def, iterate over its members and
319 // find the entry corresponding to this `member`.
320 const DexFile::ClassDef* class_def = declaring_class->GetClassDef();
321 if (class_def == nullptr) {
322 flags = kNoDexFlags;
323 } else {
324 uint32_t member_index = GetMemberDexIndex(member);
325 auto fn_visit = [&](const AccessorType& dex_member) {
326 if (dex_member.GetIndex() == member_index) {
327 flags = dex_member.GetHiddenapiFlags();
328 }
329 };
330 VisitMembers(declaring_class->GetDexFile(), *class_def, fn_visit);
David Brazdil85865692018-10-30 17:26:20 +0000331 }
David Brazdil1a658632018-12-01 17:54:26 +0000332 } else {
333 // Class was redefined using JVMTI. We have a pointer to the original dex file
334 // and the class def index of this class in that dex file, but the field/method
335 // indices are lost. Iterate over all members of the class def and find the one
336 // corresponding to this `member` by name and type string comparison.
337 // This is obviously very slow, but it is only used when non-exempt code tries
338 // to access a hidden member of a JVMTI-redefined class.
339 uint16_t class_def_idx = ext->GetPreRedefineClassDefIndex();
340 DCHECK_NE(class_def_idx, DexFile::kDexNoIndex16);
341 const DexFile::ClassDef& original_class_def = original_dex->GetClassDef(class_def_idx);
342 MemberSignature member_signature(member);
343 auto fn_visit = [&](const AccessorType& dex_member) {
344 MemberSignature cur_signature(dex_member);
345 if (member_signature.MemberNameAndTypeMatch(cur_signature)) {
346 DCHECK(member_signature.Equals(cur_signature));
347 flags = dex_member.GetHiddenapiFlags();
348 }
349 };
350 VisitMembers(*original_dex, original_class_def, fn_visit);
351 }
David Brazdil85865692018-10-30 17:26:20 +0000352
David Brazdil1a658632018-12-01 17:54:26 +0000353 CHECK_NE(flags, kInvalidDexFlags) << "Could not find hiddenapi flags for "
354 << Dumpable<MemberSignature>(MemberSignature(member));
David Brazdildcfa89b2018-10-31 11:04:10 +0000355 DCHECK(AreValidDexFlags(flags));
David Brazdil85865692018-10-30 17:26:20 +0000356 return flags;
357}
358
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700359template<typename T>
David Brazdilf50ac102018-10-17 18:00:06 +0100360bool ShouldDenyAccessToMemberImpl(T* member,
361 hiddenapi::ApiList api_list,
362 AccessMethod access_method) {
363 DCHECK(member != nullptr);
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700364
365 Runtime* runtime = Runtime::Current();
David Brazdilf50ac102018-10-17 18:00:06 +0100366 EnforcementPolicy policy = runtime->GetHiddenApiEnforcementPolicy();
367
368 const bool deny_access =
369 (policy == EnforcementPolicy::kEnabled) &&
David Brazdil2bb2fbd2018-11-13 18:24:26 +0000370 IsSdkVersionSetAndMoreThan(runtime->GetTargetSdkVersion(),
David Brazdildcfa89b2018-10-31 11:04:10 +0000371 api_list.GetMaxAllowedSdkVersion());
David Brazdilf50ac102018-10-17 18:00:06 +0100372
373 MemberSignature member_signature(member);
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700374
Mathew Inwoodc8ce5f52018-04-05 13:58:55 +0100375 // Check for an exemption first. Exempted APIs are treated as white list.
David Brazdilf50ac102018-10-17 18:00:06 +0100376 if (member_signature.IsExempted(runtime->GetHiddenApiExemptions())) {
377 // Avoid re-examining the exemption list next time.
378 // Note this results in no warning for the member, which seems like what one would expect.
379 // Exemptions effectively adds new members to the whitelist.
380 MaybeWhitelistMember(runtime, member);
381 return false;
382 }
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700383
David Brazdilf50ac102018-10-17 18:00:06 +0100384 if (access_method != AccessMethod::kNone) {
385 // Print a log message with information about this class member access.
386 // We do this if we're about to deny access, or the app is debuggable.
387 if (kLogAllAccesses || deny_access || runtime->IsJavaDebuggable()) {
David Brazdilb8c66192018-04-23 13:51:16 +0100388 member_signature.WarnAboutAccess(access_method, api_list);
Mathew Inwoodc8ce5f52018-04-05 13:58:55 +0100389 }
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700390
David Brazdilf50ac102018-10-17 18:00:06 +0100391 // If there is a StrictMode listener, notify it about this violation.
392 member_signature.NotifyHiddenApiListener(access_method);
393
394 // If event log sampling is enabled, report this violation.
395 if (kIsTargetBuild && !kIsTargetLinux) {
396 uint32_t eventLogSampleRate = runtime->GetHiddenApiEventLogSampleRate();
397 // Assert that RAND_MAX is big enough, to ensure sampling below works as expected.
398 static_assert(RAND_MAX >= 0xffff, "RAND_MAX too small");
399 if (eventLogSampleRate != 0 &&
400 (static_cast<uint32_t>(std::rand()) & 0xffff) < eventLogSampleRate) {
401 member_signature.LogAccessToEventLog(access_method, deny_access);
402 }
403 }
404
405 // If this access was not denied, move the member into whitelist and skip
406 // the warning the next time the member is accessed.
407 if (!deny_access) {
408 MaybeWhitelistMember(runtime, member);
Mathew Inwood73ddda42018-04-03 15:32:32 +0100409 }
410 }
411
David Brazdilf50ac102018-10-17 18:00:06 +0100412 return deny_access;
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700413}
414
415// Need to instantiate this.
David Brazdil1a658632018-12-01 17:54:26 +0000416template uint32_t GetDexFlags<ArtField>(ArtField* member);
417template uint32_t GetDexFlags<ArtMethod>(ArtMethod* member);
David Brazdilf50ac102018-10-17 18:00:06 +0100418template bool ShouldDenyAccessToMemberImpl<ArtField>(ArtField* member,
419 hiddenapi::ApiList api_list,
420 AccessMethod access_method);
421template bool ShouldDenyAccessToMemberImpl<ArtMethod>(ArtMethod* member,
422 hiddenapi::ApiList api_list,
423 AccessMethod access_method);
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700424} // namespace detail
Narayan Kamathe453a8d2018-04-03 15:23:46 +0100425
Andreas Gampe80f5fe52018-03-28 16:23:24 -0700426} // namespace hiddenapi
427} // namespace art