A Hidden adb Command Saved a Redmi K80 From an Infinite Boot Loop Without Wiping Data
Author: Mo Bai · 2026-11-22 · A night that almost became "format"
TL;DR Manually
adb installed an Android System WebView, the phone got stuck on the "Powered by Xiaomi HyperOS" boot animation, and system_server crashed every 5.6 seconds. All conventional repair methods (uninstall, downgrade install, safe mode, recovery, flashing) failed, because boot never completed →PackageInstallerServicerefused all write operations, creating a deadlock. Finally, a hidden commandadb shell cmd package uninstall-system-updatesdirectly deleted the bad update in/data/appduring the boot crash loop, zero data loss, non-destructive repair. The full troubleshooting process is documented below.
1. The Incident Scene: A Small Slip of the Hand, and the Phone Won't Boot
The cause was trivial: installing a newer Android System WebView on a Redmi K80.
After adb install, the phone rebooted, and then it hung on the boot animation.
Powered by Xiaomi HyperOS
(And then nothing)
The device details, which we will use repeatedly later:
| Item | Value |
|---|---|
| Model | Redmi K80 (codename zorn, model 24117RK2CC, China version) |
| OS | HyperOS 4 / Android 17 |
| Bootloader | Locked (flash.locked=1, verifiedbootstate=green) |
| Build type | ro.build.type=user (production, no root) |
| adb permission | uid=2000(shell), no su |
That is: no root, locked BL, all official toolchains restricted. This is the hardest combination to save.
2. Don't Panic First: If adb Can Still Connect, There's Still Hope
When the phone is stuck at boot, the first thing to do is not to randomly press buttons, but to check adb.
$ adb devices
a8ce7e71 device
The device status indicates the USB debugging authorization is still valid. This is critical: adbd runs independently of zygote/system_server, so even if the system core process is in a crash loop, we still have a usable window.
Check the boot completion flag first:
$ adb shell getprop sys.boot_completed
(empty)
$ adb shell getprop init.svc.zygote
running
sys.boot_completed is empty, but zygote status is running — it is not stuck, it is restarting repeatedly.
Grab the crash log (-b crash specifically stores exceptions):
$ adb logcat -d -b crash -t 200
The stack trace is very clean, repeated again and again:
FATAL EXCEPTION IN SYSTEM PROCESS: AsyncTask #1
java.lang.NullPointerException: Attempt to invoke virtual method
'android.os.ZygoteProcess android.os.ChildZygoteProcess.getZygoteProcessAsManaged()'
on a null object reference
at android.webkit.WebViewZygote.getProcess(WebViewZygote.java:65)
at com.android.server.webkit.SystemImpl.ensureZygoteStarted(SystemImpl.java:255)
at com.android.server.webkit.WebViewUpdateServiceImpl2.startZygoteWhenReady(...)
Repeats every 5.6 seconds. The time from a system_server process start to its death is very precise.
Lesson Blood-Sweat ①: Stuck at boot ≠ brick. As long as
adb devicesshowsdevice, you still hold a rescue window independent of the system boot process. Do not go into Recovery immediately — if you actually enter recovery, you lose the shell (testing this time, Xiaomi's official recovery only opens a sideload channel, not a root shell), which is like closing the window with your own hands.
3. Root Cause: It's Not That "157 Broke" — It's an Invalid Provider
Check the WebView service state:
$ adb shell dumpsys webviewupdate
Current WebView package is null
Any WebView package installed: false
Preferred WebView package (name, version): (com.google.android.webview, 158.0.8127.46)
Valid package com.google.android.webview (versionName: 158.0.8127.46, ...) is installed/enabled for all users
Several contradictory facts stack up:
Preferredpoints to version 158 (by the way, the user thought they installed 157, actually it's158.0.8127.46);- But
Current WebView packageisnull,Any WebView package installed: false; - And the system lists it as a "Valid package".
Now look at where it is installed. Pull version, path, and flags together:
$ adb shell dumpsys package com.google.android.webview | grep -E 'versionName|versionCode|codePath|flags'
codePath=/data/app/~~PvjYm06HhtnbK8BEHMkABA==/com.google.android.webview-wZ3BgKmGiR9-Fq2uWgp_Ag==
versionName=158.0.8127.46
versionCode=812704601
flags=[ SYSTEM HAS_CODE ALLOW_CLEAR_USER_DATA UPDATED_SYSTEM_APP ALLOW_BACKUP KILL_AFTER_RESTORE ]
And the system's preloaded original? In Hidden system packages:
codePath=/product/app/WebViewGoogle64/WebViewGoogle64.apk
versionName=150.0.7871.181
versionCode=787118103
Putting the two versions together makes it clear:
| Version | versionCode | Location | Identity | |
|---|---|---|---|---|
| Installed | 158.0.8127.46 | 812704601 | /data/app/~~.../base.apk |
UPDATED_SYSTEM_APP |
| Factory original | 150.0.7871.181 | 787118103 | /product/app/WebViewGoogle64/WebViewGoogle64.apk |
PRODUCT preloaded |
Conclusion:
The installed 158 version landed in
/data/appas anUPDATED_SYSTEM_APP, overriding the factory original 150.0.7871.181 (a 64-bit only package) in/product/app/WebViewGoogle64. And 158 is not a valid WebView provider for this device. WebViewUpdateService can't start the corresponding webview zygote at boot →WebViewZygote.getProcess()gets null → NPE → system_server crashes → never reachesboot_completed→ stuck on the boot animation forever.
The disease is in /data, not in /system or /product. Remember this sentence, because it determines the success of every subsequent approach.
By the way, this pit has a precedent: WebView-type components' native libraries must be executed directly from the APK, requiring zipalign and .so files stored decompressed. The generic single-APK distribution format from the Play Store often does not meet this requirement, and directly overriding onto a system device results in this exact death.
4. Deadlock: A Parking Lot That Only Lets You In, Never Lets You Out
Since we know it's a bad package in /data, why not just delete it? The problem is right there.
Boot not completed → PackageInstallerService not ready → rejects all package writes → package can't be deleted → boot never completes.
The most typical error came from a staged install session:
Exception occurred while executing 'install-create':
java.lang.SecurityException: System is not ready yet!
at com.android.server.pm.PackageInstallerService.createSessionInternal(...)
I put all attempts into a table, all tested in practice:
| Attempt | Result |
|---|---|
pm uninstall -k --user 0 / adb uninstall |
Error: device is still booting. |
adb install -r -d downgrade override to original 150 |
Also blocked by device is still booting |
pm install-create -r -d -S <size> staged session |
SecurityException: System is not ready yet! |
setprop sys.boot_completed 1 |
SELinux blocks (ro.build.type=user) |
setprop persist.sys.safemode 1 |
Same |
adb root / directly delete /data/app |
No root; /data/app is drwxrwx--x system:system, shell write permission Permission denied |
pm disable-user |
SecurityException: Cannot disable system packages. |
pm hide |
Requires MANAGE_USERS permission |
| Manual key-press to safe mode (volume down) | Can't get in |
adb reboot safemode |
HyperOS 4 ignores it; after reboot ro.sys.safemode is still empty |
cmd webviewupdate set-webview-implementation to switch provider |
Framework only allows com.google.android.webview |
cmd package suspend to suspend the bad package |
Command succeeds, but the crash stack after reboot is identical — Xiaomi's WebViewUpdateServiceImpl2.startZygoteWhenReady starts the zygote unconditionally, independent of package state |
| Recovery "Connect Xiaomi Assistant" | Only a sideload channel; adb shell returns error: closed, no root shell |
adb sideload to send a package (including an unsigned OTA probe) |
adb: failed to read command: No error, the data stream never even begins |
| fastboot | BL locked, Flashing is not allowed in lock state |
| Xiaomi Assistant data-preserving reflash / official OTA | There are public cases where the system version updated but the fault remained exactly as before — because Mi Flash's flash_all_except_storage.bat explicitly skips userdata, it can't fix a disease in /data |
At this point, more than two hours had passed. I had already drawn up the cost table for "clear data / send to service" and was ready to let the user make the call.
Because there was still one hard constraint: the phone was not unlocked, FBE encrypted storage was not mounted, /sdcard did not exist at all, and photos and chat records could not be backed up at that moment. "Factory reset" is not "fixed", it is "data wiped to zero".
Lesson Blood-Sweat ②: Diseases in
/datacannot be cured by reflashing the system. Dirty flash, OTA, and official data-preserving flashes only touch thesystem/productpartitions; theUPDATED_SYSTEM_APPupdate in/data/appstays untouched, and it will still crash after flashing. First locate which partition the disease is in, then decide whether to download those few GB of ROM — this time we saved a useless 7.8 GB download.
5. Breakthrough: A Command Hidden in the Help Output
The turn came from a very plain action: I printed out the complete subcommand table of cmd package.
$ adb shell cmd package help
Previously I had been trying install / uninstall / install-existing / suspend / disable from memory. In the full subcommand list, there was one I had never seen:
uninstall-system-updates [<PACKAGE>]
Removes updates to the given system application and falls back to its
/system version. Does nothing if the given package is not a system app.
If no package is specified, removes updates to all system applications.
"Remove updates to system applications, fall back to the /system version." — That is exactly the action we needed, word for word.
But why believe it could bypass the System is not ready yet deadlock? The clue was already there earlier: when we tried cmd package install-existing, it returned success during the crash loop.
$ adb shell cmd package install-existing com.google.android.webview
Package com.google.android.webview installed for user: 0
And install-existing and uninstall-system-updates both go through IPackageManager's Binder call, not through PackageInstallerService. So they don't have that boot check.
Pit 1: Don't Add --user 0
This command does not support that argument; --user is treated as a package name and looked up, then:
Exception occurred while executing 'uninstall-system-updates':
java.lang.NullPointerException: Attempt to invoke virtual method
'boolean android.content.pm.ApplicationInfo.isUpdatedSystemApp()' on a null object reference
at com.android.server.pm.PackageManagerShellCommand.uninstallSystemUpdates(PackageManagerShellCommand.java:622)
at com.android.server.pm.PackageManagerShellCommand.onCommand(PackageManagerShellCommand.java:390)
Interestingly, this NPE itself is good news. It proves the call really reached the implementation inside PackageManagerShellCommand (line 622), and was not blocked by the System is not ready yet! pre-check. In other words: this channel is open, just need to get the arguments right.
Pit 2: Crash Intervals
system_server crashes every 5.6 seconds, so the command randomly hits three outcomes:
cmd: Can't find service: package
cmd: Failure calling service package: Broken pipe (32)
Uninstalling updates to com.google.android.webview... Success
The first two are not permission denials, they are timing issues. Write a retry loop, and it hit success on the 4th try:
$ adb shell cmd package uninstall-system-updates com.google.android.webview
Uninstalling updates to com.google.android.webview... Success
Immediate effect:
$ adb shell pm path com.google.android.webview
package:/product/app/WebViewGoogle64/WebViewGoogle64.apk
$ adb shell dumpsys webviewupdate
Current WebView package (name, version): (com.google.android.webview, 150.0.7871.181)
Any WebView package installed: true
The update in /data is gone, and the system automatically falls back to the factory 150 in /product.
About ten seconds later:
$ adb shell getprop sys.boot_completed
1
Boot completed. The phone entered the system.
6. Verification: Not a Fluke
Reboot once for stability re-check:
sys.boot_completed = 1
init.svc.zygote = running
ro.sys.safemode = (empty, normal mode)
Updated system app flag: gone
suspended = false
logcat -b crash : no new crashes after boot
The WebViewZygote NPE never appeared again. Photos and WeChat records are all there — no data-clearing operation was ever executed throughout the entire process.
7. Retrospective: What I Learned This Time
1. First Determine Which Layer the Deadlock Is In
The root cause of two hours of fiddling was that all package operations were blocked at PackageInstallerService's System is not ready yet. And commands that go through IPackageManager don't have this check. Figuring out "which commands go through which channel" is a hundred times more useful than blindly retrying.
2. cmd <service> help Is a Treasure Trove
The common commands for pm / cmd package are only the tip of the iceberg. Hidden subcommands like archive, unarchive, uninstall-system-updates are rarely mentioned. Before troubleshooting, print out the full help output and read it — I missed this step and went around in circles for more than an hour.
3. Broken pipe ≠ "No Permission"
In a crash loop environment, Can't find service / Broken pipe just means you didn't hit the process's live window. Write a retry loop; don't draw conclusions. In a sense, these errors are actually signals that "the command has been sent in".
4. The First Command When Stuck at Boot Should Be adb devices
As long as you see device, there is still a window. The real danger is never the crash loop itself, but your finger twitching and clicking "Clear Data".
5. Version Number and codePath Are the Most Honest Evidence
The UPDATED_SYSTEM_APP flag in dumpsys package's flags field instantly reveals the root cause of "factory preload overwritten by /data update". When checking a package's state, pull out codePath + versionName + flags together — more useful than reading ten tutorials.
6. Don't Manually Override System WebView
WebView is not an ordinary app; it is loaded early during system_server startup and is a boot-critical component. Vendor preloads are often 64-bit only packages (the naming WebViewGoogle64 is a signal), and the .so compression/alignment of a generic single APK may not meet the requirement of "executing from inside the APK". Upgrades should go through system updates or app stores, not adb install overrides.
8. Appendix: Rescue Command Quick Reference
If you are stuck in the same pit, follow this order:
# 1. Confirm you can still connect
adb devices # expected: device
adb logcat -d -b crash -t 50 # confirm the crash stack is related to WebViewZygote / webviewupdate
# 2. See where WebView is installed
adb shell pm path com.google.android.webview
adb shell dumpsys webviewupdate
# 3. Core: revert system app update (can loop-retry)
for i in $(seq 1 30); do
adb shell cmd package uninstall-system-updates com.google.android.webview
adb shell pm path com.google.android.webview | grep -q /product/ && echo OK && break
sleep 1
done
# 4. Re-check and wait for boot
adb shell pm path com.google.android.webview # should point to /product/...
adb shell dumpsys webviewupdate # Current WebView should be the original version number
adb shell getprop sys.boot_completed # should be 1
Lesson Blood-Sweat ③ (and the whole article's essence): ✅ Use
cmd package uninstall-system-updates <package>❌ Do not add--user 0(it gets treated as a package name, triggering NPE atPackageManagerShellCommand:622) ✅ If you hitBroken pipe/Can't find service, retry — that's a timing issue ❌ Do notpm uninstall/adb install(they get blocked bydevice is still booting) ❌ Do not clear data, do not unlock BL, do not touch third-party EDL tools
Written at the end: This rescue went from "preparing to format your phone" to "solved with one command"; what stood in between was a single help document. In the technical world, often it's not that there is no path, but that we trust the few maps we remember too much.
—— Mo Bai, late night 2026-11-22