Skip to content

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

Merged
thymikee merged 2 commits into
callstack:mainfrom
mwolson:fix/android-framework-activity-system-surface
Nov 10, 2026
Merged

thymikee merged 2 commits into
callstack:mainfrom
mwolson:fix/android-framework-activity-system-surface

Conversation

@mwolson

@mwolson mwolson commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

Thanks, this looks good at b1146ea. The framework-owned chooser and resolver windows now come back as a system surface, and the test covers both owners. There are no conflicts. The systemui coverage comment is fixed and can be resolved.

Not blocking:

  • Two negative tests through classifyAndroidHelperContent in snapshot-content-recovery.test.ts would pin the guard: an active android-owned type-1 window next to an app-owned window with a meaningful node (not system-surface-only), and an android-owned type-1 window that is not active or focused (unusable). Today the applicationWindowRootCount === systemApplicationWindowRootCount check could change to > 0 and every test would still pass.
  • The fixture is hand-built, so a trimmed real helper XML of the resolver window would tie the checks to a real dump.
  • The live run used a patched 0.21.32 build on Waydroid. snapshot -i --json output from a head build, or a note that the run used the patched build, would make that clear.
  • The comment and changeset say "Android 13 and older", but the real Sharesheet fixture in settle.test.ts is android-owned on a modern emulator too, so describing the rule as "by framework owner" would be more accurate.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Nov 10, 2026
@thymikee
thymikee merged commit 8ae54a0 into callstack:main Nov 10, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants