[PR #2998] [CLOSED] fix(adb): read window focus from the displays section on Android 16 #5550

Closed
opened 2026-10-31 01:07:30 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/2998
Author: @cyberpunk47
Created: 10/13/2026
Status: ❌ Closed

Base: main ← Head: fix/adb-window-focus-android16


📝 Commits (1)

  • 6b407ae fix(adb): read window focus from the displays section on Android 16

📊 Changes

4 files changed (+85 additions, -10 deletions)

View changed files

📝 src/adb/AdbProvider.test.ts (+63 -6)
📝 src/adb/AdbProvider.ts (+20 -2)
📝 src/adb/AdbShellOutput.ts (+1 -1)
📝 src/contracts/adb/adbToolContracts.ts (+1 -1)

📄 Description

Summary

Fixes #2996

On Android 16, dumpsys window windows no longer prints mCurrentFocus / mFocusedApp, so inspect_adb_window returned null focus with no explanation while an app was on screen. When the windows section declares neither line, the provider now reads dumpsys window displays. Each result says which section supplied the values. When neither section declares focus, a limitation says focus is unknown, not absent.

Problem and expected behavior

  • Before (SDK 36 emulator, launcher in front): focused_window: null, focused_app: null, observed_lines: [].
  • After: focused_window: "Window{… NexusLauncherActivity}", focused_app: "ActivityRecord{… t2}", plus the limitation "Focus declarations were read from dumpsys window displays".

Violated invariant (AGENTS.md): "Unresolved identity or applicability must remain unknown rather than be treated as absent, foreign, or aligned."

Change and scope

  • src/adb/AdbProvider.ts (inspect_adb_window):
    • It still reads dumpsys window windows first, so earlier builds behave as before.
    • Only when that section declares neither line does it read dumpsys window displays.
    • A refusal from either shell call is returned unchanged.
  • New limitations:
    • one naming the source section;
    • one stating focus is unknown when neither section declares it.
  • src/contracts/adb/adbToolContracts.ts: the tool description names both sections.
  • src/adb/AdbShellOutput.ts: the doc comment names both sections; parsing is unchanged.
  • Not included:
    • no result schema change;
    • no new tool;
    • no device interaction beyond one extra read-only dumpsys call on builds that need it.

Contribution scope: not applicable (routine fix within existing boundaries).

Contract and boundary impact

  • Semantic owner and earliest changed stage: ADB provider, inspect_adb_window shell observation
  • Contribution scope fit and linked maintainer decision: routine evidence-correctness fix; not applicable
  • CLI and MCP/tool-catalog contract: result schema unchanged; tool description text updated
  • Provider, bridge, target-format, or platform compatibility: Android 16 focus is now reported; earlier builds unchanged
  • Evidence, artifact, provenance, or reconstruction contract: limitations now name the source section, or say focus is unknown
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): read-only dumpsys only
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none tracked

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated (src/adb/AdbProvider.test.ts):
    • shellStub keys can now name a third shell word (dumpsys:window:displays), so tests can tell the sections apart; existing two-word keys behave as before.
    • Android 16 layout: windows has no focus lines and displays has both. Both values are reported, and the limitation names displays.
    • Earlier layout: windows has both lines. displays is not stubbed, so a second call would fail the test.
    • Neither section declares focus: nulls, plus the "unknown, not absent" limitation.
  • Base reproduction: with only the test changes applied to the base revision, the Android 16 case fails (focused_window is null). The other two fail only on the new limitation text.
  • User-visible CLI/MCP output: see before/after above.
  • Device checks: SDK 36 emulator (BE2A.250530.026.D1) and LineageOS 23 (SDK 36). On both, windows has 0 focus lines and displays has both.
  • Remaining proof gaps: not run against a pre-Android-10 device; the windows-first order keeps their path unchanged.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npx vitest run src/adb: 5 files, 116 tests passed
  • npm run typecheck: passed
  • npm run lint: no new diagnostics in changed files. The 2 existing errors (artifactComparison.test.ts, ManagedCilDecoding.test.ts) are also on main.
  • oxfmt on changed files: clean
  • npm run jscpd: 2.93%

Compatibility, safety, and release

  • Breaking changes or migration steps: none
  • Real Hopper/Ghidra, browser, or OS coverage: Android SDK 36 emulator and device
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: one additional read-only dumpsys window displays call, only when the first section declares no focus; same timeout and output cap

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/2998 **Author:** [@cyberpunk47](https://github.com/cyberpunk47) **Created:** 10/13/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/adb-window-focus-android16` --- ### 📝 Commits (1) - [`6b407ae`](https://github.com/morluto/rea/commit/6b407ae2e6f0183dbdd1feb0bec08589f58344ac) fix(adb): read window focus from the displays section on Android 16 ### 📊 Changes **4 files changed** (+85 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/adb/AdbProvider.test.ts` (+63 -6) 📝 `src/adb/AdbProvider.ts` (+20 -2) 📝 `src/adb/AdbShellOutput.ts` (+1 -1) 📝 `src/contracts/adb/adbToolContracts.ts` (+1 -1) </details> ### 📄 Description ## Summary Fixes #2996 On Android 16, `dumpsys window windows` no longer prints `mCurrentFocus` / `mFocusedApp`, so `inspect_adb_window` returned `null` focus with no explanation while an app was on screen. When the `windows` section declares neither line, the provider now reads `dumpsys window displays`. Each result says which section supplied the values. When neither section declares focus, a limitation says focus is unknown, not absent. ## Problem and expected behavior - Before (SDK 36 emulator, launcher in front): `focused_window: null`, `focused_app: null`, `observed_lines: []`. - After: `focused_window: "Window{… NexusLauncherActivity}"`, `focused_app: "ActivityRecord{… t2}"`, plus the limitation "Focus declarations were read from `dumpsys window displays`". Violated invariant (AGENTS.md): "Unresolved identity or applicability must remain unknown rather than be treated as absent, foreign, or aligned." ## Change and scope - `src/adb/AdbProvider.ts` (`inspect_adb_window`): - It still reads `dumpsys window windows` first, so earlier builds behave as before. - Only when that section declares neither line does it read `dumpsys window displays`. - A refusal from either shell call is returned unchanged. - New limitations: - one naming the source section; - one stating focus is unknown when neither section declares it. - `src/contracts/adb/adbToolContracts.ts`: the tool description names both sections. - `src/adb/AdbShellOutput.ts`: the doc comment names both sections; parsing is unchanged. - Not included: - no result schema change; - no new tool; - no device interaction beyond one extra read-only `dumpsys` call on builds that need it. Contribution scope: not applicable (routine fix within existing boundaries). ## Contract and boundary impact - Semantic owner and earliest changed stage: ADB provider, `inspect_adb_window` shell observation - Contribution scope fit and linked maintainer decision: routine evidence-correctness fix; not applicable - CLI and MCP/tool-catalog contract: result schema unchanged; tool description text updated - Provider, bridge, target-format, or platform compatibility: Android 16 focus is now reported; earlier builds unchanged - Evidence, artifact, provenance, or reconstruction contract: limitations now name the source section, or say focus is unknown - Target selection, authority, upstream behavior, and cleanup details (if applicable): read-only `dumpsys` only - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none tracked Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - Tests added or updated (`src/adb/AdbProvider.test.ts`): - `shellStub` keys can now name a third shell word (`dumpsys:window:displays`), so tests can tell the sections apart; existing two-word keys behave as before. - Android 16 layout: `windows` has no focus lines and `displays` has both. Both values are reported, and the limitation names `displays`. - Earlier layout: `windows` has both lines. `displays` is not stubbed, so a second call would fail the test. - Neither section declares focus: nulls, plus the "unknown, not absent" limitation. - Base reproduction: with only the test changes applied to the base revision, the Android 16 case fails (`focused_window` is `null`). The other two fail only on the new limitation text. - User-visible CLI/MCP output: see before/after above. - Device checks: SDK 36 emulator (BE2A.250530.026.D1) and LineageOS 23 (SDK 36). On both, `windows` has 0 focus lines and `displays` has both. - Remaining proof gaps: not run against a pre-Android-10 device; the `windows`-first order keeps their path unchanged. For evidence-bearing changes: - [x] Observed, derived, and inferred claims remain distinguishable. - [x] Artifact identity, source provenance, and failed attempts remain preserved. - [x] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npx vitest run src/adb`: 5 files, 116 tests passed - `npm run typecheck`: passed - `npm run lint`: no new diagnostics in changed files. The 2 existing errors (`artifactComparison.test.ts`, `ManagedCilDecoding.test.ts`) are also on main. - `oxfmt` on changed files: clean - `npm run jscpd`: 2.93% ## Compatibility, safety, and release - Breaking changes or migration steps: none - Real Hopper/Ghidra, browser, or OS coverage: Android SDK 36 emulator and device - Package or release metadata impact: none - Security, privacy, process, or containment review: one additional read-only `dumpsys window displays` call, only when the first section declares no focus; same timeout and output cap ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. - [x] User-visible CLI/MCP changes include representative output. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:07:30 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#5550
No description provided.