Loading cmds/installd/dexopt.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd const char* instruction_set, const char* compiler_filter, bool debuggable, bool post_bootcomplete, bool background_job_compile, int profile_fd, const char* class_loader_context, int target_sdk_version, bool enable_hidden_api_checks, int dex_metadata_fd, const char* compilation_reason) { bool generate_compact_dex, int dex_metadata_fd, const char* compilation_reason) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) { Loading Loading @@ -438,9 +438,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd // Disable cdex if update input vdex is true since this combination of options is not // supported. // Disable cdex for non-background compiles since we don't want to regress app install until // there are enough benefits to justify the tradeoff. const bool disable_cdex = !background_job_compile || (input_vdex_fd == output_vdex_fd); const bool disable_cdex = !generate_compact_dex || (input_vdex_fd == output_vdex_fd); const char* argv[9 // program name, mandatory arguments and the final NULL + (have_dex2oat_isa_variant ? 1 : 0) Loading Loading @@ -1960,6 +1958,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins bool is_secondary_dex = (dexopt_flags & DEXOPT_SECONDARY_DEX) != 0; bool background_job_compile = (dexopt_flags & DEXOPT_IDLE_BACKGROUND_JOB) != 0; bool enable_hidden_api_checks = (dexopt_flags & DEXOPT_ENABLE_HIDDEN_API_CHECKS) != 0; bool generate_compact_dex = (dexopt_flags & DEXOPT_GENERATE_COMPACT_DEX) != 0; // Check if we're dealing with a secondary dex file and if we need to compile it. std::string oat_dir_str; Loading Loading @@ -2073,6 +2072,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins class_loader_context, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, dex_metadata_fd.get(), compilation_reason); } else { Loading cmds/installd/installd_constants.h +3 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ constexpr int DEXOPT_STORAGE_DE = 1 << 8; // controls whether extra debugging flags can be used (taking more compile time.) constexpr int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9; constexpr int DEXOPT_ENABLE_HIDDEN_API_CHECKS = 1 << 10; constexpr int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11; /* all known values for dexopt flags */ constexpr int DEXOPT_MASK = Loading @@ -65,7 +66,8 @@ constexpr int DEXOPT_MASK = | DEXOPT_STORAGE_CE | DEXOPT_STORAGE_DE | DEXOPT_IDLE_BACKGROUND_JOB | DEXOPT_ENABLE_HIDDEN_API_CHECKS; | DEXOPT_ENABLE_HIDDEN_API_CHECKS | DEXOPT_GENERATE_COMPACT_DEX; // NOTE: keep in sync with StorageManager constexpr int FLAG_STORAGE_DE = 1 << 0; Loading cmds/installd/otapreopt.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ static_assert(DEXOPT_STORAGE_CE == 1 << 7, "DEXOPT_STORAGE_CE unexpected."); static_assert(DEXOPT_STORAGE_DE == 1 << 8, "DEXOPT_STORAGE_DE unexpected."); static_assert(DEXOPT_ENABLE_HIDDEN_API_CHECKS == 1 << 10, "DEXOPT_ENABLE_HIDDEN_API_CHECKS unexpected"); static_assert(DEXOPT_GENERATE_COMPACT_DEX == 1 << 11, "DEXOPT_GENERATE_COMPACT_DEX unexpected"); static_assert(DEXOPT_MASK == (0x5fe | DEXOPT_IDLE_BACKGROUND_JOB), static_assert(DEXOPT_MASK == (0xdfe | DEXOPT_IDLE_BACKGROUND_JOB), "DEXOPT_MASK unexpected."); Loading cmds/installd/otapreopt_parameters.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ void OTAPreoptParameters::SetDefaultsForPostV1Arguments() { // The compilation reason is ab-ota (match the system property pm.dexopt.ab-ota) compilation_reason = "ab-ota"; // Flag is enabled by default for A/B otas. dexopt_flags = DEXOPT_GENERATE_COMPACT_DEX; } bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { Loading @@ -146,6 +149,8 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { return false; } SetDefaultsForPostV1Arguments(); size_t param_index = 0; for (;; ++param_index) { const char* param = argv[3 + param_index]; Loading Loading @@ -193,8 +198,9 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { constexpr int OLD_DEXOPT_BOOTCOMPLETE = 1 << 4; constexpr int OLD_DEXOPT_PROFILE_GUIDED = 1 << 5; constexpr int OLD_DEXOPT_OTA = 1 << 6; static_assert(DEXOPT_GENERATE_COMPACT_DEX > OLD_DEXOPT_OTA, "must not overlap"); int input = atoi(param); dexopt_flags = dexopt_flags |= ReplaceMask(input, OLD_DEXOPT_PUBLIC, DEXOPT_PUBLIC) | ReplaceMask(input, OLD_DEXOPT_DEBUGGABLE, DEXOPT_DEBUGGABLE) | ReplaceMask(input, OLD_DEXOPT_BOOTCOMPLETE, DEXOPT_BOOTCOMPLETE) | Loading Loading @@ -226,8 +232,6 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { return false; } SetDefaultsForPostV1Arguments(); return true; } Loading @@ -239,7 +243,9 @@ bool OTAPreoptParameters::ReadArgumentsPostV1(uint32_t version, const char** arg case 4: num_args_expected = 13; break; case 5: num_args_expected = 14; break; case 6: num_args_expected = 15; break; case 7: num_args_expected = 16; break; case 7: // Version 8 adds a new dexopt flag: DEXOPT_GENERATE_COMPACT_DEX case 8: num_args_expected = 16; break; default: LOG(ERROR) << "Don't know how to read arguments for version " << version; return false; Loading Loading @@ -302,6 +308,10 @@ bool OTAPreoptParameters::ReadArgumentsPostV1(uint32_t version, const char** arg case 6: dexopt_flags = atoi(param); // Add CompactDex generation flag for versions less than 8 since it wasn't passed // from the package manager. Only conditionally set the flag here so that it can // be fully controlled by the package manager. dexopt_flags |= (version < 8) ? DEXOPT_GENERATE_COMPACT_DEX : 0u; break; case 7: Loading cmds/installd/tests/installd_otapreopt_test.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <android-base/logging.h> #include <gtest/gtest.h> #include "installd_constants.h" #include "otapreopt_parameters.h" namespace android { Loading Loading @@ -61,7 +62,7 @@ protected: ASSERT_STREQ(params.instruction_set, args[i++]); ASSERT_EQ(params.dexopt_needed, atoi(args[i++])); ASSERT_STREQ(params.oat_dir, args[i++]); ASSERT_EQ(params.dexopt_flags, atoi(args[i++])); const int dexopt_flags = atoi(args[i++]); ASSERT_STREQ(params.compiler_filter, args[i++]); ASSERT_STREQ(params.volume_uuid, ParseNull(args[i++])); ASSERT_STREQ(params.shared_libraries, ParseNull(args[i++])); Loading Loading @@ -95,6 +96,11 @@ protected: } else { ASSERT_STREQ(params.compilation_reason, "ab-ota"); } if (version > 7) { ASSERT_EQ(params.dexopt_flags, dexopt_flags); } else { ASSERT_EQ(params.dexopt_flags, dexopt_flags | DEXOPT_GENERATE_COMPACT_DEX); } } const char* getVersionCStr(uint32_t version) { Loading @@ -106,6 +112,7 @@ protected: case 5: return "5"; case 6: return "6"; case 7: return "7"; case 8: return "8"; } return nullptr; } Loading Loading
cmds/installd/dexopt.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd const char* instruction_set, const char* compiler_filter, bool debuggable, bool post_bootcomplete, bool background_job_compile, int profile_fd, const char* class_loader_context, int target_sdk_version, bool enable_hidden_api_checks, int dex_metadata_fd, const char* compilation_reason) { bool generate_compact_dex, int dex_metadata_fd, const char* compilation_reason) { static const unsigned int MAX_INSTRUCTION_SET_LEN = 7; if (strlen(instruction_set) >= MAX_INSTRUCTION_SET_LEN) { Loading Loading @@ -438,9 +438,7 @@ static void run_dex2oat(int zip_fd, int oat_fd, int input_vdex_fd, int output_vd // Disable cdex if update input vdex is true since this combination of options is not // supported. // Disable cdex for non-background compiles since we don't want to regress app install until // there are enough benefits to justify the tradeoff. const bool disable_cdex = !background_job_compile || (input_vdex_fd == output_vdex_fd); const bool disable_cdex = !generate_compact_dex || (input_vdex_fd == output_vdex_fd); const char* argv[9 // program name, mandatory arguments and the final NULL + (have_dex2oat_isa_variant ? 1 : 0) Loading Loading @@ -1960,6 +1958,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins bool is_secondary_dex = (dexopt_flags & DEXOPT_SECONDARY_DEX) != 0; bool background_job_compile = (dexopt_flags & DEXOPT_IDLE_BACKGROUND_JOB) != 0; bool enable_hidden_api_checks = (dexopt_flags & DEXOPT_ENABLE_HIDDEN_API_CHECKS) != 0; bool generate_compact_dex = (dexopt_flags & DEXOPT_GENERATE_COMPACT_DEX) != 0; // Check if we're dealing with a secondary dex file and if we need to compile it. std::string oat_dir_str; Loading Loading @@ -2073,6 +2072,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins class_loader_context, target_sdk_version, enable_hidden_api_checks, generate_compact_dex, dex_metadata_fd.get(), compilation_reason); } else { Loading
cmds/installd/installd_constants.h +3 −1 Original line number Diff line number Diff line Loading @@ -53,6 +53,7 @@ constexpr int DEXOPT_STORAGE_DE = 1 << 8; // controls whether extra debugging flags can be used (taking more compile time.) constexpr int DEXOPT_IDLE_BACKGROUND_JOB = 1 << 9; constexpr int DEXOPT_ENABLE_HIDDEN_API_CHECKS = 1 << 10; constexpr int DEXOPT_GENERATE_COMPACT_DEX = 1 << 11; /* all known values for dexopt flags */ constexpr int DEXOPT_MASK = Loading @@ -65,7 +66,8 @@ constexpr int DEXOPT_MASK = | DEXOPT_STORAGE_CE | DEXOPT_STORAGE_DE | DEXOPT_IDLE_BACKGROUND_JOB | DEXOPT_ENABLE_HIDDEN_API_CHECKS; | DEXOPT_ENABLE_HIDDEN_API_CHECKS | DEXOPT_GENERATE_COMPACT_DEX; // NOTE: keep in sync with StorageManager constexpr int FLAG_STORAGE_DE = 1 << 0; Loading
cmds/installd/otapreopt.cpp +2 −1 Original line number Diff line number Diff line Loading @@ -81,8 +81,9 @@ static_assert(DEXOPT_STORAGE_CE == 1 << 7, "DEXOPT_STORAGE_CE unexpected."); static_assert(DEXOPT_STORAGE_DE == 1 << 8, "DEXOPT_STORAGE_DE unexpected."); static_assert(DEXOPT_ENABLE_HIDDEN_API_CHECKS == 1 << 10, "DEXOPT_ENABLE_HIDDEN_API_CHECKS unexpected"); static_assert(DEXOPT_GENERATE_COMPACT_DEX == 1 << 11, "DEXOPT_GENERATE_COMPACT_DEX unexpected"); static_assert(DEXOPT_MASK == (0x5fe | DEXOPT_IDLE_BACKGROUND_JOB), static_assert(DEXOPT_MASK == (0xdfe | DEXOPT_IDLE_BACKGROUND_JOB), "DEXOPT_MASK unexpected."); Loading
cmds/installd/otapreopt_parameters.cpp +14 −4 Original line number Diff line number Diff line Loading @@ -133,6 +133,9 @@ void OTAPreoptParameters::SetDefaultsForPostV1Arguments() { // The compilation reason is ab-ota (match the system property pm.dexopt.ab-ota) compilation_reason = "ab-ota"; // Flag is enabled by default for A/B otas. dexopt_flags = DEXOPT_GENERATE_COMPACT_DEX; } bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { Loading @@ -146,6 +149,8 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { return false; } SetDefaultsForPostV1Arguments(); size_t param_index = 0; for (;; ++param_index) { const char* param = argv[3 + param_index]; Loading Loading @@ -193,8 +198,9 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { constexpr int OLD_DEXOPT_BOOTCOMPLETE = 1 << 4; constexpr int OLD_DEXOPT_PROFILE_GUIDED = 1 << 5; constexpr int OLD_DEXOPT_OTA = 1 << 6; static_assert(DEXOPT_GENERATE_COMPACT_DEX > OLD_DEXOPT_OTA, "must not overlap"); int input = atoi(param); dexopt_flags = dexopt_flags |= ReplaceMask(input, OLD_DEXOPT_PUBLIC, DEXOPT_PUBLIC) | ReplaceMask(input, OLD_DEXOPT_DEBUGGABLE, DEXOPT_DEBUGGABLE) | ReplaceMask(input, OLD_DEXOPT_BOOTCOMPLETE, DEXOPT_BOOTCOMPLETE) | Loading Loading @@ -226,8 +232,6 @@ bool OTAPreoptParameters::ReadArgumentsV1(const char** argv) { return false; } SetDefaultsForPostV1Arguments(); return true; } Loading @@ -239,7 +243,9 @@ bool OTAPreoptParameters::ReadArgumentsPostV1(uint32_t version, const char** arg case 4: num_args_expected = 13; break; case 5: num_args_expected = 14; break; case 6: num_args_expected = 15; break; case 7: num_args_expected = 16; break; case 7: // Version 8 adds a new dexopt flag: DEXOPT_GENERATE_COMPACT_DEX case 8: num_args_expected = 16; break; default: LOG(ERROR) << "Don't know how to read arguments for version " << version; return false; Loading Loading @@ -302,6 +308,10 @@ bool OTAPreoptParameters::ReadArgumentsPostV1(uint32_t version, const char** arg case 6: dexopt_flags = atoi(param); // Add CompactDex generation flag for versions less than 8 since it wasn't passed // from the package manager. Only conditionally set the flag here so that it can // be fully controlled by the package manager. dexopt_flags |= (version < 8) ? DEXOPT_GENERATE_COMPACT_DEX : 0u; break; case 7: Loading
cmds/installd/tests/installd_otapreopt_test.cpp +9 −2 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <android-base/logging.h> #include <gtest/gtest.h> #include "installd_constants.h" #include "otapreopt_parameters.h" namespace android { Loading Loading @@ -61,7 +62,7 @@ protected: ASSERT_STREQ(params.instruction_set, args[i++]); ASSERT_EQ(params.dexopt_needed, atoi(args[i++])); ASSERT_STREQ(params.oat_dir, args[i++]); ASSERT_EQ(params.dexopt_flags, atoi(args[i++])); const int dexopt_flags = atoi(args[i++]); ASSERT_STREQ(params.compiler_filter, args[i++]); ASSERT_STREQ(params.volume_uuid, ParseNull(args[i++])); ASSERT_STREQ(params.shared_libraries, ParseNull(args[i++])); Loading Loading @@ -95,6 +96,11 @@ protected: } else { ASSERT_STREQ(params.compilation_reason, "ab-ota"); } if (version > 7) { ASSERT_EQ(params.dexopt_flags, dexopt_flags); } else { ASSERT_EQ(params.dexopt_flags, dexopt_flags | DEXOPT_GENERATE_COMPACT_DEX); } } const char* getVersionCStr(uint32_t version) { Loading @@ -106,6 +112,7 @@ protected: case 5: return "5"; case 6: return "6"; case 7: return "7"; case 8: return "8"; } return nullptr; } Loading