aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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);
}