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、支持任意模型,记忆和密码绝不离开设备。
fix(self-check): the body stays off the screen while the check page is up
booboosui2aa78b7c9b38
diff --git a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt b/app/src/main/java/net/kuafuai/andee/BodyCoreService.ktindex 8696ea0..356cc5a 100644--- a/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt+++ b/app/src/main/java/net/kuafuai/andee/BodyCoreService.kt@@ -420,7 +420,27 @@ class BodyCoreService : Service() {// report it either — the card it would raise needs the missing// permission. So this line is the only trace, and `ensureOverlays` is// the way back.- if (!window.show()) {+ // **When the checklist page is the surface the user is on, this service+ // shows nothing at all — not even the ball.**+ //+ // The page is drawn precisely when this service could not show itself,+ // and it sends the user out to system screens through its own rows, so+ // it is routinely still the page in front when this service starts+ // again. Two reasons it must then stay out of the way entirely:+ //+ // * unfolding the card puts a fullscreen overlay on top of it, and the+ // user who was mid-list reports "I granted it, came back, and I was on+ // the assistant" — the list is not gone, it is behind the card;+ // * this window is fullscreen *even when the ball is compact*, and it+ // swallows the touches it does not use — so a page with a ball in the+ // corner is a page whose buttons cannot be pressed. Measured on the+ // tablet: 完成 did nothing.+ //+ // Nothing is lost by staying out: the page's own exit calls+ // [ensureOverlays], which is what shows this window and unfolds the card.+ // See `SelfCheck.isPageOpen`.+ val pageOwnsScreen = net.kuafuai.andee.device.SelfCheck.isPageOpen(this)+ if (!pageOwnsScreen && !window.show()) {android.util.Log.e("Body", "overlay refused: no window (SYSTEM_ALERT_WINDOW?)")}// Little signboards (ask/alert cards) live in their own overlay@@ -457,7 +477,13 @@ class BodyCoreService : Service() {// exitCompact() grows it to the recorded full-screen rectangle, so this// arrives as the same geometry change a long-press makes — one code// path, not a second way for the window to be born.- window.setCompact(false)+ //+ // Skipped while the checklist page owns the screen; that window is not+ // even shown then, and [ensureOverlays] is what grows it when the page+ // leaves. See the note on `show()` above.+ if (!pageOwnsScreen) {+ window.setCompact(false)+ }net.kuafuai.andee.config.VoiceConfig.onSceneChanged = ::onSceneChanged// After the card: same window type, so insertion order is z-order and@@ -743,7 +769,14 @@ class BodyCoreService : Service() {.putLong(SELF_CHECK_SEEN_AT, now).apply()android.util.Log.w("Body", "self-check: $signature")- ui.post { showSelfCheckCard(problems) }+ // Skipped while the checklist page is up: that page *is* the list, so+ // a signboard carrying the same rows would be the same information+ // twice, one surface on top of the other. The signature is recorded+ // either way, so the card does not turn up the moment the user closes+ // the page having just read all of it. See `SelfCheck.isPageOpen`.+ if (!net.kuafuai.andee.device.SelfCheck.isPageOpen(app)) {+ ui.post { showSelfCheckCard(problems) }+ }}.start()}@@ -2816,7 +2849,7 @@ class BodyCoreService : Service() {}/** Where [runStartupSelfCheck] remembers what it already said. */- private const val SELF_CHECK_PREFS = "self_check"+ private const val SELF_CHECK_PREFS = net.kuafuai.andee.device.SelfCheck.PREFSprivate const val SELF_CHECK_SIGNATURE = "last_signature"private const val SELF_CHECK_SEEN_AT = "last_seen_at"diff --git a/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt b/app/src/main/java/net/kuafuai/andee/device/SelfCheck.ktindex 92ca1e7..935b9b2 100644--- a/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt+++ b/app/src/main/java/net/kuafuai/andee/device/SelfCheck.kt@@ -67,6 +67,48 @@ import java.util.concurrent.TimeUnit*/object SelfCheck {+ /**+ * The prefs file this feature keeps its bookkeeping in.+ *+ * Two writers, one file: `BodyCoreService.runStartupSelfCheck` remembers+ * what it has already reported, and the checklist page remembers that it is+ * still open — see [isPageOpen]. Named here rather than in both places.+ */+ const val PREFS = "self_check"++ private const val PAGE_OPEN = "page_open"++ /**+ * Is the checklist page up, with the user not yet finished with it?+ *+ * **Persisted, and that is the whole point.** The page's rows are doors to+ * system screens, and the way back from one is very often a *fresh launch*+ * rather than a resume: the platform can put a Settings screen in a task of+ * its own, and a ROM is free to clear ours while the user is away. On that+ * path neither `savedInstanceState` nor the task remembers anything, so the+ * only thing that can still know "there was a page here" is something+ * written down.+ *+ * Without it, that fresh launch takes the branch meant for a user tapping+ * the icon on a working device — hand the screen to the assistant — and the+ * list the user was working through is gone. The report: "the check said the+ * overlay was off, I granted it, came back, and I was on the assistant+ * instead of the check".+ *+ * Cleared by the user closing the page and by nothing else, which is the+ * same rule the page itself follows: only the user knows when the list is+ * finished.+ */+ fun isPageOpen(context: Context): Boolean =+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)+ .getBoolean(PAGE_OPEN, false)++ fun setPageOpen(context: Context, open: Boolean) {+ context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()+ .putBoolean(PAGE_OPEN, open)+ .apply()+ }+enum class Level { OK, NOTE, WARN, FAIL }/**diff --git a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.ktindex 491c976..af26e81 100644--- a/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt+++ b/app/src/main/java/net/kuafuai/andee/ui/SelfCheckActivity.kt@@ -10,6 +10,7 @@ import net.kuafuai.andee.ScreenBodyServiceimport net.kuafuai.andee.config.FactoryResetimport net.kuafuai.andee.config.Notebookimport net.kuafuai.andee.config.VoiceConfig+import net.kuafuai.andee.device.SelfCheckimport net.kuafuai.andee.i18n.AppLocale/**@@ -252,8 +253,19 @@ class SelfCheckActivity : StageActivity() {// it back"; only a null one means the user tapped the icon on purpose.val restored = savedInstanceState != null+ // And a page that is already open outranks both.+ //+ // The way back from a system screen is often a *fresh launch*, not a+ // resume: the platform can put a Settings screen in a task of its own,+ // and a ROM is free to clear ours while the user is away. On that path+ // `restored` is false and the intent looks exactly like a tap on the+ // icon, so the branches below would take it for one. What tells them+ // apart is whether the user is mid-list, and only something written down+ // can still know that. See [SelfCheck.isPageOpen].+ val checkOpen = SelfCheck.isPageOpen(this)+val svc = BodyCoreService.get()- if (!restored && svc != null && svc.ensureOverlays()) {+ if (!restored && !checkOpen && svc != null && svc.ensureOverlays()) {svc.dispatcherForNotification()?.expand()finish()return@@ -265,13 +277,18 @@ class SelfCheckActivity : StageActivity() {// (first launch after a fresh grant). Falling through here would draw a// checklist for a device that is working, which is the exact report// this branch was rewritten to stop producing.- if (!restored && svc == null && ScreenBodyService.get() != null && Settings.canDrawOverlays(this)) {+ if (!restored && !checkOpen && svc == null && ScreenBodyService.get() != null && Settings.canDrawOverlays(this)) {finish()return}// ---- Everything below is the case this class exists for ----//+ // Written down before a single row is drawn, because from here on the+ // question "was there a page?" has to survive the process: see+ // [SelfCheck.setPageOpen]. [onStageLeaving] is what clears it.+ SelfCheck.setPageOpen(this, true)+ //// No service: accessibility is off, or the overlay grant is missing, or// the app was just reinstalled. There is no ball, no card and no window// to fold, so the checklist is not a fallback here — it is the only@@ -345,6 +362,11 @@ class SelfCheckActivity : StageActivity() {* page opens in: nothing to hand back, and nothing to unfold.*/override fun onStageLeaving() {+ // The user is done with the list, and this is the only thing that says+ // so — everything else about the page survives on purpose, including the+ // process. Cleared *before* the overlays go up, so a launch on the far+ // side of this is a launch with no page. See [SelfCheck.setPageOpen].+ SelfCheck.setPageOpen(this, false)val svc = BodyCoreService.get()svc?.ballWindow()?.setPagePerched(false)// `ensureOverlays` before `expand`, not `expand` on its own.