diff options
| -rw-r--r-- | cmdline/cmdline_parser_test.cc | 2 | ||||
| -rw-r--r-- | cmdline/cmdline_types.h | 6 | ||||
| -rw-r--r-- | runtime/Android.bp | 12 | ||||
| -rw-r--r-- | runtime/dexopt_test.cc | 4 | ||||
| -rw-r--r-- | runtime/gc/heap.cc | 4 | ||||
| -rw-r--r-- | runtime/native/dalvik_system_ZygoteHooks.cc | 9 | ||||
| -rw-r--r-- | runtime/native_stack_dump.cc | 12 | ||||
| -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 | ||||
| -rw-r--r-- | runtime/ti/agent.cc | 7 | ||||
| -rwxr-xr-x | test/071-dexfile-get-static-size/build | 12 | ||||
| -rw-r--r-- | test/071-dexfile-get-static-size/res/test1.dex (renamed from test/071-dexfile-get-static-size/test1.dex) | bin | 1864 -> 1864 bytes | |||
| -rw-r--r-- | test/071-dexfile-get-static-size/res/test2.dex (renamed from test/071-dexfile-get-static-size/test2.dex) | bin | 1264 -> 1264 bytes | |||
| -rw-r--r-- | test/071-dexfile-get-static-size/src/Main.java | 20 | ||||
| -rw-r--r-- | test/README.md | 2 | ||||
| -rwxr-xr-x | test/etc/run-test-jar | 9 |
18 files changed, 68 insertions, 50 deletions
diff --git a/cmdline/cmdline_parser_test.cc b/cmdline/cmdline_parser_test.cc index 5d672061df..70cc07eff0 100644 --- a/cmdline/cmdline_parser_test.cc +++ b/cmdline/cmdline_parser_test.cc @@ -375,7 +375,7 @@ TEST_F(CmdlineParserTest, TestJdwpProviderEmpty) { TEST_F(CmdlineParserTest, TestJdwpProviderDefault) { const char* opt_args = "-XjdwpProvider:default"; - EXPECT_SINGLE_PARSE_VALUE(JdwpProvider::kInternal, opt_args, M::JdwpProvider); + EXPECT_SINGLE_PARSE_VALUE(JdwpProvider::kAdbConnection, opt_args, M::JdwpProvider); } // TEST_F TEST_F(CmdlineParserTest, TestJdwpProviderInternal) { diff --git a/cmdline/cmdline_types.h b/cmdline/cmdline_types.h index d0d6bfd3ce..2bc7409bb6 100644 --- a/cmdline/cmdline_types.h +++ b/cmdline/cmdline_types.h @@ -77,10 +77,10 @@ struct CmdlineType<JdwpProvider> : CmdlineTypeParser<JdwpProvider> { "Example: -XjdwpProvider:internal for internal jdwp implementation\n" "Example: -XjdwpProvider:adbconnection for adb connection mediated jdwp implementation\n" "Example: -XjdwpProvider:default for the default jdwp implementation" - " (currently internal)\n"); - } else if (option == "internal" || option == "default") { + " (currently adbconnection)\n"); + } else if (option == "internal") { return Result::Success(JdwpProvider::kInternal); - } else if (option == "adbconnection") { + } else if (option == "adbconnection" || option == "default") { return Result::Success(JdwpProvider::kAdbConnection); } else if (option == "none") { return Result::Success(JdwpProvider::kNone); diff --git a/runtime/Android.bp b/runtime/Android.bp index e30a06c0a5..07764b8151 100644 --- a/runtime/Android.bp +++ b/runtime/Android.bp @@ -67,8 +67,13 @@ cc_defaults { "liblog", // For common macros. "libbase", + "libz", ], - export_include_dirs: ["."], + + // Exporting "." would shadow the system elf.h with our elf.h, + // which in turn breaks any tools that reference this library. + // export_include_dirs: ["."], + // ART's macros.h depends on libbase's macros.h. // Note: runtime_options.h depends on cmdline. But we don't really want to export this // generically. dex2oat takes care of it itself. @@ -78,11 +83,6 @@ cc_defaults { art_cc_library { name: "libdexfile", defaults: ["libdexfile_defaults"], - vendor_available: true, - vndk: { - enabled: true, - support_system_process: true, - }, // Leave the symbols in the shared library so that stack unwinders can // produce meaningful name resolution. strip: { diff --git a/runtime/dexopt_test.cc b/runtime/dexopt_test.cc index d93d76793f..037d1fb49c 100644 --- a/runtime/dexopt_test.cc +++ b/runtime/dexopt_test.cc @@ -213,8 +213,8 @@ void DexoptTest::ReserveImageSpace() { // Ensure a chunk of memory is reserved for the image space. // The reservation_end includes room for the main space that has to come // right after the image in case of the GSS collector. - uintptr_t reservation_start = ART_BASE_ADDRESS; - uintptr_t reservation_end = ART_BASE_ADDRESS + 384 * MB; + uint64_t reservation_start = ART_BASE_ADDRESS; + uint64_t reservation_end = ART_BASE_ADDRESS + 384 * MB; std::unique_ptr<BacktraceMap> map(BacktraceMap::Create(getpid(), true)); ASSERT_TRUE(map.get() != nullptr) << "Failed to build process map"; diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc index 6da092c365..b1932d1a29 100644 --- a/runtime/gc/heap.cc +++ b/runtime/gc/heap.cc @@ -3484,10 +3484,8 @@ void Heap::GrowForUtilization(collector::GarbageCollector* collector_ran, const uint64_t bytes_allocated_during_gc = bytes_allocated + freed_bytes - bytes_allocated_before_gc; // Calculate when to perform the next ConcurrentGC. - // Calculate the estimated GC duration. - const double gc_duration_seconds = NsToMs(current_gc_iteration_.GetDurationNs()) / 1000.0; // Estimate how many remaining bytes we will have when we need to start the next GC. - size_t remaining_bytes = bytes_allocated_during_gc * gc_duration_seconds; + size_t remaining_bytes = bytes_allocated_during_gc; remaining_bytes = std::min(remaining_bytes, kMaxConcurrentRemainingBytes); remaining_bytes = std::max(remaining_bytes, kMinConcurrentRemainingBytes); if (UNLIKELY(remaining_bytes > max_allowed_footprint_)) { 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/native_stack_dump.cc b/runtime/native_stack_dump.cc index fa46709422..2fef70b2ae 100644 --- a/runtime/native_stack_dump.cc +++ b/runtime/native_stack_dump.cc @@ -333,15 +333,15 @@ void DumpNativeStack(std::ostream& os, os << prefix << StringPrintf("#%02zu pc ", it->num); bool try_addr2line = false; if (!BacktraceMap::IsValid(it->map)) { - os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR " ???" - : "%08" PRIxPTR " ???", + os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIx64 " ???" + : "%08" PRIx64 " ???", it->pc); } else { - os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIxPTR " " - : "%08" PRIxPTR " ", + os << StringPrintf(Is64BitInstructionSet(kRuntimeISA) ? "%016" PRIx64 " " + : "%08" PRIx64 " ", it->rel_pc); if (it->map.name.empty()) { - os << StringPrintf("<anonymous:%" PRIxPTR ">", it->map.start); + os << StringPrintf("<anonymous:%" PRIx64 ">", it->map.start); } else { os << it->map.name; } @@ -361,7 +361,7 @@ void DumpNativeStack(std::ostream& os, PcIsWithinQuickCode(current_method, it->pc)) { const void* start_of_code = current_method->GetEntryPointFromQuickCompiledCode(); os << current_method->JniLongName() << "+" - << (it->pc - reinterpret_cast<uintptr_t>(start_of_code)); + << (it->pc - reinterpret_cast<uint64_t>(start_of_code)); } else { os << "???"; } 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) diff --git a/runtime/ti/agent.cc b/runtime/ti/agent.cc index 62bdde6790..15c514e593 100644 --- a/runtime/ti/agent.cc +++ b/runtime/ti/agent.cc @@ -117,15 +117,18 @@ std::unique_ptr<Agent> AgentSpec::DoDlOpen(JNIEnv* env, : JavaVMExt::GetLibrarySearchPath(env, class_loader)); bool needs_native_bridge = false; + std::string nativeloader_error_msg; void* dlopen_handle = android::OpenNativeLibrary(env, Runtime::Current()->GetTargetSdkVersion(), name_.c_str(), class_loader, library_path.get(), &needs_native_bridge, - error_msg); + &nativeloader_error_msg); if (dlopen_handle == nullptr) { - *error_msg = StringPrintf("Unable to dlopen %s: %s", name_.c_str(), dlerror()); + *error_msg = StringPrintf("Unable to dlopen %s: %s", + name_.c_str(), + nativeloader_error_msg.c_str()); *error = kLoadingError; return nullptr; } diff --git a/test/071-dexfile-get-static-size/build b/test/071-dexfile-get-static-size/build index 0bba66d065..412ee6dd46 100755 --- a/test/071-dexfile-get-static-size/build +++ b/test/071-dexfile-get-static-size/build @@ -16,15 +16,13 @@ ./default-build "$@" -# Create and add as resources to the test jar file: +# Bundle with the test the following resources: # 1. test1.dex # 2. test2.dex # 3. test-jar.jar, containing test1.dex as classes.dex # 4. multi-jar.jar, containing test1.dex as classes.dex and test2.dex as classes2.dex mkdir test-jar -cp test1.dex test-jar/classes.dex -cp test2.dex test-jar/classes2.dex -zip -j test-jar.jar test-jar/classes.dex -zip -j multi-jar.jar test-jar/classes.dex test-jar/classes2.dex -jar uf ${TEST_NAME}.jar test1.dex test2.dex test-jar.jar multi-jar.jar - +cp res/test1.dex test-jar/classes.dex +cp res/test2.dex test-jar/classes2.dex +zip -j res/test-jar.jar test-jar/classes.dex +zip -j res/multi-jar.jar test-jar/classes.dex test-jar/classes2.dex diff --git a/test/071-dexfile-get-static-size/test1.dex b/test/071-dexfile-get-static-size/res/test1.dex Binary files differindex 84602d03c2..84602d03c2 100644 --- a/test/071-dexfile-get-static-size/test1.dex +++ b/test/071-dexfile-get-static-size/res/test1.dex diff --git a/test/071-dexfile-get-static-size/test2.dex b/test/071-dexfile-get-static-size/res/test2.dex Binary files differindex a07c46ef59..a07c46ef59 100644 --- a/test/071-dexfile-get-static-size/test2.dex +++ b/test/071-dexfile-get-static-size/res/test2.dex diff --git a/test/071-dexfile-get-static-size/src/Main.java b/test/071-dexfile-get-static-size/src/Main.java index 4bf453801e..8dbbba56c3 100644 --- a/test/071-dexfile-get-static-size/src/Main.java +++ b/test/071-dexfile-get-static-size/src/Main.java @@ -14,26 +14,9 @@ * limitations under the License. */ -import java.io.InputStream; -import java.io.OutputStream; -import java.io.FileOutputStream; -import java.lang.reflect.Constructor; import java.lang.reflect.Method; public class Main { - private static void extractResource(String resource, String filename) throws Exception { - ClassLoader loader = Main.class.getClassLoader(); - InputStream is = loader.getResourceAsStream(resource); - OutputStream os = new FileOutputStream(filename); - int read; - byte[] buf = new byte[4096]; - while ((read = is.read(buf)) >= 0) { - os.write(buf, 0, read); - } - is.close(); - os.close(); - } - private static long getDexFileSize(String filename) throws Exception { ClassLoader loader = Main.class.getClassLoader(); Class<?> DexFile = loader.loadClass("dalvik.system.DexFile"); @@ -47,8 +30,7 @@ public class Main { } private static void test(String resource) throws Exception { - String filename = System.getenv("DEX_LOCATION") + "/" + resource; - extractResource(resource, filename); + String filename = System.getenv("DEX_LOCATION") + "/res/" + resource; long size = getDexFileSize(filename); System.out.println("Size for " + resource + ": " + size); } diff --git a/test/README.md b/test/README.md index c68b40b135..350350e9e6 100644 --- a/test/README.md +++ b/test/README.md @@ -9,6 +9,8 @@ directory are compiled separately but to the same output directory; this can be used to exercise "API mismatch" situations by replacing class files created in the first pass. The "src-ex" directory is built separately, and is intended for exercising class loaders. +Resources can be stored in the "res" directory, which is distributed +together with the executable files. The gtests are in named directories and contain a .java source file. diff --git a/test/etc/run-test-jar b/test/etc/run-test-jar index 631b14afc8..5e40b86aa0 100755 --- a/test/etc/run-test-jar +++ b/test/etc/run-test-jar @@ -806,6 +806,10 @@ if [ "$HOST" = "n" ]; then if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then adb push profile $DEX_LOCATION fi + # Copy resource folder + if [ -d res ]; then + adb push res $DEX_LOCATION + fi else adb shell rm -r $DEX_LOCATION >/dev/null 2>&1 adb shell mkdir -p $DEX_LOCATION >/dev/null 2>&1 @@ -814,7 +818,10 @@ if [ "$HOST" = "n" ]; then if [ "$PROFILE" = "y" ] || [ "$RANDOM_PROFILE" = "y" ]; then adb push profile $DEX_LOCATION >/dev/null 2>&1 fi - + # Copy resource folder + if [ -d res ]; then + adb push res $DEX_LOCATION >/dev/null 2>&1 + fi fi LD_LIBRARY_PATH=/data/$TEST_DIRECTORY/art/$ISA |