am ab91d03b
: Merge "installd: Add support for SELF_PATCHOAT_NEEDED."
* commit 'ab91d03b0dfebf40e98034670892c278ae0a46e5': installd: Add support for SELF_PATCHOAT_NEEDED.
This commit is contained in:
commit
19db8c884b
@ -988,8 +988,8 @@ static bool calculate_odex_file_path(char path[PKG_PATH_MAX],
|
||||
}
|
||||
|
||||
int dexopt(const char *apk_path, uid_t uid, bool is_public,
|
||||
const char *pkgname, const char *instruction_set,
|
||||
bool vm_safe_mode, bool is_patchoat, bool debuggable, const char* oat_dir)
|
||||
const char *pkgname, const char *instruction_set, int dexopt_needed,
|
||||
bool vm_safe_mode, bool debuggable, const char* oat_dir)
|
||||
{
|
||||
struct utimbuf ut;
|
||||
struct stat input_stat;
|
||||
@ -1021,13 +1021,25 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
|
||||
}
|
||||
}
|
||||
|
||||
if (is_patchoat) {
|
||||
switch (dexopt_needed) {
|
||||
case DEXOPT_DEX2OAT_NEEDED:
|
||||
input_file = apk_path;
|
||||
break;
|
||||
|
||||
case DEXOPT_PATCHOAT_NEEDED:
|
||||
if (!calculate_odex_file_path(in_odex_path, apk_path, instruction_set)) {
|
||||
return -1;
|
||||
}
|
||||
input_file = in_odex_path;
|
||||
} else {
|
||||
input_file = apk_path;
|
||||
break;
|
||||
|
||||
case DEXOPT_SELF_PATCHOAT_NEEDED:
|
||||
input_file = out_path;
|
||||
break;
|
||||
|
||||
default:
|
||||
ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
|
||||
exit(72);
|
||||
}
|
||||
|
||||
memset(&input_stat, 0, sizeof(input_stat));
|
||||
@ -1062,7 +1074,7 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
|
||||
}
|
||||
|
||||
// Create a swap file if necessary.
|
||||
if (!is_patchoat && ShouldUseSwapFileForDexopt()) {
|
||||
if (ShouldUseSwapFileForDexopt()) {
|
||||
// Make sure there really is enough space.
|
||||
size_t out_len = strlen(out_path);
|
||||
if (out_len + strlen(".swap") + 1 <= PKG_PATH_MAX) {
|
||||
@ -1121,9 +1133,10 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
|
||||
exit(67);
|
||||
}
|
||||
|
||||
if (is_patchoat) {
|
||||
if (dexopt_needed == DEXOPT_PATCHOAT_NEEDED
|
||||
|| dexopt_needed == DEXOPT_SELF_PATCHOAT_NEEDED) {
|
||||
run_patchoat(input_fd, out_fd, input_file, out_path, pkgname, instruction_set);
|
||||
} else {
|
||||
} else if (dexopt_needed == DEXOPT_DEX2OAT_NEEDED) {
|
||||
const char *input_file_name = strrchr(input_file, '/');
|
||||
if (input_file_name == NULL) {
|
||||
input_file_name = input_file;
|
||||
@ -1132,6 +1145,9 @@ int dexopt(const char *apk_path, uid_t uid, bool is_public,
|
||||
}
|
||||
run_dex2oat(input_fd, out_fd, input_file_name, out_path, swap_fd, pkgname,
|
||||
instruction_set, vm_safe_mode, debuggable);
|
||||
} else {
|
||||
ALOGE("Invalid dexopt needed: %d\n", dexopt_needed);
|
||||
exit(73);
|
||||
}
|
||||
exit(68); /* only get here on exec failure */
|
||||
} else {
|
||||
|
@ -38,10 +38,10 @@ static int do_install(char **arg, char reply[REPLY_MAX] __unused)
|
||||
|
||||
static int do_dexopt(char **arg, char reply[REPLY_MAX] __unused)
|
||||
{
|
||||
/* apk_path, uid, is_public, pkgname, instruction_set, vm_safe_mode, should_relocate
|
||||
debuggable, outputPath */
|
||||
return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]), 0,
|
||||
atoi(arg[6]), arg[7]);
|
||||
/* apk_path, uid, is_public, pkgname, instruction_set,
|
||||
* dexopt_needed, vm_safe_mode, debuggable, oat_dir */
|
||||
return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], atoi(arg[5]),
|
||||
atoi(arg[6]), atoi(arg[7]), arg[8]);
|
||||
}
|
||||
|
||||
static int do_mark_boot_complete(char **arg, char reply[REPLY_MAX] __unused)
|
||||
@ -152,12 +152,6 @@ static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((u
|
||||
/* pkgName, seinfo, uid*/
|
||||
}
|
||||
|
||||
static int do_patchoat(char **arg, char reply[REPLY_MAX] __unused) {
|
||||
/* apk_path, uid, is_public, pkgname, instruction_set, vm_safe_mode, should_relocate,
|
||||
debuggable, outputPath */
|
||||
return dexopt(arg[0], atoi(arg[1]), atoi(arg[2]), arg[3], arg[4], 0, 1, 0, "!");
|
||||
}
|
||||
|
||||
static int do_create_oat_dir(char **arg, char reply[REPLY_MAX] __unused)
|
||||
{
|
||||
/* oat_dir, instruction_set */
|
||||
@ -179,7 +173,7 @@ struct cmdinfo {
|
||||
struct cmdinfo cmds[] = {
|
||||
{ "ping", 0, do_ping },
|
||||
{ "install", 4, do_install },
|
||||
{ "dexopt", 8, do_dexopt },
|
||||
{ "dexopt", 9, do_dexopt },
|
||||
{ "markbootcomplete", 1, do_mark_boot_complete },
|
||||
{ "movedex", 3, do_move_dex },
|
||||
{ "rmdex", 2, do_rm_dex },
|
||||
@ -198,7 +192,6 @@ struct cmdinfo cmds[] = {
|
||||
{ "rmuser", 1, do_rm_user },
|
||||
{ "idmap", 3, do_idmap },
|
||||
{ "restorecondata", 3, do_restorecon_data },
|
||||
{ "patchoat", 5, do_patchoat },
|
||||
{ "createoatdir", 2, do_create_oat_dir },
|
||||
{ "rmpackagedir", 1, do_rm_package_dir},
|
||||
};
|
||||
|
@ -83,6 +83,11 @@
|
||||
#define PKG_NAME_MAX 128 /* largest allowed package name */
|
||||
#define PKG_PATH_MAX 256 /* max size of any path we use */
|
||||
|
||||
/* dexopt needed flags matching those in dalvik.system.DexFile */
|
||||
#define DEXOPT_DEX2OAT_NEEDED 1
|
||||
#define DEXOPT_PATCHOAT_NEEDED 2
|
||||
#define DEXOPT_SELF_PATCHOAT_NEEDED 3
|
||||
|
||||
/* data structures */
|
||||
|
||||
typedef struct {
|
||||
@ -221,8 +226,8 @@ int get_size(const char *pkgname, userid_t userid, const char *apkpath, const ch
|
||||
int64_t *codesize, int64_t *datasize, int64_t *cachesize, int64_t *asecsize);
|
||||
int free_cache(int64_t free_size);
|
||||
int dexopt(const char *apk_path, uid_t uid, bool is_public, const char *pkgName,
|
||||
const char *instruction_set, bool vm_safe_mode, bool should_relocate, bool debuggable,
|
||||
const char* outputPath);
|
||||
const char *instruction_set, int dexopt_needed, bool vm_safe_mode,
|
||||
bool debuggable, const char* oat_dir);
|
||||
int mark_boot_complete(const char *instruction_set);
|
||||
int movefiles();
|
||||
int linklib(const char* target, const char* source, int userId);
|
||||
|
Loading…
Reference in New Issue
Block a user