'How can we use a sensor replay file in Android Emulator

Android Auto Emulators Volvo/Polestar published has a feature called Sensor Replay. However, there is no documentation or sample file on the internet about it or its format. Here is how it looks on the emulator controls:

Android Auto Emulator Controls

How can we use this feature, or find its format so we can generate our own file at least?



Solution 1:[1]

By checking the emulator source, we can see that the file is in proto-binary form. The message definition for the file is here:

https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/android-emu/android/emulation/proto/sensor_session.proto

Here is the human-readable example that exists in the source referenced below:

// Human readable example:
//
// session_metadata {
//   unix_timestamp_ms: 1599769231274
//   version {
//     major: 0
//     minor: 1
//     patch: 0
//   }
//   name: "Thu Sep 10 20:20:31 GMT 2020"
//   sensors: SENSOR_TYPE_PLATFORM_LOCATION
//   sensors: SENSOR_TYPE_CAR_PROPERTY
//   sensors: SENSOR_TYPE_SENSOR_EVENT
//   sensors: SENSOR_TYPE_FUSED_LOCATION
//   car_property_configs {
//     key: 356516106
//     value {
//       access: 1
//       area_type: 3
//       change_mode: 0
//       max_sample_rate: 0
//       min_sample_rate: 0
//       supported_areas {
//         area_id: 0
//         area_config {
//           min_int32_value: 0
//           max_int32_value: 0
//         }
//       }
//       type: "java.lang.Integer"
//     }
//   }
//   subscribed_sensors {
//     key: "android.sensor.accelerometer_Invensense Accelerometer"
//     value {
//       name: "Invensense Accelerometer"
//       vendor: "Invensense"
//       version: 1
//       type: 1
//       max_range: 39.2266
//       resolution: 0.0011971008
//       power_ma: 0.5
//       min_delay_us: 2000
//       fifo_reserved_event_count: 0
//       fifo_max_event_count: 0
//       string_type: "android.sensor.accelerometer"
//       max_delay_us: 250000
//       id: 0
//       reporting_mode: 0
//       highest_direct_report_rate_level: 0
//       direct_channel_memory_file_supported: false
//       direct_channel_hardware_buffer_supported: false
//       wake_up_sensor: false
//       dynamic_sensor: false
//       additional_info_supported: false
//     }
//   }
// sensor_records {
//   timestamp_ns: 101682689
//   sensor_events {
//     key: "android.sensor.gyroscope_uncalibrated_Invensense Gyroscope"
//     value {
//       values: 0.010652378
//       values: -0.025566613
//       values: -0.005326588
//       values: 0.011530399
//       values: -0.025104554
//       values: -0.005609416
//       accuracy: 3
//     }
//   }
// }

https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/android-emu/android/sensor_replay/sensor_session_playback.h

It also mentions that the file is generated by a sensor recording apk which currently I have failed to find.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 guness