Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/ACCESSIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,11 @@ As built (`mobium assistant "Open Calculator" --app com.google.android.calculato
- **The answer** is new text the assistant shows that is not one of its own
controls. Google Assistant's calculator card has none, so a sum asked
there answers with no text, and says so.
- **Refused**: a request that acts for the owner (call, text, message,
send, email, pay, buy, order, book, post, share, delete, transfer) unless
`app` names the app it is for; Siri on a simulator, which answers nothing
- **Refused**: a request that acts for the owner (call, dial, text,
message, send, email, mail, pay, buy, order, purchase, book, post, tweet,
share, delete, transfer, venmo, or tell someone other than "me" or "us"),
wherever the word is in it — "Can you text Alex" as much as "Text Alex" —
unless `app` names the app it is for; Siri on a simulator, which answers nothing
(CHALLENGES 351); a TV's assistant.

`assistant.sh` passes on the emulator (Google Assistant, signed out) and
Expand Down
30 changes: 29 additions & 1 deletion docs/CHALLENGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ the source.

The pattern across them is the reason the document exists: **almost nothing
here was found by reading code or by a test written from imagination.** Of
408 defects, 328 were found only by running against a real device. Eighteen
410 defects, 328 were found only by running against a real device. Eighteen
more — 255, 280, 282, 327, 329, 353, 355, 356, 359, 371, 375, 380, 382, 384, 386, 387, 388 and 406 — were met while
running against one, though the fault lay in a check, the host or Mobium's own
design rather than in the platform. The other sixty-two — 4, 5, 6, 14, 23,
Expand Down Expand Up @@ -8899,6 +8899,34 @@ were found", which 211's rule already skips.
follows, the rule 211 applies to text before it; anything else after it is
refused. The same screenshot then ended at its IEND.

### 409. A request to text was refused only as its first word

**Found by:** an audit of the RAG project's golden questions, which held
`docs/ACCESSIBILITY.md`'s rule, that a request acting for the device's owner
is refused unless `app` names the app, against `internal/agent/assistant.go`.
The rule matched the verb only at the start, after a greeting and "please".
"Can you text Alex I'm late", "Tell Alex I'm late" and "Remind me to call
Alex" were asked, and on a phone each goes to its owner's account.

**Fixed:** the words are matched anywhere in the request, as whole words, and
"tell" acts unless it is "tell me" or "tell us". A word used as a noun is
refused too, which naming the app answers. The docs list the words the code
has; they had left out dial, mail, purchase, tweet and venmo. `assistant.sh`
holds a request with its verb further in to the refusal.

### 410. A windowed emulator kept the host's audio

**Found by:** the same audit. `docs/SETUP.md` said to pass `-no-audio` by hand
"as `mobium boot` does", but `mobium boot` passed it only headless, so
`mobium boot --window` gave the emulator the host audio output that breaks up
what a capture hears (390).

**Fixed:** every boot passes `-no-audio`. The stream Mobium reads comes from
the emulator's control port, not the host, so a window loses only the Mac's
speakers. The Linux and headless commands in `SETUP.md` passed
`-no-snapshot-save`, which 186 there warns brings an old snapshot back; they
pass `-no-snapshot-load` and `-no-audio`, as `mobium boot` does.

## Findings that were not defects

Worth recording because each one closed off an approach that looked obvious.
Expand Down
2 changes: 1 addition & 1 deletion docs/RELEASE-CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[CI workflow](../.github/workflows/ci.yml) runs on every push — formatting,
vet, both modules' tests, the four non-Go clients' own tests, and six
cross-compile targets. This file is the rest, and the rest is where most
serious defects in this project have come from: 328 of 408 were found only by
serious defects in this project have come from: 328 of 410 were found only by
running against a real device.

Work through it before tagging a release, on three substrates: an Android
Expand Down
6 changes: 3 additions & 3 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sdkmanager --install "emulator" "platform-tools" \
avdmanager create avd -n mobium-test -d pixel_7 \
-k "system-images;android-35;google_apis;arm64-v8a"

emulator -avd mobium-test -no-snapshot-save -no-boot-anim &
emulator -avd mobium-test -no-snapshot-load -no-boot-anim -no-audio &
adb wait-for-device
```

Expand Down Expand Up @@ -117,7 +117,7 @@ sdkmanager --install "emulator" "platform-tools" \
avdmanager create avd -n mobium-test -d pixel_7 \
-k "system-images;android-35;google_apis;x86_64"

emulator -avd mobium-test -no-snapshot-save -no-boot-anim &
emulator -avd mobium-test -no-snapshot-load -no-boot-anim -no-audio &
adb wait-for-device
```

Expand All @@ -143,7 +143,7 @@ Add `-no-window`. Everything mobium does works unchanged, screenshots
included — `adb exec-out screencap` reads the framebuffer, not the window:

```sh
emulator -avd mobium-test -no-window -no-snapshot-save -no-boot-anim -no-audio &
emulator -avd mobium-test -no-window -no-snapshot-load -no-boot-anim -no-audio &
```

**Unlike an iOS simulator, the window cannot be attached afterwards.** `simctl
Expand Down
7 changes: 5 additions & 2 deletions docs/checks/assistant.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
# "Open MobiumApp" on an iPhone, with --app naming it, answers reached;
# - the same request naming another app answers not reached — the app in
# front once the panel closes is never taken for the assistant's doing;
# - a request that acts for the owner ("Text …") is refused without --app,
# before anything is asked;
# - a request that acts for the owner ("Text …", "Can you text …") is
# refused without --app, before anything is asked;
# - a simulator is refused: its Siri answers nothing (CHALLENGES 351).
#
# Each request goes to the account the assistant is signed in to, and Gemini
Expand Down Expand Up @@ -49,6 +49,9 @@ esac
out=$($M assistant "Text Mom that I am late" 2>&1) && fail "a request to text was sent without --app: $out"
echo "$out" | grep -q "on the device owner's behalf" || fail "the refusal did not say why: $out"
row "refused" "a request to text, with no app named"
out=$($M assistant "Can you text Mom that I am late" 2>&1) && fail "a request to text, not as its first word, was sent without --app: $out"
echo "$out" | grep -q "on the device owner's behalf" || fail "the refusal did not say why: $out"
row "refused" "a request to text further in, with no app named"

if [ "$KIND" = phone ]; then
REQ="Open MobiumApp"; APP=dev.mobium.mobiumapp; START=com.apple.Preferences
Expand Down
22 changes: 14 additions & 8 deletions internal/agent/assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,22 @@ func (v *AssistantView) text() string {
return b.String()
}

// sideEffects are requests that act for the device's owner: placing a
// call, sending something, paying. Matched as the request's first verb,
// after a greeting.
var sideEffects = regexp.MustCompile(`(?i)^(?:(?:hey|ok|okay)\s+(?:google|siri|gemini)[,\s]*)?(?:please\s+)?` +
`(call|dial|text|message|send|email|mail|text|pay|buy|order|purchase|book|post|tweet|share|delete|transfer|venmo)\b`)
// sideEffects are words that act for the device's owner: placing a call,
// sending something, paying, telling someone. Matched anywhere in the
// request as a whole word, not only as its first: "Can you text Alex" and
// "Remind me to call Alex" act as much as "Text Alex". A word used as a noun,
// "what does this text say", is refused too; naming the app answers it.
var sideEffects = regexp.MustCompile(`(?i)\b(call|dial|text|message|send|email|mail|pay|buy|order|purchase|book|post|tweet|share|delete|transfer|venmo|tell\s+\w+)\b`)

// actsForSomeone names the verb when request acts for the owner, or "".
// actsForSomeone names the word when request acts for the owner, or "".
// "Tell me" and "tell us" ask, and are skipped; "tell Alex" acts.
func actsForSomeone(request string) string {
if m := sideEffects.FindStringSubmatch(strings.TrimSpace(request)); m != nil {
return strings.ToLower(m[1])
for _, m := range sideEffects.FindAllStringSubmatch(request, -1) {
w := strings.Fields(strings.ToLower(m[1]))
if w[0] == "tell" && (w[1] == "me" || w[1] == "us") {
continue
}
return w[0]
}
return ""
}
Expand Down
10 changes: 8 additions & 2 deletions internal/agent/assistant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ import (
"github.com/mobiumdev/mobium/internal/uitree"
)

// A request that acts for the device's owner is refused without an app;
// asking something, or opening an app, is not.
// A request that acts for the device's owner is refused without an app,
// wherever its verb is; asking something, or opening an app, is not.
func TestActsForSomeone(t *testing.T) {
for req, want := range map[string]string{
"Text Mom that I am late": "text",
"Hey Google, call Alex": "call",
"OK Siri please send an email": "send",
"Buy more milk": "buy",
"Can you text Alex I'm late": "text",
"Tell Alex I'm late": "tell",
"Remind me to call Alex": "call",
"Hey Siri, I want to pay Sam": "pay",
"Tell me a joke": "",
"Tell me to call Alex later": "call",
"Open Clock": "",
"What is 15 times 3": "",
"Show my texts": "",
Expand Down
17 changes: 13 additions & 4 deletions internal/device/boot.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,18 @@ type Booted struct {
Note string `json:"note,omitempty"`
}

// emulatorArgs cold-boots avd with no host audio, headless unless window.
// -no-audio goes on a window too: the host's audio output breaks up what a
// capture hears (CHALLENGES 390), and the stream Mobium reads is not the
// host's, so a window loses only the Mac's speakers.
func emulatorArgs(avd string, window bool) []string {
args := []string{"-avd", avd, "-no-snapshot-load", "-no-boot-anim", "-no-audio"}
if !window {
args = append(args, "-no-window")
}
return args
}

// BootEmulator starts the AVD named avd and waits until Android has booted:
// adb sees it and sys.boot_completed is 1. It cold-boots: the quick-boot
// snapshot has brought back an app days older than the one installed
Expand All @@ -139,10 +151,7 @@ func BootEmulator(ctx context.Context, avd string, window bool, log string) (Boo
before[d.Serial] = true
}
}
args := []string{"-avd", avd, "-no-snapshot-load", "-no-boot-anim"}
if !window {
args = append(args, "-no-window", "-no-audio")
}
args := emulatorArgs(avd, window)
if err := os.MkdirAll(filepath.Dir(log), 0o755); err != nil {
return Booted{}, err
}
Expand Down
23 changes: 23 additions & 0 deletions internal/device/boot_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package device

import (
"slices"
"testing"
)

// Every boot has no host audio, headed or not: the host's output breaks up
// what a capture hears (CHALLENGES 390).
func TestEmulatorArgsAlwaysNoAudio(t *testing.T) {
for _, window := range []bool{false, true} {
args := emulatorArgs("mobium-test", window)
if !slices.Contains(args, "-no-audio") {
t.Errorf("window=%v: %v has no -no-audio", window, args)
}
if slices.Contains(args, "-no-window") == window {
t.Errorf("window=%v: %v", window, args)
}
if !slices.Contains(args, "-no-snapshot-load") {
t.Errorf("window=%v: %v does not cold-boot", window, args)
}
}
}