Skip to content

Wake device before launching Android apps - #12322

Open
jonathanpeppers wants to merge 2 commits into
mainfrom
jonathanpeppers-wake-device-on-run
Open

Wake device before launching Android apps#12322
jonathanpeppers wants to merge 2 commits into
mainfrom
jonathanpeppers-wake-device-on-run

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

  • wake sleeping devices before Microsoft.Android.Run starts an activity
  • dismiss non-secure keyguards so the deployed app becomes visible
  • keep wakeup, keyguard dismissal, and activity launch in one adb shell invocation
  • add --no-wake-device, available to MSBuild callers through $(_AndroidRunExtraArgs), as an escape hatch

Fixes #11064.

Testing

  • built Xamarin.Android.sln and configured the local Android workload
  • created an app with the in-tree dotnet new android template
  • deployed and launched it with dotnet-local.cmd run on a sleeping, locked physical device
  • confirmed the device woke, dismissed the keyguard, and displayed the app
  • verified --no-wake-device omits both device-preparation commands

Wake sleeping devices and dismiss non-secure keyguards before starting deployed applications, keeping preparation and launch in one adb shell invocation.

Add --no-wake-device as an escape hatch through the existing _AndroidRunExtraArgs passthrough and cover both command modes in device integration tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 7, 2026 20:20

Copilot AI 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.

Pull request overview

This PR updates Microsoft.Android.Run to proactively wake an Android device and dismiss a non-secure keyguard before launching an app activity, with an opt-out flag (--no-wake-device) and a device integration test validating both behaviors.

Changes:

  • Added --no-wake-device option to Microsoft.Android.Run to skip wake/keyguard dismissal.
  • Updated the activity-start adb invocation to include wake + keyguard dismissal when enabled.
  • Extended device integration coverage to assert the adb command-line behavior with and without wakeup.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Microsoft.Android.Run/Program.cs Adds wake/keyguard behavior to the adb shell … am start … launch path and introduces --no-wake-device.
tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs Adds parameterized test coverage asserting wake vs. non-wake dotnet run behavior via verbose output.

Comment thread src/Microsoft.Android.Run/Program.cs
Treat wakeup and keyguard dismissal as best effort so unsupported or secure-device behavior cannot prevent am start from running or control its exit status.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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.

Run adb shell input keyevent KEYCODE_WAKEUP during deploy/run to wake sleeping devices

2 participants