diff options
author | 2018-01-20 20:08:54 +0000 | |
---|---|---|
committer | 2018-01-20 20:08:54 +0000 | |
commit | e57043081e6b091a9fd23a84043373148ae72f1f (patch) | |
tree | 7e4affc0b98ab6006da335465c9ee184c820ef58 | |
parent | b98747c267b9c7abee60dd95e1341d9138b4e5c6 (diff) | |
parent | c5e5aedab28e74416fcee4f55fab6d5807363471 (diff) |
Merge changes I485051ab,I8bd5b7ef
* changes:
Add DISABLE_HIDDEN_API_CHECKS flag to ZygoteHooks
Add runtime option for no hidden API access checks
-rw-r--r-- | runtime/native/dalvik_system_ZygoteHooks.cc | 9 | ||||
-rw-r--r-- | runtime/parsed_options.cc | 2 | ||||
-rw-r--r-- | runtime/runtime.cc | 5 | ||||
-rw-r--r-- | runtime/runtime.h | 11 | ||||
-rw-r--r-- | runtime/runtime_options.def | 1 |
5 files changed, 28 insertions, 0 deletions
diff --git a/runtime/native/dalvik_system_ZygoteHooks.cc b/runtime/native/dalvik_system_ZygoteHooks.cc index fd80aaeaf7..e22726b79b 100644 --- a/runtime/native/dalvik_system_ZygoteHooks.cc +++ b/runtime/native/dalvik_system_ZygoteHooks.cc @@ -173,6 +173,7 @@ enum { DEBUG_JAVA_DEBUGGABLE = 1 << 8, DISABLE_VERIFIER = 1 << 9, ONLY_USE_SYSTEM_OAT_FILES = 1 << 10, + DISABLE_HIDDEN_API_CHECKS = 1 << 11, }; static uint32_t EnableDebugFeatures(uint32_t runtime_flags) { @@ -284,6 +285,11 @@ static void ZygoteHooks_nativePostForkChild(JNIEnv* env, runtime_flags &= ~ONLY_USE_SYSTEM_OAT_FILES; } + if ((runtime_flags & DISABLE_HIDDEN_API_CHECKS) != 0) { + Runtime::Current()->DisableHiddenApiChecks(); + runtime_flags &= ~DISABLE_HIDDEN_API_CHECKS; + } + if (runtime_flags != 0) { LOG(ERROR) << StringPrintf("Unknown bits set in runtime_flags: %#x", runtime_flags); } @@ -331,6 +337,9 @@ static void ZygoteHooks_nativePostForkChild(JNIEnv* env, } } + DCHECK(!is_system_server || !Runtime::Current()->AreHiddenApiChecksEnabled()) + << "SystemServer should be forked with DISABLE_HIDDEN_API_CHECKS"; + if (instruction_set != nullptr && !is_system_server) { ScopedUtfChars isa_string(env, instruction_set); InstructionSet isa = GetInstructionSetFromString(isa_string.c_str()); diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index 2f60162c77..92eb703338 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -330,6 +330,8 @@ std::unique_ptr<RuntimeParser> ParsedOptions::MakeParser(bool ignore_unrecognize .Define("-Xtarget-sdk-version:_") .WithType<int>() .IntoKey(M::TargetSdkVersion) + .Define("-Xno-hidden-api-checks") + .IntoKey(M::NoHiddenApiChecks) .Ignore({ "-ea", "-da", "-enableassertions", "-disableassertions", "--runtime-arg", "-esa", "-dsa", "-enablesystemassertions", "-disablesystemassertions", "-Xrs", "-Xint:_", diff --git a/runtime/runtime.cc b/runtime/runtime.cc index 007d361976..33bebe0887 100644 --- a/runtime/runtime.cc +++ b/runtime/runtime.cc @@ -265,6 +265,7 @@ Runtime::Runtime() oat_file_manager_(nullptr), is_low_memory_mode_(false), safe_mode_(false), + do_hidden_api_checks_(false), dump_native_stack_on_sig_quit_(true), pruned_dalvik_cache_(false), // Initially assume we perceive jank in case the process state is never updated. @@ -1168,6 +1169,10 @@ bool Runtime::Init(RuntimeArgumentMap&& runtime_options_in) { target_sdk_version_ = runtime_options.GetOrDefault(Opt::TargetSdkVersion); + if (runtime_options.Exists(Opt::NoHiddenApiChecks)) { + do_hidden_api_checks_ = false; + } + no_sig_chain_ = runtime_options.Exists(Opt::NoSigChain); force_native_bridge_ = runtime_options.Exists(Opt::ForceNativeBridge); diff --git a/runtime/runtime.h b/runtime/runtime.h index 6d2887cc42..022a1be124 100644 --- a/runtime/runtime.h +++ b/runtime/runtime.h @@ -520,6 +520,14 @@ class Runtime { bool IsVerificationEnabled() const; bool IsVerificationSoftFail() const; + void DisableHiddenApiChecks() { + do_hidden_api_checks_ = false; + } + + bool AreHiddenApiChecksEnabled() const { + return do_hidden_api_checks_; + } + bool IsDexFileFallbackEnabled() const { return allow_dex_file_fallback_; } @@ -957,6 +965,9 @@ class Runtime { // Whether the application should run in safe mode, that is, interpreter only. bool safe_mode_; + // Whether access checks on hidden API should be performed. + bool do_hidden_api_checks_; + // Whether threads should dump their native stack on SIGQUIT. bool dump_native_stack_on_sig_quit_; diff --git a/runtime/runtime_options.def b/runtime/runtime_options.def index 3996989920..6e1a68b07d 100644 --- a/runtime/runtime_options.def +++ b/runtime/runtime_options.def @@ -119,6 +119,7 @@ RUNTIME_OPTIONS_KEY (std::vector<std::string>, \ RUNTIME_OPTIONS_KEY (verifier::VerifyMode, \ Verify, verifier::VerifyMode::kEnable) RUNTIME_OPTIONS_KEY (int, TargetSdkVersion, Runtime::kUnsetSdkVersion) +RUNTIME_OPTIONS_KEY (Unit, NoHiddenApiChecks) RUNTIME_OPTIONS_KEY (std::string, NativeBridge) RUNTIME_OPTIONS_KEY (unsigned int, ZygoteMaxFailedBoots, 10) RUNTIME_OPTIONS_KEY (Unit, NoDexFileFallback) |