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、支持任意模型,记忆和密码绝不离开设备。

fix(permissions): fold the card before firing, or the sheet is never seen

booboosuib7e2b25fa2f5
diff --git a/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt b/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
index f74fc6e..19c86e7 100644
--- a/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
+++ b/app/src/main/java/net/kuafuai/andee/brain/LocalPrompt.kt
@@ -130,7 +130,9 @@ So when a request arrives, ask "**how many steps is this on the interface, and w
**"It takes several steps" is not "I can't do it" — it just takes several steps.**
-**And the system's permission sheet is one of them — this one surprises people, so read it twice.** It is *not* an ordinary screen: it exposes no elements at all, and it does not take a tap you inject. Measured on this device, four separate ways: `get_screen_element` comes back empty with a picture and no e-numbers, a tap aimed at 「允许」 does nothing, the same tap injected another way does nothing, and even the back key leaves it up. **The only hands it answers to are the user's.** So when `request_permissions` leaves a sheet on screen, that is the one step of the errand that is theirs — your job is to put it in front of them and say so, in one line, and then wait or carry on with what does not need it. Do not tap at it, do not fire it twice, and do not conclude from \"it did not react\" that the screen is broken — **it is reacting correctly to a tap it is built to ignore.**
+**And the system's permission sheet is one of them — this one surprises people, so read it twice.** It is *not* an ordinary screen: it exposes no elements at all — `get_screen_element` comes back empty, with a picture and no e-numbers — and the back key leaves it up. A picture and no elements is the whole difficulty: **you cannot read it, so you cannot aim at it.** A tap would land, and that is exactly the trap — with no elements to aim by you are guessing at a screen whose bottom button is 「禁止后不再提示」, and a guess that lands there is permanent and cannot be undone by anyone. That is why this one step is theirs. So when `request_permissions` leaves a sheet on screen, your job is to put it in front of them and say so, in one line, and then wait or carry on with what does not need it. Do not aim at it, do not fire it twice, and do not read its stillness as the screen being broken.
+
+You will not always see that sheet, and a missing sheet is not a missing question. The device folds your card before firing precisely so the sheet is not hidden behind it, but a folded ball still sits above the system's window, and a screenshot taken the instant a result comes back can catch the moment before the sheet is drawn. So `waiting` with nothing visible means *nothing visible yet*, not *the request did nothing* — say the line and let them look, rather than reporting a failure you cannot actually see. When in doubt, wait_for_screen and look again: a sheet that is up stays up until a finger answers it.
How much ceremony that costs you is what the `mode` decides, and **the mode is the device's decision, not your own judgement about how sensitive the grant looks**. It follows what the grant reaches: your own data is `solo` — fire it, say one line, done asking. Other people's data, and things that cannot be taken back, are `handoff` — ask with ask_user first and say what you are waiting for. `settings` means there is no sheet at all and the errand is a switch inside Settings — that one is an ordinary screen and you can walk it yourself.
diff --git a/app/src/main/java/net/kuafuai/andee/device/PermissionsController.kt b/app/src/main/java/net/kuafuai/andee/device/PermissionsController.kt
index 33a7f72..2141843 100644
--- a/app/src/main/java/net/kuafuai/andee/device/PermissionsController.kt
+++ b/app/src/main/java/net/kuafuai/andee/device/PermissionsController.kt
@@ -207,14 +207,16 @@ class PermissionsController(private val context: Context) {
// sheet that never came and never will. Look first — firing again is
// the one move that cannot help.
//
- // And note what is NOT offered here: tapping the sheet. Measured, a
- // system permission sheet exposes no elements and ignores an injected
- // tap, so "tap Allow yourself" would be advice that cannot be taken.
+ // And note what is NOT offered here: aiming at the sheet. Measured, it
+ // exposes no elements — so a tap would be a guess, and the button at the
+ // bottom of this particular screen is an irreversible deny. "Tap Allow
+ // yourself" is not caution withheld; it is a step nobody should take
+ // blind.
else -> "Look at the screen before anything else: if nothing was drawn, do not " +
"fire again — say it did not go through and that this step needs their hand. " +
when (mode) {
- "solo" -> "If the sheet is there, it is waiting on their finger — you cannot " +
- "tap it. Say one line that it is up, and carry on with what does not need it."
+ "solo" -> "If the sheet is there, it is waiting on their finger. Say one " +
+ "line that it is up, and carry on with what does not need it."
"handoff" -> "If the sheet is there it is theirs to answer — ask with ask_user, " +
"saying what you are waiting for."
else -> "A Settings page is open and only they can flip that switch — " +
diff --git a/app/src/main/java/net/kuafuai/andee/net/CommandDispatcher.kt b/app/src/main/java/net/kuafuai/andee/net/CommandDispatcher.kt
index a07a4aa..b0b9591 100644
--- a/app/src/main/java/net/kuafuai/andee/net/CommandDispatcher.kt
+++ b/app/src/main/java/net/kuafuai/andee/net/CommandDispatcher.kt
@@ -232,7 +232,8 @@ class CommandDispatcher(
// card: asking "am I online" is a conversation, not an actuation.
// All bounded-latency, no listeners outlive the call. `device.scan`
// and `device.look` fold anyway, in their own branches — they are
- // queries that draw a camera preview the user has to see.
+ // queries that draw a camera preview the user has to see. So does
+ // `device.permissions.request`, for the same reason.
"device.connectivity" -> deviceInfo.connectivity()
"device.apps" -> deviceInfo.installedApps()
"device.location" -> deviceInfo.location(
@@ -381,10 +382,34 @@ class CommandDispatcher(
// ---- device.* : permissions concierge + camera eye -------------
"device.permissions" -> permissions.status()
- "device.permissions.request" -> permissions.request(
- ids = requireNotNull(params?.optJSONArray("ids")) { "device.permissions.request requires ids[]" },
- confirm = params?.optBoolean("confirm", false) ?: false,
- )
+ "device.permissions.request" -> {
+ val confirm = params?.optBoolean("confirm", false) ?: false
+ // The third exception to "device.* never folds". Every other
+ // branch in this namespace reads or acts on state the user is
+ // not being asked to look at; this one is a question addressed
+ // to them, drawn by the system in a window of its own — and our
+ // overlay sits above every activity, so an expanded card (which
+ // is a fullscreen surface) hides the sheet completely. Measured
+ // on device: the dialog really was up — GrantPermissionsActivity
+ // was both ResumedActivity and mCurrentFocus — while the
+ // screenshot showed nothing but the card. A question nobody can
+ // see is worse than no question.
+ //
+ // Folding only when confirm=true: the first call is the script
+ // the brain reads back, and that one belongs in the card.
+ if (confirm) {
+ ensureCompact()
+ // Folded, so the nod is the only thing left saying "the
+ // device just did something" — same as `device.vault.fill`.
+ window.pulseTool()
+ }
+ permissions.request(
+ ids = requireNotNull(params?.optJSONArray("ids")) {
+ "device.permissions.request requires ids[]"
+ },
+ confirm = confirm,
+ )
+ }
"device.scan" -> {
// The two exceptions to "device.* never folds" above: both put a
// camera preview on screen, and our overlay sits above every
diff --git a/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt b/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
index 1c869ea..69e575b 100644
--- a/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
+++ b/app/src/main/java/net/kuafuai/andee/net/ToolSchemas.kt
@@ -732,14 +732,15 @@ object ToolSchemas {
"no_dialog" the system never drew a sheet at all
"waiting" it is on screen and nobody has answered yet
- 🔴 **A system permission sheet cannot be tapped by you.** It exposes no
- elements (get_screen_element comes back empty, with a picture and no
- e-numbers) and it ignores a tap you inject. Putting it on screen is the
+ 🔴 **You cannot read a system permission sheet, so do not aim at it.**
+ It exposes no elements at all (get_screen_element comes back empty, with
+ a picture and no e-numbers). A tap would land — that is the trap: with
+ nothing to aim by, you are guessing at a screen whose bottom button is
+ 「禁止后不再提示」, which nothing can undo. Putting it on screen is the
whole of what firing does; answering it is the user's one step. So when
the result is "waiting", say one line — 「屏幕上弹了个权限框,点一下允许」—
and either wait via ask_user or go on with whatever does not need it.
- Do not tap at it, and do not read its stillness as the screen being
- broken.
+ Do not read its stillness as the screen being broken.
Never fire the same request twice in a row. "no_dialog" means the system
has stopped asking (usually after two refusals) and firing again is