Skip to content

Commit

Permalink
[updater] use ota device name stored in BoardConfig.mk
Browse files Browse the repository at this point in the history
should fix possibly flash error (http://bit.ly/1GVWppT)

Change-Id: I567623328b28a96dca6b3208857f19e3dc09a1a3
  • Loading branch information
yacuken committed Mar 21, 2016
1 parent 69bdd3c commit 7bd5c10
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Android.mk
Expand Up @@ -215,6 +215,12 @@ UPDATER_SCRIPT_SRC := $(LOCAL_PATH)/updater-script
ANDROID_VERSION_MAJOR := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
ANDROID_VERSION_MINOR := $(word 2, $(subst ., , $(PLATFORM_VERSION)))

ifeq ($(TARGET_OTA_ASSERT_DEVICE),)
ASSERT_DEVICE := assert(getprop("ro.product.device") == "$(TARGET_DEVICE)" \|\| getprop("ro.build.product") == "$(TARGET_DEVICE)" \|\| getprop("ro.cm.device") == "$(TARGET_DEVICE)");
else
ASSERT_DEVICE := $(subst |,\|,$(shell $(LOCAL_PATH)/assert-device $(TARGET_OTA_ASSERT_DEVICE)))
endif

USE_SET_METADATA := $(shell test $(ANDROID_VERSION_MAJOR) -eq 4 -a $(ANDROID_VERSION_MINOR) -ge 4 -o $(ANDROID_VERSION_MAJOR) -ge 5 && echo true)

ifeq ($(USE_SET_METADATA),true)
Expand All @@ -230,6 +236,7 @@ $(LOCAL_BUILT_MODULE): $(UPDATER_SCRIPT_SRC)
@sed -e 's %DEVICE% $(TARGET_DEVICE) g' \
-e 's %BOOT_PART% $(HYBRIS_BOOT_PART) g' \
-e 's %DATA_PART% $(HYBRIS_DATA_PART) g' \
-e 's|%ASSERT_DEVICE%|$(ASSERT_DEVICE)|' \
-e 's|%SET_PERMISSIONS%|$(SET_PERMISSIONS)|' \
$(UPDATER_SCRIPT_SRC) > $@

Expand Down
14 changes: 14 additions & 0 deletions assert-device
@@ -0,0 +1,14 @@
#!/usr/bin/env python

import sys

device = sys.argv[1]

"""Assert that the device identifier is the given string."""
cmd = ('assert(' +
' || '.join(['getprop("ro.product.device") == "%s" || getprop("ro.build.product") == "%s"'
% (i, i) for i in device.split(",")]) +
' || abort("This package is for device: %s; ' +
'this device is " + getprop("ro.product.device") + ".");' +
');') % device
print(cmd)
2 changes: 1 addition & 1 deletion updater-script
Expand Up @@ -12,7 +12,7 @@ ui_print(" /data -> %DATA_PART%");
ui_print("========================================");
ui_print("");

assert(getprop("ro.product.device") == "%DEVICE%" || getprop("ro.build.product") == "%DEVICE%" || getprop("ro.cm.device") == "%DEVICE%");
%ASSERT_DEVICE%

ui_print("Device check succeeded, mounting filesystems ...");
mount("ext4", "EMMC", "%DATA_PART%", "/data");
Expand Down

0 comments on commit 7bd5c10

Please sign in to comment.