Otapreopt: Implement new A/B OTA path

Refactor otapreopt_script, otapreopt_chroot and otapreopt such
that the actual work will be done as a child of the script driven
by update_engine.

The script now uses the new OtaDexoptService command to get the
right parameters for a dexopt call in otapreopt. As we reach
otapreopt_chroot and otapreopt directly, we can add parameters
without tainting the regular installd path. Use this to add the
target slot suffix, and make naming of the A/B artifacts include
the suffix instead of the generic "b."

Otapreopt_chroot startup is slightly complicated because all file
descriptors must be closed. Otherwise, dex2oat needs selinux
permissions to inherit the descriptors from update_engine.

Bug: 25612095
Bug: 28069686
Change-Id: I9d7b86ac8ecfdf91af3800f7e96f41534c0afc0f
(cherry picked from commit 0354bd0eaf24de533e86885b811f816f1e4d15c8)
diff --git a/cmds/installd/globals.cpp b/cmds/installd/globals.cpp
index 6a67e29..93e1ce5 100644
--- a/cmds/installd/globals.cpp
+++ b/cmds/installd/globals.cpp
@@ -30,6 +30,22 @@
 namespace android {
 namespace installd {
 
+static constexpr const char* APP_SUBDIR = "app/"; // sub-directory under ANDROID_DATA
+
+static constexpr const char* PRIV_APP_SUBDIR = "priv-app/"; // sub-directory under ANDROID_DATA
+
+static constexpr const char* EPHEMERAL_APP_SUBDIR = "app-ephemeral/"; // sub-directory under
+                                                                      // ANDROID_DATA
+
+static constexpr const char* APP_LIB_SUBDIR = "app-lib/"; // sub-directory under ANDROID_DATA
+
+static constexpr const char* MEDIA_SUBDIR = "media/"; // sub-directory under ANDROID_DATA
+
+static constexpr const char* PROFILES_SUBDIR = "misc/profiles"; // sub-directory under ANDROID_DATA
+
+static constexpr const char* PRIVATE_APP_SUBDIR = "app-private/"; // sub-directory under
+                                                                  // ANDROID_DATA
+
 /* Directory records that are used in execution of commands. */
 dir_rec_t android_app_dir;
 dir_rec_t android_app_ephemeral_dir;
@@ -77,7 +93,7 @@
 
     // Get the android ephemeral app directory.
     if (copy_and_append(&android_app_ephemeral_dir, &android_data_dir, EPHEMERAL_APP_SUBDIR) < 0) {
-        return -1;
+        return false;
     }
 
     // Get the android app native library directory.
@@ -86,7 +102,7 @@
     }
 
     // Get the sd-card ASEC mount point.
-    if (get_path_from_env(&android_asec_dir, "ASEC_MOUNTPOINT") < 0) {
+    if (get_path_from_env(&android_asec_dir, ASEC_MOUNTPOINT_ENV_NAME) < 0) {
         return false;
     }