Use synthetic data providers to simulate sensor data from Health Services and test your app as though an exercise were really happening. You can use one of the preconfigured exercise profiles, or configure a custom one using flags.
There are two options available for generating simulated data:
Synthetic data providers: Offers extensive options for data generation. This method uses
adbcommands, and is described on this page.
To use synthetic data providers on an emulator, ensure developer options are enabled.
Emulator extended controls: The emulator in Android Studio offers the extended controls panel, available by clicking the three dots in the button bar. From the extended controls, the developer can load in KML/GPX files to simulate location, or specify the behaviour of the heart rate sensor.
Enable synthetic data providers
- Enable developer options
- Issue the following adb command to enable synthetic providers:
adb shell am broadcast \ -a "whs.USE_SYNTHETIC_PROVIDERS" \ com.google.android.wearable.healthservices
Once synthetic providers are enabled, issue commands described later in this page to control the behavior of a “synthetic user.”
Disable synthetic data providers
To switch back to using real sensors, run the following command:
adb shell am broadcast \ -a "whs.USE_SENSOR_PROVIDERS" \ com.google.android.wearable.healthservices
Health Services supports the following exercise types:
- Running on treadmill:
The exercises generate realistic synthetic data for the following data types:
- Heart rate
- Step count per minute
- GPS location (using a single default route)
- Duration of the activity
- Elevation and floors
In addition, the following states can be generated:
- Sleep state (asleep/awake)
- Fall detection
To start simulating an exercise, issue the appropriate broadcast to
# start the "walking" synthetic exercise $ adb shell am broadcast \ -a "whs.synthetic.user.START_WALKING" \ com.google.android.wearable.healthservices
Each of these activities has presets for the supported metrics:
|Activity||Heart rate||Average speed||Elevation change||Use location|
|Walking||120 bpm||1.4 m/sec||20.0 m/min||true|
|Running||170 bpm||2.3 m/sec||20.0 m/min||true|
|Hiking||150 bpm||1.3 m/sec||20.0 m/min||true|
|Swimming||150 bpm||1.6 m/sec||0.0 m/min||true|
|Running treadmill||160 bpm||2.3 m/sec||20.0 m/min||false|
To stop the synthetic activity, use the following command:
adb shell am broadcast \ -a "whs.synthetic.user.STOP_EXERCISE" \ com.google.android.wearable.healthservices
For more precise control over what metrics are generated, start a custom
exercise activity by using the action string
and providing any combination of the following flags:
--ei exercise_options_duration_secs <int>Duration of the exercise in seconds. Default:
--ei exercise_options_heart_rate <int>Heart rate in beats per minute. Average:
--ef exercise_options_average_speed <float>Average speed in meters per second. Also affects cadence (steps per minute). Default:
--ez exercise_options_use_location <boolean>Whether to emit location data during the exercise (using a default route). Default:
--ef exercise_options_max_elevation_rate <float>Maximum possible elevation change rate in meters per minute. Default:
For example, set exercise options in the following way:
adb shell am broadcast \ -a "whs.synthetic.user.START_EXERCISE" \ --ei exercise_options_heart_rate 90 \ --ef exercise_options_average_speed 1.2 \ --ez exercise_options_use_location true \ com.google.android.wearable.healthservices
It's also possible to change the data types that are available, whether or not the real or emulated hardware supports it.
For example, you can enable or disable absolute elevation, as shown in the following snippet:
# enable synthetic mode and enable absolute elevation $ adb shell am broadcast \ -a "whs.CONFIGURE_SYNTHETIC_DEVICE" \ --ez absolute_elevation true \ com.google.android.wearable.healthservices # enable synthetic mode and disable absolute elevation $ adb shell am broadcast \ -a "whs.CONFIGURE_SYNTHETIC_DEVICE" \ --ez absolute_elevation false \ com.google.android.wearable.healthservices
Other states and events
Sleep states can also be triggered for the synthetic user. Two states are supported: asleep and awake.
To enter ‘asleep’ state, do the following:
adb shell am broadcast \ -a "whs.synthetic.user.START_SLEEPING" \ com.google.android.wearable.healthservices
To enter ‘awake’ state do the following:
adb shell am broadcast \ -a "whs.synthetic.user.STOP_SLEEPING" \ com.google.android.wearable.healthservices
To simulate a fall, run this command:
adb shell am broadcast \ -a "whs.synthetic.user.FALL_OVER" \ com.google.android.wearable.healthservices
It may take up to a minute for health services to deliver the fall event.