aboutsummaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
authorpadarshr <padarshr@codeaurora.org>2015-09-11 12:33:10 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:20:39 -0600
commite8baf4a8e8d8a8de4ae276a9f29956008c13f7ba (patch)
tree1ba855eb0ae1f897cf29fc465fa2fb8c781f83fc /updater
parentb9083e63af1fc4519df459de5796ced0990cdf85 (diff)
downloadbootable_recovery-e8baf4a8e8d8a8de4ae276a9f29956008c13f7ba.zip
bootable_recovery-e8baf4a8e8d8a8de4ae276a9f29956008c13f7ba.tar.gz
bootable_recovery-e8baf4a8e8d8a8de4ae276a9f29956008c13f7ba.tar.bz2
recovery:updater: Changes to support 32->64 bit upgrades
We now support upgrading from 32 to 64 bit builds. The check for device to package compatibility now takes into account if the product name on the device vs the product name on the upgrade build differs only by the _32 or _64 trailing chars. In addition we also force compile the updater binary as 32 bit executable so that it can run on the 32 bit build we are upgrading from. Change-Id: Iebe6107e55719141fbcc496efa0c60ef1f9368c8
Diffstat (limited to 'updater')
-rw-r--r--updater/Android.mk11
-rw-r--r--updater/install.c69
2 files changed, 79 insertions, 1 deletions
diff --git a/updater/Android.mk b/updater/Android.mk
index ff02a33..f4ed954 100644
--- a/updater/Android.mk
+++ b/updater/Android.mk
@@ -57,7 +57,11 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
# any subsidiary static libraries required for your registered
# extension libs.
+ifeq ($(TARGET_ARCH),arm64)
+inc := $(call intermediates-dir-for,PACKAGING,updater_extensions,,,32)/register.inc
+else
inc := $(call intermediates-dir-for,PACKAGING,updater_extensions)/register.inc
+endif
# Encode the value of TARGET_RECOVERY_UPDATER_LIBS into the filename of the dependency.
# So if TARGET_RECOVERY_UPDATER_LIBS is changed, a new dependency file will be generated.
@@ -79,13 +83,18 @@ $(inc) : $(inc_dep_file)
$(hide) $(foreach lib,$(libs),echo " Register_$(lib)();" >> $@;)
$(hide) echo "}" >> $@
-$(call intermediates-dir-for,EXECUTABLES,updater,,,$(TARGET_PREFER_32_BIT))/updater.o : $(inc)
+ifeq ($(TARGET_ARCH),arm64)
+$(call intermediates-dir-for,EXECUTABLES,updater,,,32)/updater.o : $(inc)
+else
+$(call intermediates-dir-for,EXECUTABLES,updater)/updater.o : $(inc)
+endif
LOCAL_C_INCLUDES += $(dir $(inc))
inc :=
inc_dep_file :=
LOCAL_MODULE := updater
+LOCAL_32_BIT_ONLY := true
LOCAL_FORCE_STATIC_EXECUTABLE := true
diff --git a/updater/install.c b/updater/install.c
index 01a5dd2..ba2dda7 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -931,6 +931,74 @@ Value* GetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
return StringValue(strdup(value));
}
+//Check to confirm if this is the same hardware as the one the package was
+//generated on or not. 32 vs 64 bit variants are upgrade compatible but have
+//names such as msmWXYZ msmWXYZ_32 vs msmWXYZ_64.Input to this
+//function is the BuildProp value that gets stored in the update package
+//at the time it it created.
+Value* ConfirmDevVariant(const char* name, State* state, int argc, Expr* argv[])
+{
+ //ro.product.device that was on the build that the update package was made
+ //from
+ char* package_dev_variant;
+ //ro.product.device on the current hardware
+ char current_dev_variant[PROPERTY_VALUE_MAX];
+ int comparison_len;
+ int package_dev_variant_len;
+ int current_dev_variant_len;
+ if (argc != 1) {
+ return ErrorAbort(state, "%s() expects 1 arg, got %d", name, argc);
+ }
+ package_dev_variant = Evaluate(state, argv[0]);
+ if (!package_dev_variant) goto error;
+ property_get("ro.product.device", current_dev_variant, "n/a");
+ if (!strncmp(current_dev_variant,"n/a",3)) {
+ ErrorAbort(state, "Failed to get valid ro.product.device");
+ goto error;
+ }
+ package_dev_variant_len = strlen(package_dev_variant);
+ current_dev_variant_len = strlen(current_dev_variant);
+ //Ensure device variant lengths are atleast 3 characters long
+ if ((package_dev_variant_len < 3) || (current_dev_variant_len < 3)) {
+ ErrorAbort(state, "Device Variant length is less than 3 characters");
+ goto error;
+ }
+ //Length of the largest string - 3(for _32/64)
+ comparison_len =
+ (package_dev_variant_len >= current_dev_variant_len ?
+ package_dev_variant_len :
+ current_dev_variant_len) - 3;
+ //Complete match
+ if (!strncmp(current_dev_variant, package_dev_variant,
+ strlen(current_dev_variant)))
+ goto success;
+ //Match except for the last 3 char's of either string which are _32 or _64
+ if (!strncmp(current_dev_variant, package_dev_variant, comparison_len)) {
+ if (package_dev_variant_len >= current_dev_variant_len) {
+ if (!strncmp(&package_dev_variant[package_dev_variant_len-3],
+ "_32", 3) ||
+ !strncmp(&package_dev_variant[package_dev_variant_len-3],
+ "_64", 3))
+ goto success;
+ } else {
+ if (!strncmp(&current_dev_variant[current_dev_variant_len-3],
+ "_32", 3) ||
+ !strncmp(&current_dev_variant[current_dev_variant_len-3],
+ "_64", 3))
+ goto success;
+ }
+ ErrorAbort(state, "Invalid target for update package");
+ goto error;
+ }
+success:
+ free(package_dev_variant);
+ return StringValue(strdup("OK"));
+error:
+ if (package_dev_variant) {
+ free(package_dev_variant);
+ }
+ return StringValue(strdup("ERROR"));
+}
// file_getprop(file, key)
//
@@ -1622,4 +1690,5 @@ void RegisterInstallFunctions() {
RegisterFunction("enable_reboot", EnableRebootFn);
RegisterFunction("tune2fs", Tune2FsFn);
+ RegisterFunction("get_device_compatible", ConfirmDevVariant);
}