Loading cmds/installd/InstalldNativeService.cpp +20 −9 Original line number Diff line number Diff line Loading @@ -3291,7 +3291,7 @@ binder::Status InstalldNativeService::dexopt( const char* oat_dir = getCStr(outputPath); const char* instruction_set = instructionSet.c_str(); if (oat_dir != nullptr && !createOatDir(packageName, oat_dir, instruction_set).isOk()) { if (oat_dir != nullptr && !createOatDirs(packageName, oat_dir, {instruction_set}).isOk()) { // Can't create oat dir - let dexopt use cache dir. oat_dir = nullptr; } Loading Loading @@ -3499,17 +3499,15 @@ binder::Status InstalldNativeService::restoreconSdkDataLocked( return res; } binder::Status InstalldNativeService::createOatDir(const std::string& packageName, binder::Status InstalldNativeService::createOatDirs(const std::string& packageName, const std::string& oatDir, const std::string& instructionSet) { const std::vector<std::string>& oatSubDirs) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_PACKAGE_NAME(packageName); CHECK_ARGUMENT_PATH(oatDir); LOCK_PACKAGE(); const char* oat_dir = oatDir.c_str(); const char* instruction_set = instructionSet.c_str(); char oat_instr_dir[PKG_PATH_MAX]; if (validate_apk_path(oat_dir)) { return error("Invalid path " + oatDir); Loading @@ -3520,9 +3518,22 @@ binder::Status InstalldNativeService::createOatDir(const std::string& packageNam if (selinux_android_restorecon(oat_dir, 0)) { return error("Failed to restorecon " + oatDir); } snprintf(oat_instr_dir, PKG_PATH_MAX, "%s/%s", oat_dir, instruction_set); if (fs_prepare_dir(oat_instr_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) { return error(StringPrintf("Failed to prepare %s", oat_instr_dir)); for (const std::string& sub_dir : oatSubDirs) { // Create the given sub-directory as well as any nonexistent parent directories. std::filesystem::path current_path(oat_dir); std::filesystem::path sub_path(sub_dir); if (sub_path.is_absolute()) { return error("Invalid oat sub directory " + sub_dir); } for (const std::filesystem::path& component : sub_path) { current_path /= component; std::string path_str = current_path.string(); CHECK_ARGUMENT_PATH(path_str); if (fs_prepare_dir(path_str.c_str(), S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) { return error(StringPrintf("Failed to prepare %s", path_str.c_str())); } } } return ok(); } Loading cmds/installd/InstalldNativeService.h +2 −2 Original line number Diff line number Diff line Loading @@ -170,8 +170,8 @@ public: int32_t flags); binder::Status linkNativeLibraryDirectory(const std::optional<std::string>& uuid, const std::string& packageName, const std::string& nativeLibPath32, int32_t userId); binder::Status createOatDir(const std::string& packageName, const std::string& oatDir, const std::string& instructionSet); binder::Status createOatDirs(const std::string& packageName, const std::string& oatDir, const std::vector<std::string>& oatSubDirs); binder::Status linkFile(const std::string& packageName, const std::string& relativePath, const std::string& fromBase, const std::string& toBase); binder::Status moveAb(const std::string& packageName, const std::string& apkPath, Loading cmds/installd/binder/android/os/IInstalld.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ interface IInstalld { void freeCache(@nullable @utf8InCpp String uuid, long targetFreeBytes, int flags); void linkNativeLibraryDirectory(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, @utf8InCpp String nativeLibPath32, int userId); void createOatDir(@utf8InCpp String packageName, @utf8InCpp String oatDir, @utf8InCpp String instructionSet); void createOatDirs(@utf8InCpp String packageName, @utf8InCpp String oatDir, in @utf8InCpp List<String> oatSubDirs); void linkFile(@utf8InCpp String packageName, @utf8InCpp String relativePath, @utf8InCpp String fromBase, @utf8InCpp String toBase); void moveAb(@utf8InCpp String packageName, @utf8InCpp String apkPath, Loading cmds/installd/tests/installd_dexopt_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -775,7 +775,7 @@ TEST_F(DexoptTest, DexoptPrimaryPublic) { TEST_F(DexoptTest, DexoptPrimaryPublicCreateOatDir) { LOG(INFO) << "DexoptPrimaryPublic"; ASSERT_BINDER_SUCCESS(service_->createOatDir(package_name_, app_oat_dir_, kRuntimeIsa)); ASSERT_BINDER_SUCCESS(service_->createOatDirs(package_name_, app_oat_dir_, {kRuntimeIsa})); CompilePrimaryDexOk("verify", DEXOPT_BOOTCOMPLETE | DEXOPT_PUBLIC, app_oat_dir_.c_str(), Loading libs/binder/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -573,6 +573,15 @@ cc_defaults { }), } cc_defaults { name: "libbinder_fix_double_derefs_flag_default", cflags: select(release_flag("RELEASE_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"), { true: ["-DLIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], false: ["-DNO_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], default: ["-DNO_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], }), } cc_defaults { name: "libbinder_kernel_defaults", defaults: [ Loading @@ -580,6 +589,7 @@ cc_defaults { "libbinder_defer_bc_request_freeze_notification_flag_default", "libbinder_addservice_cache_flag", "libbinder_remove_cache_static_list_flag", "libbinder_fix_double_derefs_flag_default", ], srcs: [ "BufferedTextOutput.cpp", Loading Loading
cmds/installd/InstalldNativeService.cpp +20 −9 Original line number Diff line number Diff line Loading @@ -3291,7 +3291,7 @@ binder::Status InstalldNativeService::dexopt( const char* oat_dir = getCStr(outputPath); const char* instruction_set = instructionSet.c_str(); if (oat_dir != nullptr && !createOatDir(packageName, oat_dir, instruction_set).isOk()) { if (oat_dir != nullptr && !createOatDirs(packageName, oat_dir, {instruction_set}).isOk()) { // Can't create oat dir - let dexopt use cache dir. oat_dir = nullptr; } Loading Loading @@ -3499,17 +3499,15 @@ binder::Status InstalldNativeService::restoreconSdkDataLocked( return res; } binder::Status InstalldNativeService::createOatDir(const std::string& packageName, binder::Status InstalldNativeService::createOatDirs(const std::string& packageName, const std::string& oatDir, const std::string& instructionSet) { const std::vector<std::string>& oatSubDirs) { ENFORCE_UID(AID_SYSTEM); CHECK_ARGUMENT_PACKAGE_NAME(packageName); CHECK_ARGUMENT_PATH(oatDir); LOCK_PACKAGE(); const char* oat_dir = oatDir.c_str(); const char* instruction_set = instructionSet.c_str(); char oat_instr_dir[PKG_PATH_MAX]; if (validate_apk_path(oat_dir)) { return error("Invalid path " + oatDir); Loading @@ -3520,9 +3518,22 @@ binder::Status InstalldNativeService::createOatDir(const std::string& packageNam if (selinux_android_restorecon(oat_dir, 0)) { return error("Failed to restorecon " + oatDir); } snprintf(oat_instr_dir, PKG_PATH_MAX, "%s/%s", oat_dir, instruction_set); if (fs_prepare_dir(oat_instr_dir, S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) { return error(StringPrintf("Failed to prepare %s", oat_instr_dir)); for (const std::string& sub_dir : oatSubDirs) { // Create the given sub-directory as well as any nonexistent parent directories. std::filesystem::path current_path(oat_dir); std::filesystem::path sub_path(sub_dir); if (sub_path.is_absolute()) { return error("Invalid oat sub directory " + sub_dir); } for (const std::filesystem::path& component : sub_path) { current_path /= component; std::string path_str = current_path.string(); CHECK_ARGUMENT_PATH(path_str); if (fs_prepare_dir(path_str.c_str(), S_IRWXU | S_IRWXG | S_IXOTH, AID_SYSTEM, AID_INSTALL)) { return error(StringPrintf("Failed to prepare %s", path_str.c_str())); } } } return ok(); } Loading
cmds/installd/InstalldNativeService.h +2 −2 Original line number Diff line number Diff line Loading @@ -170,8 +170,8 @@ public: int32_t flags); binder::Status linkNativeLibraryDirectory(const std::optional<std::string>& uuid, const std::string& packageName, const std::string& nativeLibPath32, int32_t userId); binder::Status createOatDir(const std::string& packageName, const std::string& oatDir, const std::string& instructionSet); binder::Status createOatDirs(const std::string& packageName, const std::string& oatDir, const std::vector<std::string>& oatSubDirs); binder::Status linkFile(const std::string& packageName, const std::string& relativePath, const std::string& fromBase, const std::string& toBase); binder::Status moveAb(const std::string& packageName, const std::string& apkPath, Loading
cmds/installd/binder/android/os/IInstalld.aidl +2 −2 Original line number Diff line number Diff line Loading @@ -90,8 +90,8 @@ interface IInstalld { void freeCache(@nullable @utf8InCpp String uuid, long targetFreeBytes, int flags); void linkNativeLibraryDirectory(@nullable @utf8InCpp String uuid, @utf8InCpp String packageName, @utf8InCpp String nativeLibPath32, int userId); void createOatDir(@utf8InCpp String packageName, @utf8InCpp String oatDir, @utf8InCpp String instructionSet); void createOatDirs(@utf8InCpp String packageName, @utf8InCpp String oatDir, in @utf8InCpp List<String> oatSubDirs); void linkFile(@utf8InCpp String packageName, @utf8InCpp String relativePath, @utf8InCpp String fromBase, @utf8InCpp String toBase); void moveAb(@utf8InCpp String packageName, @utf8InCpp String apkPath, Loading
cmds/installd/tests/installd_dexopt_test.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -775,7 +775,7 @@ TEST_F(DexoptTest, DexoptPrimaryPublic) { TEST_F(DexoptTest, DexoptPrimaryPublicCreateOatDir) { LOG(INFO) << "DexoptPrimaryPublic"; ASSERT_BINDER_SUCCESS(service_->createOatDir(package_name_, app_oat_dir_, kRuntimeIsa)); ASSERT_BINDER_SUCCESS(service_->createOatDirs(package_name_, app_oat_dir_, {kRuntimeIsa})); CompilePrimaryDexOk("verify", DEXOPT_BOOTCOMPLETE | DEXOPT_PUBLIC, app_oat_dir_.c_str(), Loading
libs/binder/Android.bp +10 −0 Original line number Diff line number Diff line Loading @@ -573,6 +573,15 @@ cc_defaults { }), } cc_defaults { name: "libbinder_fix_double_derefs_flag_default", cflags: select(release_flag("RELEASE_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"), { true: ["-DLIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], false: ["-DNO_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], default: ["-DNO_LIBBINDER_FIX_RECURSIVE_DOUBLE_DEREFS"], }), } cc_defaults { name: "libbinder_kernel_defaults", defaults: [ Loading @@ -580,6 +589,7 @@ cc_defaults { "libbinder_defer_bc_request_freeze_notification_flag_default", "libbinder_addservice_cache_flag", "libbinder_remove_cache_static_list_flag", "libbinder_fix_double_derefs_flag_default", ], srcs: [ "BufferedTextOutput.cpp", Loading