adb keys on the S1: how does a new computer get in, and why does Android 10 forget keys?
Status (2026-11-29): Aqara's adbd doesn't check keys; with the frame agent's Magisk module it does (both
verified). Aqara's adbd skips the key exchange: it never asks a computer to sign, although ro.adb.secure=1. The
reason is one store it makes right after reading ro.adb.secure. The frame agent patches that store out through a
Magisk module (the fix). Across a reboot (attempt 7), the patched adbd lets in the keys in adb_keys,
refuses a key it doesn't know, and puts it up as asking for Manage's Allow. Manage's Allow lets the computer in only
when it connects again (attempt 8). That comes from a stock Android 10 bug in libadbd.so, which the module now patches
too: with it, Allow lets the waiting computer in within about 4 s (attempt 9). The rest of this note, Android 10's key handling and the agent's side, still holds, and is read from AOSP
android10-release or tested off-device in frames/aqara-s1-plus/tools/radio/test/.
Device: Aqara Panel Hub S1 Plus, Android 10 (Aqara firmware 4.5.80). Source: AOSP platform/frameworks/base,
branch android10-release.
Question
A maintainer noticed they had never had to accept an adb key on the S1. Does the panel let in any key? And can Manage let in a new computer, as it does on the Mirror (privileged-app.md)?
How we got here
The first question seemed to have a quick answer, and it turned out to be wrong. Our first guess was this:
ro.adb.secure=1 (findings.md), so adbd lets in only keys listed in
/data/misc/adb/adb_keys, and nobody ever sees the prompt because the installer bakes its computer's key
into the boot image (overlay.d/sbin/glassworks_adb_keys), and glassworks_firstboot.sh copies it into adb_keys
once. A dev boot image (glassworks_devsu.sh) adds it back at every boot. Attempt 4 and the binary disproved that
guess: Aqara's adbd skips the key check altogether (the fix).
For the second question, the Mirror's way doesn't carry over. On the Mirror the app reads the system log for
Received public key: and calls the hidden IUsbManager.allowUsbDebugging, which needs MANAGE_USB, a permission
its privileged app holds. Android 10 moved that call to IAdbManager (core/java/android/debug/IAdbManager.aidl),
behind MANAGE_DEBUGGING, and the S1 app is an ordinary app. It can't hold that permission, and it can't read the
system log either. But the S1 has a root side, the frame agent, and root has every permission. So the agent can
answer Android itself.
That led us to read how Android 10's AdbDebuggingManager handles keys. It turned up a second problem. Android 10
added key expiry: AdbKeyStore copies every key in adb_keys into adb_temp_keys.xml with a last-connection time,
and a scheduled job rewrites adb_keys without any key whose computer hasn't connected for
adb_allowed_connection_time. That setting defaults to 7 days. So the installer's key should drop out of adb_keys a
week after its last connection, and the next connection would ask on the panel's screen. Nobody had noticed, because
the dev panel's boot image adds the key back at every boot and the maintainer connects often.
Expiry also breaks a Remove button. The keystore keeps its keys in memory and rewrites adb_keys from them, so a key
taken out of the file can come back the next time a key expires. We asked the maintainer, who chose to turn the
timeout off (adb_allowed_connection_time = 0). That's the same as Android 11's developer option "Disable adb
authorization timeout". With the timeout off, the file is the record, and Manage's list can be trusted.
Turning the timeout off stops future drops, but it doesn't bring back a key Android already dropped, and first boot runs only once. So the agent also puts the boot image's key back at every start. The maintainer's call (2026-11-28) was to show that key on Manage as Kiln, or as the computer that ran the command-line installer, and let an administrator remove it like any other key. The agent records that removal and doesn't undo it.
What we tried
-
Read Android 10's adb framework (2026-11-28, read). The files:
$ curl -s 'https://android.googlesource.com/platform/frameworks/base/+/refs/heads/android10-release/<file>?format=TEXT' | base64 -d services/core/java/com/android/server/adb/AdbDebuggingManager.java (1143 lines) services/core/java/com/android/server/adb/AdbService.java (323 lines) core/java/android/debug/IAdbManager.aidl (44 lines)What they show:
IAdbManagerdeclaresallowDebugging(boolean alwaysAllow, String publicKey)first, so it's transaction 1. It's published as theadbservice (AdbService.java:71,Context.ADB_SERVICE).AdbService.allowDebuggingchecksMANAGE_DEBUGGING(:238). Root (uid 0) passes every permission check.- adbd hands Android a computer's key as
PK<key>, and Android logsSlog.d(TAG, "Received public key: " + key)under the tagAdbDebuggingManager(AdbDebuggingManager.java:196). It also logsReceived connected key message:when a listed key connects (:210). MESSAGE_ADB_ALLOWtakes the call only when the key's fingerprint is the one asking: otherwise it logsFingerprints do not match(:358–361). WithalwaysAllowit records the key (setLastConnectionTime), which appends it toadb_keysonly when the keystore doesn't know it yet (:1100–1102).AdbKeyStore.addUserKeysToKeyStorecopies every line ofadb_keysinto the keystore with the current time (:943–962).filterOutOldKeysdrops keys older thangetAllowedConnectionTime(), then rewritesadb_keysfrom the keystore (:1009–1028). That setting isSettings.Global.ADB_ALLOWED_CONNECTION_TIME(adb_allowed_connection_time), defaulting to604800000ms, 7 days (Settings.java:12393).0means never./adb_keys(system keys) never expire, but on this system-as-root image that's the system partition, and we don't write it.isKeyAuthorized(:1123) isn't called anywhere in Android 10. adbd decides from the file alone.
-
Built it in the frame agent (2026-11-28, tested off-device). See
glassworks_agent.sh, "computers allowed over USB adb", and the contract in radio.md. The tests are intools/radio/test/shell-tests.sh, "computers over USB adb". They use made-up keys and mocklogcat,service,settingsand system_server's pid. They cover log lines from another pid or older than 10 minutes, Allow for a computer other than the one asking, Android writing the key itself or not, keeping the owner and mode, putting the installer's key back after Android drops it, keeping it out once it's removed on Manage, and stale or malformed requests. -
Looked at the dev panel's adb files (2026-11-28, verified, read-only, from METIS's run 20 step 0). The panel runs app 0.9.0 (900) on a frame-loader boot image, with the agent source
boot.$ getprop ro.adb.secure -> 1 $ ls -la /data/misc/adb/ -> drwxr-s--- system shell, empty (only . and ..) $ ls /data/misc/adb/adb_keys -> No such file or directory $ settings get global adb_allowed_connection_time -> null (Android's 7 days)Both
adb_keysandadb_temp_keys.xmlwere gone, yet METIS's adb session still worked. Android deletes both files when every key in its keystore has expired:persistKeyStore(AdbDebuggingManager.java:971–977) callsdeleteKeyStore, which callsdeleteKeyFileand deletes the XML too (:1059–1066). adbd doesn't re-check a connection it has already let in, so METIS's open session survives. On an adbd that checks keys, the next restart or replug would ask on the screen; Aqara's doesn't check (attempt 4), so it wouldn't. This fits the 7-day expiry, but it doesn't prove it: we never saw the files before they went. -
Run 20b: a throwaway computer on the panel (2026-11-28, verified; driven from METIS, the maintainer's Windows machine, with the PR's agent pinned at
cf217d5through the loader's dev override). The props werero.adb.secure=1,ro.secure=1,ro.debuggable=0,sys.usb.config=adb, and the system log held noAdbDebuggingManagerlines.- The agent worked as built. It started from the dev override with its adb status
ok, set the timeout to0, and put the boot image's key back into anadb_keysthat Android had deleted ("the installer's key is back in the adb key list"). Remove took that key out again through the request file (ok removed), and kept the file's owner and mode. - adbd lets in any key. TCP adb was turned on with
setprop service.adb.tcp.port 5555; stop adbd; start adbd. A second adb server on the same machine, with a freshly generated key and USB off, then connected:
No$ adb -P 5099 connect <panel>:5555; adb -P 5099 devices -> device (expected: unauthorized) $ adb -P 5099 -s <panel>:5555 shell id -un -> shellReceived public keyline appeared, and the agent never saw anyone asking.adb_keysdidn't change, and no window drew on the screen. adbd's own log shows the connection go straight from transport to shell, with no auth step. Android's AdbDebuggingManager lost its socket to adbd at the restart ("Connection refused"), so nothing there could have approved it either. - Corrected by attempt 7: the throwaway wasn't one. METIS's second adb server (
-P 5099) also loaded METIS's own key from the real profile folder: adb 37.0.3 on Windows ignoresUSERPROFILE,HOMEandANDROID_USER_HOMEfor the user key (ADB_TRACE=auth). So the "fresh key" was signed with METIS's key too, anddevicealone shows nothing. What still holds is adbd's own log. It went straight from transport to shell, with nosend_auth_request, which the patched adbd always logs (attempt 7). That fits the binary (the store, below). - What it rules out. It isn't Android approving computers on its own: nothing reached the framework. The maintainer never approved METIS or their
MacBook, and both got in with an empty
/data/misc/adb/, which fits. - Not proven yet. Only TCP was tested with a fresh key; that USB behaves the same is inferred from the two computers above. Why adbd skips the check is open too: an Aqara build of adbd without authentication is the likeliest reason.
- The agent worked as built. It started from the dev override with its adb status
The fix
Why adbd doesn't check (2026-11-28, read). This is Aqara's 4.5.80 /system/bin/adbd, from the OTA's
system.new.dat.br, rebuilt with a small sdat2img script and dumped with debugfs. It's kept outside the repo, under
/tmp. It's 30,336 bytes, sha256 f122608055852e0b5a809703b7cafb4d04e4aab225680b414d502486766fe2ee, from the build
peony_evb2-user 10 QP1A.191105.004 test-keys.
$ llvm-objdump -d --start-address=0x20b4 --stop-address=0x20d6 adbd (adbd_main)
20b4: blx GetBoolProperty("ro.adb.secure", false)
20c2: strb r0, [r4] ; auth_required = ro.adb.secure (r4 = &auth_required, GOT at 0x23a8)
20ce: movs r0, #0x0
20d0: strb r0, [r4] ; auth_required = false <- the extra store
20d2: blx adbd_auth_init
auth_required lives in libadbd.so (.data 0x3609c, initial value 1). Its only other use is a read in
handle_packet, at 0x12710–0x12716: on a connection, if (auth_required) send_auth_request else handle_online.
libadbd.so still reads keys from /adb_keys and /data/misc/adb/adb_keys. So it's one store, and only that store
turns the check off. AOSP 10's adbd_main sets auth_required from ro.adb.secure only under ALLOW_ADBD_NO_AUTH,
and never writes false after.
The patch. At file offset 0x20d0 (the text segment maps file offset to address one to one), 20 70
(strb r0, [r4]) becomes 00 bf (nop). auth_required then keeps the value read from ro.adb.secure, which is 1.
The patched file's sha256 is a5648f6c772ca074d84b8b1fab332f58faf652dab30bcd47fc120fbb8657d16d. Patching the first
instruction (movs) instead doesn't work: r0 holds whatever the itt ne branch left there.
How it reaches panels. It can't ship as a file: it's Aqara's binary (hard rule 3). So the frame agent makes it on the panel, from the panel's own adbd:
- It checks that the live adbd's hash is 4.5.80's and that the 4 bytes at
0x20ceare00 20 20 70. - It writes the 2 bytes and checks the result's hash.
- It puts the copy into the Magisk module
glassworks_adbd_auth(system/bin/adbd, 0755 root:shell,adbd_exec).
Magisk mounts it over /system/bin/adbd at the next boot, before init starts adbd. The undo, the watch that takes the
module out if adbd doesn't run, and the status are described in radio.md.
Tested off-device in shell-tests.sh ("adbd checks keys"), with a made-up file.
Why Allow reaches the wrong computer (2026-11-29, read; found after attempt 8). This is a bug in stock Android 10,
not in anything Aqara changed. libadbd.so from the same build (239,892 bytes, sha256
ae8f0bc19dd7123e7ec9f9d26e3673c4a3c81cbb38e0c5dd84b252792eafc8e6) keeps one global for "the connection waiting
for Android's answer", adb_transport at 0x38098 (usb_transport in older AOSP). Three functions use it:
adbd_auth_confirm_key 29cda: cmp r1,#0 ; 29cde: bne 29cec ; claim it only if empty ...
(a key Android must answer) 29ce2: str r5,[r0] ; 29ce8: blx AddDisconnect ; ... and clear it when that one goes
adbd_notify_framework_connected_key 2a0be: cbnz r1,2a0ce ; 2a0c2: str.w r11,[r0] ; the same claim, for a listed
(a key adb_keys let in) ; computer that got in by signature
adbd_auth_event (Android's reply) 2aaac: "OK" -> 2aac6: blxne adbd_auth_verified(adb_transport)
So the first connection to claim the slot keeps it until that connection closes, and a listed computer that's
connected claims it before any new one asks. Android answers only its newest question (AdbDebuggingManager checks the
fingerprint). Its OK then goes to whichever connection holds the slot: adbd_auth_verified logs adb client authorized and sends that connection a second CNXN, while the computer that asked keeps waiting. In attempts 7 and
8 the slot was always METIS's own USB connection, listed by MF. That explains both runs. Only a computer that asks
while no listed computer is connected (and nobody asked before it) gets in live.
The second patch. At file offset 0x29cde of libadbd.so (also mapped one to one), 05 d1 (bne) becomes 00 bf
(nop). confirm_key then always gives the slot to the connection asking now, which is the one Android answers, and
registers the same disconnect hook, so the slot can never point at a closed connection. Notify's claim stays, but an
asking connection takes the slot over. The patched file's sha256 is
df98428d6f6298a45efa2b27406b2e975ff3eac029da5aff3b5fa1cd20e850a0. One edge stays: if two computers ask at once and
the earlier one closes, its disconnect empties the slot. If the later one was allowed each time, its key is in
adb_keys and it gets in on its next connection; after Allow once nothing was saved, so it asks again.
A second edge, which the patch narrows but doesn't close (read, not tried on the panel): Android's answer is the two
bytes OK, with no key and no connection in it, so adbd lets in whichever connection holds the slot when it reads
them. With the patch, a computer B that asks in the moment between Android sending OK for A and adbd reading it
takes the slot, and the answer meant for A. Stock Android 10 has the same gap, only wider: the slot stays with the
first computer that asked, so a B that connects before A and stays connected gets A's answer with no timing at all.
The agent narrows the window from its side. Every new question replaces the one it publishes, and an Allow for a
fingerprint that isn't the one asking any more is refused (changed). So B has to ask after the last question
the agent saw and before adbd reads the OK: the follower's lag in reading the system log, plus the service call
itself. We haven't measured that window (untested); our estimate is under a second, and B can't see it coming. Closing it would mean binding the answer
to a connection inside adbd, a larger patch than these 2 bytes. Only
adbd loads libadbd.so (every ELF in the image's /system/bin and /system/lib was checked for it). The module
carries it as system/lib/libadbd.so (0644 root:root, system_lib_file), made the same way as adbd: the live file's
hash, the 4 bytes 05 92 05 d1 at 0x29cdc, the 2-byte write, then the result's hash. Verified from the trial's
mount in attempt 9, and from Magisk's own mount across a reboot in attempt 10.
Attempt 5: run 20c, the patched adbd on the panel (2026-11-28, verified; driven from METIS with the agent and
trial.sh pinned at 19e097df, no reboot).
- The agent built the module as designed. Status
on after a restart, the module's adbda5648f6c…,-rwxr-xr-x root shell,u:object_r:adbd_exec:s0, 30,336 bytes, and/system/bin/adbduntouched. Against the panel's own adbd,cmp -lshows exactly the two bytes:8401 40 0 8402 160 277 - The patched adbd never ran.
trial.shbind-mounted the module's file straight over/system/bin/adbdand restarted adbd. init could not start it, at any try:
The trial log showedinit: cannot execve('/system/bin/adbd'): Permission denied type=1401 audit: op=security_bounded_transition seresult=denied oldcontext=u:r:init:s0 newcontext=u:r:adbd:s0 init: Service 'adbd' (pid …) exited with status 127adbd restartingat 10, 30 and 60 s. The panel had no adb at all, over USB or TCP, until the script's 900 s ran out and put Aqara's adbd back (exe f1226080). The panel was restored as found. - Why. This denial isn't a policy rule: the kernel refuses it even with the rest of SELinux permissive on this
panel. A bind mount keeps the flags of its source's mount, and
/datais mountednosuid. On anosuidmount the kernel allows only a "bounded" domain change, andinit → adbdisn't one. So the file is fine; where it's mounted from is the problem. - What it rules out and changes. A plain bind mount from
/datacan't replace a binary that init starts in its own domain. Whether Magisk's boot-time mount of the module hits the same wall is untested: it depends on how Magisk v31.1 mounts module files.trial.shnow copies the file to its own tmpfs (nonosuid) and binds from there, and it puts Aqara's adbd back after 60 s instead of 900 if adbd isn't running. - Also seen. Aqara's
AqaraSensorsDataapp logged "native restart : adbd" and queued an analytics event for it, with the panel's model and an id derived from its MAC. Aqara's telemetry hears about adbd restarts. - Still open: whether the patched adbd checks keys (3b to 3g of the run didn't happen).
Attempt 6: run 20d, the patched adbd from a tmpfs copy (2026-11-28, verified; driven from METIS, trial.sh
pinned at e9087d59, no reboot).
- The patched adbd starts. The trial's log shows the change of mount working, with no
nosuid:
It enabled USB (mounted: /system/bin/adbd a5648f6c772c, u:object_r:adbd_exec:s0, rw,seclabel,relatime,mode=755 at 10s: adbd running, pid 23766, exe a5648f6c772c (also at 30 s and 60 s)FUNCTIONFS_BIND,FUNCTIONFS_ENABLE) and listened on tcp 5555. - It checks keys, and a key in
adb_keyspasses. After the trial's own restart of the same binary, METIS came back over USB, and system_server logged what Aqara's adbd never sends (attempt 4 had none):
So adbd now goes through the key exchange, and METIS's key (MF, inAdbDebuggingManager: Received connected key message: <MF> <user>@<host> AdbDebuggingManager: Logging key <MF> …, state = 4, alwaysAllow = true, …adb_keyssince run 20b) let it in. - Not yet seen: a key that isn't listed being refused. At the first start of the patched adbd, METIS didn't
see the panel over USB at all for 15 minutes, not even as
unauthorized, so the throwaway key was never tried. The same binary came up on USB at once after the second restart. The cause is unconfirmed: dmesg had rolled past the first start, and the Windows host may not have re-enumerated the device. trial.shcouldn't put Aqara's adbd back while the patched one ran.back()unmounted before it stopped adbd, and the kernel refuses to unmount a file a running process executes from. So the restart brought the patched adbd back. METIS put Aqara's back by hand (stop adbd; umount; start adbd), andtrial.shnow stops adbd first.adb_keysheld MF twice afterwards, byte for byte, written while the framework logged MF withalwaysAllow = true. Which component wrote the second copy is unknown. It's harmless, and the agent now lists a computer once however many copies the file holds. The panel was otherwise restored as found, andadb_temp_keys.xmlnow exists (Android's record of MF's connection).
Attempt 7: run 20e, the Magisk module across a reboot (2026-11-28, verified; driven from METIS, the agent
pinned at 9b393f8c through the dev override; Magisk 31.1:MAGISK:R / 31100).
- Magisk's mount works. The agent made the module (
on after a restart;cmp -lshowed the two bytes), andadb rebootfollowed. USB was back 20 s later, through the patched adbd (exea5648f6c), with the statuson. The watch never fired. Magisk mounts the file from the block device, not through/data, so it doesn't carrynosuid:
(/dev/block/by-name/UDISK /system/bin/adbd f2fs ro,lazytime,seclabel,noatime,…/dataitself isrw,…,nosuid,nodev). So attempt 5's wall was the trial's own bind mount, not Magisk's. - A listed key gets in through the key exchange. adbd's log shows
Calling send_auth_request,Loading keys from /data/misc/adb/adb_keysandadb client authorized, and system_server loggedReceived connected key messagefor METIS's key (MF). - An unknown key is refused. Windows' adb always adds the user's own key (attempt 4's correction), so METIS
used a small Python adb client that holds one key only. With MF's key as a control, it got
deviceand a shell. With a fresh key:unauthorized. adbd refused the signature and sent a new token, and the client offered its public key.- It was put up as asking. system_server logged
Received public key: <fingerprint>, Android's "Allow USB debugging?" (UsbDebuggingActivity) opened on the panel, and the agent'sadb-askingshowed the fingerprint within a second. onceansweredok once, withadb_keysunchanged. After a reconnect the computer wasunauthorizedand asking again.allowansweredok allowed, and the key went intoadb_keys. After a reconnect:deviceand a shell.removeansweredok removed, andadb_keyswas as before. After a reconnect:unauthorized.- The status
sys.glassworks.adb.authstayedonthroughout.
- Not seen: a waiting computer let in live. After
onceand afterallow, adbd loggedadb client authorized, but the connection that was waiting never got itsCNXN. Only a reconnect let it in. This run had an earlier asking connection that had closed, which looked like the cause. Attempt 8 ruled that out: the OK goes to METIS's own connection (why). - Android's own dialog stays on the screen after Manage answers, over the kiosk, until someone dismisses it.
- The panel was restored as found: the module removed, Aqara's adbd put back without a reboot (stop, unmount,
start), and
adb_keysback to METIS's key.
Attempt 8: run 20f, one computer kept connected, and the dialog (2026-11-29, verified; driven from METIS, the agent
and trial.sh pinned at 64982bf5, no reboot). The patched adbd ran from the trial's tmpfs copy (a5648f6c, no
nosuid). Two fresh keys, each from a one-key Python client that connected once and kept that one connection open:
- Allow didn't let the waiting computer in. For
allow(K1), Manage's request was answeredok allowed, and adbd loggedadb client authorized3.3 s after the request. The open connection got no packet in 75 s. After a reconnect, K1 gotdevicestraight after its signature, and a shell. Foronce(K2) it was the same:authorized3.4 s after the request, noCNXNin 60 s. After a reconnect K2 wasunauthorizedand asking again, asonceshould be. So attempt 7's closed connection wasn't the cause: METIS's own listed connection held the slot (why). - The agent never pressed Back, so the dialog stayed.
dumpsys window windowson this Android 10 has nomCurrentFocusline at all (402 lines, none), so the agent never saw the dialog.dumpsys window displaysand plaindumpsys windowhave it. The agent now readsdisplays. - Back closes the dialog, but only with the screen on. With the dialog in focus, one
input keyevent 4closed it, and the kiosk stayed on its Home page. With the screen off (it sleeps after 15 s here), Back did nothing. The agent now waits formWakefulness=Awake(dumpsys power), up to 10 minutes, and gives up if a new question comes first. - The panel was restored as found: the trial ended early, Aqara's adbd came back (
f1226080, no mount), andadb_keysis back to METIS's key. Android's own keystore (adb_temp_keys.xml) keeps entries for K1 and K2 until it expires them. Their private keys are deleted.
Attempt 9: run 20g, both patches, with a listed computer connected (2026-11-29, verified; driven from METIS, the
agent and trial.sh pinned at 1d88b566, no reboot). METIS stayed connected over USB with its listed key the whole
time, the case that failed in attempt 8.
- The agent built both files. Status
on after a restart, moduleversion=2. Itslibadbd.soisdf98428d…,-rw-r--r-- root root,u:object_r:system_lib_file:s0, and against the panel's owncmp -lshows the two bytes:171231 5 0 171232 321 277 - The trial ran both. adbd's exe was
a5648f6c, and its maps showed/system/lib/libadbd.so, which readdf98428d. METIS's ownecho hianswered: a listed key still gets in by signature. - Allow lets the waiting computer in live. A fresh key (K1) connected once, from the one-key client, and kept that
connection open. After
t1 allow, itsCNXNcame 4.4 s later, on that same connection, andecho hianswered. adbd loggedadb client authorized, and Android loggedstate = 2, alwaysAllow = true. - Allow once does too. With a second key (K2) and the screen asleep,
CNXNcame 3.8 s aftert2 once, andadb_keysdidn't change. When K2 connected again later, it wasunauthorizedand asking again, asoncemeans. - METIS stayed
devicethroughout (96 checks, every 2 s). - The dialog closes. After
allow, with the screen on, the focus was back on the kiosk, on the same page, with no dialog. Afteronce, with the screen asleep, the agent sent no Back (adb-dialogread… 0). When the screen woke, the dialog was gone within 2 s, after one press. - The panel was restored as found: the trial put both files back (
f1226080,ae8f0bc1, no mounts), andadb_keysis METIS's key again.
Attempt 10: run 20h, both files through Magisk across a reboot (2026-11-29, verified; driven from METIS, the agent
pinned at 0a7f2d75, Magisk 31.1:MAGISK:R). The agent built module version 2 (both files, both cmp -l as in
attempt 9), then adb reboot.
- USB was back 20 s after the reboot, through both patched files. The exe was
a5648f6c,/system/lib/libadbd.soreaddf98428dand adbd mapped it, and the status wason. The watch stayed quiet. Magisk mounts both from the block device, withoutnosuid:/dev/block/by-name/UDISK /system/bin/adbd f2fs ro,lazytime,seclabel,noatime,… /dev/block/by-name/UDISK /system/lib/libadbd.so f2fs ro,lazytime,seclabel,noatime,… - METIS's listed key got in at the first boot (
Received connected key message). - Live Allow works after the reboot, with METIS on USB: a fresh key's kept-open connection got its
CNXN1.8 s aftert1 allow, and a shell. The dialog closed, and the kiosk stayed on its page. - The panel was restored as found without another reboot: the module removed, then a detached
stop adbd, both unmounts andstart adbd(exef1226080,libadbd.soae8f0bc1, no mounts), andadb_keysis METIS's key again.
Attempt 11: run 20i, the agent's key-list rewrites on the panel (2026-11-29, verified; driven from METIS, the agent
pinned at 983ceebe, trial.sh as in attempt 9). After the review fixes every adb_keys rewrite goes through one
checked builder, and the "once" record keeps a line per computer, in milliseconds. The container runs Debian's tools,
so this run checked them on the panel's mksh and toybox, with a check after every request that METIS's own lines were
still there.
Commands (METIS, root through su -c; fingerprints shortened, key lines and hashes not shown):
$ su -c 'cp -p /data/misc/adb/adb_keys /data/local/tmp/gw20i-adb_keys.0' # step 0: the copy for a restore
$ su -c 'cut -d" " -f1-2 /data/glassworks-pub/adb-asking' # step 3: the app's copy of the question
1795945957 A9:C1:…:D2:BD
$ su -c 'cut -d" " -f1-2 /data/s1kiosk/radio/adb-asking' # the agent's own record
1795945957.080 A9:C1:…:D2:BD
$ su -c 'echo "t1 allow A9:C1:…:D2:BD" > /data/data/sh.edm.s1kiosk/files/adb/request; chown <app uid> …' # what Manage writes
$ su -c 'cat /data/glassworks-pub/adb-result'
t1 ok allowed
$ su -c 'wc -l < /data/misc/adb/adb_keys; head -n 3 /data/misc/adb/adb_keys | sha256sum' # after every request
4
<H1>
$ su -c 'cut -d" " -f1-2 /data/s1kiosk/radio/adb-once' # step 4, after two Allow once answers
1795946105.210 B6:EC:…:B3:E8
1795946155.376 A7:7E:…:31:28
$ su -c 'sha256sum /data/misc/adb/adb_keys; stat -c "%u:%g %a" /data/misc/adb/adb_keys; ls /data/misc/adb/' # step 5
<H1>
1000:2000 640
adb_keys adb_temp_keys.xml
- The key list kept every line it should. The installer's key put back at the agent's start made 3 lines (H1).
Allow (K1) added one line, and the first 3 still hashed to H1. Two Allow once answers (K2, K3) left the file as it
was. Remove (K1) brought it back to H1 byte for byte, with its final newline. The owner, mode and label
(
1000:2000,640,adb_keys_file) held throughout, no temporary file was left, and METIS's two lines were there after every request. - Allow and Allow once let the waiting computers in live, with METIS on USB:
CNXN3.9 s, 4.1 s and 3.5 s after the request, and a shell each time. - The record formats: the agent's own asking record reads
<epoch>.<ms>(….080), and the copy published for the app keeps whole seconds.adb-onceheld two lines, one per computer (<epoch>.<ms> FP2and<epoch>.<ms> FP3), root0600, and neither computer showed as asking again. - Requests with no computer asking (a client script that didn't start) answered
none-askingand left the list as it was. - The panel was restored as found: trial ended, both files stock, no mounts,
adb_keysback to H0. Android'sadb_temp_keys.xmlkeeps entries for the three throwaway keys until it expires them; their private halves are deleted.
Result
| Question | Answer | Evidence |
|---|---|---|
| Does Aqara's adbd check keys? | No. It never starts the key exchange, although ro.adb.secure=1 |
The binary (the store at 0x20d0); adbd's log in attempt 4 (no send_auth_request) |
| Does the patched adbd check keys? | Yes. Through Magisk across a reboot, listed keys get in and an unknown key is unauthorized and asks; Allow, once and Remove act from the next connection |
Attempt 7 (run 20e, 2026-11-28) |
| Why did Allow need a reconnect? | Stock Android 10: Android's OK goes to the first connection that claimed adb_transport, and a connected listed computer claims it first |
libadbd.so 0x29cde, 0x2a0be, 0x2aac6 (the fix); attempt 8 |
| Does Allow let a waiting computer in now? | Yes, within about 2–4 s, with the module's libadbd.so, also through Magisk across a reboot; Allow once too |
Attempts 9 and 10 (runs 20g and 20h, 2026-11-29) |
| Why? | Aqara's adbd stores false over auth_required right after reading ro.adb.secure |
adbd_main 0x20ce–0x20d0 (the fix) |
| Can root answer "Allow USB debugging?" | Yes, through service call adb 1 i32 1 s16 <key>, only for the computer asking |
IAdbManager.aidl, AdbService.java:238, AdbDebuggingManager.java:358 |
| Does Android 10 forget keys? | Yes, 7 days after the last connection, and the installer's key with them | AdbDebuggingManager.java:943–1028, Settings.java:12393 |
| Does a dropped installer key come back? | Not by itself: first boot runs once. The agent puts it back at every start, unless it was removed on Manage | glassworks_firstboot.sh (its marker), glassworks_agent.sh (adb_restore) |
| Who's asking? | Received public key: from system_server's pid, in the system log |
AdbDebuggingManager.java:196 |
How to reproduce
On a panel with a frame bundle that has this agent (writes adb_keys and one global setting; undo below). The agent
installs the adbd patch as a Magisk module, which takes effect from the next restart, so restart the panel once after
the bundle installs. Without the patch, Aqara's adbd lets the new computer in without asking, and steps 2 and 3 can't
happen.
adb shell getprop sys.glassworks.adb.authshowson,adb shell getprop sys.glassworks.adb.statusshowsok, andsettings get global adb_allowed_connection_timeshows0.- Plug in a computer whose key isn't listed.
adb devicesshows it asunauthorized, and Manage's Security page shows its fingerprint. - Allow it on the page. The computer gets in within a few seconds, its key is in
adb_keys, and Android's dialog on the panel closes (once the screen is on). - Remove it on the page. It can't get in the next time it connects.
Undo: settings delete global adb_allowed_connection_time (tools/install.sh --undo runs it). Remove takes a key
out of adb_keys.
Open questions
- USB: is it the same as TCP? Plug in a computer with a fresh key over USB. The expected answer is yes.
- Stock firmware: stock ships with adb off (
persist.sys.usb.config=none), so only panels where adb is on are open. Glassworks' first boot turns it on.
The questions below were written before attempt 4:
All of these need a real panel:
- Does Aqara's Android 10 log
Received public key:the way AOSP does, in the system buffer, from system_server? - Does the S1's
logcattake-T <epoch>.000? The agent falls back to-T 1when logcat ends at once. - Does
service call adb 1 i32 1 s16 <key>as root let a waiting computer in without a replug? - Is
adb_temp_keys.xmlon a panel that still has keys, with the installer's key and alastConnectiontime? The dev panel had neither file (attempt 3), which is what Android leaves once every key has expired. - Does Android's own dialog stay on the screen after Manage answers it? On Android 6 it stays until the computer is
unplugged (
UsbDebugging.coverin the core). - After Remove, Android's keystore still holds the key in memory until the next reboot. With the timeout off that doesn't let it in, because adbd reads only the file. But if the timeout is ever turned back on, the next rewrite could put the key back.