No description
Find a file
Dmitry Muhomor 55c6f0db6b rewrite aapt2-based overlay parser
Previous parser relied on text output of `aapt2/ dump xmltree` and `aapt2 dump resources` commands,
which is not meant for parsing.

This led to multiple parsing bugs: cutoff multiline strings, floating point parsing issues,
quoting issues, non-English locale issues etc.

Rewritten parser instead relies on protobuf aapt2 output, which allows to resolve most of these
issues.

A simple patch to aapt2 in frameworks/base is required to slightly expand its protobuf output.

Other notable changes:
- support for the "fraction" resource type
- parsing is now parallelized at APK level
2023-08-31 16:03:43 -04:00
.github github: Add funding links 2021-12-23 00:17:59 -08:00
bin require adevtool to always be started from the root of OS tree 2023-08-31 16:03:43 -04:00
config remove product/etc/CarrierSettings/ from dep_files 2023-08-31 16:03:43 -04:00
docs docs: Document system source formats 2022-04-04 15:47:01 -04:00
external extract_android_ota_payload.py: don't keep temporary payload.bin file 2023-08-31 16:03:43 -04:00
scripts unpack-images.sh: avoid race condition when creating destination dir 2023-06-20 16:26:04 -04:00
src rewrite aapt2-based overlay parser 2023-08-31 16:03:43 -04:00
vendor-skels do not use BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES 2023-08-31 16:03:43 -04:00
vendor-specs do not use BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES 2023-08-31 16:03:43 -04:00
.editorconfig add a script for unpacking file system images from factory zip files 2023-03-06 09:36:40 -05:00
.eslintignore Create oclif project 2021-11-06 23:34:51 -07:00
.eslintrc eslint: Remove AirBnB config 2022-04-04 15:47:01 -04:00
.gitignore update gitignore 2023-08-31 16:03:43 -04:00
.prettierrc prettier: Add initial config 2021-12-25 01:47:05 -08:00
LICENSE add GrapheneOS copyright notice 2023-07-13 21:58:04 -04:00
mountimages.bash Simplify mountimages.bash directories 2022-04-04 15:47:01 -04:00
package.json add ts-proto dependency 2023-08-31 16:03:43 -04:00
README.md readme: Document choice of language 2022-04-04 15:47:01 -04:00
tsconfig.json tsconfig: Enable ES module interop 2021-11-23 20:14:09 -08:00
yarn.lock add ts-proto dependency 2023-08-31 16:03:43 -04:00

adevtool

Android ROM device support and bringup tool, designed for maximum automation and speed.

Demo video on asciinema

Features

This tool automates the following tasks for devices that mostly run AOSP out-of-the-box (e.g. Google Pixel):

  • Downloading factory images and full OTA packages
  • Generating a list of proprietary files
  • Resolving overridden build rules and building modules from source (when possible)
  • Extracting, converting, and mounting factory images (supported source formats)
  • Extracting proprietary files
  • Extracting bootloader and radio firmware
  • Finding and adding missing system properties
  • Overriding build fingerprint to help pass SafetyNet
  • Adding missing SELinux policies
  • Adding missing HALs to vendor interface manifests
  • Generating resource overlays for device configs
  • Fixing privileged app signing certificates referenced in SELinux policies

This typically results in better device support with fewer bugs and issues, and makes it possible to quickly add support for new devices.

Example generated vendor modules for Pixel devices

Non-AOSP devices

Pixel devices will benefit from the most automation, but several features can still be used to ease manual bringup on other devices:

  • Extract files from proprietary-files.txt up to 2000% faster than LineageOS extract-utils (speed comparison)
    • LineageOS extract-utils: 1 min 27 sec
    • adevtool: 4 sec
    • Tested with Pixel 5 (redfin), cache cleared before testing
  • Compare a built system against stock images to find missing files, properties, and vendor interface declarations
  • List system files relevant to bringup (in all partitions)
  • Resolve overridden build rules from build warnings
  • Check SELinux policies to identify apps that should be presigned

Installation

Pre-requisites:

  • Node.js
  • Optional:
    • For converting sparse factory images: simg2img
    • For extracting OTA packages: payload-dumper-go
    • For extracting OTAs or factory images: unzip
    • For generating overlays: AAPT2 (included in AOSP and Android SDK)

To run adevtool without installation:

npx adevtool

To install adevtool globally using npm:

npm install -g adevtool

Using Yarn:

yarn global add adevtool

Usage

Why TypeScript?

TypeScript is not a common language for Android-related tools, but I picked it for several reasons:

  • Fast (enough) and easily parallelizable
  • Good static type system (for developer experience: fewer bugs and better editor code intelligence)
  • Good libraries for friendly CLI interfaces with pretty output
  • Relatively lightweight

Why not...

  • Python: May not meet speed/parallelization goals easily, types aren't as nice
  • Kotlin: Requires big+heavy JVM to run, CLI libraries aren't as good
  • Go: Good choice overall, but error checking can be overly verbose

Overall, TypeScript is a decent compromise on all of these points.

License

This tool is licensed under the MIT license, ensuring that anyone is free to use it for any purpose in compliance with the license. Contributions are welcome!