// This code goes into libarttest(d).so, which means: // - It's in the com_android_art linker namespace and has full access to ART internals. // - It's under /apex/com.android.art, so hiddenapi classifies it as // core-platform domain.
// Should be the same as dalvik.system.VMRuntime.PREVENT_META_REFLECTION_BLOCKLIST_ACCESS static constexpr uint64_t kPreventMetaReflectionBlocklistAccess = 142365358;
// The JNI entrypoints below end up in libarttest(d).so, but for the native // methods in src-ex (Java_ChildClass_* and Java_Reflection_*) the test makes // copies of libarttest(d)_external.so and loads them instead. Those libs have // DT_NEEDED dependencies on libarttest(d).so, so its exported symbols become // visible directly in them too. Hence we don't need to create wrappers for them // in libarttest(d)_external.so.
extern"C" JNIEXPORT void JNICALL
Java_Main_addDefaultNamespaceLibsLinkToSystemLinkerNamespace(JNIEnv*, jclass) { #ifdef ART_TARGET_ANDROID constchar* links = getenv("NATIVELOADER_DEFAULT_NAMESPACE_LIBS"); if (links == nullptr || *links == 0) {
LOG(FATAL) << "Expected NATIVELOADER_DEFAULT_NAMESPACE_LIBS to be set";
} struct android_namespace_t* system_ns = android_get_exported_namespace("system"); if (system_ns == nullptr) {
LOG(FATAL) << "Failed to retrieve system namespace";
} if (!android_link_namespaces(system_ns, nullptr, links)) {
LOG(FATAL) << "Error adding linker namespace link from system to default for " << links << ": "
<< dlerror();
} #endif
}
// Note that this method is used by several hiddenapi-related run tests. extern"C" JNIEXPORT void JNICALL Java_Main_init(JNIEnv* env, jclass) {
Runtime* runtime = Runtime::Current();
runtime->SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled);
runtime->SetCorePlatformApiEnforcementPolicy(hiddenapi::EnforcementPolicy::kEnabled);
runtime->SetDedupeHiddenApiWarnings(false);
// Set targetSdkVersion through the Java method, to get the same setting in // both the Java and native instances.
ScopedLocalRef<jclass> runtime_class(env, env->FindClass("dalvik/system/VMRuntime"));
CHECK_NE(runtime_class.get(), nullptr);
jmethodID get_runtime =
env->GetStaticMethodID(runtime_class.get(), "getRuntime", "()Ldalvik/system/VMRuntime;");
CHECK_NE(get_runtime, nullptr);
ScopedLocalRef<jobject> runtime_obj(
env, env->CallStaticObjectMethod(runtime_class.get(), get_runtime));
CHECK_NE(runtime_obj.get(), nullptr);
jmethodID set_target_sdk_version =
env->GetMethodID(runtime_class.get(), "setTargetSdkVersion", "(I)V");
CHECK_NE(set_target_sdk_version, nullptr);
uint32_t target_sdk_version = static_cast<uint32_t>(hiddenapi::ApiList::MaxTargetO().GetMaxAllowedSdkVersion());
env->CallVoidMethod(runtime_obj.get(), set_target_sdk_version, target_sdk_version);
}
extern"C" JNIEXPORT void JNICALL Java_Reflection_setHiddenApiCheckHardening(JNIEnv*,
jclass,
jboolean value) {
CompatFramework& compat_framework = Runtime::Current()->GetCompatFramework();
std::set<uint64_t> disabled_changes = compat_framework.GetDisabledCompatChanges(); if (value == JNI_TRUE) { // If hidden api check hardening is enabled, remove it from the set of disabled changes.
disabled_changes.erase(kPreventMetaReflectionBlocklistAccess);
} else { // If hidden api check hardening is disabled, add it to the set of disabled changes.
disabled_changes.insert(kPreventMetaReflectionBlocklistAccess);
}
compat_framework.SetDisabledCompatChanges(disabled_changes);
}
} // namespace Test674HiddenApi
} // namespace art
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.11 Sekunden
(vorverarbeitet am 2026-06-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.