fix(android): return framework share sheets as a system surface

Merged
MW
7d ago
+64-2

Summary

On Android 13 and older (and Waydroid's LineageOS image), the share sheet is the framework's ChooserActivity or ResolverActivity. It runs in an application window (type 1) owned by the android package, while the app that opened it still owns the task. The snapshot classifier counts android nodes as system UI but only treats non-application windows as a system surface, so the sheet's content counts toward neither bucket and every snapshot fails with "Android snapshot helper returned insufficient foreground app content". The agent cannot see the sheet, so it cannot act on it or get back to the app.

An active application window whose root belongs to android or com.android.systemui now counts as a system surface, and a capture where every application window is framework-owned is returned as system-surface-only, the same path the notification shade takes. Application windows from other packages are classified as before.

Observed diagnostics from a real capture (share sheet over a React Native app on Waydroid, agent-device 0.21.31):

helperNodeCount: 77, helperSystemUiNodeCount: 77, helperWindowRootCount: 3,
helperApplicationWindowRootCount: 1, helperMeaningfulNodeCount: 46,
helperApplicationMeaningfulNodeCount: 0, helperForegroundAppMeaningfulNodeCount: 0,
helperWindowTypes: [1, 3]

Validation

  • New test in snapshot-content-recovery.test.ts: an active application window owned by android or by com.android.systemui, over a foreground app, returns system-surface-only. Both cases fail without the change.
  • pnpm exec vitest run packages/platform-android: 135 files, 1,367 tests passed.
  • pnpm run typecheck, oxlint --deny-warnings and oxfmt --check on the changed files are clean.
  • Live on Waydroid (LineageOS, x86_64): with am start -a android.intent.action.SEND -t text/plain over the app, snapshot -i failed every time before the change. With the same classifier change applied to the published 0.21.32 dist, it returns the resolver's options ("Just once", "Always", the target list) with the system-surface note.

Separately, on that Waydroid image ResolverActivity ignores the Back key, so reopening the app is the reliable way out; that is a device quirk, not part of this change.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.