Make system use patchoat to relocate during runtime.

Make installd understand a patchoat directive and carry it out.

Bug: 15358152

(cherry picked from commit 7365a10689df23334d245b211ce272502ad20669)

Change-Id: Id84a15e626ddde63876914068d3d9aa037abc65b
diff --git a/cmds/installd/installd.c b/cmds/installd/installd.c
index 62579b9..746ce57 100644
--- a/cmds/installd/installd.c
+++ b/cmds/installd/installd.c
@@ -39,7 +39,7 @@
 static int do_dexopt(char **arg, char reply[REPLY_MAX])
 {
         /* apk_path, uid, is_public, pkgname, instruction_set */
-    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4]);
+    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], 0);
 }
 
 static int do_move_dex(char **arg, char reply[REPLY_MAX])
@@ -151,6 +151,10 @@
     return prune_dex_cache(arg[0] /* subdirectory name */);
 }
 
+static int do_patchoat(char **arg, char reply[REPLY_MAX]) {
+    return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], 1);
+}
+
 struct cmdinfo {
     const char *name;
     unsigned numargs;
@@ -179,6 +183,7 @@
     { "idmap",                3, do_idmap },
     { "restorecondata",       3, do_restorecon_data },
     { "prunedexcache",        1, do_prune_dex_cache },
+    { "patchoat",             5, do_patchoat },
 };
 
 static int readx(int s, void *_buf, int count)