summaryrefslogtreecommitdiff
path: root/scripts/update_device.py
diff options
context:
space:
mode:
authorKelvin Zhang <zhangkelvin@google.com>2021-03-02 12:36:14 -0500
committerKelvin Zhang <zhangkelvin@google.com>2021-03-04 09:15:19 -0500
commit5bd4622bd6e91e97355c5cc0a4c9dc439cc29779 (patch)
treeaa8de11085f1e90a141d0acba4ee188be049cd68 /scripts/update_device.py
parenta314d2b875965dda7c41a3677a4348f678c6b1b0 (diff)
Push care_map.pb to device when serving an OTA
When rebooting, device will skip update_verifier if care_map.pb isn't found. For better testing, push care_map.pb to device by default Test: python2 update_device.py some_ota.zip Bug: 181499957 Change-Id: Ic47735be7dd7b1c1541613a88cab69ef57394b5a
Diffstat (limited to 'scripts/update_device.py')
-rwxr-xr-xscripts/update_device.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/scripts/update_device.py b/scripts/update_device.py
index ae24418f..348c3b70 100755
--- a/scripts/update_device.py
+++ b/scripts/update_device.py
@@ -409,6 +409,8 @@ def main():
parser.add_argument('--allocate_only', action='store_true',
help='Allocate space for this OTA, instead of actually \
applying the OTA.')
+ parser.add_argument('--no_care_map', action='store_true',
+ help='Do not push care_map.pb to device.')
args = parser.parse_args()
logging.basicConfig(
level=logging.WARNING if args.no_verbose else logging.INFO)
@@ -434,7 +436,7 @@ def main():
with zipfile.ZipFile(args.otafile, "r") as zfp:
extracted_path = os.path.join(tmpdir, "payload.bin")
with zfp.open("payload.bin") as payload_fp, \
- open(extracted_path, "wb") as output_fp:
+ open(extracted_path, "wb") as output_fp:
# Only extract the first |data_offset| bytes from the payload.
# This is because allocateSpaceForPayload only needs to see
# the manifest, not the entire payload.
@@ -457,6 +459,17 @@ def main():
if args.no_slot_switch:
args.extra_headers += "\nSWITCH_SLOT_ON_REBOOT=0"
+ with zipfile.ZipFile(args.otafile) as zfp:
+ CARE_MAP_ENTRY_NAME = "care_map.pb"
+ if CARE_MAP_ENTRY_NAME in zfp.namelist() and not args.no_care_map:
+ # Need root permission to push to /data
+ dut.adb(["root"])
+ with tempfile.NamedTemporaryFile("w+") as care_map_fp:
+ care_map_fp.write(zfp.read(CARE_MAP_ENTRY_NAME))
+ care_map_fp.flush()
+ dut.adb(["push", care_map_fp.name,
+ "/data/ota_package/" + CARE_MAP_ENTRY_NAME])
+
if args.file:
# Update via pushing a file to /data.
device_ota_file = os.path.join(OTA_PACKAGE_PATH, 'debug.zip')