BetterKnownInstalled v1.6.1
New
- OTA update support —
updateJsonadded tomodule.prop, so the manager can now notify you when a new BKI release is available. - Regression harness (
tools/bki_debug.sh) — a self-contained test suite that dot-sources the real module functions and validates them against anypackages.xmldump (e.g. fromabx2xml) without touching the live system. Covers uid resolution, DB build/prune/update, patch semantics (no duplicate attributes, well-formed output), end-to-endprocess_xml, byte-identical idempotency, and the uninstall restore round-trip. Expect24 passed, 0 failed. Verified against a real 868-packagepackages.xmlon-device. - Full ABX variant support —
installerUid-int,packageSource-int,isOrphaned-bool, andinstallInitiatorUninstalled-boolattribute variants are now handled consistently across the patch, the metadata DB, and the uninstall restore.
Fixes
- Invalid XML on multi-line
packages.xml— when the system writes package attributes wrapped across multiple lines, the old engine injected a duplicateinstallerattribute (and silently skipped the wrapped attributes), which could make Package Manager reject the file. The new walker edits the complete<package>element regardless of line wrapping. packages.xmlgrew on every boot — the old line-split → modify → collapse round-trip was not idempotent. The new pre-split and patch are fixed points: a second full run is byte-identical, verified by the harness.- Multi-line packages skipped — they were invisible to the
metadata.dbbuild/scan and to the v1.6.0 uninstall restore.
Changes
- Engine rewrite — the 8-pass
sedpipeline is replaced by a single streamingawkpass that walks the file once and edits one<package>element at a time. Output is now byte-minimal: everything outside patched user apps is preserved verbatim instead of being reformatted. uninstall.shrebuilt on the same engine — streaming restore (no moretr '\n' ' 'collapse), strips and re-injects all installer-related attribute variants, keeps the safety backup, atomic write + verify.- Shared helpers consolidated —
ensure_abx_tools()andrestore_perms()moved toutil_functions.shalongsidewait_for_data().
Technical
- Engine: single-pass streaming
awk(walker hands one<package>…</package>segment at a time tohandle_package()); heredoc-quoted fragments, noeval - Idempotency: pre-split
s|</package>\(.\)|…\n\1|gand the patch are both fixed points — repeated boots do not modify or grow the file - State:
metadata.dbschema unchanged (8 pipe-delimited fields) — v1.6.0 DBs are fully compatible - Scope: unchanged —
codePath="/data/app/"whitelist,system="true"/"1"guard - UID source:
com.android.vendingself-entry → existing Play Store app fallback (both now multi-line-safe)
Upgrade Note
Upgrading from v1.6.0 is seamless — the DB schema is unchanged and existing entries are reused. The v1.6.0 caveat still applies for apps first patched before v1.6.0 (their patched values are recorded as "originals," so uninstall won't revert those to the true pre-BKI state). Everything installed after v1.6.0 restores exactly.