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、支持任意模型,记忆和密码绝不离开设备。
feat(mac): 重新检测 on the self-check card, so a grant made in System Settings shows up
booboosuif47ab3b6322e
diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.ktindex 76c0a42..93b5cd5 100644--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/Cards.kt@@ -19,6 +19,7 @@ import androidx.compose.foundation.shape.RoundedCornerShapeimport androidx.compose.foundation.verticalScrollimport androidx.compose.material.Textimport androidx.compose.runtime.Composable+import androidx.compose.runtime.LaunchedEffectimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.remember@@ -40,7 +41,14 @@ import androidx.compose.ui.unit.spfun SelfCheckCard(onDone: () -> Unit, onOpenSettings: () -> Unit) {val zh = Strings.lang() == "zh"data class CheckRow(val id: String, val name: String, val ok: Boolean, val why: String, val fix: (() -> Unit)?)- val rows = buildList {+ // Re-read on demand. Every row here is changed in *another* app — System+ // Settings for the three permissions, the settings card for the two keys —+ // and a card that computed its rows once would go on saying "cannot see the+ // screen" after the person had just allowed it. This is the same reason the+ // phone's card carries 重新检查: checking whether a fix took should not mean+ // closing this card and finding it again.+ var refresh by remember { mutableStateOf(0) }+ val rows = remember(refresh) { buildList {val ax = net.kuafuai.andee.desktop.mac.Bridge.axTrusted()add(CheckRow("ax", if (zh) "辅助功能" else "Accessibility", ax,if (ax) if (zh) "能读、能操作别的 app" else "Can read and drive other apps" else if (zh) "读不到屏幕,也无法操作" else "Cannot read or drive the screen",@@ -61,6 +69,16 @@ fun SelfCheckCard(onDone: () -> Unit, onOpenSettings: () -> Unit) {add(CheckRow("voice", if (zh) "语音 Key" else "Voice key", voice,if (voice) if (zh) "能听能说" else "Can hear and speak" else if (zh) "还没配,说不了话" else "Missing — Andee cannot speak",{ onOpenSettings() }))+ }+ }+ // Re-reading is instant and, more often than not, changes nothing — so a tap+ // that only recomputed would look like a tap that did nothing.+ var justChecked by remember { mutableStateOf(false) }+ LaunchedEffect(refresh) {+ if (refresh == 0) return@LaunchedEffect+ justChecked = true+ kotlinx.coroutines.delay(1_500)+ justChecked = false}Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(20.dp)) {GlassHeader(if (zh) "自检" else "Self-check", if (zh) "每一项都可能悄悄坏掉" else "Each of these can fail silently", onClose = onDone)@@ -82,6 +100,18 @@ fun SelfCheckCard(onDone: () -> Unit, onOpenSettings: () -> Unit) {}Spacer(Modifier.height(8.dp))}+ Row(Modifier.fillMaxWidth().padding(vertical = 2.dp), verticalAlignment = Alignment.CenterVertically) {+ Text(if (zh) "重新检测" else "Check again", color = Palette.accent, fontSize = 13.sp,+ modifier = Modifier.clickable {+ // The one row whose answer is decided at launch, not on read.+ net.kuafuai.andee.desktop.mac.MacNotifications.recheck()+ refresh+++ }.padding(6.dp))+ if (justChecked) {+ Spacer(Modifier.width(8.dp))+ Text(if (zh) "已重新检测" else "Just checked", color = Palette.secondary, fontSize = 11.sp)+ }+ }}}diff --git a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/mac/MacNotifications.kt b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/mac/MacNotifications.ktindex abf1c74..4a69a3d 100644--- a/desktop/src/main/kotlin/net/kuafuai/andee/desktop/mac/MacNotifications.kt+++ b/desktop/src/main/kotlin/net/kuafuai/andee/desktop/mac/MacNotifications.kt@@ -82,6 +82,27 @@ object MacNotifications {Log.i(TAG, "notification store: $state (from record $lastId)")}+ /**+ * Decides [state] again, for the self-check card's 重新检测.+ *+ * [start] decides it once, at launch. Full Disk Access is granted later, in+ * System Settings, on a Mac where Andee has already concluded it cannot read+ * the store — and the row would keep saying so until the next restart. Both+ * calls here are reads of the store, and the watch is only re-armed when it+ * never took, so calling this more than once is harmless.+ */+ fun recheck() {+ val id = Bridge.notifLatestId()+ if (id > lastId) lastId = id+ if (state == State.WATCHING) return+ state = when {+ id < 0 -> State.NO_ACCESS+ Bridge.notifWatch(onChange) -> State.WATCHING+ else -> State.NO_ACCESS+ }+ Log.i(TAG, "notification store re-checked: $state (from record $lastId)")+ }+/*** Several file events arrive per notification (the WAL grows, the directory* changes), and the row may lag the first of them by seconds. So one read is