Skip to content

armgit / andee

Public Imported from GitHub
0

Andee lives on your phone or Mac and uses any app like you do—no integrations, no root, any model; memory and passwords never leave your device | Andee 住进你的手机或 Mac,像你一样操作任何 App——无需集成、无需 Root、支持任意模型,记忆和密码绝不离开设备。

docs(claude): catch the self-check notes up with the last two fixes

booboosui0553014ec5e4
diff --git a/CLAUDE.md b/CLAUDE.md
index 3195376..ac89e82 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -412,20 +412,20 @@ The edge glow is a **separate** signal and tracks the task, not the fold: `begin
### Startup self-check
-Every failure this app has is silent by construction. A missing `SYSTEM_ALERT_WINDOW` grant means `FloatingWindowUi.show()` catches the `addView` failure and returns false — the service runs perfectly with nothing on screen. A backend that cannot be reached means the ball spins once and says nothing. A notification grant that survived a reinstall reads as **on** in Settings while the listener was never bound, so every notification is dropped. Each has been reported by the user as "坏了", and each is decidable before it happens.
+Every failure this app has is silent by construction. A missing `SYSTEM_ALERT_WINDOW` grant means the service runs perfectly with nothing on screen — and it arrives there in two different ways. Where `addView` is rejected, `FloatingWindowUi.show()` catches the failure and returns false. On HONOR/MagicOS (measured on LIO-TL00) `addView` **succeeds** under a denied appop and the system hides the window instead: it is in the window list with `alpha=0.0`, `mAppOpVisibility=false`, `isReadyForDisplay()=false`, so the view object outlives the grant and `isShown()` — which is only `root != null` — keeps answering true. That second shape is why the grant is asked **directly** (`Settings.canDrawOverlays`) rather than inferred from a view object existing, at every door where the answer decides something: `ScreenBodyService.ensureOverlays` / `showSelfCheckCard`, and `SelfCheckActivity`'s `onOpenSettings`. A backend that cannot be reached means the ball spins once and says nothing. A notification grant that survived a reinstall reads as **on** in Settings while the listener was never bound, so every notification is dropped. Each has been reported by the user as "坏了", and each is decidable before it happens.
`device/SelfCheck.kt` is that decision, in one list, and it is the **only** place the list exists — and there is **one renderer** for it (`ui/SelfCheckUi`) behind all three readers, so no two of them can disagree, which is the failure a second hand-written checklist would have within a week:
-- **`ScreenBodyService.runStartupSelfCheck()`** — the nudge. Runs on a worker thread (the two probes do network I/O), and puts up **one** `CardUi.ask` listing everything wrong, with 去处理 → the card. Deduped by *content*, not by time: the signature is the set of `id:level`, an unchanged set stays quiet for `REPEAT_AFTER_MS` (6 h), and any change — a new failure, or one fixed — gets through immediately. A tablet that reboots on a dog twenty times a day must not nag twenty times, and a user must not have to wait out a window after fixing something. When everything is clean the record is *cleared*, so a relapse reports at once. It bails if `window.isShown()` is false: the overlay grant is one of the things being reported, and a card needs the very permission it is about to complain about.
+- **`ScreenBodyService.runStartupSelfCheck()`** — the nudge. Runs on a worker thread (the two probes do network I/O), and puts up **one** `CardUi.ask` listing everything wrong, with 去处理 → the card. Deduped by *content*, not by time: the signature is the set of `id:level`, an unchanged set stays quiet for `REPEAT_AFTER_MS` (6 h), and any change — a new failure, or one fixed — gets through immediately. A tablet that reboots on a dog twenty times a day must not nag twenty times, and a user must not have to wait out a window after fixing something. When everything is clean the record is *cleared*, so a relapse reports at once. It bails if `Settings.canDrawOverlays()` is false and again if `window.isShown()` is false: the overlay grant is one of the things being reported, and a card needs the very permission it is about to complain about. The grant is asked as a grant rather than inferred from the window object, because on some ROMs that object outlives the permission — see `ensureOverlays`.
- **`ui/SelfCheckUi`** — the card, and the only code that draws a row. `✓` in the control bar opens it through `ScreenBodyService.openSelfCheck()`. Fix button per row, paints from `SelfCheck.local()` (no network, instant) then fills in the probes behind it, and offers 重新检查 because the user is being sent to *other* apps to change things and a two-tap fix should not become a round trip through the launcher.
-- **`ui/SelfCheckActivity`** — the launcher icon, and the **only** surface in this app that runs while the assistant does not: everything else is an overlay owned by an accessibility service, so with accessibility off there is no ball, no card, no window and no way in at all. It is also the only place the `accessibility` row can be *red and read*. With the service **up** it draws nothing — it calls `dispatcher.expand()`, the same thing a long-press on the ball does, and finishes; with the service **down** it hosts the same `SelfCheckUi` card on its `stage` instead of in a window. See "The launcher icon opens two doors".
+- **`ui/SelfCheckActivity`** — the launcher icon, and the **only** surface in this app that runs while the assistant does not: everything else is an overlay owned by an accessibility service, so with accessibility off there is no ball, no card, no window and no way in at all. It is also the only place the `accessibility` row can be *red and read*. When the overlays are genuinely usable it draws nothing — it calls `dispatcher.expand()`, the same thing a long-press on the ball does, and finishes; otherwise (no service, no overlay grant, or an overlay not yet attached) it hosts the same `SelfCheckUi` card on its `stage` instead of in a window. See "The launcher icon opens two doors".
-Five things in the design are load-bearing:
+Seven things in the design are load-bearing:
- **Levels, and only two of them may interrupt.** `FAIL` (dead now — the complaint will be "没反应"), `WARN` (works, but something degrades silently), `NOTE` (a fact worth being able to read — the wake phrase is not taught yet, a probe was skipped), `OK`. `needsAttention` is `FAIL || WARN`, and `NOTE` **never** raises a card. Without that split this is nagware and the user learns to dismiss it unread.
- **`Fix` is a closed set of values, not a lambda.** `Screen(action, data)` / `Link(url)` / `Grant(permissions)` / `Adb(command)` / `OurSettings` / `Nothing`. `actionable` is defined from that set. Values rather than closures because the list is built off the main thread and consumed up to seconds later — an `Intent` described at 200 ms is still good at 3 s, where a captured `Context` would be a leak waiting to be filed as a bug. `Link` is its own member rather than `Screen(ACTION_VIEW, url)`: the button it produces is a different word (去下载 is not 去开启), and a Settings-labelled button that opens a browser is the small lie this list exists to avoid.
- **`Fix.Adb` deliberately has no button.** `WRITE_SECURE_SETTINGS` is `signature|privileged|development`, so `adb shell pm grant` is the only way and there is no switch in Settings to find. The row shows a **selectable** command and says it is an adb errand — a user hunting Settings for a switch that does not exist there is the failure mode being prevented.
-- **`Fix.OurSettings` is the one door that can be missing, and the card says so instead of drawing it.** Our settings sheet is an overlay the *service* owns, so with accessibility off there is nothing for 打开设置 to open. `SelfCheckUi.serviceUp` reads that off the `accessibility` row — one source of truth, never a second test that could disagree with the red row directly above it — and when it is false the row gets **no** button and a note above the list says why. Same rule as `Fix.Adb`: a button that does nothing is worse than no button.
+- **`Fix.OurSettings` is the one door that can be missing, and the card omits it rather than drawing one that does nothing.** `SelfCheckUi.canOpenSettings` is `onOpenSettings != null` — a fact the *host* already knows, not an inference about the service. The service host always passes it (`openSettings()`); `SelfCheckActivity` passes it only when `Settings.canDrawOverlays()` is true, because its own `openOwnSettings()` raises a `SettingsUi` as an overlay and would have nowhere to draw without the grant. So the rows lose their button in exactly one case — the Activity host with the overlay grant missing — which is also the case where the red overlay row sitting right there carries the fix. Same rule as `Fix.Adb`: a button that does nothing is worse than no button. It used to be inferred instead: `serviceUp` asked "is the accessibility row green" and suppressed the button when it was not, which was true only while the service was the sole raiser of our sheet — and the two rows it gates (大脑, 语音密钥) are precisely the ones a user configures *before* the assistant works, so that inference suppressed the button in the case it exists for.
- **The keyboard row tests the exact component this app switches to.** `typeViaAdbKeyboard` is a broadcast to `com.android.adbkeyboard`, which has to be an *enabled* IME for the `commitText` to land — so "can the assistant type into other apps *this way*" is decided by two facts on the device that had no way of announcing themselves, and the symptom is an error that blames the app being driven. One row rather than two, because the three states are three steps of one errand and the button changes as they are completed: not there → 去下载, there but off → `INPUT_METHOD_SETTINGS` (the screen with the toggle, not `showInputMethodPicker`, which `ImeSwitch` refuses on purpose), enabled → OK. A permanent red "not installed" above a green "enabled" is what two rows would buy. Installed-ness is asked through `getInputMethodList()` — "is there a keyboard *in* that package", not "does the package exist", so a truncated APK does not send the user to a keyboard list that cannot contain it — and that only works because the manifest declares `QUERY_ALL_PACKAGES`; enabled-ness is the **exact** id, because a build with a renamed service is one this app cannot switch to and a green row beside a dead `type_text` is the lie this whole page exists to prevent. The download is the **v2.5-dev release asset**, not the `master/ADBKeyboard.apk` every blog post links to — upstream itself labels that one "[Old]", and v2.5-dev exists to fix it on android-36, which is what a newly bought tablet arrives on. Both APKs were read before choosing (`com.android.adbkeyboard.AdbIME`, `ADB_INPUT_TEXT`/`ADB_CLEAR_TEXT`/`ADB_EDITOR_CODE`, `commitText` — the same component and actions `ScreenController` names). It is **not** vendored into `assets/` and installed through a `FileProvider`, which would make it one tap instead of three: redistributing someone else's APK is a licensing decision rather than a build detail.
- **The two typing rows are graded by whether the other channel is open, and `imeChannelOpen()` is the single source for that.** `adbKeyboard` and `secureSettings` are `WARN` when the accessibility IME is unavailable and **`NOTE` when it is** — the feature is not broken, the row has become a spare for Android 12 and below. They are graded identically to each other for the reason they always were: one broken feature must not be two different colours. A third row, `typing_channel`, is `NOTE` at every value and exists only to name which channel is in play; without it a user reading two grey rows about a keyboard they never installed has no way to learn that typing works anyway. `imeChannelOpen()` reads `FLAG_INPUT_METHOD_EDITOR` off the **running service's** `serviceInfo` rather than trusting the config XML, and returns true when the service is not up (pre-33 is the only hard no) — a checklist should not invent a failure it cannot observe. Note `Fix.Adb` on the `secureSettings` row stays drawn even at `NOTE`: the command is still the only way to get the spare working.
- **The backend probe distinguishes three things the symptom cannot.** `GET /models` decides all of them without spending a token: URL wrong → the connection fails; key wrong → 401/403; **model name wrong → the name is not in the returned list**. That last one is the likeliest, because it is the one a person types by hand, and its error names *what was on offer* rather than a bare 400. Gateways with no `/models` (404/405) fall back to a `max_tokens: 1` + thinking-disabled chat request, and an empty list on a 200 is read as "reachable" rather than invented into a model complaint. The voice host gets a bare **TCP connect** and not a credential check — reproducing the 火山 handshake here would mean a second copy of that protocol, and what this row is for is the failure this device actually had (`ASR ws connect timeout`, network up, host unreachable), so a green row beside a failing ASR means the key, by elimination.
@@ -449,10 +449,10 @@ The `■` stop button left the bar in the same change, and `✓` took its **slot
The icon used to mean one thing — the checklist — and that was wrong, because on a working device the checklist is not what the user is asking for when they tap their app. It now branches in `onCreate`:
-- **Service up** (`ScreenBodyService.get() != null && ballWindow() != null`) → `dispatcher.expand()` and `finish()`. That is *literally* the long-press-the-ball call, not a copy of it: two entry points must not be able to drift into meaning different things, and the icon is the one every other app on the device has trained the user to read as "open this".
-- **Service down** → the card, as before. This is the case the Activity exists for and nothing about it changed: no ball, no card, no window, so this page is the only thing that can say *why* the equipment in the user's hand is doing nothing.
+- **Overlays actually usable** (`ScreenBodyService.get() != null && svc.ensureOverlays()`) → `dispatcher.expand()` and `finish()`. That is *literally* the long-press-the-ball call, not a copy of it: two entry points must not be able to drift into meaning different things, and the icon is the one every other app on the device has trained the user to read as "open this".
+- **Anything else** → the card. That is a **wider** door than "service down", and widening it was the fix: it now covers no service at all, a service whose overlay grant is missing, and one that is alive but has not attached its overlay yet. This is the case the Activity exists for: no ball, no card, no window, so this page is the only thing that can say *why* the equipment in the user's hand is doing nothing.
-`ballWindow()` rather than just the instance, because a service that is alive but has not attached its overlay yet is not something to unfold — the same guard `openSettingsForUser` uses.
+`ensureOverlays()` rather than a bare `isShown()` test, and rather than the `ballWindow()` test this branch used to make. It is a **call** and not a check because the interesting case is the one where the answer is "no but fixable" — a service that connected while the grant was missing, with the grant arriving afterwards, which nothing else notices because the grant alone does not re-run `onServiceConnected`. Asking the question is also the retry; without it the icon is a door that reports the room is empty. And the predicate inside is `Settings.canDrawOverlays`, the same one the checklist's own 悬浮窗 row uses, so the page and the door can never contradict each other — which is exactly what they did before this: the page said 没开 while the door took the expand branch and finished on an empty screen. Reported twice as "the icon does nothing, and it does it again every time" — see `ensureOverlays`'s KDoc for the two ROM behaviours behind it.
The icon became invisible on the working path thanks to `Theme.Body.Stage.NoPreview` (`android:windowDisablePreview` + `Theme.Body.Stage`), added for this Activity only. Without it the platform paints a `windowBackground` starting window before the first draw, so "tap the icon, the card grows" was "tap the icon, the screen goes black, the card grows" — a flash the long-press does not have. The cost is the *other* path: with the service off, the launcher now stays visible for as long as the card takes to build instead of being replaced by black immediately. That trade is taken deliberately — the working path is what happens every day, and `SelfCheck.local()` gives the card its first frame synchronously anyway.
@@ -474,7 +474,7 @@ It survives testing on one host because the hosted path builds **synchronously**
**Language is in the card's header, and the reason it is cheap is the same reason the findings can be reused.** `Finding` carries a `@StringRes Int` and a `detailArgs` list, never a finished sentence, so the list is **language-free** and sentences are rendered from it at draw time. Re-rendering the same list after a pick is therefore *correct* rather than a shortcut — and it is also free: had the rows held strings, switching language would mean re-running a probe that does network I/O, to change words about a fact that did not change. Three rules fall out of that:
- **`lctx` (`AppLocale.wrap`) is re-derived on every repaint, never cached in a `by lazy`.** Findings are language-free; the context you ask for a string is not. A lazily-created one keeps answering in the language the card opened in, which is precisely the half-translated surface `AppLocale`'s own docs warn about.
-- **The language can change from two places while the card is up**, because the card's own 打开设置 row opens the settings sheet **on top of it**. So `SelfCheckUi.repaintForLanguage()` is called both from the card's `LangToggle` (which also tells the service, via `onLocaleChanged` → `FloatingWindowUi.onLocaleChanged()`, so the ball and the scrollback follow) and from `ScreenBodyService.openSettings()`'s `onDismiss` — the same news arriving from the other direction, repaint only and never re-announce, or the ball is rebuilt twice for one change. The Activity host has a third path and catches it in `onResume()` by comparing `VoiceConfig.uiLanguage()` against what it painted. That third path is narrow on purpose: with the service off there is no settings sheet to open (the 打开设置 row is not drawn at all — see `serviceUp`), so what reaches it is a change written while the user was off in a system screen, and the card's own picker hands its value to the host through `onLocaleChanged` so a resume after it does not rebuild the card for nothing.
+- **The language can change from two places while the card is up**, because the card's own 打开设置 row opens the settings sheet **on top of it**. So `SelfCheckUi.repaintForLanguage()` is called both from the card's `LangToggle` (which also tells the service, via `onLocaleChanged` → `FloatingWindowUi.onLocaleChanged()`, so the ball and the scrollback follow) and from `ScreenBodyService.openSettings()`'s `onDismiss` — the same news arriving from the other direction, repaint only and never re-announce, or the ball is rebuilt twice for one change. The Activity host has a third path and catches it in `onResume()` by comparing `VoiceConfig.uiLanguage()` against what it painted. That third path is narrow on purpose: both of this card's own doors already report their change through `onLocaleChanged` — the `LangToggle`, and the Activity's own settings sheet (`openOwnSettings`) — so what reaches it is a change written while the user was off in a system screen, and the card's own picker hands its value to the host through `onLocaleChanged` so a resume after it does not rebuild the card for nothing.
- **It writes the same `lang` key through the same `VoiceConfig.save` as `SettingsUi`** — not a second preference, so "does it survive a restart" has one answer for both. Nothing caches the pick, and nothing needs to. The picker's two labels are `中` and `EN`, **hardcoded rather than pulled from resources** — a language picker that translates its own options is a picker you cannot read once you are in the wrong one.
It also has to sit *here* rather than only in Settings: this is where a user lands when the app is broken, and sending them through a different app's settings to change the language they are reading is the wrong trade for one row of chrome. `LangToggle` is a second *copy* of the control, never a second setting.