Skip to content

Commit

Permalink
Merge "CM11 Themes: Common overlay for sharing resources. [2/2]" into…
Browse files Browse the repository at this point in the history
… cm-11.0
  • Loading branch information
0xD34D authored and Gerrit Code Review committed May 7, 2014
2 parents d6abee6 + 85290ea commit b0f3fdc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
28 changes: 22 additions & 6 deletions cmds/installd/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,8 @@ int idmap(const char *target_apk, const char *overlay_apk, uid_t uid,
return -1;
}

static void run_aapt(const char *source_apk, const char *internal_path, int restable_fd, int resapk_fd, int pkgId)
static void run_aapt(const char *source_apk, const char *internal_path, int restable_fd,
int resapk_fd, int pkgId, const char *common_res_path)
{
static const char *AAPT_BIN = "/system/bin/aapt";
static const char *MANIFEST = "/data/app/AndroidManifest.xml";
Expand All @@ -1282,23 +1283,38 @@ static void run_aapt(const char *source_apk, const char *internal_path, int rest
snprintf(restable_str, sizeof(restable_str), "%d", restable_fd);
snprintf(resapk_str, sizeof(resapk_str), "%d", resapk_fd);
snprintf(pkgId_str, sizeof(pkgId_str), "%d", pkgId);
bool hasCommonResources = (common_res_path != NULL && common_res_path[0] != '\0');

execl(AAPT_BIN, AAPT_BIN, "package",
if (hasCommonResources) {
execl(AAPT_BIN, AAPT_BIN, "package",
"-M", MANIFEST,
"-S", source_apk,
"-X", internal_path,
"-R", restable_str,
"-I", FRAMEWORK_RES,
"-I", common_res_path,
"-r", resapk_str,
"-x", pkgId_str,
(char*)NULL);
} else {
execl(AAPT_BIN, AAPT_BIN, "package",
"-M", MANIFEST,
"-S", source_apk,
"-X", internal_path,
"-R", restable_str,
"-I", FRAMEWORK_RES,
"-r", resapk_str,
"-x", pkgId_str,
(char*)NULL);
}
ALOGE("execl(%s) failed: %s\n", AAPT_BIN, strerror(errno));
}

int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid, int pkgId)
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
int pkgId, const char *common_res_path)
{
ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d\n",
source_apk, internal_path, out_restable, uid, pkgId);
ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d, common_res_path=%s",
source_apk, internal_path, out_restable, uid, pkgId, common_res_path);
static const int PARENT_READ_PIPE = 0;
static const int CHILD_WRITE_PIPE = 1;

Expand Down Expand Up @@ -1374,7 +1390,7 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
}
}

run_aapt(source_apk, internal_path, restable_fd, resapk_fd, pkgId);
run_aapt(source_apk, internal_path, restable_fd, resapk_fd, pkgId, common_res_path);

if (pipefd[CHILD_WRITE_PIPE] > 0) {
close(pipefd[CHILD_WRITE_PIPE]);
Expand Down
4 changes: 2 additions & 2 deletions cmds/installd/installd.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static int do_idmap(char **arg, char reply[REPLY_MAX])

static int do_aapt(char **arg, char reply[REPLY_MAX])
{
return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]));
return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), arg[5]);
}

struct cmdinfo {
Expand Down Expand Up @@ -163,7 +163,7 @@ struct cmdinfo cmds[] = {
{ "rmuser", 1, do_rm_user },
{ "restorecondata", 0, do_restorecon_data },
{ "idmap", 6, do_idmap },
{ "aapt", 5, do_aapt },
{ "aapt", 6, do_aapt },
};

char write_error = 0;
Expand Down
3 changes: 2 additions & 1 deletion cmds/installd/installd.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ int linklib(const char* target, const char* source, int userId);
int restorecon_data();
int idmap(const char *target_path, const char *overlay_path, uid_t uid,
uint32_t target_hash, uint32_t overlay_hash, const char *redirections);
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid, int pkgId);
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
int pkgId, const char *common_res_path);

0 comments on commit b0f3fdc

Please sign in to comment.