Using the emulator

If you don’t have the actual hardware device, you can use the Accessory Emulator included with Sony Add-on SDK. The Accessory Emulator emulates most accessories that support the Smart Extension APIs and allows you to test and debug your app.

Overview

The Accessory Emulator is an APK that either comes installed in the Android emulator included with the Sony Add-on SDK, or as an apk file in the apks directory of the Sony Add-on SDK, which you can then install on a phone or tablet.

The Accessory Emulator can emulate these accessories:

  • SmartWatch
  • SmartWatch 2
Accessory Emulator app on Android device.

Accessory Emulator app on Android device.

Selecting an accessory to emulate on the Accessory Emulator.

Selecting an accessory to emulate on the Accessory Emulator.

Please note that the following functionalities in SmartWatch 2 are currently not supported by the emulator:

  • Clock apps
  • Widget apps
  • Active Low Power

If your app uses these integrations, you will need to use an actual accessory to test it. For more information on testing your app with actual hardware, see the Using hardware guide.

How to use the Accessory Emulator

The Accessory Emulator acts as a host application for the accessory that is being emulated. Depending on what the specific accessory supports, it will provide emulations for the different Smart Extension APIs – Notification API, Widget API, Control API, and Sensor API.

Note: For the Active Low Power mode API, emulation of Active Low Power mode is currently not supported.

In this section, the original SmartWatch and SmartWatch 2 will be the example accessories shown in the following figures and examples.

Accessory Emulator main screen.

Accessory Emulator main screen.

The main screen of the Accessory Emulator lists the available Smart Extension APIs that are supported by the current emulated accessory, as well as a possibility to find out more details about the currently available apps. At the bottom of the screen, the currently emulated accessory is shown. By clicking this area, a dialog will be shown that will enable you to change the current accessory.

Registered extension and Extension registration details.

Registered extension and Extension registration details.

By tapping the Extensions row of the emulator main screen, you are taken to the Registered extensions view. It is a list of the currently registered Smart Extensions on the phone. If you click on an app in the list, you will be shown registration details about the app. This is the registration data that has been registered into the Smart Connect application database. You are able to check if the registration details are correct, for example, that you have registered for the correct Smart Extension APIs. In the example in above, it is the Open Source Music player app, which is a Control app.

Clicking the Show extension settings button takes you to the app settings dialog, as shown below.

App settings.

App settings.

Notification API

Clicking the Notification API row of the emulator main screen takes you to the Notification API emulation for the specific accessory.

Notification API – choose notification source.

Notification API – choose notification source.

Clicking in the middle of the screen lets you choose a notification source to work with. In the example above, the source from the Sample Notification app is selected.

Notification event with notification options.

Notification event with notification options.

After a source has been chosen, the available events will be displayed in the emulated accessory. By swiping left and right, you can step between the different events. Clicking the option button on the right will display the registered source actions, as shown above. When clicking any of the options, the app will be notified and the action can be executed.

The accessory Back button will take you back to the source selection screen. The accessory Home button will end the Notification API emulation and take you back to the emulator main screen.

Widget API

The Widget API emulation is currently only available for the first SmartWatch. When you enter the Widget API emulation, you will be presented with the first currently installed widget app.

Widget sample on SmartWatch.

Widget sample on SmartWatch.

By swiping left and right, you can then step between the widgets, much like it is actually displayed on the SmartWatch itself.

Control API

Clicking the Control API row of the main screen of the accessory emulator takes you to the Control API emulation.

Control API – choose app, then choose emulated extension.

Control API – choose app, then choose emulated extension.

Clicking the middle of the screen of the accessory will display a dialog of the available Control apps. In this example, the Sample control app is selected. As shown above, the chosen Control app is presented in the accessory display. The emulation will include all possible scenarios supported by the specific accessory – how the accessory reacts to input data from the app, and how the accessory supports output events, such as touch, click and swipe.

For SmartWatch 2, there are also possibilities to intercept, or hijack, the hardware buttons of the accessory, such as the Back button and the Options button. This behavior is exemplified in the figure above, where the Sample control app reacts to the Options button being pressed by the user. If the Back button has been intercepted by the app, the Key event will be sent to the app and it can react as appropriate. If not, the Back button will exit the app and take you back to the Choose extension screen.

Sensor API

The Sensor API emulation will emulate the specific accessory sensors that are available on the phone device. For SmartWatch, this means the accelerometer; for SmartWatch 2, this means light and accelerometer.

Sensor API – choose app, then choose emulated app.

Sensor API – choose app, then choose emulated app.

Clicking the middle of the screen of the accessory will present a dialog of the available Sensor apps. In this example, the Sample sensor app is selected.

Sensor sample showing data.

Sensor sample showing data.

As shown above, the chosen Sensor app will be presented in the accessory display. The emulator will harvest sensor data from the phone sensors, and feed the data to the emulated app.

Test using the Accessory Emulator on a phone or tablet

If you are testing using the Accessory Emulator on a hardware device such as a phone or tablet, you’ll need to set up the Android device you plan to use with the emulator. Note that the Android device must be running Android 4.0 or newer. For the Android smartphone or tablet, perform the following steps:

  1. Download and install Smart Connect from Google Play.
  2. Connect the device to your computer with a USB cable.
  3. Locate the Accessory Emulator.apk from the apk folder inside the Sony Add-on SDK and install it on the Android device using adb.
  4. Deploy the app on the Android device or emulator using adb.
  5. Launch the Accessory Emulator, then select the accessory to emulate, for example SmartWatch 2.
  6. In the Accessory Emulator overview for the emulated accessory, select the Extensions row to show the registered apps on the Android device.

    Accessory Emulator main screen.

    Accessory Emulator main screen.

  7. In the Registered extensions list, look for the app to confirm that it exists on the Android device.

    Registered extensions display.

    Registered extensions display.

  8. Press back to return to the Accessory Emulator list. Depending on which functionality of the app you want to test, for example, notification, simply select the corresponding API from the Accessory Emulator overview screen, for example Notification API, then select the source, and the available events are displayed on the emulated accessory.
    Testing the app’s API functionality.

    Testing the app’s API functionality.

    Test using the Accessory Emulator on the Android Emulator

    To test using the Accessory Emulator on the Android Emulator, perform the following steps:

    1. Ensure that you have installed the Sony Add-on SDK and set up an AVD.
    2. Launch the AVD.
    3. Deploy the app on the Android device or emulator using adb.
    4. Launch the Accessory Emulator, then select the accessory to emulate, for example SmartWatch 2.
    5. In the Accessory Emulator overview for the emulated accessory, select the Extensions row to show the registered apps on the Android device.

      Accessory Emulator main screen.

      Accessory Emulator main screen.

    6. In the Registered extensions list, look for the app to confirm that it exists on the Android device.

      Registered extensions display.

      Registered extensions display.

    7. Press back to return to the Accessory Emulator list. Depending on which functionality of the app you want to test, for example, notification, simply select the corresponding API from the Accessory Emulator overview screen, for example Notification API, then select the source, and the available events are displayed on the emulated accessory.

      Testing the app’s API functionality.

      Testing the app’s API functionality.