summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/installd/dexopt.cpp19
-rw-r--r--cmds/installd/installd_constants.h4
-rw-r--r--cmds/installd/otapreopt.cpp3
-rw-r--r--cmds/installd/otapreopt_parameters.cpp2
-rw-r--r--cmds/installd/tests/installd_otapreopt_test.cpp1
5 files changed, 18 insertions, 11 deletions
diff --git a/cmds/installd/dexopt.cpp b/cmds/installd/dexopt.cpp
index e1e73c7a61..27776629de 100644
--- a/cmds/installd/dexopt.cpp
+++ b/cmds/installd/dexopt.cpp
@@ -1264,8 +1264,8 @@ class Dex2oatFileWrapper {
};
// (re)Creates the app image if needed.
-Dex2oatFileWrapper maybe_open_app_image(const char* out_oat_path, bool profile_guided,
- bool is_public, int uid, bool is_secondary_dex) {
+Dex2oatFileWrapper maybe_open_app_image(const char* out_oat_path,
+ bool generate_app_image, bool is_public, int uid, bool is_secondary_dex) {
// We don't create an image for secondary dex files.
if (is_secondary_dex) {
@@ -1278,11 +1278,11 @@ Dex2oatFileWrapper maybe_open_app_image(const char* out_oat_path, bool profile_g
return Dex2oatFileWrapper();
}
- // Use app images only if it is enabled (by a set image format) and we are compiling
- // profile-guided (so the app image doesn't conservatively contain all classes).
- if (!profile_guided) {
- // In case there is a stale image, remove it now. Ignore any error.
- unlink(image_path.c_str());
+ // In case there is a stale image, remove it now. Ignore any error.
+ unlink(image_path.c_str());
+
+ // Not enabled, exit.
+ if (!generate_app_image) {
return Dex2oatFileWrapper();
}
char app_image_format[kPropertyValueMax];
@@ -1959,6 +1959,7 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
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;
+ bool generate_app_image = (dexopt_flags & DEXOPT_GENERATE_APP_IMAGE) != 0;
// Check if we're dealing with a secondary dex file and if we need to compile it.
std::string oat_dir_str;
@@ -2027,8 +2028,8 @@ int dexopt(const char* dex_path, uid_t uid, const char* pkgname, const char* ins
unique_fd swap_fd = maybe_open_dexopt_swap_file(out_oat_path);
// Create the app image file if needed.
- Dex2oatFileWrapper image_fd =
- maybe_open_app_image(out_oat_path, profile_guided, is_public, uid, is_secondary_dex);
+ Dex2oatFileWrapper image_fd = maybe_open_app_image(
+ out_oat_path, generate_app_image, is_public, uid, is_secondary_dex);
// Open the reference profile if needed.
Dex2oatFileWrapper reference_profile_fd = maybe_open_reference_profile(
diff --git a/cmds/installd/installd_constants.h b/cmds/installd/installd_constants.h
index 26aa443d4e..c928631d8f 100644
--- a/cmds/installd/installd_constants.h
+++ b/cmds/installd/installd_constants.h
@@ -54,6 +54,7 @@ constexpr int DEXOPT_STORAGE_DE = 1 << 8;
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;
+constexpr int DEXOPT_GENERATE_APP_IMAGE = 1 << 12;
/* all known values for dexopt flags */
constexpr int DEXOPT_MASK =
@@ -67,7 +68,8 @@ constexpr int DEXOPT_MASK =
| DEXOPT_STORAGE_DE
| DEXOPT_IDLE_BACKGROUND_JOB
| DEXOPT_ENABLE_HIDDEN_API_CHECKS
- | DEXOPT_GENERATE_COMPACT_DEX;
+ | DEXOPT_GENERATE_COMPACT_DEX
+ | DEXOPT_GENERATE_APP_IMAGE;
// NOTE: keep in sync with StorageManager
constexpr int FLAG_STORAGE_DE = 1 << 0;
diff --git a/cmds/installd/otapreopt.cpp b/cmds/installd/otapreopt.cpp
index 58355f9db0..96d8c47a8a 100644
--- a/cmds/installd/otapreopt.cpp
+++ b/cmds/installd/otapreopt.cpp
@@ -82,8 +82,9 @@ 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_GENERATE_APP_IMAGE == 1 << 12, "DEXOPT_GENERATE_APP_IMAGE unexpected");
-static_assert(DEXOPT_MASK == (0xdfe | DEXOPT_IDLE_BACKGROUND_JOB),
+static_assert(DEXOPT_MASK == (0x1dfe | DEXOPT_IDLE_BACKGROUND_JOB),
"DEXOPT_MASK unexpected.");
diff --git a/cmds/installd/otapreopt_parameters.cpp b/cmds/installd/otapreopt_parameters.cpp
index d56aec9e2b..cf3de018c0 100644
--- a/cmds/installd/otapreopt_parameters.cpp
+++ b/cmds/installd/otapreopt_parameters.cpp
@@ -246,6 +246,8 @@ bool OTAPreoptParameters::ReadArgumentsPostV1(uint32_t version, const char** arg
case 7:
// Version 8 adds a new dexopt flag: DEXOPT_GENERATE_COMPACT_DEX
case 8: num_args_expected = 16; break;
+ // Version 9 adds a new dexopt flag: DEXOPT_GENERATE_APP_IMAGE
+ case 9: num_args_expected = 16; break;
default:
LOG(ERROR) << "Don't know how to read arguments for version " << version;
return false;
diff --git a/cmds/installd/tests/installd_otapreopt_test.cpp b/cmds/installd/tests/installd_otapreopt_test.cpp
index 63426cb4e0..b5185073d2 100644
--- a/cmds/installd/tests/installd_otapreopt_test.cpp
+++ b/cmds/installd/tests/installd_otapreopt_test.cpp
@@ -113,6 +113,7 @@ protected:
case 6: return "6";
case 7: return "7";
case 8: return "8";
+ case 9: return "9";
}
return nullptr;
}