1// Copyright (C) 2018 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15// Note that if you add/remove methods in this file you must update 16// the metrics sql as well ./android/scripts/gen-grpc-sql.py 17// 18// Please group deleted methods in a block including the date (MM/DD/YY) 19// it was removed. This enables us to easily keep metrics around after removal 20// 21// List of deleted methods 22// rpc iWasDeleted (03/12/12) 23// ... 24syntax = "proto3"; 25 26option java_multiple_files = true; 27option java_package = "com.android.emulator.control"; 28option objc_class_prefix = "AEC"; 29 30package android.emulation.control; 31import "google/protobuf/empty.proto"; 32 33// An EmulatorController service lets you control the emulator. 34// Note that this is currently an experimental feature, and that the 35// service definition might change without notice. Use at your own risk! 36// 37// We use the following rough conventions: 38// 39// streamXXX --> streams values XXX (usually for emulator lifetime). Values 40// are updated as soon as they become available. 41// getXXX --> gets a single value XXX 42// setXXX --> sets a single value XXX, does not returning state, these 43// usually have an observable lasting side effect. 44// sendXXX --> send a single event XXX, possibly returning state information. 45// android usually responds to these events. 46service EmulatorController { 47 // set/get/stream the sensor data 48 rpc streamSensor(SensorValue) returns (stream SensorValue) {} 49 rpc getSensor(SensorValue) returns (SensorValue) {} 50 rpc setSensor(SensorValue) returns (google.protobuf.Empty) {} 51 52 // set/get/stream the physical model, this is likely the one you are 53 // looking for when you wish to modify the device state. 54 rpc setPhysicalModel(PhysicalModelValue) returns (google.protobuf.Empty) {} 55 rpc getPhysicalModel(PhysicalModelValue) returns (PhysicalModelValue) {} 56 rpc streamPhysicalModel(PhysicalModelValue) 57 returns (stream PhysicalModelValue) {} 58 59 // Atomically set/get the current primary clipboard data. 60 rpc setClipboard(ClipData) returns (google.protobuf.Empty) {} 61 rpc getClipboard(google.protobuf.Empty) returns (ClipData) {} 62 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 clip 67 // event. It is possible to lose clipboard events if the clipboard updates 68 // very rapidly. 69 rpc streamClipboard(google.protobuf.Empty) returns (stream ClipData) {} 70 71 // Set/get the battery to the given state. 72 rpc setBattery(BatteryState) returns (google.protobuf.Empty) {} 73 rpc getBattery(google.protobuf.Empty) returns (BatteryState) {} 74 75 // Set the state of the gps, gps support will only work 76 // properly if: 77 // 78 // - no location ui is active. That is the emulator 79 // is launched in headless mode (-no-window) or the location 80 // ui is disabled (-no-location-ui). 81 // - the passiveUpdate is set to false. Setting this to false 82 // will disable/break the LocationUI. 83 // 84 // Keep in mind that android usually only samples the gps at 1 hz. 85 rpc setGps(GpsState) returns (google.protobuf.Empty) {} 86 87 // Gets the latest gps state as delivered by the setGps call, or location ui 88 // if active. 89 // 90 // Note: this is not necessarily the actual gps coordinate visible at the 91 // time, due to gps sample frequency (usually 1hz). 92 rpc getGps(google.protobuf.Empty) returns (GpsState) {} 93 94 // Simulate a touch event on the finger print sensor. 95 rpc sendFingerprint(Fingerprint) returns (google.protobuf.Empty) {} 96 97 // Send a keyboard event. Translating the event. 98 rpc sendKey(KeyboardEvent) returns (google.protobuf.Empty) {} 99 100 // Send touch/mouse events. Note that mouse events can be simulated 101 // by touch events. 102 rpc sendTouch(TouchEvent) returns (google.protobuf.Empty) {} 103 rpc sendMouse(MouseEvent) returns (google.protobuf.Empty) {} 104 105 // Make a phone call. 106 rpc sendPhone(PhoneCall) returns (PhoneResponse) {} 107 108 // Sends an sms message to the emulator. 109 rpc sendSms(SmsMessage) returns (PhoneResponse) {} 110 111 // Retrieve the status of the emulator. This will contain general 112 // hardware information, and whether the device has booted or not. 113 rpc getStatus(google.protobuf.Empty) returns (EmulatorStatus) {} 114 115 // Gets an individual screenshot in the desired format. 116 // 117 // The image will be scaled to the desired ImageFormat, while maintaining 118 // the aspect ratio. The returned image will never exceed the provided width 119 // and height. Not setting the width or height (i.e. they are 0) will result 120 // in using the device width and height. 121 // 122 // The resulting image will be properly oriented and can be displayed 123 // directly without post processing. For example, if the device has a 124 // 1080x1920 screen and is in landscape mode and called with no width or 125 // height parameter, it will return an 1920x1080 image. 126 // 127 // This method will return an empty image if the display is not visible. 128 rpc getScreenshot(ImageFormat) returns (Image) {} 129 130 // Streams a series of screenshots in the desired format. 131 // A new frame will be delivered whenever the device produces a new frame. 132 // (Beware that this can produce a significant amount of data, and that 133 // certain translations are (png transform) can be costly). 134 // 135 // If the requested display is not visible it will send a single empty image 136 // and wait start producing images once the display becomes active, again 137 // producing a single empty image when the display becomes inactive. 138 rpc streamScreenshot(ImageFormat) returns (stream Image) {} 139 140 // Streams a series of audio packets in the desired format. 141 // A new frame will be delivered whenever the emulated device 142 // produces a new audio frame. You can expect packets to be 143 // delivered in intervals of 20-30ms. 144 // 145 // Be aware that this can block when the emulator does not 146 // produce any audio whatsoever! 147 rpc streamAudio(AudioFormat) returns (stream AudioPacket) {} 148 149 150 // Injects a series of audio packets to the android microphone. 151 // A new frame will be delivered whenever the emulated device 152 // requests a new audio frame. Audio is usually delivered at a rate 153 // that the emulator is requesting frames. Audio will be stored in a 154 // temporary buffer that can hold 300ms of audio. 155 // 156 // Notes: 157 // - Only the first audio format packet that is delivered will be 158 // honored. There is no need to send the audio format multiple times. 159 // - Real time audio currently immediately overrides the buffer. This 160 // means you must provide a constant rate of audio packets. The real 161 // time mode is experimental. Timestamps of audio packets might be 162 // used in the future to improve synchronization. 163 // 164 // - INVALID_ARGUMENT (code 3) The sampling rate was too high/low 165 // - INVALID_ARGUMENT (code 3) The audio packet was too large to handle. 166 // - FAILED_PRECONDITION (code 9) If there was a microphone registered already. 167 rpc injectAudio(stream AudioPacket) returns (google.protobuf.Empty) {} 168 169 // Returns the last 128Kb of logcat output from the emulator 170 // Note that parsed logcat messages are only available after L (Api >23). 171 // it is possible that the logcat buffer gets overwritten, or falls behind. 172 rpc getLogcat(LogMessage) returns (LogMessage) {} 173 174 // Streams the logcat output from the emulator. The first call 175 // can retrieve up to 128Kb. This call will not return. 176 // Note that parsed logcat messages are only available after L (Api >23) 177 // it is possible that the logcat buffer gets overwritten, or falls behind. 178 rpc streamLogcat(LogMessage) returns (stream LogMessage) {} 179 180 // Transition the virtual machine to the desired state. Note that 181 // some states are only observable. For example you cannot transition 182 // to the error state. 183 rpc setVmState(VmRunState) returns (google.protobuf.Empty) {} 184 185 // Gets the state of the virtual machine. 186 rpc getVmState(google.protobuf.Empty) returns (VmRunState) {} 187 188 // Atomically changes the current multi-display configuration. 189 // After this call the given display configurations will be activated. You 190 // can only update secondary displays. Displays with id 0 will be ignored. 191 // 192 // This call can result in the removal or addition of secondary displays, the final 193 // display state can be observed by the returned configuration. 194 // 195 // The following gRPC error codes can be returned: 196 // - FAILED_PRECONDITION (code 9) if the AVD does not support a configurable 197 // secondary display. 198 // - INVALID_ARGUMENT (code 3) if: 199 // - The same display id is defined multiple times. 200 // - The display configurations are outside valid ranges. 201 // See DisplayConfiguration for details on valid ranges. 202 // - INTERNAL (code 13) if there was an internal emulator failure. 203 rpc setDisplayConfigurations(DisplayConfigurations) 204 returns (DisplayConfigurations) {} 205 206 // Returns all currently valid logical displays. 207 // 208 // The gRPC error code FAILED_PRECONDITION (code 9) is returned if the AVD 209 // does not support a configurable secondary display. 210 rpc getDisplayConfigurations(google.protobuf.Empty) 211 returns (DisplayConfigurations) {} 212 213 // Notifies client of the following changes: 214 // 215 // - Virtual scene camera status change. 216 // - Display configuration changes from extended ui. This will only be fired 217 // if the user makes modifications the extended displays through the extended 218 // control tab. 219 // 220 // Note that this method will send the initial virtual scene state immediately. 221 rpc streamNotification(google.protobuf.Empty) returns (stream Notification) {} 222 223 // RotationRadian is relative to the camera's current orientation. 224 rpc rotateVirtualSceneCamera(RotationRadian) returns (google.protobuf.Empty) { 225 } 226 // Velocity is absolute 227 rpc setVirtualSceneCameraVelocity(Velocity) 228 returns (google.protobuf.Empty) {} 229 // Set foldable posture 230 rpc setPosture(Posture) returns (google.protobuf.Empty) {} 231 232 // Get the backlight brightness. 233 // The following gRPC error codes can be returned: 234 // - FAILED_PRECONDITION (code 9) if the AVD does not support hw-control. 235 rpc getBrightness(BrightnessValue) returns (BrightnessValue) {} 236 237 // Set the backlight brightness. 238 // The following gRPC error codes can be returned: 239 // - FAILED_PRECONDITION (code 9) if the AVD does not support hw-control. 240 // - INVALID_ARGUMENT (code 3) The brightness exceeds the valid range. 241 rpc setBrightness(BrightnessValue) returns (google.protobuf.Empty) {} 242 243 // Returns the current mode of the primary display of a resizable AVD. 244 // The following gRPC error codes can be returned: 245 // - FAILED_PRECONDITION (code 9) if the AVD is not resizable. 246 rpc getDisplayMode(google.protobuf.Empty) returns (DisplayMode) {} 247 248 // Sets the size of the primary display of a resizable AVD. Fails if the AVD is 249 // not resizable. 250 // The following gRPC error codes can be returned: 251 // - FAILED_PRECONDITION (code 9) if the AVD is not resizable. 252 rpc setDisplayMode(DisplayMode) returns (google.protobuf.Empty) {} 253} 254 255// A Run State that describes the state of the Virtual Machine. 256message VmRunState { 257 enum RunState { 258 // The emulator is in an unknown state. You cannot transition to this state. 259 UNKNOWN = 0; 260 // Guest is actively running. You can transition to this state from the 261 // paused state. 262 RUNNING = 1; 263 // Guest is paused to load a snapshot. You cannot transition to this state. 264 RESTORE_VM = 2; 265 // Guest has been paused. Transitioning to this state will pause the 266 // emulator the guest will not be consuming any cpu cycles. 267 PAUSED = 3; 268 // Guest is paused to take or export a snapshot. You cannot 269 // transition to this state. 270 SAVE_VM = 4; 271 // System shutdown, note that it is similar to power off. It tries to set 272 // the system status and notify guest. The system is likely going to 273 // disappear soon and do proper cleanup of resources, possibly taking 274 // a snapshot. This is the same behavior as closing the emulator by clicking 275 // the X (close) in the user interface. 276 SHUTDOWN = 5; 277 // Immediately terminate the emulator. No resource cleanup will take place. 278 // There is a good change to corrupt the system. 279 TERMINATE = 7; 280 // Will cause the emulator to reset. This is not a state you can observe. 281 RESET = 9; 282 // Guest experienced some error state, you cannot transition to this state. 283 INTERNAL_ERROR = 10; 284 } 285 286 RunState state = 1; 287} 288 289message ParameterValue { repeated float data = 1 [ packed = true ]; } 290 291message PhysicalModelValue { 292 enum State { 293 OK = 0; 294 NO_SERVICE = -3; // qemud service is not available/initiated. 295 DISABLED = -2; // Sensor is disabled. 296 UNKNOWN = -1; // Unknown sensor (should not happen) 297 } 298 299 // Details on the sensors documentation can be found here: 300 // https://developer.android.com/reference/android/hardware/Sensor.html#TYPE_ 301 // The types must follow the order defined in "external/qemu/android/hw-sensors.h" 302 enum PhysicalType { 303 POSITION = 0; 304 305 // All values are angles in degrees. 306 // values = [x,y,z] 307 ROTATION = 1; 308 309 MAGNETIC_FIELD = 2; 310 311 // Temperature in °C 312 TEMPERATURE = 3; 313 314 // Proximity sensor distance measured in centimeters 315 PROXIMITY = 4; 316 317 // Ambient light level in SI lux units 318 LIGHT = 5; 319 320 // Atmospheric pressure in hPa (millibar) 321 PRESSURE = 6; 322 323 // Relative ambient air humidity in percent 324 HUMIDITY = 7; 325 326 VELOCITY = 8; 327 AMBIENT_MOTION = 9; 328 329 // Describing a hinge angle sensor in degrees. 330 HINGE_ANGLE0 = 10; 331 HINGE_ANGLE1 = 11; 332 HINGE_ANGLE2 = 12; 333 334 ROLLABLE0 = 13; 335 ROLLABLE1 = 14; 336 ROLLABLE2 = 15; 337 338 // Describing the device posture; the value should be an enum defined 339 // in Posture::PostureValue. 340 POSTURE = 16; 341 342 // Heart rate in bpm 343 HEART_RATE = 17; 344 345 // Ambient RGBC light intensity. Values are in order (Red, Green, Blue, 346 // Clear). 347 RGBC_LIGHT = 18; 348 349 // Wrist tilt gesture (1 = gaze, 0 = ungaze) 350 WRIST_TILT = 19; 351 } 352 PhysicalType target = 1; 353 354 // [Output Only] 355 State status = 2; 356 357 // Value interpretation depends on sensor. 358 ParameterValue value = 3; 359} 360 361// A single sensor value. 362message SensorValue { 363 enum State { 364 OK = 0; 365 NO_SERVICE = -3; // qemud service is not available/initiated. 366 DISABLED = -2; // Sensor is disabled. 367 UNKNOWN = -1; // Unknown sensor (should not happen) 368 } 369 370 // These are the various sensors that can be available in an emulated 371 // devices. 372 enum SensorType { 373 // Measures the acceleration force in m/s2 that is applied to a device 374 // on all three physical axes (x, y, and z), including the force of 375 // gravity. 376 ACCELERATION = 0; 377 // Measures a device's rate of rotation in rad/s around each of the 378 // three physical axes (x, y, and z). 379 GYROSCOPE = 1; 380 // Measures the ambient geomagnetic field for all three physical axes 381 // (x, y, z) in μT. 382 MAGNETIC_FIELD = 2; 383 // Measures degrees of rotation that a device makes around all three 384 // physical axes (x, y, z) 385 ORIENTATION = 3; 386 // Measures the temperature of the device in degrees Celsius (°C). 387 TEMPERATURE = 4; 388 // Measures the proximity of an object in cm relative to the view screen 389 // of a device. This sensor is typically used to determine whether a 390 // handset is being held up to a person's ear. 391 PROXIMITY = 5; 392 // Measures the ambient light level (illumination) in lx. 393 LIGHT = 6; 394 // Measures the ambient air pressure in hPa or mbar. 395 PRESSURE = 7; 396 // Measures the relative ambient humidity in percent (%). 397 HUMIDITY = 8; 398 MAGNETIC_FIELD_UNCALIBRATED = 9; 399 GYROSCOPE_UNCALIBRATED = 10; 400 401 // HINGE_ANGLE0 (11), HINGE_ANGLE1 (12), HINGE_ANGLE2 (13) are 402 // skipped; clients should use get/setPhysicalModel() instead for these 403 // "sensors". 404 405 // Measures the heart rate in bpm. 406 HEART_RATE = 14; 407 // Measures the ambient RGBC light intensity. 408 // Values are in order (Red, Green, Blue, Clear). 409 RGBC_LIGHT = 15; 410 // WIRST_TILT (16) is skipped; clients should use get/setPhysicalModel() 411 // instead. 412 } 413 414 // Type of sensor 415 SensorType target = 1; 416 417 // [Output Only] 418 State status = 2; 419 420 // Value interpretation depends on sensor enum. 421 ParameterValue value = 3; 422} 423 424// A single backlight brightness value. 425message BrightnessValue { 426 enum LightType { 427 // Display backlight. This will affect all displays. 428 LCD = 0; 429 KEYBOARD = 1; 430 BUTTON = 2; 431 } 432 433 // Type of light 434 LightType target = 1; 435 436 // Light intensity, ranges from 0-255. 437 uint32 value = 2; 438} 439 440// in line with android/emulation/resizable_display_config.h 441enum DisplayModeValue { 442 PHONE = 0; 443 FOLDABLE = 1; 444 TABLET = 2; 445 DESKTOP = 3; 446} 447 448message DisplayMode{ 449 DisplayModeValue value = 1; 450} 451 452message LogMessage { 453 // [Output Only] The contents of the log output. 454 string contents = 1; 455 // The starting byte position of the output that was returned. This 456 // should match the start parameter sent with the request. If the serial 457 // console output exceeds the size of the buffer, older output will be 458 // overwritten by newer content and the start values will be mismatched. 459 int64 start = 2; 460 //[Output Only] The position of the next byte of content from the serial 461 // console output. Use this value in the next request as the start 462 // parameter. 463 int64 next = 3; 464 465 // Set the sort of response you are interested it in. 466 // It the type is "Parsed" the entries field will contain the parsed 467 // results. otherwise the contents field will be set. 468 LogType sort = 4; 469 470 // [Output Only] The parsed logcat entries so far. Only set if sort is 471 // set to Parsed 472 repeated LogcatEntry entries = 5; 473 474 enum LogType { 475 Text = 0; 476 Parsed = 1; 477 } 478} 479 480// A parsed logcat entry. 481message LogcatEntry { 482 // The possible log levels. 483 enum LogLevel { 484 UNKNOWN = 0; 485 DEFAULT = 1; 486 VERBOSE = 2; 487 DEBUG = 3; 488 INFO = 4; 489 WARN = 5; 490 ERR = 6; 491 FATAL = 7; 492 SILENT = 8; 493 } 494 495 // A Unix timestamps in milliseconds (The number of milliseconds that 496 // have elapsed since January 1, 1970 (midnight UTC/GMT), not counting 497 // leap seconds) 498 uint64 timestamp = 1; 499 500 // Process id. 501 uint32 pid = 2; 502 503 // Thread id. 504 uint32 tid = 3; 505 LogLevel level = 4; 506 string tag = 5; 507 string msg = 6; 508} 509 510// Information about the hypervisor that is currently in use. 511message VmConfiguration { 512 enum VmHypervisorType { 513 // An unknown hypervisor 514 UNKNOWN = 0; 515 516 // No hypervisor is in use. This usually means that the guest is 517 // running on a different CPU than the host, or you are using a 518 // platform where no hypervisor is available. 519 NONE = 1; 520 521 // The Kernel based Virtual Machine 522 // (https://www.linux-kvm.org/page/Main_Page) 523 KVM = 2; 524 525 // Intel® Hardware Accelerated Execution Manager (Intel® HAXM) 526 // https://github.com/intel/haxm 527 HAXM = 3; 528 529 // Hypervisor Framework. 530 // https://developer.apple.com/documentation/hypervisor 531 HVF = 4; 532 533 // Window Hypervisor Platform 534 // https://docs.microsoft.com/en-us/virtualization/api/ 535 WHPX = 5; 536 537 GVM = 6; 538 } 539 540 VmHypervisorType hypervisorType = 1; 541 int32 numberOfCpuCores = 2; 542 int64 ramSizeBytes = 3; 543} 544 545// Representation of a clipped data object on the clipboard. 546message ClipData { 547 // UTF-8 Encoded text. 548 string text = 1; 549} 550 551// The Touch interface represents a single contact point on a 552// touch-sensitive device. The contact point is commonly a finger or stylus 553// and the device may be a touchscreen or trackpad. 554message Touch { 555 // The horizontal coordinate. This is the physical location on the 556 // screen For example 0 indicates the leftmost coordinate. 557 int32 x = 1; 558 559 // The vertical coordinate. This is the physical location on the screen 560 // For example 0 indicates the top left coordinate. 561 int32 y = 2; 562 563 // The identifier is an arbitrary non-negative integer that is used to 564 // identify and track each tool independently when multiple tools are 565 // active. For example, when multiple fingers are touching the device, 566 // each finger should be assigned a distinct tracking id that is used as 567 // long as the finger remains in contact. Tracking ids may be reused 568 // when their associated tools move out of range. 569 // 570 // The emulator currently supports up to 10 concurrent touch events. The 571 // identifier can be any uninque value and will be mapped to the next 572 // available internal identifier. 573 int32 identifier = 3; 574 575 // Reports the physical pressure applied to the tip of the tool or the 576 // signal strength of the touch contact. 577 // 578 // The values reported must be non-zero when the tool is touching the 579 // device and zero otherwise to indicate that the touch event is 580 // completed. 581 // 582 // Make sure to deliver a pressure of 0 for the given identifier when 583 // the touch event is completed, otherwise the touch identifier will not 584 // be unregistered! 585 int32 pressure = 4; 586 587 // Optionally reports the cross-sectional area of the touch contact, or 588 // the length of the longer dimension of the touch contact. 589 int32 touch_major = 5; 590 591 // Optionally reports the length of the shorter dimension of the touch 592 // contact. This axis will be ignored if touch_major is reporting an 593 // area measurement greater than 0. 594 int32 touch_minor = 6; 595 596 enum EventExpiration { 597 // The system will use the default time of 120s to track 598 // the touch event with the given identifier. If no update happens 599 // within this timeframe the identifier is considered expired 600 // and can be made available for re-use. This means that a touch event 601 // with pressure 0 for this identifier will be send to the emulator. 602 EVENT_EXPIRATION_UNSPECIFIED = 0; 603 604 // Never expire the given slot. You must *ALWAYS* close the identifier 605 // by sending a touch event with 0 pressure. 606 NEVER_EXPIRE = 1; 607 } 608 609 EventExpiration expiration = 7; 610} 611 612// A TouchEvent contains a list of Touch objects that are in contact with 613// the touch surface. 614// 615// Touch events are delivered in sequence as specified in the touchList. 616// 617// TouchEvents are delivered to the emulated devices using ["Protocol 618// B"](https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt) 619message TouchEvent { 620 // The list of Touch objects, note that these do not need to be unique 621 repeated Touch touches = 1; 622 623 // The display device where the touch event occurred. 624 // Omitting or using the value 0 indicates the main display. 625 // 626 // Touch events cannot be send to displays other than 0, due to 627 // https://issuetracker.google.com/issues/150699691 628 int32 display = 2; 629} 630 631// The MouseEvent interface represents events that occur due to the user 632// interacting with a pointing device (such as a mouse). 633message MouseEvent { 634 // The horizontal coordinate. This is the physical location on the 635 // screen For example 0 indicates the leftmost coordinate. 636 int32 x = 1; 637 638 // The vertical coordinate. This is the physical location on the screen 639 // For example 0 indicates the top left coordinate. 640 int32 y = 2; 641 642 // Indicates which buttons are pressed. 643 // 0: No button was pressed 644 // 1: Primary button (left) 645 // 2: Secondary button (right) 646 int32 buttons = 3; 647 648 // The display device where the mouse event occurred. 649 // Omitting or using the value 0 indicates the main display. 650 int32 display = 4; 651} 652 653// KeyboardEvent objects describe a user interaction with the keyboard; each 654// event describes a single interaction between the user and a key (or 655// combination of a key with modifier keys) on the keyboard. 656// This follows the pattern as set by 657// (javascript)[https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent] 658// 659// Note: that only keyCode, key, or text can be set and that the semantics 660// will slightly vary. 661message KeyboardEvent { 662 // Code types that the emulator can receive. Note that the emulator 663 // will do its best to translate the code to an evdev value that 664 // will be send to the emulator. This translation is based on 665 // the chromium translation tables. See 666 // (this)[https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android/android-grpc/android/emulation/control/keyboard/keycode_converter_data.inc] 667 // for details on the translation. 668 enum KeyCodeType { 669 Usb = 0; 670 Evdev = 1; 671 XKB = 2; 672 Win = 3; 673 Mac = 4; 674 } 675 676 enum KeyEventType { 677 // Indicates that this keyevent should be send to the emulator 678 // as a key down event. Meaning that the key event will be 679 // translated to an EvDev event type and bit 11 (0x400) will be 680 // set before it is sent to the emulator. 681 keydown = 0; 682 683 // Indicates that the keyevent should be send to the emulator 684 // as a key up event. Meaning that the key event will be 685 // translated to an EvDev event type and 686 // sent to the emulator. 687 keyup = 1; 688 689 // Indicates that the keyevent will be send to the emulator 690 // as e key down event and immediately followed by a keyup event. 691 keypress = 2; 692 } 693 694 // Type of keycode contained in the keyCode field. 695 KeyCodeType codeType = 1; 696 697 // The type of keyboard event that should be sent to the emulator 698 KeyEventType eventType = 2; 699 700 // This property represents a physical key on the keyboard (as opposed 701 // to the character generated by pressing the key). In other words, this 702 // property is a value which isn't altered by keyboard layout or the 703 // state of the modifier keys. This value will be interpreted by the 704 // emulator depending on the KeyCodeType. The incoming key code will be 705 // translated to an evdev code type and send to the emulator. 706 // The values in key and text will be ignored. 707 int32 keyCode = 3; 708 709 // The value of the key pressed by the user, taking into consideration 710 // the state of modifier keys such as Shift as well as the keyboard 711 // locale and layout. This follows the w3c standard used in browsers. 712 // You can find an accurate description of valid values 713 // [here](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) 714 // 715 // Note that some keys can result in multiple evdev events that are 716 // delivered to the emulator. for example the Key "A" will result in a 717 // sequence: 718 // ["Shift", "a"] -> [0x2a, 0x1e] whereas "a" results in ["a"] -> [0x1e]. 719 // 720 // Not all documented keys are understood by android, and only printable 721 // ASCII [32-127) characters are properly translated. 722 // 723 // Keep in mind that there are a set of key values that result in android 724 // specific behavior 725 // [see](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values#Phone_keys): 726 // 727 // - "AppSwitch": Behaves as the "Overview" button in android. 728 // - "GoBack": The Back button. 729 // - "GoHome": The Home button, which takes the user to the phone's main 730 // screen (usually an application launcher). 731 // - "Power": The Power button. 732 string key = 4; 733 734 // Series of utf8 encoded characters to send to the emulator. An attempt 735 // will be made to translate every character will an EvDev event type and 736 // send to the emulator as a keypress event. The values in keyCode, 737 // eventType, codeType and key will be ignored. 738 // 739 // Note that most printable ASCII characters (range [32-127) can be send 740 // individually with the "key" param. Do not expect arbitrary UTF symbols to 741 // arrive in the emulator (most will be ignored). 742 // 743 // Note that it is possible to overrun the keyboard buffer by slamming this 744 // endpoint with large quantities of text (>1kb). The clipboard api is better 745 // suited for transferring large quantities of text. 746 string text = 5; 747} 748 749message Fingerprint { 750 // True when the fingprint is touched. 751 bool isTouching = 1; 752 753 // The identifier of the registered fingerprint. 754 int32 touchId = 2; 755} 756 757message GpsState { 758 // Setting this to false will disable auto updating from the LocationUI, 759 // otherwise the location UI will override the location at a frequency of 1hz. 760 // 761 // - This is unused if the emulator is launched with -no-window, or when he 762 // location ui is disabled. 763 // - This will BREAK the location ui experience if it is set to false. For 764 // example routing will no longer function. 765 bool passiveUpdate = 1; 766 767 // The latitude, in degrees. 768 double latitude = 2; 769 770 // The longitude, in degrees. 771 double longitude = 3; 772 773 // The speed if it is available, in meters/second over ground 774 double speed = 4; 775 776 // gets the horizontal direction of travel of this device, and is not 777 // related to the device orientation. It is guaranteed to be in the 778 // range [0.0, 360.0] if the device has a bearing. 0=North, 90=East, 779 // 180=South, etc.. 780 double bearing = 5; 781 782 // The altitude if available, in meters above the WGS 84 reference 783 // ellipsoid. 784 double altitude = 6; 785 786 // The number of satellites used to derive the fix 787 int32 satellites = 7; 788} 789 790message BatteryState { 791 enum BatteryStatus { 792 UNKNOWN = 0; 793 CHARGING = 1; 794 DISCHARGING = 2; 795 NOT_CHARGING = 3; 796 FULL = 4; 797 } 798 799 enum BatteryCharger { 800 NONE = 0; 801 AC = 1; 802 USB = 2; 803 WIRELESS = 3; 804 } 805 806 enum BatteryHealth { 807 GOOD = 0; 808 FAILED = 1; 809 DEAD = 2; 810 OVERVOLTAGE = 3; 811 OVERHEATED = 4; 812 } 813 814 bool hasBattery = 1; 815 bool isPresent = 2; 816 BatteryCharger charger = 3; 817 int32 chargeLevel = 4; 818 BatteryHealth health = 5; 819 BatteryStatus status = 6; 820} 821 822// An ImageTransport allows for specifying a side channel for 823// delivering image frames versus using the standard bytes array that is 824// returned with the gRPC request. 825message ImageTransport { 826 enum TransportChannel { 827 // Return full frames over the gRPC transport 828 TRANSPORT_CHANNEL_UNSPECIFIED = 0; 829 830 // Write images to the a file/shared memory handle. 831 MMAP = 1; 832 } 833 834 // The desired transport channel used for delivering image frames. Only 835 // relevant when streaming screenshots. 836 TransportChannel channel = 1; 837 838 // Handle used for writing image frames if transport is mmap. The client sets 839 // and owns this handle. It can be either a shm region, or a mmap. A mmap 840 // should be a url that starts with `file:///` 841 // Note: the mmap can result in tearing. 842 string handle = 2; 843} 844 845// The aspect ratio (width/height) will be different from the one 846// where the device is unfolded. 847message FoldedDisplay { 848 uint32 width = 1; 849 uint32 height = 2; 850 // It is possible for the screen to be folded in different ways depending 851 // on which surface is shown to the user. So xOffset and yOffset indicate 852 // the top left corner of the folded screen within the original unfolded screen. 853 uint32 xOffset = 3; 854 uint32 yOffset = 4; 855} 856 857message ImageFormat { 858 enum ImgFormat { 859 // Portable Network Graphics format 860 // (https://en.wikipedia.org/wiki/Portable_Network_Graphics) 861 PNG = 0; 862 863 // Three-channel RGB color model supplemented with a fourth alpha 864 // channel. https://en.wikipedia.org/wiki/RGBA_color_model 865 // Each pixel consists of 4 bytes. 866 RGBA8888 = 1; 867 868 // Three-channel RGB color model, each pixel consists of 3 bytes 869 RGB888 = 2; 870 } 871 872 // The (desired) format of the resulting bytes. 873 ImgFormat format = 1; 874 875 // [Output Only] The rotation of the image. The image will be rotated 876 // based upon the coarse grained orientation of the device. 877 Rotation rotation = 2; 878 879 // The (desired) width of the image. When passed as input 880 // the image will be scaled to match the given 881 // width, while maintaining the aspect ratio of the device. 882 // The returned image will never exceed the given width, but can be less. 883 // Omitting this value (or passing in 0) will result in no scaling, 884 // and the width of the actual device will be used. 885 uint32 width = 3; 886 887 // The (desired) height of the image. When passed as input 888 // the image will be scaled to match the given 889 // height, while maintaining the aspect ratio of the device. 890 // The returned image will never exceed the given height, but can be less. 891 // Omitting this value (or passing in 0) will result in no scaling, 892 // and the height of the actual device will be used. 893 uint32 height = 4; 894 895 // The (desired) display id of the device. Setting this to 0 (or omitting) 896 // indicates the main display. 897 uint32 display = 5; 898 899 // Set this if you wish to use a different transport channel to deliver image 900 // frames. 901 ImageTransport transport = 6; 902 903 // [Output Only] Display configuration when screen is folded. The value is the 904 // original configuration before scaling. 905 FoldedDisplay foldedDisplay = 7; 906 907 // [Output Only] Display mode when AVD is resizable. 908 DisplayModeValue displayMode = 8; 909} 910 911message Image { 912 ImageFormat format = 1; 913 914 uint32 width = 2 [ deprecated = true ]; // width is contained in format. 915 uint32 height = 3 [ deprecated = true ]; // height is contained in format. 916 917 // The organization of the pixels in the image buffer is from left to 918 // right and bottom up. This will be empty if an alternative image transport 919 // is requested in the image format. In that case the side channel should 920 // be used to obtain the image data. 921 bytes image = 4; 922 923 // [Output Only] Monotonically increasing sequence number in a stream of 924 // screenshots. The first screenshot will have a sequence of 0. A single 925 // screenshot will always have a sequence number of 0. The sequence is not 926 // necessarily contiguous, and can be used to detect how many frames were 927 // dropped. An example sequence could be: [0, 3, 5, 7, 9, 11]. 928 uint32 seq = 5; 929 930 // [Output Only] Unix timestamp in microseconds when the emulator estimates 931 // the frame was generated. The timestamp is before the actual frame is 932 // copied and transformed. This can be used to calculate variance between 933 // frame production time, and frame depiction time. 934 uint64 timestampUs = 6; 935} 936 937message Rotation { 938 enum SkinRotation { 939 PORTRAIT = 0; // 0 degrees 940 LANDSCAPE = 1; // 90 degrees 941 REVERSE_PORTRAIT = 2; // -180 degrees 942 REVERSE_LANDSCAPE = 3; // -90 degrees 943 } 944 945 // The rotation of the device, derived from the sensor state 946 // of the emulator. The derivation reflects how android observes 947 // the rotation state. 948 SkinRotation rotation = 1; 949 950 // Specifies the angle of rotation, in degrees [-180, 180] 951 double xAxis = 2; 952 double yAxis = 3; 953 double zAxis = 4; 954} 955 956message PhoneCall { 957 enum Operation { 958 InitCall = 0; 959 AcceptCall = 1; 960 RejectCallExplicit = 2; 961 RejectCallBusy = 3; 962 DisconnectCall = 4; 963 PlaceCallOnHold = 5; 964 TakeCallOffHold = 6; 965 } 966 Operation operation = 1; 967 string number = 2; 968} 969 970message PhoneResponse { 971 enum Response { 972 OK = 0; 973 BadOperation = 1; // Enum out of range 974 BadNumber = 2; // Mal-formed telephone number 975 InvalidAction = 3; // E.g., disconnect when no call is in progress 976 ActionFailed = 4; // Internal error 977 RadioOff = 5; // Radio power off 978 } 979 Response response = 1; 980} 981 982message Entry { 983 string key = 1; 984 string value = 2; 985} 986 987message EntryList { repeated Entry entry = 1; } 988 989message EmulatorStatus { 990 // The emulator version string. 991 string version = 1; 992 993 // The time the emulator has been active in .ms 994 uint64 uptime = 2; 995 996 // True if the device has completed booting. 997 // For P and later this information will accurate, 998 // for older images we rely on adb. 999 bool booted = 3; 1000 1001 // The current vm configuration 1002 VmConfiguration vmConfig = 4; 1003 1004 // The hardware configuration of the running emulator as 1005 // key valure pairs. 1006 EntryList hardwareConfig = 5; 1007} 1008 1009message AudioFormat { 1010 enum SampleFormat { 1011 AUD_FMT_U8 = 0; // Unsigned 8 bit 1012 AUD_FMT_S16 = 1; // Signed 16 bit (little endian) 1013 } 1014 1015 enum Channels { 1016 Mono = 0; 1017 Stereo = 1; 1018 } 1019 1020 enum DeliveryMode { 1021 // The audio queue will block and wait until the emulator requests packets. 1022 // The client does not have to throttle and can push packets at will. 1023 // This can result in the client falling behind. 1024 MODE_UNSPECIFIED = 0; 1025 // Audio packets will be delivered in real time (when possible). The audio queue 1026 // will be overwritten with incoming data if data is made available. 1027 // This means the client needs to control timing properly, or packets will get 1028 // overwritten. 1029 MODE_REAL_TIME = 1; // 1030 } 1031 // Sampling rate to use, defaulting to 44100 if this is not set. 1032 // Note, that android devices typically will not use a sampling 1033 // rate higher than 48kHz. See https://developer.android.com/ndk/guides/audio. 1034 uint64 samplingRate = 1; 1035 Channels channels = 2; 1036 SampleFormat format = 3; 1037 1038 // [Input Only] 1039 // The mode used when delivering audio packets. 1040 DeliveryMode mode = 4; 1041} 1042 1043message AudioPacket { 1044 AudioFormat format = 1; 1045 1046 // Unix epoch in us when this frame was captured. 1047 uint64 timestamp = 2; 1048 1049 // Contains a sample in the given audio format. 1050 bytes audio = 3; 1051} 1052 1053message SmsMessage { 1054 // The source address where this message came from. 1055 // 1056 // The address should be a valid GSM-formatted address as specified by 1057 // 3GPP 23.040 Sec 9.1.2.5. 1058 // 1059 // For example: +3106225412 or (650) 555-1221 1060 string srcAddress = 1; 1061 1062 // A utf8 encoded text message that should be delivered. 1063 string text = 2; 1064} 1065 1066// A DisplayConfiguration describes a primary or secondary 1067// display available to the emulator. The screen aspect ratio 1068// cannot be longer (or wider) than 21:9 (or 9:21). Screen sizes 1069// larger than 4k will be rejected. 1070// 1071// Common configurations (w x h) are: 1072// - 480p (480x720) 142 dpi 1073// - 720p (720x1280) 213 dpi 1074// - 1080p (1080x1920) 320 dpi 1075// - 4K (2160x3840) 320 dpi 1076// - 4K (2160x3840) 640 dpi (upscaled) 1077// 1078// The behavior of the virtual display depends on the flags that are provided to 1079// this method. By default, virtual displays are created to be private, 1080// non-presentation and unsecure. 1081message DisplayConfiguration { 1082 1083 // These are the set of known android flags and their respective values. 1084 // you can combine the int values to (de)construct the flags field below. 1085 enum DisplayFlags { 1086 DISPLAYFLAGS_UNSPECIFIED = 0; 1087 1088 // When this flag is set, the virtual display is public. 1089 // A public virtual display behaves just like most any other display 1090 // that is connected to the system such as an external or wireless 1091 // display. Applications can open windows on the display and the system 1092 // may mirror the contents of other displays onto it. see: 1093 // https://developer.android.com/reference/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PUBLIC 1094 VIRTUAL_DISPLAY_FLAG_PUBLIC = 1; 1095 1096 // When this flag is set, the virtual display is registered as a 1097 // presentation display in the presentation display category. 1098 // Applications may automatically project their content to presentation 1099 // displays to provide richer second screen experiences. 1100 // https://developer.android.com/reference/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_PRESENTATION 1101 VIRTUAL_DISPLAY_FLAG_PRESENTATION = 2; 1102 1103 // When this flag is set, the virtual display is considered secure as 1104 // defined by the Display#FLAG_SECURE display flag. The caller promises 1105 // to take reasonable measures, such as over-the-air encryption, to 1106 // prevent the contents of the display from being intercepted or 1107 // recorded on a persistent medium. 1108 // see: 1109 // https://developer.android.com/reference/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_SECURE 1110 VIRTUAL_DISPLAY_FLAG_SECURE = 4; 1111 1112 // This flag is used in conjunction with VIRTUAL_DISPLAY_FLAG_PUBLIC. 1113 // Ordinarily public virtual displays will automatically mirror the 1114 // content of the default display if they have no windows of their own. 1115 // When this flag is specified, the virtual display will only ever show 1116 // its own content and will be blanked instead if it has no windows. See 1117 // https://developer.android.com/reference/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY 1118 VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY = 8; 1119 1120 // Allows content to be mirrored on private displays when no content is 1121 // being shown. 1122 // This flag is mutually exclusive with 1123 // VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY. If both flags are specified 1124 // then the own-content only behavior will be applied. 1125 // see: 1126 // https://developer.android.com/reference/android/hardware/display/DisplayManager#VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR) 1127 VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR = 16; 1128 } 1129 1130 // The width of the display, restricted to: 1131 // 320 * (dpi / 160) <= width 1132 uint32 width = 1; 1133 1134 // The heigh of the display, restricted to: 1135 // * 320 * (dpi / 160) <= height 1136 uint32 height = 2; 1137 1138 // The pixel density (dpi). 1139 // See https://developer.android.com/training/multiscreen/screendensities 1140 // for details. This value should be in the range [120, ..., 640] 1141 uint32 dpi = 3; 1142 1143 // A combination of virtual display flags. These flags can be constructed 1144 // by combining the DisplayFlags enum described above. 1145 // 1146 // The behavior of the virtual display depends on the flags. By default 1147 // virtual displays are created to be private, non-presentation and 1148 // unsecure. 1149 uint32 flags = 4; 1150 1151 // The id of the display. 1152 // The primary (default) display has the display ID of 0. 1153 // A secondary display has a display ID not 0. 1154 // 1155 // A display with the id in the range [1, userConfigurable] 1156 // can be modified. See DisplayConfigurations below for details. 1157 // 1158 // The id can be used to get or stream a screenshot. 1159 uint32 display = 5; 1160} 1161// Provides information about all the displays that can be attached 1162// to the emulator. The emulator will always have at least one display. 1163// 1164// The emulator usually has the following display configurations: 1165// 0: The default display. 1166// 1 - 3: User configurable displays. These can be added/removed. 1167// For example the standalone emulator allows you to modify these 1168// in the extended controls. 1169// 6 - 11: Fixed external displays. For example Android Auto uses fixed 1170// displays in this range. 1171message DisplayConfigurations { 1172 repeated DisplayConfiguration displays = 1; 1173 1174 // Display configurations with id [1, userConfigurable] are 1175 // user configurable, that is they can be added, removed or 1176 // updated. 1177 uint32 userConfigurable = 2; 1178 1179 // The maximum number of attached displays this emulator supports. 1180 // This is the total number of displays that can be attached to 1181 // the emulator. 1182 // 1183 // Note: A display with an id that is larger than userConfigurable cannot 1184 // be modified. 1185 uint32 maxDisplays = 3; 1186} 1187 1188message Notification { 1189 enum EventType { 1190 VIRTUAL_SCENE_CAMERA_INACTIVE = 0; 1191 VIRTUAL_SCENE_CAMERA_ACTIVE = 1; 1192 1193 // Fired when an update to a display event has been fired through 1194 // the extended ui. This does not fire events when the display 1195 // is changed through the console or gRPC endpoint. 1196 DISPLAY_CONFIGURATIONS_CHANGED_UI = 2; 1197 // Keep adding more for other event types 1198 } 1199 1200 EventType event = 1; 1201} 1202 1203message RotationRadian { 1204 float x = 1; // x axis is horizontal and orthogonal to the view direction. 1205 float y = 2; // y axis points up and is perpendicular to the floor. 1206 float z = 3; // z axis is the view direction and is set to 0.0 in 1207 // rotateVirtualSceneCamera call. 1208} 1209 1210message Velocity { 1211 float x = 1; // x axis is horizontal and orthogonal to the view direction. 1212 float y = 2; // y axis points up and is perpendicular to the floor. 1213 float z = 3; // z axis is the view direction 1214} 1215 1216// must follow the definition in "external/qemu/android/hw-sensors.h" 1217message Posture { 1218 enum PostureValue { 1219 POSTURE_UNKNOWN = 0; 1220 POSTURE_CLOSED = 1; 1221 POSTURE_HALF_OPENED = 2; 1222 POSTURE_OPENED = 3; 1223 POSTURE_FLIPPED = 4; 1224 POSTURE_TENT = 5; 1225 POSTURE_MAX = 6; 1226 } 1227 PostureValue value = 3; 1228} 1229