android / health-samples

Apache License 2.0
244 stars 138 forks source link

Using Synthetic Data on Wear OS 4 #183

Open cancan101 opened 8 months ago

cancan101 commented 8 months ago

The docs on the repo for using synthetic data state to use adb; however, the docs for Wear OS 4 say that is no longer needed and that the emulator now natively supports these events.

How do I control the emulator to walk vs run, etc? I tried this slider in the emulator extended controls, but it seems to have no effect: image

Does this repo work with Wear OS 4 and if so what are the steps for synthetic data on that OS?

breanatate commented 8 months ago

We need to update the instructions in the sample--thanks for pointing that out! The docs from your second link are the best resource for synthetic data generation with Wear 4.

If you are using the latest version of the Wear 4 emulator in Android Studio Hedgehog, Health Services will automatically generate data appropriate for the exercise specified your exercise config.

If you aren't using the latest version of the emulator, you can still use the emulator extended controls for Heart Rate, but the emulator has to be running in a separate window.

cancan101 commented 8 months ago

Android Studio Hedgehog

It doesn't look like Hedgehog is released yet. I am on Giraffe. Will this work with Giraffe?

the exercise specified your exercise config

What is an exercise config?

running in a separate window

What do you mean here? Is this as simple as "popping" out the window within Android studio?

breanatate commented 8 months ago
  1. You can download Hedgehog here. If you can't download Hedgehog, you can still generate data in Giraffe, it just takes a few extra steps: Enable developer options, then run this command: adb shell am broadcast \ -a "whs.USE_SYNTHETIC_HAL" \ com.google.android.wearable.healthservices

This will kick start the behavior on Wear 4 emulators outside of Hedgehog.

  1. The exercise config is where you can specify the exercise type. The synthetic data generation will change based on the type of exercise and other behavior you've specified there.

  2. Yep, you can specify this behavior from Settings > Emulator > deselect Launch in Running Devices Tool Window

cancan101 commented 8 months ago

Health Services will automatically generate data appropriate for the exercise specified your exercise config. The exercise config is where you can specify the exercise type. The synthetic data generation will change based on the type of exercise and other behavior you've specified there.

Okay, but what about in the case that I am testing out either spot measurements or passive (background monitoring)? In those cases how do I specify the synthetic data to generate?

And in the case of a "run" exercise, Is there some equivalent to saying I want "running" vs "walking" speed (ie what existed in Wear OS 3)? i.e. from external to the code it self, to control the synthetic data being piped in

adb shell am broadcast \ -a "whs.USE_SYNTHETIC_HAL" \ com.google.android.wearable.healthservices

After running that code, do I then use the same adb broadcast as I would in the Wear OS 3 instructions?

breanatate commented 8 months ago

You can simulate passive events (such as sleeping, fall detection), but can't simulate passive data generation.

The team is working on implementing support for custom values in Wear 4, but it isn't supported yet.

After running that code, do I then use the same adb broadcast as I would in the Wear OS 3 instructions?

If developer options are enabled, data should be automatically generated, without the need to run any additional commands.

cancan101 commented 8 months ago

So I am trying to run the MeasureDataCompose app with synthetic data. I have upgraded to hedgehog, upgraded the emulator to the newest version and set this in the extended controls: image However I am not seeing that value reported by the app.

I also ran adb shell am broadcast \ -a "whs.USE_SYNTHETIC_HAL" \ com.google.android.wearable.healthservices

Do I also need to pop-out the emulator and / or turn on developer settings (on the watch?)?

breanatate commented 8 months ago

The extended emulator controls are separate from synthetic data generated by Health Services. I can check with the emulator team regarding the expected behavior in Hedgehog + Wear 4 (just tested with the Wear 3 emulator, and the app is responding to the extended controls). Can you confirm if you're seeing any values at all (perhaps the ones automatically generated by Health Services?).

If you're on hedgehog and have downloaded the SDK updates, you don't need to run the command, it's only for pre-Hedgehog Android Studio.

cancan101 commented 8 months ago

In the MeasureDataCompose app, I am seeing BPM values that seem to step linearly from 60 to 150 (all marked with low accuracy).