Use synthetic data generated from Health Services on Wear OS to test your app as though an exercise were really happening.
If you're testing on an emulator running Wear OS 4 (API 33) or Wear OS 3 (API 30), you can use synthetic data generated by the emulator. Consult the following guide to learn more about differences between synthetic data generation for Wear OS 3 and Wear OS 4.
Use synthetic data on Wear OS 4
If you're testing on an emulator running Wear OS 4 (API 33), you can use synthetic data generated by the emulator to test your app. This introduces a number of improvements over how synthetic data is generated on Wear OS 3:
Synthetic data generation on Wear OS 4 is integrated with the Health Services API lifecycle. This means that there is no need for adb commands to start or stop the exercise. Instead, you can start or stop the exercise in-app as a user would.
Use your in-app controls to start, pause, and end synthetic data generation.
Also note that the emulator generates the same data values for each exercise.
You can simulate various events in the emulator such as
The following command can be used to trigger those events:
adb shell am broadcast -a "whs.event-key" com.google.android.wearable.healthservices
Golf Shot Detected
For example, you can use the following command to trigger an auto pause event:
adb shell am broadcast -a "whs.AUTO_PAUSE_DETECTED" com.google.android.wearable.healthservices
You have the option of specifying a classified or unclassified golf shot event. Classified events take additional parameters for golf shot swing type, which are outlined below:
Golf Shot Swing Type
Swing Putt Type
Swing Partial Type
Swing Full Type
To trigger a classified golf shot event, add the golf shot event type after specifying the golf shot event:
adb shell am broadcast -a "whs.GOLF_SHOT" --es golf_shot_swing_type \ "golf-swing-type-parameter" com.google.android.wearable.healthservices
For example, the following command triggers a partial golf shot:
adb shell am broadcast -a "whs.GOLF_SHOT" --es golf_shot_swing_type "partial" \ com.google.android.wearable.healthservices
Use synthetic data on Wear OS 3
If you're testing on an emulator running Wear OS 3, you can also use synthetic data to test your app.
Enable synthetic data generation
Complete the following steps to enable synthetic data generation on Wear OS 3.
- Enable developer options.
Issue the following
adbcommand to enable synthetic mode:
adb shell am broadcast \ -a "whs.USE_SYNTHETIC_PROVIDERS" \ com.google.android.wearable.healthservices
Once synthetic data generation is enabled, issue commands described on this page to control the behavior of the "synthetic user."
Disable synthetic data generation
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 a 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 or 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 activity 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 on 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 using the action string
Provide 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 steps per minute, or cadence. 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
You can also change the data types that are available, whether or not the real or emulated hardware supports a particular data type. 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
You can also trigger sleep states for the synthetic user. Two states are supported: asleep and awake.
To enter the asleep state, run this command:
adb shell am broadcast \ -a "whs.synthetic.user.START_SLEEPING" \ com.google.android.wearable.healthservices
To enter the awake state, run this command:
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 can take up to a minute for health services to deliver the fall event.