Use the Surface Duo emulator
This article describes functionality and guidance that is in public preview and may be substantially modified before it's generally available. Microsoft makes no warranties, express or implied, with respect to the information provided here.
With the Surface Duo image and the Android Emulator you can test your app without access to a physical device. The emulator simulates postures, gestures, hinge angle, mimicking the seam between the two screens, and more. We'll continue to add functionality over time.
See Get the Surface Duo emulator if you don't yet have the tools installed.
How to Debug your App on the emulator
Directly in Android Studio
- Open your project in Android Studio.
- Build your project: Build > Make Project or Ctrl+F9.
- Select "Microsoft SurfaceDuoEmulator API 29" from the list of Running Devices.
- Run your project to deploy it to the emulator: Run > Run 'project name' or Shift+F10.
- To stop debugging: Run > Stop 'project name' or Ctrl+F2.
Using ADB commands
Follow these steps to debug using ADB commands.
Find your emulator device ID
Find the package you want to debug.
adb shell pm list packages.
package:com.android.managedprovisioning package:com.android.smspush package:com.android.wallpaper.livepicker package:com.android.storagemanager package:com.android.bookmarkprovider package:com.android.settings package:com.android.calculator2 package:com.android.vpndialogs package:com.android.email package:com.android.music
Set the app to debug at startup (note the -w)
adb shell am set-debug-app -w com.microsoft.device.display.samples.masterdetail.
Start the app in the emulator.
You will get a popup that the app is waiting for a debug to attach. You will need to re-run the set debug each time (or use --persistent option).
Connect Android Studio Debugger
In Android Studio menu options, select Run->Attach debugger. The emulator and process should be listed.
Point to source code and set breakpoints.
Span your app in the emulator
To span your app in the emulator, drag the app from the white bar at the bottom of the app screen towards the middle of the device. When the background turns white across both screens, release the app.
Rotate your app in the emulator
You can rotate the emulator using these buttons in the emulator toolbox, or use Control+Left arrow and Control+Right arrow keyboard shortcuts:
If the screen elements don't rotate, check that Auto-rotate is enabled. You can use Settings > Display > Auto-rotate screen or pull down from the status bar and ensure the Auto-rotate option is enabled (blue):
Move, rotate, and preview the device posture
The latest version 2020.1014.2 of the emulator supports the Device Pose view in the Extended controls window. Use the Rotate and Move radio buttons to show sliders to adjust the device's position, or click and drag in the preview window:
You can also use the Rotation buttons to center the device and set the rotation to 0, 90, 180, or 270 degrees.
Simulate the hinge angle changing
The latest version 2020.1014.2 of the emulator has a hinge angle slider. Access the slider in the Extended controls window, Virtual sensors section, by choosing the Fold radio button:
When the hinge angle exceeds 235 degrees the device will enter Flip mode and one screen will be turned off.
Simulate different device postures
The Surface Duo can be placed in a number of different postures, some of which will affect your app (such as if the app is spanned but the device is folded into tent or flip mode, and one screen is turned off).
The latest version of the emulator (2020.1014.2) has a set of buttons to all you to quickly choose a posture. Access these buttons in the Extended controls window, Virtual sensors section, by choosing the Fold radio button:
These buttons will set a specific hinge angle. Use the Rotate and Move radio buttons to adjust the device position and orientation, which also affects how the app displays. You can also change the rotation of the device by dragging on the 3D posture preview.
|Posture name||Hinge angle range *|
|Closed||0 - 22.5|
|Tent ^||22.5 - 107.5|
|Half-Open||107.5 - 125|
|Open||125 - 240|
|Flipped ^||240 - 360|
* these ranges reflect the current emulator preview behavior but are subject to change in a future release. To accurately simulate a specific posture use the hinge-angle slider.
^ both Tent and Flipped postures should only have one active screen. The second screen is disabled at angles greater than 235 degrees.
Use the camera
Use this command to list the webcams available on the machine:
If necessary, change the path to match your local installation.
Copy the camera name you want to use, and open the config.ini file. In there you will see something like this:
For example, you can change the front camera to use the host machine's webcam.