summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord34d <clark@cyngn.com>2016-01-18 19:41:38 -0800
committerClark Scheff <clark@cyngn.com>2016-01-22 09:30:36 -0800
commit66163bb2974983f72b9ad8a8e51a75251af84681 (patch)
tree3b7d7837da06252be351a9c5c949735547588913
parent8af4e664d998a6d94d59b51bca47dd24ebf91d11 (diff)
downloadandroid_frameworks_native-66163bb2974983f72b9ad8a8e51a75251af84681.tar.gz
android_frameworks_native-66163bb2974983f72b9ad8a8e51a75251af84681.tar.bz2
android_frameworks_native-66163bb2974983f72b9ad8a8e51a75251af84681.zip
Themes: Reference app resource when compiling theme [1/2]
This allows us to pass in the path to the target apk as an additional included resource apk, allowing theme designers to reference styles and attributes from the original package without needing to duplicate them. Duplicating attributes never worked quite well, and causes all sorts of issues, including crashing apps. Instead of a theme declaring attributes, that are app specific, it simply reference the originals. This way things like colors that are style specific get included correctly. Here's an example of stat_sys_wifi_signal_4_fully.xml using this feature. By using ?com.android.systemui:attr/ we are able to reference attributes defined in SystemUI directly in our themed resource. <vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="17.25dp" android:height="18dp" android:viewportWidth="46.0" android:viewportHeight="48.0"> <path android:fillColor="?com.android.systemui:attr/backgroundColor" android:pathData="M20.4,18.0"/> <path android:fillColor="?com.android.systemui:attr/fillColor" android:pathData="M42.0,32.0l0.0,-4.0L26.0,18.0L26.0,7.0c0.0,-1.7 -1.3,-3.0 -3.0, -3.0c-1.7,0.0 -3.0,1.3 -3.0,3.0l0.0,11.0L4.0,28.0l0.0,4.0l16.0,-5.0l0.0,11.0l-4.0, 3.0l0.0,3.0l7.0,-2.0l7.0,2.0l0.0,-3.0l-4.0,-3.0L26.0,27.0L42.0,32.0z"/> </vector> Change-Id: Ic00b5d91fc651a29a8c3ab341e5494107acd0463 TICKET: CYNGNOS-1645 (cherry picked from commit 7c2be690f4949abc4d547627d8d856231e2fa4e7)
-rw-r--r--cmds/installd/commands.cpp58
-rw-r--r--cmds/installd/installd.cpp8
-rw-r--r--cmds/installd/installd.h2
3 files changed, 39 insertions, 29 deletions
diff --git a/cmds/installd/commands.cpp b/cmds/installd/commands.cpp
index 322d537ee..50346c836 100644
--- a/cmds/installd/commands.cpp
+++ b/cmds/installd/commands.cpp
@@ -1721,7 +1721,8 @@ fail:
}
static void run_aapt(const char *source_apk, const char *internal_path,
- int resapk_fd, int pkgId, int min_sdk_version, const char *common_res_path)
+ int resapk_fd, int pkgId, int min_sdk_version,
+ const char *app_res_path, const char *common_res_path)
{
static const char *AAPT_BIN = "/system/bin/aapt";
static const char *MANIFEST = "/data/app/AndroidManifest.xml";
@@ -1735,40 +1736,48 @@ static void run_aapt(const char *source_apk, const char *internal_path,
snprintf(resapk_str, sizeof(resapk_str), "%d", resapk_fd);
snprintf(pkgId_str, sizeof(pkgId_str), "%d", pkgId);
snprintf(minSdkVersion_str, sizeof(minSdkVersion_str), "%d", min_sdk_version);
+
bool hasCommonResources = (common_res_path != NULL && common_res_path[0] != '\0');
+ bool hasAppResources = (app_res_path != NULL && app_res_path[0] != '\0');
if (hasCommonResources) {
execl(AAPT_BIN, AAPT_BIN, "package",
- "--min-sdk-version", minSdkVersion_str,
- "-M", MANIFEST,
- "-S", source_apk,
- "-X", internal_path,
- "-I", FRAMEWORK_RES,
- "-I", common_res_path,
- "-r", resapk_str,
- "-x", pkgId_str,
- "-f",
- (char*)NULL);
+ "--min-sdk-version", minSdkVersion_str,
+ "-M", MANIFEST,
+ "-S", source_apk,
+ "-X", internal_path,
+ "-I", FRAMEWORK_RES,
+ "-r", resapk_str,
+ "-x", pkgId_str,
+ "-f",
+ "-I", common_res_path,
+ hasAppResources ? "-I" : (char*)NULL,
+ hasAppResources ? app_res_path : (char*) NULL,
+ (char*)NULL);
} else {
execl(AAPT_BIN, AAPT_BIN, "package",
- "--min-sdk-version", minSdkVersion_str,
- "-M", MANIFEST,
- "-S", source_apk,
- "-X", internal_path,
- "-I", FRAMEWORK_RES,
- "-r", resapk_str,
- "-x", pkgId_str,
- "-f",
- (char*)NULL);
+ "--min-sdk-version", minSdkVersion_str,
+ "-M", MANIFEST,
+ "-S", source_apk,
+ "-X", internal_path,
+ "-I", FRAMEWORK_RES,
+ "-r", resapk_str,
+ "-x", pkgId_str,
+ "-f",
+ hasAppResources ? "-I" : (char*)NULL,
+ hasAppResources ? app_res_path : (char*) NULL,
+ (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 min_sdk_version, const char *common_res_path)
+ int pkgId, int min_sdk_version, const char *app_res_path, const char *common_res_path)
{
- ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d,min_sdk_version=%d, common_res_path=%s",
- source_apk, internal_path, out_restable, uid, pkgId, min_sdk_version, common_res_path);
+ ALOGD("aapt source_apk=%s internal_path=%s out_restable=%s uid=%d, pkgId=%d,min_sdk_version=%d,\
+ app_res_path=%s, common_res_path=%s",
+ source_apk, internal_path, out_restable, uid, pkgId, min_sdk_version, app_res_path,
+ common_res_path);
static const int PARENT_READ_PIPE = 0;
static const int CHILD_WRITE_PIPE = 1;
@@ -1828,7 +1837,8 @@ int aapt(const char *source_apk, const char *internal_path, const char *out_rest
}
}
- run_aapt(source_apk, internal_path, resapk_fd, pkgId, min_sdk_version, common_res_path);
+ run_aapt(source_apk, internal_path, resapk_fd, pkgId, min_sdk_version, app_res_path,
+ common_res_path);
close(resapk_fd);
if (pipefd[CHILD_WRITE_PIPE] > 0) {
diff --git a/cmds/installd/installd.cpp b/cmds/installd/installd.cpp
index c92bed020..df159e364 100644
--- a/cmds/installd/installd.cpp
+++ b/cmds/installd/installd.cpp
@@ -163,12 +163,12 @@ static int do_idmap(char **arg, char reply[REPLY_MAX] __unused)
static int do_aapt(char **arg, char reply[REPLY_MAX] __unused)
{
- return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), atoi(arg[5]), "");
+ return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), atoi(arg[5]), arg[6], "");
}
static int do_aapt_with_common(char **arg, char reply[REPLY_MAX] __unused)
{
- return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), atoi(arg[5]), arg[6]);
+ return aapt(arg[0], arg[1], arg[2], atoi(arg[3]), atoi(arg[4]), atoi(arg[5]), arg[6], arg[7]);
}
static int do_restorecon_data(char **arg, char reply[REPLY_MAX] __attribute__((unused)))
@@ -223,8 +223,8 @@ struct cmdinfo cmds[] = {
{ "mkuserconfig", 1, do_mk_user_config },
{ "rmuser", 2, do_rm_user },
{ "idmap", 6, do_idmap },
- { "aapt", 6, do_aapt },
- { "aapt_with_common", 7, do_aapt_with_common },
+ { "aapt", 7, do_aapt },
+ { "aapt_with_common", 8, do_aapt_with_common },
{ "restorecondata", 4, do_restorecon_data },
{ "createoatdir", 2, do_create_oat_dir },
{ "rmpackagedir", 1, do_rm_package_dir },
diff --git a/cmds/installd/installd.h b/cmds/installd/installd.h
index 70e5e16c8..b4c5961d3 100644
--- a/cmds/installd/installd.h
+++ b/cmds/installd/installd.h
@@ -253,7 +253,7 @@ int linklib(const char* uuid, const char* pkgname, const char* asecLibDir, int u
int idmap(const char *target_path, const char *overlay_path, const char *cache_path, uid_t uid,
uint32_t target_hash, uint32_t overlay_hash);
int aapt(const char *source_apk, const char *internal_path, const char *out_restable, uid_t uid,
- int pkgId, int min_sdk_version, const char *common_res_path);
+ int pkgId, int min_sdk_version, const char *app_res_path, const char *common_res_path);
int restorecon_data(const char *uuid, const char* pkgName, const char* seinfo, uid_t uid);
int create_oat_dir(const char* oat_dir, const char *instruction_set);
int rm_package_dir(const char* apk_path);