Skip to content

feat(serve-emu): expose Android emulator fold controls - #135

Merged
szdziedzic merged 10 commits into
expo:mainfrom
juliusmarminge:feat/android-fold-controls
Sep 25, 2026
Merged

szdziedzic merged 10 commits into
expo:mainfrom
juliusmarminge:feat/android-fold-controls

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Android foldable emulators can report their hinge angle and physical device state and accept fold/unfold commands, but serve-emu did not expose those capabilities to API clients.

This adds typed GET /api/fold status and POST /api/fold control to both serve-emu HTTP hosts. Status uses read-only emulator console and Android physical-state queries, so polling does not enable or reconfigure gRPC. Commands use the emulator's documented fold/unfold actions and read back the resulting posture. Physical Android devices and emulator profiles without a hinge sensor report unsupported. Commands are limited to closed and opened; continuous hinge-angle control is outside this change.

Validation:

  • bun run --filter serve-emu check — 1,094 tests passed, typecheck, build, docs sync, and package smoke test passed.
  • Pixel 9 Pro Fold AVD on Android 37: passive opened/180° status → closed/0° → opened/180°, with status read back after each command. No gRPC endpoint was activated during the run.

Built with Codex (GPT-6 Sol).

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

Devin Review found 3 new potential issues.

Devin Review

@@ -0,0 +1,5 @@
---
'expo-device-hub': minor

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Fold controls omitted from Hub releases

The new changeset targets expo-device-hub's ignored dependency serve-emu instead of expo-device-hub. Changesets excludes serve-emu, so this feature does not trigger a Hub release.

Learn more

The Changesets configuration ignores serve-emu. The published Hub package vendors that code rather than publishing serve-emu independently, so a changeset targeting the ignored name cannot version the Hub release. The repository release guidance requires changes that ship in Hub to target expo-device-hub.

Example: A release run after merging this feature sees no new expo-device-hub changeset from the fold controls and leaves Hub at its previous version instead of scheduling the minor release.

Recommended fix: Target expo-device-hub in this changeset so the release workflow versions the package that distributes the new API.

Suggested change
'expo-device-hub': minor
'expo-device-hub': minor

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This finding does not match the PR diff: .changeset/android-fold-controls.md already targets 'expo-device-hub': minor, the package that publishes Hub. No changeset change is needed.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Devin Review

const posture = name ? POSTURES[name] : undefined;
return {
supported: true,
posture: name ? posture ?? null : angle <= 5 ? "closed" : angle >= 175 ? "opened" : null,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Unknown state names hide fold posture

When base-state reports an unfamiliar name, getFoldStatus returns a null posture even at a closed or opened hinge angle. setFoldPosture then rejects a successful command because its confirmation never sees the requested posture.

Learn more

An emulator can report a hinge sensor reading and a physical state name not present in POSTURES. The name branch now discards the angle fallback for such states. During setFoldPosture, the command can succeed, but every status read returns a null posture until confirmation times out.

Example: An emulator reports hinge-angle0 = 0 and Committed state: DeviceState{identifier=2, name='FOLDED'}. A request to close it succeeds at the console but returns Emulator did not confirm closed posture instead of the closed status.

Recommended fix: Preserve angle-based fallback when POSTURES[name] is undefined, while keeping recognized names such as TENT authoritative over extreme hinge angles.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@szdziedzic
szdziedzic merged commit 1b3086e into expo:main Sep 25, 2026
10 of 11 checks passed
@jiunshinn jiunshinn mentioned this pull request Oct 5, 2026
4 of 6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants