跪拜 Guibai
← All articles
Android · WebView · Debug

A Hidden adb Command Saved a Redmi K80 From an Infinite Boot Loop Without Wiping Data

By 用户08126803741 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Any sideload of WebView or a similar system-native component onto a locked-bootloader device can trigger this boot loop. The rescue command works even while system_server is crashing, preserving user data and avoiding a service center detour that would otherwise end in a factory reset.

Summary

A Redmi K80 with a locked bootloader and no root gets stuck on the HyperOS boot animation after a manual `adb install` of an updated Android System WebView. system_server crashes every 5.6 seconds on a WebViewZygote null pointer, so the phone never reaches boot_completed. The bad update sits in /data/app as an UPDATED_SYSTEM_APP, but the system refuses to recognize it as a valid WebView provider.

All standard rescue attempts fail. PackageInstallerService rejects every package operation with `System is not ready yet` or `device is still booting` because boot never completes, while adb has no write access to /data. Safe mode, recovery, sideload, and official OTA all fail to remove the /data-based update.

The escape route is a hidden subcommand, `cmd package uninstall-system-updates`, which talks to IPackageManager directly and skips the boot check. After a few retries to land inside the crash window, it removes the bad update, the phone falls back to the factory WebView, and boot completes in about ten seconds. A subsequent reboot confirms the fix, with zero data loss.

Takeaways
— The boot loop results from an invalid WebView provider: a manual `adb install` places the update in /data/app, and WebViewUpdateService cannot start a zygote for it, crashing system_server every 5.6 seconds.
— `adb devices` still shows 'device' during the crash loop because adbd runs independently of system_server; this connection is the only rescue window, so don't enter recovery prematurely.
— The deadlock is: boot completion waits for package manager readiness, but PackageInstallerService blocks all writes until boot completes, so `pm uninstall`, `adb install`, and session-based installs all fail with 'System is not ready yet' or 'device is still booting'.
— `cmd package uninstall-system-updates <package>` bypasses the deadlock because it uses IPackageManager Binder, not PackageInstallerService, and carries no boot check.
— Do not append `--user 0` to that command; it is parsed as a package name and triggers a NullPointerException in PackageManagerShellCommand.
— 'Broken pipe' or 'Can't find service' errors during the crash loop are timing artifacts, not permission denials; a retry loop lands the command in a stable window.
— After the command succeeds, the phone automatically falls back to the factory WebView, and `sys.boot_completed` flips to 1 within about ten seconds.
— Official OTA or Mi Flash's 'flash_all_except_storage' preserves userdata but also preserves the broken /data update, so those methods cannot fix this class of boot loop.
Conclusions

The distinction between PackageInstallerService and IPackageManager Binder calls explains why nothing else worked: any package write that goes through the installer service inherits the boot check, while direct binder calls bypass it.

The NPE from `--user 0` is useful diagnostic evidence: it proves the command reached the implementation, confirming the channel is open even when the system is mid-crash. Error messages in a deadlock can validate a path, not just signal failure.

WebView is boot-time critical; treating it as a normal APK that can be rewritten via adb is the root mistake. The article's advice generalizes to any system component with native libraries that run from inside the APK, where alignment and storage requirements are stricter than typical sideloads.

Concepts & terms
UPDATED_SYSTEM_APP
A package flag in Android's package manager indicating that a system app has been updated with a newer version stored in /data/app, overriding the factory APK in /system or /product.
PackageInstallerService
The Android system service that manages install/uninstall sessions. It refuses to accept any package operation until the system has completed booting, throwing 'System is not ready yet'.
WebViewZygote
A dedicated zygote process for WebView renderers. When the WebView provider is invalid, it returns null and crashes system_server with a NullPointerException, causing a boot loop.
IPackageManager Binder
The low-level binder interface for package management that some shell commands use directly. It does not carry the boot-completion check that PackageInstallerService imposes.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗