Use the Surface Duo emulator

Important

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 SDK if you don't yet have the tools installed. Read the Xamarin Developers section for help setting up the Surface Duo Emulator to work with Visual Studio.


Using the Surface Duo SDK

Multiple development languages are supported by the SDK.

Follow these steps to add the Surface Duo SDK and layout controls to your Java or Kotlin app:

  1. In the top-level build.gradle file, add these lines inside the allprojects { repositories { section:

    maven {
        url 'https://pkgs.dev.azure.com/MicrosoftDeviceSDK/DuoSDK-Public/_packaging/Duo-SDK-Feed/maven/v1'
    }
    
  2. In your module-level build.gradle file, add these lines in the dependencies { section:

    implementation "com.microsoft.device.display:display-mask:0.3.0"
    implementation "com.microsoft.device:dualscreen-layout:1.0.0-alpha01"
    
  3. Java projects should also add this line to their build.gradle dependencies, because the library is built with Kotlin (note that the $kotlin_version will need to be defined as well):

    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    

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.

  1. Find your emulator device ID

    Run C:\>adb devices.

    emulator-5554   device
    
  2. Find the package you want to debug.

    Run 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
    
  3. Set the app to debug at startup (note the -w)

    Run adb shell am set-debug-app -w com.microsoft.device.display.samples.masterdetail.

  4. 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).

  5. Connect Android Studio Debugger

    In Android Studio menu options, select Run->Attach debugger. The emulator and process should be listed.

  6. 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.

Steps to span an app in the Surface Duo emulator

Use the camera

Use this command to list the webcams available on the machine:

~/Android/Sdk/emulator/emulator -webcam-list

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:

 hw.camera.back=virtualscene
 hw.camera.front=emulated

For example, you can change the front camera to use the host machine's webcam.

 hw.camera.back=virtualscene
 hw.camera.front=webcam0

Xamarin Developers

Follow the Xamarin-specific instructions to download, install, and use the Surface Duo emulator preview.