Skip to content

Commit

Permalink
Add parsing metadata from OTA package
Browse files Browse the repository at this point in the history
Since Oreo, there is no `system/build.prop`, it is packaged into
`system.new.dat`. So timestamp generation hasn't worked for years now.

The OTA metadata on the other hand stores this timestamp (called
`post-timestamp`), so let's parse that instead.
  • Loading branch information
pourekrami authored and lifehackerhansol committed May 28, 2024
1 parent 49fb589 commit 023b318
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions gen_mirror_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@
sha256 = hashlib.sha256()
for buf in iter(lambda: data.read(128 * 1024), b''):
sha256.update(buf)

try:
with zipfile.ZipFile(f'{FILE_BASE}/{filename}', 'r') as update_zip:
build_prop = update_zip.read('system/build.prop').decode('utf-8')
timestamp = int(re.findall('ro.build.date.utc=([0-9]+)', build_prop)[0])
except Exception:
build_prop = update_zip.read('META-INF/com/android/metadata').decode('utf-8')
timestamp = (re.findall('post-timestamp=([0-9]+)', build_prop)[0])
except Exception as e:
print(e)
timestamp = int(mktime(datetime.strptime(builddate, '%Y%m%d').timetuple()))

builds.setdefault(device, []).append({
Expand Down

0 comments on commit 023b318

Please sign in to comment.