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
diff --git a/scripts/update_device.py b/scripts/update_device.py
index ae24418..348c3b7 100755
--- a/scripts/update_device.py
+++ b/scripts/update_device.py
@@ -409,6 +409,8 @@
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 @@
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 @@
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')