The module helps reduce the chance of OEM unlocking being disabled,
whether by the user or by some OS's initial setup wizard. It works by
running some Java code at boot, which connects to the `OemLockService`
binder service and calls `setOemUnlockAllowedByUser(true)`, the same as
what the Settings app does.
Fixes: #8
Issue: #84
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
These versions are missing Magisk commit
1f8c063dc64806c4f7320ed66c785ff7bc116383, which fixes booting into
recovery on devices that use Android 13 GKIs. Trying to use these
versions with avbroot would prevent the user from installing future OTAs
without manually flashing a boot image patched with a newer Magisk
version while booted into Android first.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
In addition to the preinit device, Magisk now requires a random seed to
be added to the Magisk config in the boot image. Magisk's boot_patch.sh
generates a new seed every time an image is patched, but avbroot will
use the hardcoded seed 0xfedcba9876543210 to guarantee byte-for-byte
reproducibility of the output file. This can be overridden with
--magisk-random-seed <uint64>.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
Unlike the prior RULESDEVICE, PREINITDEVICE uses a block device name
since the rdev major/minor is not guaranteed to remain the same across
reboots. This commit completely drops support for RULESDEVICE (25207
through 25210) since it never made it to a stable Magisk release.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
Newer Magisk versions no longer try to autodetect a writable ext4
partition for storing SELinux rules during boot. Instead, the block
device is detected during boot image patching and is stored in the
ramdisk's `.backup/.magisk` as `makedev(rdev_maj, rdev_min)`.
This unfortunately complicates the patching process for avbroot. Even if
we replicate Magisk's algorithm for finding a suitable partition,
there's no way to find the block device's rdev for it with the
information contained in the OTA package. This is the first change that
adds a hard dependency on information only attainable from a running
device.
For these newer Magisk versions, the user will have to patch the boot
image once in the Magisk app (must be on the target device) and then run
`avbroot magisk-info` to show the computed device ID. Then, avbroot can
use this during patching via `--magisk-rules-device`. If the user's
device is unable to run the Magisk app prior to patching (eg.
unbootable), they'll have to go through the patching process twice, once
with `--ignore-magisk-warnings` and a second time with the proper device
ID specified.
When using `--ignore-magisk-warnings`, root still works, but there will
be subtle issues, like certain modules failing to load.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This way, the module path is automatically updated when avbroot is
imported. This also fixes the lint warning about `external` being
imported, but not used.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This commit merges the CI tests from `tests_ci/` into `tests/` so we
have a single way to test against both full OTAs and stripped/dummy
OTAs.
Features kept from tests_ci:
* Support for dummy OTAs. They're now called stripped OTAs to hopefully
better signify that they're a stripped down version of the original
file instead of a test file created from scratch.
* Extracting AVB partitions and verifying their hashes.
* Writing sparse files where possible.
* Ability to change the working directory for downloads and output
files.
Test script changes:
* There are now 4 subcommands:
strip -i <input> -o <output>
add -u <url> -d <device> [-H <expected hash>]
download [--magisk | --no-magisk] [[-d <device>] ... | --no-devices]
test [[-d <device>] ...]
* Downloads now use the parallel downloader for both full and stripped
OTAs.
Config file changes:
* It now uses strictyaml instead of configparser/TOML since it's a bit
more readable now that we have more nesting in the data structure. The
config loader now also makes use of strictyaml's schema feature.
* All hashes are now SHA-256 for consistency.
* For stripped OTAs, the list of byte ranges now uses half-open
intervals for easier calculations.
* Use device IDs as the key instead of the marketing model name.
CI changes:
* Compute all cache keys (and prefixes) in the main workflow and pass
them to the preload scripts.
* Only run on `push` for the `master` branch to avoid double workflow
runs on PRs from internal branches.
* Increase timeout for patching tests because `tests.py` patches twice
(once with `--magisk` and once with `--prepatched`).
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
This significantly reduces the size when patching dummy OTAs. This is a
naive implementation that just seeks when the entire write() buffer is
all zeroes, but that seems to be more than sufficient. The output files
have fewer blocks allocated than the (dummy) input files.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>
No fancy algorithm. Just a simple moving average over 5 seconds, updated
at 100ms intervals.
Signed-off-by: Andrew Gunnerson <accounts+github@chiller3.com>