android-emulator-webrtc 1.0.18 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +93 -204
  2. package/dist/components/emulator/emulator.d.ts +64 -0
  3. package/dist/components/emulator/emulator.js +161 -173
  4. package/dist/components/emulator/net/emulator_status.d.ts +45 -0
  5. package/dist/components/emulator/net/emulator_status.js +35 -42
  6. package/dist/components/emulator/net/logcat.js +37 -54
  7. package/dist/components/emulator/net/logger.d.ts +7 -0
  8. package/dist/components/emulator/net/logger.js +20 -0
  9. package/dist/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
  10. package/dist/components/emulator/net/ws_jsep_protocol_driver.js +640 -0
  11. package/dist/components/emulator/views/event_handler.d.ts +37 -0
  12. package/dist/components/emulator/views/event_handler.js +274 -260
  13. package/dist/components/emulator/views/webrtc_view.d.ts +27 -0
  14. package/dist/components/emulator/views/webrtc_view.js +42 -20
  15. package/dist/index.d.ts +8 -0
  16. package/dist/index.js +0 -7
  17. package/dist/proto/emulator_controller_pb.d.ts +1 -0
  18. package/dist/proto/emulator_controller_pb.js +146 -287
  19. package/dist/src/components/emulator/emulator.d.ts +64 -0
  20. package/dist/src/components/emulator/net/emulator_status.d.ts +45 -0
  21. package/dist/src/components/emulator/net/logger.d.ts +7 -0
  22. package/dist/src/components/emulator/net/ws_jsep_protocol_driver.d.ts +213 -0
  23. package/dist/src/components/emulator/views/event_handler.d.ts +37 -0
  24. package/dist/src/components/emulator/views/webrtc_view.d.ts +27 -0
  25. package/dist/src/index.d.ts +8 -0
  26. package/dist/src/proto/emulator_controller_pb.d.ts +1 -0
  27. package/package.json +17 -17
  28. package/proto/emulator_controller.proto +746 -181
  29. package/.vscode/launch.json +0 -21
  30. package/.vscode/settings.json +0 -3
  31. package/CONTRIBUTING.md +0 -28
  32. package/Makefile +0 -123
  33. package/android-emulator-webrtc.code-workspace +0 -7
  34. package/api_descriptor.pb +0 -0
  35. package/babel.config.js +0 -16
  36. package/cloudbuild.yaml +0 -41
  37. package/cloudbuilders/.gcloudignore +0 -1
  38. package/cloudbuilders/Dockerfile +0 -20
  39. package/cloudbuilders/README.md +0 -29
  40. package/cloudbuilders/cloudbuild.yaml +0 -19
  41. package/dist/components/emulator/net/jsep_protocol_driver.js +0 -365
  42. package/dist/components/emulator/views/simple_png_view.js +0 -110
  43. package/dist/proto/emulator_controller_grpc_web_pb.js +0 -1601
  44. package/dist/proto/emulator_web_client.js +0 -176
  45. package/dist/proto/rtc_service_grpc_web_pb.js +0 -231
  46. package/dist/proto/rtc_service_pb.js +0 -338
  47. package/emulator/index.js +0 -1
  48. package/eslint_prefix.py +0 -37
  49. package/gen_md_doc.js +0 -40
  50. package/npmrc.enc +0 -0
  51. package/proto/rtc_service.proto +0 -117
  52. package/protoc-plugin/Makefile +0 -31
  53. package/protoc-plugin/grpc_generator.cc +0 -1755
  54. package/src/components/emulator/emulator.js +0 -217
  55. package/src/components/emulator/net/emulator_status.js +0 -94
  56. package/src/components/emulator/net/jsep_protocol_driver.js +0 -364
  57. package/src/components/emulator/net/logcat.js +0 -155
  58. package/src/components/emulator/views/event_handler.js +0 -268
  59. package/src/components/emulator/views/simple_png_view.js +0 -105
  60. package/src/components/emulator/views/webrtc_view.js +0 -142
  61. package/src/index.js +0 -20
  62. package/src/proto/emulator_web_client.js +0 -140
  63. package/test/cloudbuild.yaml +0 -41
  64. package/test/emulator.test.js +0 -125
  65. package/test/event_handler.test.js +0 -91
  66. package/test/fake_events.js +0 -50
  67. package/test/jsep_protocol_driver.test.js +0 -228
  68. package/test/simple_png_view.test.js +0 -145
  69. package/test/touch_event_handler.test.js +0 -118
@@ -45,255 +45,606 @@ import "google/protobuf/empty.proto";
45
45
  // android usually responds to these events.
46
46
  service EmulatorController {
47
47
  // set/get/stream the sensor data
48
+ // This RPC is not implemented in EmulatorController and will return an unimplemented error.
48
49
  rpc streamSensor(SensorValue) returns (stream SensorValue) {}
50
+ // Gets the current value of a specified sensor.
51
+ //
52
+ // The following gRPC error codes can be returned:
53
+ // - INTERNAL (code 13) if `getSensorSize` fails to retrieve sensor dimensions.
54
+ //
55
+ // The `status` field in the `SensorValue` reply indicates the operational state:
56
+ // - `OK` (0): Sensor data retrieved successfully.
57
+ // - `UNKNOWN` (2): Unknown sensor type (should not happen if using valid `SensorType`).
58
+ // - `DISABLED` (3): The sensor is disabled.
59
+ // - `NO_SERVICE` (4): The `qemud` service responsible for sensors is not available or initiated.
49
60
  rpc getSensor(SensorValue) returns (SensorValue) {}
61
+ // Sets the override value for a specified sensor. This operation is asynchronous
62
+ // and executed on the emulator's main looper. An immediate subsequent `getSensor`
63
+ // call might not reflect the newly set value.
64
+ //
65
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
66
+ // No specific gRPC error codes are returned by this method itself, but underlying
67
+ // operations might log warnings if the sensor agent is unavailable.
50
68
  rpc setSensor(SensorValue) returns (google.protobuf.Empty) {}
51
69
 
52
70
  // set/get/stream the physical model, this is likely the one you are
53
71
  // looking for when you wish to modify the device state.
72
+ //
73
+ // This operation is asynchronous and executed on the emulator's main looper. An immediate subsequent `getPhysicalModel`
74
+ // call might not reflect the newly set value. The `interpolation` field from the request is used to determine the
75
+ // physical interpolation method, mapped using `abs((static_cast<int>(physicalValue.interpolation())) - 1)`.
76
+ //
77
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
54
78
  rpc setPhysicalModel(PhysicalModelValue) returns (google.protobuf.Empty) {}
79
+ // Gets the current value of a specified physical model parameter.
80
+ //
81
+ // The `status` field in the `PhysicalModelValue` reply indicates the operational state:
82
+ // - `OK` (0): Physical model data retrieved successfully.
83
+ // - `UNKNOWN` (2): Unknown physical type (should not happen if using valid `PhysicalType`).
84
+ // - `NO_SERVICE` (3): The `qemud` service responsible for physical parameters is not available or initiated.
55
85
  rpc getPhysicalModel(PhysicalModelValue) returns (PhysicalModelValue) {}
86
+ // This RPC is not implemented in EmulatorController and will return an unimplemented error.
56
87
  rpc streamPhysicalModel(PhysicalModelValue)
57
88
  returns (stream PhysicalModelValue) {}
58
89
 
59
- // Atomically set/get the current primary clipboard data.
90
+ // Atomically sets the current primary clipboard data. This operation is asynchronous
91
+ // and executed on the emulator's main looper. It triggers a `ClipboardEvent`
92
+ // to all listeners (except the originating channel) indicating the new content.
93
+ //
94
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
60
95
  rpc setClipboard(ClipData) returns (google.protobuf.Empty) {}
96
+ // Retrieves the current primary clipboard data. This is a synchronous operation.
97
+ //
98
+ // This method returns `OK` (code 0) and the current `ClipData` upon success.
61
99
  rpc getClipboard(google.protobuf.Empty) returns (ClipData) {}
62
100
 
63
- // Streams the current data on the clipboard. This will immediately produce
64
- // a result with the current state of the clipboard after which the stream
65
- // will block and wait until a new clip event is available from the guest.
66
- // Calling the setClipboard method above will not result in generating a
67
- // clip event. It is possible to lose clipboard events if the clipboard
68
- // updates very rapidly.
101
+ // Streams real-time updates of the clipboard content. Upon subscription,
102
+ // it immediately sends the current clipboard state. Subsequent updates are
103
+ // streamed as new content becomes available from the guest or is set via `setClipboard`
104
+ // from a different client. Events originating from the same client that initiated
105
+ // the stream are filtered out to prevent echoing.
106
+ //
107
+ // It is possible to miss very rapid clipboard updates. The stream will block
108
+ // awaiting new events after the initial state is sent.
109
+ //
110
+ // This method returns a server-side streaming reactor.
69
111
  rpc streamClipboard(google.protobuf.Empty) returns (stream ClipData) {}
70
112
 
71
- // Set/get the battery to the given state.
113
+ // Sets the emulator's battery state to the provided values. This operation is
114
+ // executed asynchronously on the main looper.
115
+ //
116
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling
117
+ // of the operation. No explicit gRPC error codes are returned by this method.
72
118
  rpc setBattery(BatteryState) returns (google.protobuf.Empty) {}
119
+ // Retrieves the current battery state from the emulator. This is a
120
+ // synchronous operation that waits for completion.
121
+ //
122
+ // This method returns `OK` (code 0) and populates the `BatteryState` reply
123
+ // with the current information upon success. No explicit gRPC error codes
124
+ // are returned by this method.
73
125
  rpc getBattery(google.protobuf.Empty) returns (BatteryState) {}
74
126
 
75
- // Set the state of the gps.
76
- // Note: Setting the gps position will not be reflected in the user
77
- // interface. Keep in mind that android usually only samples the gps at 1
78
- // hz.
127
+ // Sets the state of the GPS in the emulator. This operation is asynchronous
128
+ // and executed on the main looper. It updates the emulator's GPS location
129
+ // (latitude, longitude, altitude, speed, bearing, and satellites) and sets
130
+ // the timestamp.
131
+ //
132
+ // Note: Setting the GPS position will not be immediately reflected in the user
133
+ // interface. Android typically samples GPS at 1 Hz.
134
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling
135
+ // of the operation.
79
136
  rpc setGps(GpsState) returns (google.protobuf.Empty) {}
80
137
 
81
- // Gets the latest gps state as delivered by the setGps call, or location ui
82
- // if active.
138
+ // Gets the latest GPS state as reported by the emulator. This includes data
139
+ // delivered by previous `setGps` calls or from the location UI if active.
140
+ // This is a synchronous operation that waits for completion.
83
141
  //
84
- // Note: this is not necessarily the actual gps coordinate visible at the
85
- // time, due to gps sample frequency (usually 1hz).
142
+ // Note: The returned GPS state is not necessarily the exact coordinate
143
+ // visible at the time due to Android's typical 1 Hz GPS sample frequency.
144
+ //
145
+ // This method returns `OK` (code 0) and populates the `GpsState` reply
146
+ // with the retrieved information upon success. No explicit gRPC error codes
147
+ // are returned by this method.
86
148
  rpc getGps(google.protobuf.Empty) returns (GpsState) {}
87
149
 
88
- // Simulate a touch event on the finger print sensor.
150
+ // Simulates a touch event on the fingerprint sensor. This operation is
151
+ // executed asynchronously on the main looper.
152
+ //
153
+ // The `isTouching` field indicates whether the fingerprint sensor is being
154
+ // touched, and `touchId` specifies the identifier of the registered
155
+ // fingerprint. The `setTouch` agent function is used to apply these values.
156
+ //
157
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling
158
+ // of the operation. No explicit gRPC error codes are returned by this method.
89
159
  rpc sendFingerprint(Fingerprint) returns (google.protobuf.Empty) {}
90
160
 
91
- // Send a keyboard event. Translating the event.
161
+ // Sends a keyboard event to the emulator. This operation is asynchronous
162
+ // and executed on the main looper.
163
+ //
164
+ // The `KeyboardEvent` message allows specifying input using `keyCode`, `key` (W3C standard string), or `text` (UTF-8 string).
165
+ // The `KeyEventSender` prioritizes `key`, then `keyCode`, then `text`.
166
+ // - If `key` is a non-printable W3C key string (e.g., "Backspace", "ArrowUp"), it's translated to an evdev keycode and sent.
167
+ // - If `key` is a printable Unicode character, it's converted to a sequence of evdev keydown/keyup events, handling modifiers.
168
+ // - If `keyCode` is provided, it's translated from its `codeType` (Usb, Evdev, XKB, Win, Mac) to an evdev keycode and sent as keydown/keyup pairs.
169
+ // - If `text` is provided, each UTF-8 character is converted to evdev keypress (keydown then keyup) events.
170
+ //
171
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
92
172
  rpc sendKey(KeyboardEvent) returns (google.protobuf.Empty) {}
93
-
94
- // Send touch/mouse events. Note that mouse events can be simulated
95
- // by touch events.
173
+ // Sends touch events to the emulator. This operation is asynchronous and executed on the main looper.
174
+ //
175
+ // The `TouchEvent` contains a list of `Touch` objects, each with `x`, `y` coordinates, `identifier`, `pressure`, `touch_major`, `touch_minor`, `expiration`, and `orientation`.
176
+ // Coordinates are scaled to the emulator's display resolution. Each `Touch` `identifier` is mapped to an internal Linux multitouch slot.
177
+ // Expiration handling ensures that inactive touch events are properly "lifted" after 120 seconds.
178
+ //
179
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation. Warnings are logged if no touch slots are available.
96
180
  rpc sendTouch(TouchEvent) returns (google.protobuf.Empty) {}
181
+ // Sends mouse events to the emulator. This operation is asynchronous and executed on the main looper.
182
+ //
183
+ // The `MouseEvent` specifies `x`, `y` coordinates, `buttons` state (bitmask: 1 for left, 2 for right), and `display` ID.
184
+ // In certain virtual input configurations (VirtioInput enabled, but VirtioMouse and VirtioTablet disabled), `buttons` may be masked to only consider the primary button.
185
+ // The event is sent to the emulator's `user_event_agent`.
186
+ //
187
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
97
188
  rpc sendMouse(MouseEvent) returns (google.protobuf.Empty) {}
189
+ // Injects a stream of wheel events into the emulator. This is a server-side streaming RPC.
190
+ //
191
+ // Each `WheelEvent` contains `dx`, `dy` (delta values, `dy` is pre-multiplied by 120 for scroll clicks), and `display` ID.
192
+ // If the emulator's input device has rotary capabilities (e.g., AVD_WEAR flavor), `dy` is scaled and sent as a rotary event.
193
+ // Otherwise, it's sent as a standard mouse wheel event.
194
+ //
195
+ // This method returns a server-side streaming reactor.
98
196
  rpc injectWheel(stream WheelEvent) returns (google.protobuf.Empty) {}
99
197
 
100
- // Make a phone call.
198
+ // Streams a series of generic input events to the emulator. The events are processed in the order they arrive.
199
+ // This is a server-side streaming RPC that supports various input types encapsulated within `InputEvent`'s `oneof type` field.
200
+ //
201
+ // Supported input types:
202
+ // - `key_event` (KeyboardEvent): Processed by `KeyEventSender` as described in `sendKey`.
203
+ // - `touch_event` (TouchEvent): Processed by `TouchEventSender` as described in `sendTouch`.
204
+ // - `mouse_event` (MouseEvent): Processed by `MouseEventSender` as described in `sendMouse`.
205
+ // - `android_event` (AndroidEvent): Raw Linux input events (`type`, `code`, `value`) sent directly to the kernel.
206
+ // - `pen_event` (PenEvent): Processed by `PenEventSender` for pen input, including pressure, orientation, and button state.
207
+ // - `wheel_event` (WheelEvent): Processed by `WheelEventSender` as described in `injectWheel`.
208
+ // - `xr_command` (XrCommand): Executes XR-specific commands (e.g., `RECENTER` to recenter the viewport). Unknown actions are logged as warnings.
209
+ // - `xr_head_rotation_event` (RotationRadian): Sends head rotation data in radians. Logs an error if the agent call fails.
210
+ // - `xr_head_movement_event` (Translation): Sends head movement data in meters. Logs an error if the agent call fails.
211
+ // - `xr_head_angular_velocity_event` (AngularVelocity): Sends head angular velocity data in radians per second. Logs an error if the agent call fails.
212
+ // - `xr_head_velocity_event` (Velocity): Sends head velocity data in meters per second. Logs an error if the agent call fails.
213
+ // - `touchpad_event` (TouchpadEvent): Processed by `TouchpadEventSender` for touchpad input, similar to touch events but for a touchpad device.
214
+ //
215
+ // All underlying input sending operations for XR events are executed asynchronously on the main looper.
216
+ //
217
+ // Returns `INVALID_ARGUMENT` (code 3) if an unrecognized input event type is received, indicating a potential out-of-date emulator.
218
+ // The stream reactor automatically deletes itself upon completion.
219
+ rpc streamInputEvent(stream InputEvent) returns (google.protobuf.Empty) {}
220
+
221
+ // Initiates or manipulates a phone call in the emulator. This is a synchronous
222
+ // operation executed on the main looper.
223
+ //
224
+ // The `PhoneCall` message specifies the `operation` (e.g., InitCall, AcceptCall)
225
+ // and the target phone `number`. The `telephonyCmd` agent function handles the
226
+ // actual call action.
227
+ //
228
+ // Returns a `PhoneResponse` indicating the outcome:
229
+ // - `OK` (0): The operation was successful.
230
+ // - `BadOperation` (1): The provided `operation` enum is out of range.
231
+ // - `BadNumber` (2): The provided `number` is malformed.
232
+ // - `InvalidAction` (3): The requested `operation` is invalid given the current call state (e.g., disconnecting when no call is active).
233
+ // - `ActionFailed` (4): An internal error occurred, typically if the modem agent is unavailable.
234
+ // - `RadioOff` (5): The emulator's radio is turned off.
101
235
  rpc sendPhone(PhoneCall) returns (PhoneResponse) {}
102
236
 
103
- // Sends an sms message to the emulator.
237
+ // Sends an SMS message to the emulator. This is a synchronous operation.
238
+ //
239
+ // The `SmsMessage` contains the `srcAddress` (source phone number) and the `text` of the message.
240
+ // The `srcAddress` is validated for GSM formatting. The message `text` is converted into SMS PDUs
241
+ // (Protocol Data Units) and delivered via the modem agent.
242
+ //
243
+ // Returns a `PhoneResponse` indicating the outcome:
244
+ // - `OK` (0): The SMS message was successfully delivered.
245
+ // - `BadNumber` (2): The `srcAddress` is malformed.
246
+ // - `ActionFailed` (4): An internal error occurred, e.g., if the modem agent is unavailable or PDU creation fails.
247
+ //
248
+ // Other error cases from PDU creation (e.g., invalid characters in text) also result in `ActionFailed`.
104
249
  rpc sendSms(SmsMessage) returns (PhoneResponse) {}
105
250
 
106
- // Sends an sms message to the emulator.
251
+ // Sets the emulator's phone number. This is a synchronous operation.
252
+ //
253
+ // The `PhoneNumber` message contains the new `number` to be set. The modem agent's
254
+ // `amodem_update_phone_number` function is used for this update.
255
+ //
256
+ // Returns a `PhoneResponse` indicating the outcome:
257
+ // - `OK` (0): The phone number was successfully updated.
258
+ // - `BadNumber` (2): The provided `number` is invalid for the modem.
259
+ // - `ActionFailed` (4): An internal error occurred, typically if the modem agent is unavailable.
107
260
  rpc setPhoneNumber(PhoneNumber) returns (PhoneResponse) {}
108
261
 
109
- // Retrieve the status of the emulator. This will contain general
110
- // hardware information, and whether the device has booted or not.
262
+ // Retrieves the current status of the emulator. This includes comprehensive
263
+ // information about the virtual machine's configuration and the guest operating system's state.
264
+ //
265
+ // The `EmulatorStatus` reply contains:
266
+ // - `version`: The emulator version string.
267
+ // - `uptime`: The time the emulator has been active in milliseconds.
268
+ // - `booted`: A boolean indicating if the device has completed booting.
269
+ // - `vmConfig`: Detailed `VmConfiguration` (hypervisor type, CPU cores, RAM size).
270
+ // - `hardwareConfig`: Key-value pairs describing the emulator's hardware configuration.
271
+ // - `heartbeat`: A monotonically increasing number indicating guest activity (incremented approximately once per second).
272
+ // - `guestConfig`: A map of key-value pairs with guest-specific configurations, including:
273
+ // - "multidisplay": "available" or "unavailable" based on display pipe readiness.
274
+ // - "androidVersion": The Android version of the guest OS.
275
+ // - "hypervisorVersion": The hypervisor version used by the guest.
276
+ //
277
+ // This method returns `OK` (code 0) upon successful retrieval of the emulator status.
111
278
  rpc getStatus(google.protobuf.Empty) returns (EmulatorStatus) {}
112
279
 
113
- // Gets an individual screenshot in the desired format.
280
+ // Retrieves a single screenshot in the desired format.
281
+ //
282
+ // The image will be scaled to the `desiredWidth` and `desiredHeight` specified in `ImageFormat`, while maintaining
283
+ // the aspect ratio. If `width` or `height` are 0, the device's current display dimensions are used.
284
+ // The returned image will never exceed the device's actual display resolution, but can be smaller.
114
285
  //
115
- // The image will be scaled to the desired ImageFormat, while maintaining
116
- // the aspect ratio. The returned image will never exceed resolution of the
117
- // device display. Not setting the width or height (i.e. they are 0) will
118
- // result in using the display width and height.
286
+ // The `display` field in `ImageFormat` specifies the target display; 0 (or omitted) indicates the main display.
287
+ // For folded Pixel Fold devices, the display ID might be internally remapped, and `foldedDisplay` information will be populated.
288
+ // The resulting image is properly oriented based on the device's coarse-grained orientation, derived from sensor state.
119
289
  //
120
- // The resulting image will be properly oriented and can be displayed
121
- // directly without post processing. For example, if the device has a
122
- // 1080x1920 screen and is in landscape mode and called with no width or
123
- // height parameter, it will return a 1920x1080 image.
290
+ // The `transport` field in `ImageFormat` can specify `MMAP` for shared memory delivery, but if the shared memory region
291
+ // is too small, a `FAILED_PRECONDITION` error will be returned.
124
292
  //
125
- // The dimensions of the returned image will never exceed the corresponding
126
- // display dimensions. For example, this method will return a 1920x1080
127
- // screenshot, if the display resolution is 1080x1920 and a screenshot of
128
- // 2048x2048 is requested when the device is in landscape mode.
293
+ // This method returns:
294
+ // - `OK` (code 0) and an `Image` object upon success.
295
+ // - `INVALID_ARGUMENT` (code 3) if the specified `display` ID is invalid or disabled.
296
+ // - `CANCELLED` (code 1) if the gRPC context is cancelled during the operation (an expensive operation).
297
+ // - `FAILED_PRECONDITION` (code 9) if the guest has not posted a new frame yet (for non-PNG formats when fast path is used).
129
298
  //
130
- // This method will return an empty image if the display is not visible.
299
+ // This method will return an image with width 0 and height 0 if the display is not visible.
131
300
  rpc getScreenshot(ImageFormat) returns (Image) {}
132
301
 
133
- // Streams a series of screenshots in the desired format.
302
+ // Streams a series of screenshots in the desired format. This is a server-side streaming RPC.
303
+ //
304
+ // A new frame is delivered whenever the device produces a new frame or when sensor changes occur.
305
+ // Initial state: The first frame delivered might be an empty image (width 0, height 0) if the display is inactive.
306
+ // Subsequent frames are delivered when new content is available or a sensor event triggers an update.
307
+ // If the display becomes inactive, an empty image will be delivered again. Images resume when the display becomes active.
134
308
  //
135
- // A new frame will be delivered whenever the device produces a new frame.
136
- // Beware that this can produce a significant amount of data and that
137
- // certain translations can be very costly. For example, streaming a series
138
- // of png images is very cpu intensive.
309
+ // `ImageFormat` parameters (format, width, height, display) behave as described in `getScreenshot`.
310
+ // The `transport` field in `ImageFormat` can specify `MMAP` for shared memory delivery. If `MMAP` is used and the
311
+ // provided shared memory handle is valid and mapped, pixel data will be written directly to it.
312
+ // The `image` field in the `Image` reply will be empty if `MMAP` transport is used.
139
313
  //
140
- // Images are produced according to the getScreenshot API described above.
314
+ // Performance considerations:
315
+ // - Streaming can produce a significant amount of data.
316
+ // - `PNG` format is CPU-intensive due to encoding overhead.
317
+ // - Using `MMAP` transport can significantly reduce gRPC overhead for pixel data.
141
318
  //
142
- // If the display is inactive, or becomes inactive, an empty image will be
143
- // delivered. Images will be delived again if the display becomes active and
144
- // new frames are produced.
319
+ // This method returns:
320
+ // - A server-side streaming reactor.
321
+ // - `INVALID_ARGUMENT` (code 3) if the specified `display` ID is invalid or disabled.
322
+ // - `CANCELLED` (code 1) if the gRPC context is cancelled during the operation.
145
323
  rpc streamScreenshot(ImageFormat) returns (stream Image) {}
146
324
 
147
- // Streams a series of audio packets in the desired format.
148
- // A new frame will be delivered whenever the emulated device
149
- // produces a new audio frame. You can expect packets to be
150
- // delivered in intervals of 20-30ms.
325
+ // Streams a series of audio packets in the desired format. This is a server-side streaming RPC.
326
+ // A new frame is delivered approximately every 20-30ms when the emulated device produces audio.
327
+ // If `samplingRate` is 0, it defaults to 44100 Hz.
328
+ // The stream may block indefinitely if the emulator ceases to produce audio.
329
+ // Packets are allocated with a buffer size calculated based on the audio format and a 30ms frame time.
151
330
  //
152
- // Be aware that this can block when the emulator does not
153
- // produce any audio whatsoever!
331
+ // This method returns `OK` (code 0) upon successful streaming initiation.
154
332
  rpc streamAudio(AudioFormat) returns (stream AudioPacket) {}
155
333
 
156
- // Injects a series of audio packets to the android microphone.
157
- // A new frame will be delivered whenever the emulated device
158
- // requests a new audio frame. Audio is usually delivered at a rate
159
- // that the emulator is requesting frames. Audio will be stored in a
160
- // temporary buffer that can hold 300ms of audio.
334
+ // Injects a series of audio packets into the Android microphone. This is a client-side streaming RPC.
335
+ // Audio packets are processed at a rate determined by the emulator's request for frames.
336
+ // An internal buffer can hold approximately 300ms of audio.
161
337
  //
162
338
  // Notes:
163
- // - Only the first audio format packet that is delivered will be
164
- // honored. There is no need to send the audio format multiple times.
165
- // - Real time audio currently immediately overrides the buffer. This
166
- // means you must provide a constant rate of audio packets. The real
167
- // time mode is experimental. Timestamps of audio packets might be
168
- // used in the future to improve synchronization.
169
- //
170
- // - INVALID_ARGUMENT (code 3) The sampling rate was too high/low
171
- // - INVALID_ARGUMENT (code 3) The audio packet was too large to handle.
172
- // - FAILED_PRECONDITION (code 9) If there was a microphone registered
173
- // already.
339
+ // - Only the `AudioFormat` from the first received packet is honored. Subsequent `AudioFormat` changes are ignored.
340
+ // - `MODE_REAL_TIME` is experimental: incoming data may overwrite existing data if the client does not control timing properly.
341
+ // - The circular buffer attempts to deliver all queued samples upon stream closure by writing silence for up to 300ms.
342
+ //
343
+ // Returns the following gRPC error codes:
344
+ // - `FAILED_PRECONDITION` (code 9): If another microphone is already active, or if unable to register the microphone.
345
+ // - `INVALID_ARGUMENT` (code 3): If the desired `samplingRate` exceeds 48kHz, or if an `AudioPacket` is too large for the internal buffer.
346
+ //
347
+ // This method returns `OK` (code 0) upon successful completion of the stream.
174
348
  rpc injectAudio(stream AudioPacket) returns (google.protobuf.Empty) {}
175
349
 
176
- // Returns the last 128Kb of logcat output from the emulator
177
- // Note that parsed logcat messages are only available after L (Api >23).
178
- // it is possible that the logcat buffer gets overwritten, or falls behind.
179
- rpc getLogcat(LogMessage) returns (LogMessage) {}
350
+ // Retrieves the current settings for the microphone
351
+ rpc getMicrophoneState(google.protobuf.Empty) returns (MicrophoneState) {}
180
352
 
181
- // Streams the logcat output from the emulator. The first call
182
- // can retrieve up to 128Kb. This call will not return.
183
- // Note that parsed logcat messages are only available after L (Api >23)
184
- // it is possible that the logcat buffer gets overwritten, or falls behind.
353
+ // Sets the state for the microphone
354
+ rpc setMicrophoneState(MicrophoneState) returns (google.protobuf.Empty) {}
355
+
356
+ // Deprecated, please use the streamLogcat method instead.
357
+ rpc getLogcat(LogMessage) returns (LogMessage) {
358
+ option deprecated = true;
359
+ }
360
+
361
+ // Streams the logcat output from the emulator in real-time. This is a server-side streaming RPC.
362
+ // The stream sources its data from the `logcat` command executed via `AdbShellStream` in the Android guest.
363
+ // Log lines are processed individually as they arrive.
364
+ //
365
+ // The `LogMessage.sort` field determines the output format:
366
+ // - If `LogMessage.sort` is `Parsed`, each incoming log line is parsed into a structured `LogcatEntry` object,
367
+ // and these entries are returned in the `LogMessage.entries` field. Structured parsing is typically
368
+ // available for Android API Level 23 (Marshmallow) and later.
369
+ // - If `LogMessage.sort` is `Text` (or unspecified), the raw log line is returned in the `LogMessage.contents` field.
370
+ //
371
+ // The stream continues as long as the underlying `logcat` process is running and the client is connected.
372
+ // The stream will naturally terminate if the `logcat` process stops or the connection is lost.
373
+ // No explicit gRPC error codes are returned by this method during active streaming.
185
374
  rpc streamLogcat(LogMessage) returns (stream LogMessage) {}
186
375
 
187
- // Transition the virtual machine to the desired state. Note that
188
- // some states are only observable. For example you cannot transition
189
- // to the error state.
376
+ // Transitions the virtual machine to the desired state. This operation is scheduled
377
+ // asynchronously.
378
+ //
379
+ // Transition commands:
380
+ // - `RUNNING` or `START`: Starts or resumes execution of the virtual machine.
381
+ // - `PAUSED` or `STOP`: Pauses execution of the virtual machine, halting CPU cycles.
382
+ // - `RESET` or `RESTART`: Performs a warm reset of the virtual machine.
383
+ // - `SHUTDOWN`: Initiates a graceful shutdown of the emulator.
384
+ // - `TERMINATE`: Forcefully terminates the emulator process immediately without cleanup.
385
+ // This can cause data corruption and must be used with caution.
386
+ //
387
+ // Note that write-only actions (`START`, `STOP`, `RESET`, `RESTART`) perform the
388
+ // transition but are not observed as states in `getVmState`. Purely observable states
389
+ // (`UNKNOWN`, `RESTORE_VM`, `SAVE_VM`, `INTERNAL_ERROR`) cannot be set directly.
390
+ //
391
+ // Returns once the operation has been scheduled.
392
+ // Note: The call may not return when the state is set to `TERMINATE` or `SHUTDOWN`.
190
393
  rpc setVmState(VmRunState) returns (google.protobuf.Empty) {}
191
394
 
192
- // Gets the state of the virtual machine.
395
+ // Retrieves the current execution state of the virtual machine.
396
+ //
397
+ // The returned `VmRunState` represents the current condition of the VM:
398
+ // - `RUNNING`: The virtual machine is actively executing.
399
+ // - `PAUSED`: Execution is suspended (CPUs are halted).
400
+ // - `SHUTDOWN`: The guest operating system has initiated a shutdown.
401
+ // - `RESTORE_VM`: The virtual machine is paused while restoring its state (e.g., loading a snapshot).
402
+ // - `SAVE_VM`: The virtual machine is paused while saving its state (e.g., taking a snapshot).
403
+ // - `INTERNAL_ERROR`: Execution has stopped due to a guest panic, I/O error, or hypervisor failure.
404
+ // - `UNKNOWN`: The virtual machine is in an unmapped or transient state.
405
+ //
406
+ // This is a synchronous query operation.
193
407
  rpc getVmState(google.protobuf.Empty) returns (VmRunState) {}
194
408
 
195
- // Atomically changes the current multi-display configuration.
196
- // After this call the given display configurations will be activated. You
197
- // can only update secondary displays. Displays with id 0 will be ignored.
409
+ // Atomically changes the current multi-display configuration. This operation applies
410
+ // the provided `DisplayConfigurations`, with special handling for secondary displays.
411
+ // Display ID 0 (the primary display) cannot be modified via this RPC.
198
412
  //
199
- // This call can result in the removal or addition of secondary displays,
200
- // the final display state can be observed by the returned configuration.
413
+ // Preconditions:
414
+ // - The `android::featurecontrol::MultiDisplay` feature must be enabled.
201
415
  //
202
- // The following gRPC error codes can be returned:
203
- // - FAILED_PRECONDITION (code 9) if the AVD does not support a
204
- // configurable
205
- // secondary display.
206
- // - INVALID_ARGUMENT (code 3) if:
207
- // - The same display id is defined multiple times.
208
- // - The display configurations are outside valid ranges.
209
- // See DisplayConfiguration for details on valid ranges.
210
- // - INTERNAL (code 13) if there was an internal emulator failure.
416
+ // Input Validation:
417
+ // - `INVALID_ARGUMENT` (code 3): If duplicate `display` IDs are found in the request.
418
+ // - `INVALID_ARGUMENT` (code 3): If any `DisplayConfiguration` (width, height, dpi, flags)
419
+ // is outside valid ranges as determined by `multiDisplayParamValidate`.
420
+ // - `INVALID_ARGUMENT` (code 3): If any `display` ID is outside the configurable range
421
+ // `[1, userConfigurable]`.
422
+ //
423
+ // Atomic Update and Rollback:
424
+ // The system attempts to apply each display configuration. If any update fails
425
+ // (e.g., after multiple retries for transient pipe errors), a rollback mechanism
426
+ // is initiated: successfully updated displays are reverted to their previous state,
427
+ // and newly added displays are deleted. In such cases, an `INTERNAL` error is returned.
428
+ //
429
+ // Deletion of Unrequested Displays:
430
+ // Any displays that were active before this call but are not present in the new
431
+ // `request.displays` (and are not display ID 0) will be deleted.
432
+ //
433
+ // Notifications:
434
+ // Upon successful completion, `notifyDisplayChanges()` is called to inform
435
+ // third-party subscribers.
436
+ //
437
+ // Returns the following gRPC error codes:
438
+ // - `OK` (code 0): Upon successful application of all configurations, returning the final active `DisplayConfigurations`.
439
+ // - `FAILED_PRECONDITION` (code 9): If the multi-display feature is not available.
440
+ // - `INTERNAL` (code 13): If an internal emulator failure occurs during display modification or rollback.
211
441
  rpc setDisplayConfigurations(DisplayConfigurations)
212
442
  returns (DisplayConfigurations) {}
213
443
 
214
- // Returns all currently valid logical displays.
444
+ // Returns all currently valid logical displays configured in the emulator. This is a synchronous operation.
445
+ //
446
+ // Preconditions:
447
+ // - The `android::featurecontrol::MultiDisplay` feature must be enabled.
448
+ //
449
+ // The `DisplayConfigurations` reply contains:
450
+ // - `displays`: A repeated field of `DisplayConfiguration` objects, each detailing
451
+ // the width, height, DPI, flags, and ID of an active display.
452
+ // For Pixel Fold devices, only the main display configuration might be relevant.
453
+ // - `userConfigurable`: The maximum number of user-configurable displays (IDs from 1 up to this value).
454
+ // - `maxDisplays`: The total maximum number of displays the emulator supports.
215
455
  //
216
- // The gRPC error code FAILED_PRECONDITION (code 9) is returned if the AVD
217
- // does not support a configurable secondary display.
456
+ // This method returns:
457
+ // - `OK` (code 0) and the current `DisplayConfigurations` upon success.
458
+ // - `FAILED_PRECONDITION` (code 9): If the AVD does not support the multi-display feature.
218
459
  rpc getDisplayConfigurations(google.protobuf.Empty)
219
460
  returns (DisplayConfigurations) {}
220
461
 
221
- // Notifies client of the following changes:
462
+ // Notifies the client of various emulator state changes in real-time. This is a server-side streaming RPC.
463
+ // Upon subscription, the current states of virtual scene camera, foldable posture, boot completion,
464
+ // and XR options are immediately sent. The stream then continuously delivers new notifications
465
+ // when relevant events occur. `UniqueEventStreamWriter` ensures that only distinct state changes are streamed.
222
466
  //
223
- // - Virtual scene camera status change.
224
- // - Display configuration changes from extended ui. This will only be fired
225
- // if the user makes modifications the extended displays through the
226
- // extended control tab.
467
+ // Notifications include:
468
+ // - `CameraNotification`: Reports virtual scene camera activation/deactivation and associated display.
469
+ // - `DisplayConfigurationsChangedNotification`: Triggered when display configurations are modified via the extended UI. Does not fire for changes made through console or gRPC.
470
+ // - `Posture`: Reports changes in the device's foldable posture.
471
+ // - `BootCompletedNotification`: Indicates when the emulator has finished booting.
472
+ // - `BrightnessValue`: Reports changes in backlight brightness (LCD, keyboard, or button).
473
+ // - `TextViewFocus`: Sent when a text view gains or loses focus, or immediately on subscription.
474
+ // - `XrOptions`: Reports changes in XR-related settings (environment, passthrough coefficient), or immediately on subscription.
475
+ // - `MicrophoneState` : Reports changes in the microphone state (currently whether host microphone access is allowed)
476
+ // - `LedIndicator`: Reports changes in AI Glasses XR LED light state on subscription.
227
477
  //
228
- // Note that this method will send the initial virtual scene state
229
- // immediately.
478
+ // This method returns a server-side streaming reactor.
230
479
  rpc streamNotification(google.protobuf.Empty)
231
480
  returns (stream Notification) {}
232
481
 
233
- // RotationRadian is relative to the camera's current orientation.
482
+ // Rotates the virtual scene camera relative to its current orientation. This operation is asynchronous
483
+ // and executed on the main looper.
484
+ //
485
+ // The `RotationRadian` message specifies angles in radians around the x, y, and z axes. The z component of rotation is currently unused.
486
+ // The coordinate system is right-handed: x-axis points right, y-axis points up, and z-axis points towards the viewer.
487
+ // This operation only succeeds if the virtual scene camera is actively connected.
488
+ //
489
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
234
490
  rpc rotateVirtualSceneCamera(RotationRadian)
235
491
  returns (google.protobuf.Empty) {}
236
- // Velocity is absolute
492
+ // Sets the absolute velocity of the virtual scene camera. This operation is asynchronous
493
+ // and executed on the main looper.
494
+ //
495
+ // The `Velocity` message specifies components in meters per second along the x, y, and z axes.
496
+ // The coordinate system is right-handed: x-axis points right, y-axis points up, and z-axis points towards the viewer.
497
+ // The transition to these target velocity values may be smoothed over time by the implementation.
498
+ // This operation only succeeds if the virtual scene camera is actively connected.
499
+ //
500
+ // This method returns `OK` (code 0) upon successful asynchronous scheduling of the operation.
237
501
  rpc setVirtualSceneCameraVelocity(Velocity)
238
502
  returns (google.protobuf.Empty) {}
239
- // Set foldable posture
503
+ // Sets the foldable posture of the device. This operation is asynchronous
504
+ // and executed on the main looper.
505
+ //
506
+ // The `Posture` message contains a `PostureValue` enum, defining the desired
507
+ // physical configuration of the foldable device.
508
+ //
509
+ // Returns the following gRPC error codes:
510
+ // - `OK` (code 0): Upon successful asynchronous scheduling of the operation.
511
+ // - `FAILED_PRECONDITION` (code 9): If the emulator is unable to set the specified posture.
240
512
  rpc setPosture(Posture) returns (google.protobuf.Empty) {}
241
513
 
242
- // Get the backlight brightness.
243
- // The following gRPC error codes can be returned:
244
- // - FAILED_PRECONDITION (code 9) if the AVD does not support hw-control.
514
+ // Retrieves the current backlight brightness for a specified light type. This is a synchronous operation.
515
+ //
516
+ // The `BrightnessValue.target` field (e.g., `LCD`, `KEYBOARD`, `BUTTON`) determines which light's brightness is queried.
517
+ // Internal mapping converts these to string names like "lcd_backlight".
518
+ //
519
+ // Returns the following gRPC error codes:
520
+ // - `OK` (code 0): Upon successful retrieval, populating the `BrightnessValue` reply with the `target` and current `value`.
521
+ // - `FAILED_PRECONDITION` (code 9): If the AVD does not support the `hw-control` agent or its `getBrightness` function is unavailable.
245
522
  rpc getBrightness(BrightnessValue) returns (BrightnessValue) {}
246
523
 
247
- // Set the backlight brightness.
248
- // The following gRPC error codes can be returned:
249
- // - FAILED_PRECONDITION (code 9) if the AVD does not support hw-control.
250
- // - INVALID_ARGUMENT (code 3) The brightness exceeds the valid range.
524
+ // Sets the backlight brightness for a specified light type. This operation is asynchronous
525
+ // and executed on the main looper.
526
+ //
527
+ // The `BrightnessValue.target` field (e.g., `LCD`, `KEYBOARD`, `BUTTON`) determines which light's brightness is set.
528
+ // The `BrightnessValue.value` specifies the desired intensity, ranging from 0 to 255.
529
+ // Internal mapping converts `LightType` to string names like "lcd_backlight".
530
+ //
531
+ // Returns the following gRPC error codes:
532
+ // - `OK` (code 0): Upon successful asynchronous scheduling of the operation.
533
+ // - `FAILED_PRECONDITION` (code 9): If the AVD does not support the `hw-control` agent or its `setBrightness` function is unavailable.
534
+ // - `INVALID_ARGUMENT` (code 3): If the `brightness` value exceeds the valid range (0-255).
251
535
  rpc setBrightness(BrightnessValue) returns (google.protobuf.Empty) {}
252
536
 
253
- // Returns the current mode of the primary display of a resizable AVD.
254
- // The following gRPC error codes can be returned:
255
- // - FAILED_PRECONDITION (code 9) if the AVD is not resizable.
537
+ // Returns the current mode of the primary display of a resizable AVD. This is a synchronous operation.
538
+ //
539
+ // Preconditions:
540
+ // - The AVD must be configured to support resizable displays (`resizableEnabled()` must be true).
541
+ //
542
+ // The `DisplayMode.value` field will be populated with the current `DisplayModeValue`,
543
+ // derived from the `getResizableActiveConfigId()`.
544
+ //
545
+ // Returns the following gRPC error codes:
546
+ // - `OK` (code 0): Upon successful retrieval of the display mode.
547
+ // - `FAILED_PRECONDITION` (code 9): If the AVD is not resizable.
256
548
  rpc getDisplayMode(google.protobuf.Empty) returns (DisplayMode) {}
257
549
 
258
- // Sets the size of the primary display of a resizable AVD. Fails if the AVD
259
- // is not resizable. The following gRPC error codes can be returned:
260
- // - FAILED_PRECONDITION (code 9) if the AVD is not resizable.
550
+ // Sets the size of the primary display of a resizable AVD to the specified `DisplayModeValue`. This operation is asynchronous
551
+ // and executed on the main looper.
552
+ //
553
+ // Preconditions:
554
+ // - The AVD must be configured to support resizable displays (`resizableEnabled()` must be true).
555
+ // - The emulator's `changeResizableDisplay` agent function must be available.
556
+ //
557
+ // The `DisplayMode.value` field specifies the desired display configuration (e.g., `PHONE`, `FOLDABLE`, `TABLET`, `DESKTOP`).
558
+ //
559
+ // Returns the following gRPC error codes:
560
+ // - `OK` (code 0): Upon successful asynchronous scheduling of the operation.
561
+ // - `FAILED_PRECONDITION` (code 9): If the AVD is not resizable.
562
+ // - `INTERNAL` (code 13): If the internal window agent function `changeResizableDisplay` is not available.
261
563
  rpc setDisplayMode(DisplayMode) returns (google.protobuf.Empty) {}
564
+
565
+ // Changes the XR-related settings of the emulator. This operation is asynchronous
566
+ // and executed on the main looper.
567
+ //
568
+ // The `XrOptions` message specifies the `environment` (e.g., `LIVING_ROOM_DAY`, `LIVING_ROOM_NIGHT`)
569
+ // and `passthrough_coefficient` (a float between 0.0 and 1.0 for real/artificial environment visibility).
570
+ // Values for `passthrough_coefficient` outside [0.0, 1.0] are ignored.
571
+ //
572
+ // Returns the following gRPC error codes:
573
+ // - `OK` (code 0): Upon successful asynchronous scheduling of the operation.
574
+ // - `FAILED_PRECONDITION` (code 9): If the `setXrOptions` agent function fails (e.g., if XR is not supported).
575
+ rpc setXrOptions(XrOptions) returns (google.protobuf.Empty) {}
576
+
577
+ // Retrieves the current state of XR-related settings from the emulator. This is a synchronous operation.
578
+ //
579
+ // Preconditions:
580
+ // - XR mode must be supported in the current AVD (`isXrGuestOs()` must be true).
581
+ // (Note: Current implementation of `isXrGuestOs()` always returns true).
582
+ //
583
+ // The `XrOptions` reply contains the current `environment` and `passthrough_coefficient`.
584
+ //
585
+ // Returns the following gRPC error codes:
586
+ // - `OK` (code 0): Upon successful retrieval of the XR options.
587
+ // - `FAILED_PRECONDITION` (code 9): If XR mode is not supported in the current AVD or if the `getXrOptions` agent function fails.
588
+ rpc getXrOptions(google.protobuf.Empty) returns (XrOptions) {}
589
+
590
+ // Sets the environment background for AI glasses.
591
+ rpc setEnvironment(Environment) returns (google.protobuf.Empty) {}
592
+
593
+ // Gets the current environment configuration for AI glasses. Values that are not set in environment.ini
594
+ // will be set to default values.
595
+ rpc getEnvironment(google.protobuf.Empty) returns (Environment) {}
596
+
597
+ // Returns the list of video cameras connected to the host machine.
598
+ rpc getHostCameras(google.protobuf.Empty) returns (CameraList) {}
262
599
  }
263
600
 
264
- // A Run State that describes the state of the Virtual Machine.
601
+ // Represents the execution state of the virtual machine, used for both querying the
602
+ // current status and requesting state transitions.
265
603
  message VmRunState {
266
604
  enum RunState {
267
- // The emulator is in an unknown state. You cannot transition to this
268
- // state.
605
+ // Purely observable state. The virtual machine is in an unmapped or transient state.
606
+ // Cannot be set directly.
269
607
  UNKNOWN = 0;
270
- // Guest is actively running. You can transition to this state from the
271
- // paused state.
608
+
609
+ // Active execution state. Setting this state resumes the virtual machine.
272
610
  RUNNING = 1;
273
- // Guest is paused to load a snapshot. You cannot transition to this
274
- // state.
611
+
612
+ // Purely observable state. The virtual machine is paused while restoring its state
613
+ // (e.g., loading a snapshot). Cannot be set directly.
275
614
  RESTORE_VM = 2;
276
- // Guest has been paused. Transitioning to this state will pause the
277
- // emulator the guest will not be consuming any cpu cycles.
615
+
616
+ // Suspended execution state. Setting this state pauses the virtual machine and halts
617
+ // CPU cycles.
278
618
  PAUSED = 3;
279
- // Guest is paused to take or export a snapshot. You cannot
280
- // transition to this state.
619
+
620
+ // Purely observable state. The virtual machine is paused while saving its state
621
+ // (e.g., taking a snapshot). Cannot be set directly.
281
622
  SAVE_VM = 4;
282
- // System shutdown, note that it is similar to power off. It tries to
283
- // set the system status and notify guest. The system is likely going to
284
- // disappear soon and do proper cleanup of resources, possibly taking
285
- // a snapshot. This is the same behavior as closing the emulator by
286
- // clicking the X (close) in the user interface.
623
+
624
+ // Graceful shutdown state. Setting this state initiates a clean shutdown of the
625
+ // virtual machine.
287
626
  SHUTDOWN = 5;
288
- // Immediately terminate the emulator. No resource cleanup will take
289
- // place. There is a good change to corrupt the system.
627
+
628
+ // Write-only command. Immediately terminates the emulator process without cleanup.
629
+ // Can cause data corruption and must be used with caution.
290
630
  TERMINATE = 7;
291
- // Will cause the emulator to reset. This is not a state you can
292
- // observe.
631
+
632
+ // Write-only command. Triggers a warm reset of the virtual machine.
293
633
  RESET = 9;
294
- // Guest experienced some error state, you cannot transition to this
295
- // state.
634
+
635
+ // Purely observable state. The virtual machine has stopped execution due to a guest
636
+ // panic, internal error, or I/O failure. Cannot be set directly.
296
637
  INTERNAL_ERROR = 10;
638
+
639
+ // Write-only command. Triggers a warm reset of the virtual machine (equivalent to `RESET`).
640
+ RESTART = 11;
641
+
642
+ // Write-only command. Starts or resumes execution of the virtual machine (equivalent
643
+ // to `RUNNING`).
644
+ START = 12;
645
+
646
+ // Write-only command. Stops execution of the virtual machine (equivalent to `PAUSED`).
647
+ STOP = 13;
297
648
  }
298
649
 
299
650
  RunState state = 1;
@@ -372,6 +723,14 @@ message PhysicalModelValue {
372
723
 
373
724
  // Value interpretation depends on sensor.
374
725
  ParameterValue value = 3;
726
+
727
+ enum Interpolation {
728
+ SMOOTH = 0;
729
+ STEP = 1;
730
+ }
731
+
732
+ // [Input Only] How to transition to the target value.
733
+ Interpolation interpolation = 4;
375
734
  }
376
735
 
377
736
  // A single sensor value.
@@ -427,6 +786,9 @@ message SensorValue {
427
786
  // instead.
428
787
  // Measures acceleration force and provides bias data.
429
788
  ACCELERATION_UNCALIBRATED = 17;
789
+ // A sensor of this type measures the direction in which the device is
790
+ // pointing relative to true north in degrees.
791
+ HEADING = 18;
430
792
  }
431
793
 
432
794
  // Type of sensor
@@ -467,6 +829,50 @@ message DisplayMode {
467
829
  DisplayModeValue value = 1;
468
830
  }
469
831
 
832
+ message XrOptions {
833
+ enum Environment {
834
+ LIVING_ROOM_DAY = 0;
835
+ LIVING_ROOM_NIGHT = 1;
836
+ // More environments may be added later.
837
+ }
838
+
839
+ // The currently active artificial surrounding environment (a.k.a.
840
+ // passthrough environment).
841
+ Environment environment = 1;
842
+
843
+ // A value of 0.0 means that the real or artificial surrounding environment
844
+ // (a.k.a. passthrough environment) is not visible. A value of 1.0 means
845
+ // that the passthrough environment is fully visible. Any value outside of
846
+ // the range [0.0-1.0] is ignored and leaves the state of passthrough
847
+ // unchanged. For simplicity of the implementation, this number may be
848
+ // rounded to an integer before applying.
849
+ float passthrough_coefficient = 2;
850
+
851
+ float dimming_value = 4;
852
+ }
853
+
854
+ // The state of one LED indicator of AI glasses.
855
+ message LedIndicator {
856
+ enum Facing {
857
+ INSIDE = 0;
858
+ OUTSIDE = 1;
859
+ }
860
+
861
+ enum State {
862
+ OFF = 0;
863
+ ON = 1;
864
+ }
865
+
866
+ // The indicator's identifier.
867
+ optional uint32 id = 1;
868
+ // Determines whether the indicator is inside or outside of the glasses frames.
869
+ optional Facing facing = 2;
870
+ // Determines whether the indicator is on or off.
871
+ optional State state = 3;
872
+ // Color in RGB format.
873
+ optional uint32 color = 4;
874
+ }
875
+
470
876
  message LogMessage {
471
877
  // [Output Only] The contents of the log output.
472
878
  string contents = 1;
@@ -474,11 +880,11 @@ message LogMessage {
474
880
  // should match the start parameter sent with the request. If the serial
475
881
  // console output exceeds the size of the buffer, older output will be
476
882
  // overwritten by newer content and the start values will be mismatched.
477
- int64 start = 2;
883
+ int64 start = 2 [deprecated = true];
478
884
  //[Output Only] The position of the next byte of content from the serial
479
885
  // console output. Use this value in the next request as the start
480
886
  // parameter.
481
- int64 next = 3;
887
+ int64 next = 3 [deprecated = true];
482
888
 
483
889
  // Set the sort of response you are interested it in.
484
890
  // It the type is "Parsed" the entries field will contain the parsed
@@ -541,8 +947,7 @@ message VmConfiguration {
541
947
  KVM = 2;
542
948
 
543
949
  // Intel® Hardware Accelerated Execution Manager (Intel® HAXM)
544
- // https://github.com/intel/haxm
545
- HAXM = 3;
950
+ HAXM = 3 [deprecated = true];
546
951
 
547
952
  // Hypervisor Framework.
548
953
  // https://developer.apple.com/documentation/hypervisor
@@ -625,6 +1030,21 @@ message Touch {
625
1030
  }
626
1031
 
627
1032
  EventExpiration expiration = 7;
1033
+
1034
+ // The orientation of the contact, if any.
1035
+ int32 orientation = 8;
1036
+ }
1037
+
1038
+ // A Pen is similar to a touch, with the addition
1039
+ // of button and rubber information.
1040
+ message Pen {
1041
+ Touch location = 1;
1042
+
1043
+ // True if the button is pressed or not
1044
+ bool button_pressed = 2;
1045
+
1046
+ // True if it is a rubber pointer.
1047
+ bool rubber_pointer = 3;
628
1048
  }
629
1049
 
630
1050
  // A TouchEvent contains a list of Touch objects that are in contact with
@@ -640,9 +1060,31 @@ message TouchEvent {
640
1060
 
641
1061
  // The display device where the touch event occurred.
642
1062
  // Omitting or using the value 0 indicates the main display.
643
- //
644
- // Touch events cannot be send to displays other than 0, due to
645
- // https://issuetracker.google.com/issues/150699691
1063
+ int32 display = 2;
1064
+ }
1065
+
1066
+ // A TouchpadEvent contains a list of Touch objects that are in contact with
1067
+ // the touchpad surface.
1068
+ //
1069
+ // Touchpad events are delivered in sequence as specified in the touchList.
1070
+ //
1071
+ // TouchpadEvents are delivered to the emulated devices using ["Protocol
1072
+ // B"](https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt)
1073
+ message TouchpadEvent {
1074
+ // The list of Touch objects, note that these do not need to be unique
1075
+ repeated Touch touches = 1;
1076
+
1077
+ // The touchpad device where the touch event occurred.
1078
+ // Omitting or using the value 0 indicates the main touchpad.
1079
+ int32 touchpad = 2;
1080
+ }
1081
+
1082
+ message PenEvent {
1083
+ // The list of Pen objects, note that these do not need to be unique
1084
+ repeated Pen events = 1;
1085
+
1086
+ // The display device where the pen event occurred.
1087
+ // Omitting or using the value 0 indicates the main display.
646
1088
  int32 display = 2;
647
1089
  }
648
1090
 
@@ -650,11 +1092,11 @@ message TouchEvent {
650
1092
  // interacting with a pointing device (such as a mouse).
651
1093
  message MouseEvent {
652
1094
  // The horizontal coordinate. This is the physical location on the
653
- // screen For example 0 indicates the leftmost coordinate.
1095
+ // screen, where 0 indicates the leftmost coordinate.
654
1096
  int32 x = 1;
655
1097
 
656
- // The vertical coordinate. This is the physical location on the screen
657
- // For example 0 indicates the top left coordinate.
1098
+ // The vertical coordinate. This is the physical location on the screen,
1099
+ // where 0 indicates the topmost coordinate.
658
1100
  int32 y = 2;
659
1101
 
660
1102
  // Indicates which buttons are pressed.
@@ -780,6 +1222,58 @@ message KeyboardEvent {
780
1222
  string text = 5;
781
1223
  }
782
1224
 
1225
+ message XrCommand {
1226
+ enum Action {
1227
+ // Recenter the viewport position and rotation.
1228
+ RECENTER = 0;
1229
+ }
1230
+
1231
+ Action action = 1;
1232
+ }
1233
+
1234
+ // An input event that can be delivered to the emulator.
1235
+ message InputEvent {
1236
+ oneof type {
1237
+ KeyboardEvent key_event = 1;
1238
+ TouchEvent touch_event = 2;
1239
+ MouseEvent mouse_event = 3;
1240
+ AndroidEvent android_event = 4;
1241
+ PenEvent pen_event = 5;
1242
+ WheelEvent wheel_event = 6;
1243
+ MouseEvent xr_hand_event = 7;
1244
+ MouseEvent xr_eye_event = 8;
1245
+ XrCommand xr_command = 9;
1246
+ RotationRadian xr_head_rotation_event = 10;
1247
+ Translation xr_head_movement_event = 11;
1248
+ AngularVelocity xr_head_angular_velocity_event = 12;
1249
+ Velocity xr_head_velocity_event = 13;
1250
+ TouchpadEvent touchpad_event = 14;
1251
+ }
1252
+ };
1253
+
1254
+ // The android input event system is a framework for handling input from a
1255
+ // variety of devices by generating events that describe changes in the
1256
+ // state of the devices and forwarding them to user space applications.
1257
+ //
1258
+ // An AndroidEvents will be delivered directly to the kernel as is.
1259
+ message AndroidEvent {
1260
+ // The type of the event. The types of the event are specified
1261
+ // by the android kernel. Some examples are:
1262
+ // EV_SYN, EV_KEY, EV_SW, etc..
1263
+ // The exact definitions can be found in the input.h header file.
1264
+ int32 type = 1;
1265
+
1266
+ // The actual code to be send to the kernel. The actual meaning
1267
+ // of the code depends on the type definition.
1268
+ int32 code = 2;
1269
+
1270
+ // The actual value of the event.
1271
+ int32 value = 3;
1272
+
1273
+ // The display id associated with this input event.
1274
+ int32 display = 4;
1275
+ };
1276
+
783
1277
  message Fingerprint {
784
1278
  // True when the fingprint is touched.
785
1279
  bool isTouching = 1;
@@ -1039,9 +1533,22 @@ message EmulatorStatus {
1039
1533
  // The current vm configuration
1040
1534
  VmConfiguration vmConfig = 4;
1041
1535
 
1042
- // The hardware configuration of the running emulator as
1043
- // key valure pairs.
1044
- EntryList hardwareConfig = 5;
1536
+ // Use platformConfig instead
1537
+ EntryList hardwareConfig = 5 [deprecated = true];
1538
+
1539
+ // Some guests will produce a heart beat, that can be used to
1540
+ // detect if the guest is active.
1541
+ // This is a monotonically increasing number that gets incremented
1542
+ // around once a second.
1543
+ uint64 heartbeat = 6;
1544
+
1545
+ // The configuration of services in the guest, this map
1546
+ // contains key value pairs that are specific to the image
1547
+ // used by the guest.
1548
+ map<string, string> guestConfig = 7;
1549
+
1550
+ // Configuration of the emulator hardware
1551
+ map<string, string> platformConfig = 8;
1045
1552
  }
1046
1553
 
1047
1554
  message AudioFormat {
@@ -1089,6 +1596,11 @@ message AudioPacket {
1089
1596
  bytes audio = 3;
1090
1597
  }
1091
1598
 
1599
+ message MicrophoneState {
1600
+ // Whether or not host microphone access is enabled
1601
+ bool realAudioEnabled = 1;
1602
+ }
1603
+
1092
1604
  message SmsMessage {
1093
1605
  // The source address where this message came from.
1094
1606
  //
@@ -1224,29 +1736,35 @@ message DisplayConfigurations {
1224
1736
  }
1225
1737
 
1226
1738
  message Notification {
1227
- enum EventType {
1228
- VIRTUAL_SCENE_CAMERA_INACTIVE = 0;
1229
- VIRTUAL_SCENE_CAMERA_ACTIVE = 1;
1230
-
1231
- // Fired when an update to a display event has been fired through
1232
- // the extended ui. This does not fire events when the display
1233
- // is changed through the console or gRPC endpoint.
1234
- DISPLAY_CONFIGURATIONS_CHANGED_UI = 2;
1235
- // Keep adding more for other event types
1236
- }
1237
-
1238
- // Deprecated, use the type below to get detailed information
1239
- // regarding the event.
1240
- EventType event = 1 [deprecated = true];
1241
-
1242
1739
  // Detailed notification information.
1243
1740
  oneof type {
1244
1741
  CameraNotification cameraNotification = 2;
1245
1742
  DisplayConfigurationsChangedNotification
1246
1743
  displayConfigurationsChangedNotification = 3;
1744
+ Posture posture = 4;
1745
+ BootCompletedNotification booted = 5;
1746
+ BrightnessValue brightness = 6;
1747
+
1748
+ // This notification is sent when a TextView receives or loses focus.
1749
+ // It is also sent immediately in response to the streamNotification
1750
+ // call.
1751
+ TextViewFocus textViewFocus = 7;
1752
+ // This notification is sent when XrOptions change.
1753
+ // It is also sent immediately in response to the streamNotification
1754
+ // call.
1755
+ XrOptions xrOptions = 8;
1756
+ MicrophoneState microphoneState = 9;
1757
+ // This notification is sent when AI glasses LED light status change.
1758
+ LedIndicator ledIndicator = 10;
1247
1759
  }
1248
1760
  }
1249
1761
 
1762
+ message BootCompletedNotification {
1763
+ // The time in milliseconds it took for the boot to complete.
1764
+ // Note that this value can be 0 when you are loading from a snapshot.
1765
+ int32 time = 1;
1766
+ }
1767
+
1250
1768
  // Fired when the virtual scene camera is activated or deactivated and also in
1251
1769
  // response to the streamNotification call.
1252
1770
  message CameraNotification {
@@ -1256,6 +1774,15 @@ message CameraNotification {
1256
1774
  int32 display = 2;
1257
1775
  }
1258
1776
 
1777
+ message TextViewFocus {
1778
+ // Indicates whether a text view currently has focus.
1779
+ bool textViewHasFocus = 1;
1780
+
1781
+ // If a text view has focus, the display where the text view is located.
1782
+ // Otherwise, unset.
1783
+ int32 display = 2;
1784
+ }
1785
+
1259
1786
  // Fired when an update to a display event has been fired through the extended
1260
1787
  // ui. This does not fire events when the display is changed through the console
1261
1788
  // or the gRPC endpoint.
@@ -1264,19 +1791,39 @@ message DisplayConfigurationsChangedNotification {
1264
1791
  }
1265
1792
 
1266
1793
  message RotationRadian {
1267
- float x = 1; // x axis is horizontal and orthogonal to the view direction.
1268
- float y = 2; // y axis points up and is perpendicular to the floor.
1269
- float z = 3; // z axis is the view direction and is set to 0.0 in
1270
- // rotateVirtualSceneCamera call.
1794
+ // Components of the rotation vector in radians.
1795
+ // Rotation angles are relative to the current orientation.
1796
+ float x = 1; // Angle of rotation around the x axis in right-handed direction.
1797
+ float y = 2; // Angle of rotation around the y axis in right-handed direction.
1798
+ float z = 3; // Angle of rotation around the z axis in right-handed direction.
1799
+ }
1800
+
1801
+ message Translation {
1802
+ // Components of the translation vector in meters.
1803
+ float delta_x = 1;
1804
+ float delta_y = 2;
1805
+ float delta_z = 3;
1806
+ }
1807
+
1808
+ message AngularVelocity {
1809
+ // Components of the target angular velocity vector in radians per second.
1810
+ // Transition to these values is implementation dependent, and may be
1811
+ // smoothed over time.
1812
+ float omega_x = 1;
1813
+ float omega_y = 2;
1814
+ float omega_z = 3;
1271
1815
  }
1272
1816
 
1273
1817
  message Velocity {
1274
- float x = 1; // x axis is horizontal and orthogonal to the view direction.
1275
- float y = 2; // y axis points up and is perpendicular to the floor.
1276
- float z = 3; // z axis is the view direction
1818
+ // Components of the target velocity vector in meters per second.
1819
+ // Transition to these values is implementation dependent, and may be
1820
+ // smoothed over time.
1821
+ float x = 1;
1822
+ float y = 2;
1823
+ float z = 3;
1277
1824
  }
1278
1825
 
1279
- // must follow the definition in "external/qemu/android/hw-sensors.h"
1826
+ // Must follow the definition in "external/qemu/android/hw-sensors.h"
1280
1827
  message Posture {
1281
1828
  enum PostureValue {
1282
1829
  POSTURE_UNKNOWN = 0;
@@ -1298,3 +1845,21 @@ message PhoneNumber {
1298
1845
  // For example: +3106225412 or (650) 555-1221
1299
1846
  string number = 1;
1300
1847
  }
1848
+
1849
+ // Specifies environment background for AI glasses.
1850
+ message Environment {
1851
+ // Key/value pairs corresponing to the contents of the environment.ini file.
1852
+ // An empty map means no environment.
1853
+ map<string, string> environment = 1;
1854
+ }
1855
+
1856
+ message Camera {
1857
+ // Human-readable name for use with UI
1858
+ string display_name = 1;
1859
+ // Os Specific identifier
1860
+ string id = 2;
1861
+ }
1862
+
1863
+ message CameraList {
1864
+ repeated Camera cameras = 1;
1865
+ }