Add installd logic for compiling secondary dex files
Secondary dex compilation takes almost the same path as primary apk
compilation.
The main difference is in the fact that for secondary dex files we
create the oat dir on the fly and execute dexoptanalyzer (the equivalent
of GetDexOptNeeded) to check if we really need to perform the
compilation.
Test: adb shell cmd package compile -f -m speed --secondary-dex com.google.android.gms
Bug: 32871170
Change-Id: I2c56d57322899968a338ccabffca575d66f8ee08
diff --git a/cmds/installd/installd_constants.h b/cmds/installd/installd_constants.h
index 401e581..d8a754c 100644
--- a/cmds/installd/installd_constants.h
+++ b/cmds/installd/installd_constants.h
@@ -42,6 +42,14 @@
constexpr int DEXOPT_DEBUGGABLE = 1 << 3;
constexpr int DEXOPT_BOOTCOMPLETE = 1 << 4;
constexpr int DEXOPT_PROFILE_GUIDED = 1 << 5;
+constexpr int DEXOPT_SECONDARY_DEX = 1 << 6;
+// DEXOPT_FORCE, DEXOPT_STORAGE_CE, DEXOPT_STORAGE_DE are exposed for secondary
+// dex files only. Primary apks are analyzed in PackageManager and installd
+// does not need to know if the compilation is forced or on what kind of storage
+// the dex files are.
+constexpr int DEXOPT_FORCE = 1 << 7;
+constexpr int DEXOPT_STORAGE_CE = 1 << 8;
+constexpr int DEXOPT_STORAGE_DE = 1 << 9;
/* all known values for dexopt flags */
constexpr int DEXOPT_MASK =
@@ -49,7 +57,15 @@
| DEXOPT_SAFEMODE
| DEXOPT_DEBUGGABLE
| DEXOPT_BOOTCOMPLETE
- | DEXOPT_PROFILE_GUIDED;
+ | DEXOPT_PROFILE_GUIDED
+ | DEXOPT_SECONDARY_DEX
+ | DEXOPT_FORCE
+ | DEXOPT_STORAGE_CE
+ | DEXOPT_STORAGE_DE;
+
+// NOTE: keep in sync with StorageManager
+constexpr int FLAG_STORAGE_DE = 1 << 0;
+constexpr int FLAG_STORAGE_CE = 1 << 1;
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))