Recent Changes‎ > ‎

    Sensor emulation

    posted Dec 13, 2011, 2:20 PM by Xavier Ducrohet
    Note: This feature is present in tools revision 16. It is a bit rough regarding setup and we'd love feedback.

    For a realistic sensor emulation, the emulator uses a connection with an actual Android device running the SdkControllerSensor application. The application monitors changes in the sensors on the device, and transmits them to the emulator. The emulator then injects those changes into the guest system image. This requires Android 4.0, system image revision 2.

    The SdkControllerSensor application source code is located in $SDK/tools/apps/SdkController/
    ADB port forwarding is used for the data transfer between the device and the emulator.

    Here is how you enable sensor emulation:
    1. Connect a device to the host machine via USB, make sure USB debugging is enabled on the device.
    2. Start the SdkControllerSensor application on the device.
    3. Use application’s UI to select sensors that you want to emulate.
    4. Run adb forward tcp:1968 tcp:1968 in the host’s shel / command line.
    5. Start the emulator.

    Note that port forwarding between the host and the device can be fragile. If you see that sensor events have stopped in the emulator, run the adb forward tcp:1968 tcp:1968 command again. This should restore the connection.