Repository navigation
feat(reboot): let reboot() take a target such as bootloader or recovery - #584
Merged
Merged
Conversation
device.reboot() always sent reboot:, so there was no way to do adb reboot bootloader, recovery, sideload or fastboot. It now takes an optional target and sends reboot:<target>, which adbd hands to the device as is. Without a target it still sends exactly reboot:. Fixes #235 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Karol Wrótniak <karol.wrotniak@droidsonroids.pl>
The README still listed a callback as reboot()'s argument, so a JavaScript caller doing reboot(fn) would now send the function's source as the target. Only a string is used as the target now; anything else sends plain reboot: as before. The stale callback line is removed from the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Karol Wrótniak <karol.wrotniak@droidsonroids.pl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature
device.reboot()always sentreboot:, so there was no way to doadb reboot bootloader,recovery,sideloadorfastboot. It now takes an optional target and sendsreboot:<target>, which adbd passes to the device as is. Without an argument it still sends exactlyreboot:, so existing callers (stf among them) are unaffected.Caveat, documented in the README and JSDoc: if the device refuses the target, adbd keeps the connection open and the promise doesn't settle.
adb reboot <target>doesn't return either. I didn't add a timeout or AbortSignal, since that's more than the issue asks for.Fixes #235
Verification
reboot:bootloader,reboot:recoveryandreboot:sideloadare sent as is, a FAIL rejects, anddevice.reboot()/device.reboot('recovery')send exactlyreboot:/reboot:recovery.npm test: 290 passing.npm run lintis clean.adb get-stateandsys.boot_completedpolled every 2 s):reboot()true; offline at +0 s,deviceat +17 s, booted at +24 s;sys.boot.reason=reboot,shellreboot('bootloader')true; offline, back at +15 s, booted at +19 s, back into Android;sys.boot.reason=bootloader(an emulator has no bootloader)reboot('bootloader')true; back at +10 s, booted at +22 s, into Android;sys.boot.reason=bootloaderreboot('recovery')Received sys.powerctl='reboot,recovery'and thenFailed to set bootloader message: failed to find /misc partition.adb -s emulator-5620 reboot recoveryalso hung (still running after 20 s).stf local emulator-5620, adbkit from this branch'snpm pack): Advanced, then Restart Device, then OK, driven with Playwright.tx.donesuccess: true, stf loggedRebooting, the device's uptime went from 1048 s to 16 s (sys.boot.reason=reboot,shell), and stf's device unit wasFully operationalagain 25 s later.Merge order
#545 (a contributor's JSDoc fix, waiting for their sign-off) rewrites the description line of the same
reboot()JSDoc block. This PR leaves that line alone and adds a@paramline below it, and the two merge cleanly in either order (checked with a test merge). Merging #545 first keeps the history tidier.Review follow-up (commit
38152de)The README still listed
callback(err)forreboot(), so a JavaScript caller doingreboot(fn)would have sent the function's source as the target (reboot:() => undefined). Only a string is used as the target now. Anything else, such asundefinedor a function, sends plainreboot:. The stale callback line is gone from the README, which now saysreboot()takes no callback.reboot(undefined)andreboot(fn)send exactlyreboot:. Without the fix the function case sentreboot:() => undefined.npm test292 passing, lint clean.reboot(function cb(err) {})on API 36 resolvedtrue; the device came back with uptime 9.6 s andsys.boot.reason=reboot,shell.🤖 Generated with Claude Code