Skip to main content

EmulatorControllerClient

Struct EmulatorControllerClient 

Source
pub struct EmulatorControllerClient<T> { /* private fields */ }
Expand description

An EmulatorController service lets you control the emulator. Note that this is currently an experimental feature, and that the service definition might change without notice. Use at your own risk!

We use the following rough conventions:

streamXXX –> streams values XXX (usually for emulator lifetime). Values are updated as soon as they become available. getXXX –> gets a single value XXX setXXX –> sets a single value XXX, does not returning state, these usually have an observable lasting side effect. sendXXX –> send a single event XXX, possibly returning state information. android usually responds to these events.

Implementations§

Source§

impl EmulatorControllerClient<Channel>

Source

pub async fn connect<D>(dst: D) -> Result<Self, Error>
where D: TryInto<Endpoint>, D::Error: Into<StdError>,

Attempt to create a new client by connecting to a given endpoint.

Source§

impl<T> EmulatorControllerClient<T>
where T: GrpcService<Body>, T::Error: Into<StdError>, T::ResponseBody: Body<Data = Bytes> + Send + 'static, <T::ResponseBody as Body>::Error: Into<StdError> + Send,

Source

pub fn new(inner: T) -> Self

Source

pub fn with_origin(inner: T, origin: Uri) -> Self

Source

pub fn with_interceptor<F>( inner: T, interceptor: F, ) -> EmulatorControllerClient<InterceptedService<T, F>>
where F: Interceptor, T::ResponseBody: Default, T: Service<Request<Body>, Response = Response<<T as GrpcService<Body>>::ResponseBody>>, <T as Service<Request<Body>>>::Error: Into<StdError> + Send + Sync,

Source

pub fn send_compressed(self, encoding: CompressionEncoding) -> Self

Compress requests with the given encoding.

This requires the server to support it otherwise it might respond with an error.

Source

pub fn accept_compressed(self, encoding: CompressionEncoding) -> Self

Enable decompressing responses.

Source

pub fn max_decoding_message_size(self, limit: usize) -> Self

Limits the maximum size of a decoded message.

Default: 4MB

Source

pub fn max_encoding_message_size(self, limit: usize) -> Self

Limits the maximum size of an encoded message.

Default: usize::MAX

Source

pub async fn stream_sensor( &mut self, request: impl IntoRequest<SensorValue>, ) -> Result<Response<Streaming<SensorValue>>, Status>

set/get/stream the sensor data

Source

pub async fn get_sensor( &mut self, request: impl IntoRequest<SensorValue>, ) -> Result<Response<SensorValue>, Status>

Source

pub async fn set_sensor( &mut self, request: impl IntoRequest<SensorValue>, ) -> Result<Response<()>, Status>

Source

pub async fn set_physical_model( &mut self, request: impl IntoRequest<PhysicalModelValue>, ) -> Result<Response<()>, Status>

set/get/stream the physical model, this is likely the one you are looking for when you wish to modify the device state.

Source

pub async fn get_physical_model( &mut self, request: impl IntoRequest<PhysicalModelValue>, ) -> Result<Response<PhysicalModelValue>, Status>

Source

pub async fn stream_physical_model( &mut self, request: impl IntoRequest<PhysicalModelValue>, ) -> Result<Response<Streaming<PhysicalModelValue>>, Status>

Source

pub async fn set_clipboard( &mut self, request: impl IntoRequest<ClipData>, ) -> Result<Response<()>, Status>

Atomically set/get the current primary clipboard data. Note that a call to setClipboard will result in an immediate event for those who made a call to streamClipboard and are on a different channel than the one used to set the clipboard.

Source

pub async fn get_clipboard( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<ClipData>, Status>

Source

pub async fn stream_clipboard( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<Streaming<ClipData>>, Status>

Streams the current data on the clipboard. This will immediately produce a result with the current state of the clipboard after which the stream will block and wait until a new clip event is available from the guest. Calling the setClipboard method above will not result in generating a clip event. It is possible to lose clipboard events if the clipboard updates very rapidly.

Source

pub async fn set_battery( &mut self, request: impl IntoRequest<BatteryState>, ) -> Result<Response<()>, Status>

Set/get the battery to the given state.

Source

pub async fn get_battery( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<BatteryState>, Status>

Source

pub async fn set_gps( &mut self, request: impl IntoRequest<GpsState>, ) -> Result<Response<()>, Status>

Set the state of the gps. Note: Setting the gps position will not be reflected in the user interface. Keep in mind that android usually only samples the gps at 1 hz.

Source

pub async fn get_gps( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<GpsState>, Status>

Gets the latest gps state as delivered by the setGps call, or location ui if active.

Note: this is not necessarily the actual gps coordinate visible at the time, due to gps sample frequency (usually 1hz).

Source

pub async fn send_fingerprint( &mut self, request: impl IntoRequest<Fingerprint>, ) -> Result<Response<()>, Status>

Simulate a touch event on the finger print sensor.

Source

pub async fn send_key( &mut self, request: impl IntoRequest<KeyboardEvent>, ) -> Result<Response<()>, Status>

Send a keyboard event. Translating the event.

Source

pub async fn send_touch( &mut self, request: impl IntoRequest<TouchEvent>, ) -> Result<Response<()>, Status>

Send touch/mouse events. Note that mouse events can be simulated by touch events.

Source

pub async fn send_mouse( &mut self, request: impl IntoRequest<MouseEvent>, ) -> Result<Response<()>, Status>

Source

pub async fn inject_wheel( &mut self, request: impl IntoStreamingRequest<Message = WheelEvent>, ) -> Result<Response<()>, Status>

Source

pub async fn stream_input_event( &mut self, request: impl IntoStreamingRequest<Message = InputEvent>, ) -> Result<Response<()>, Status>

Stream a series of input events to the emulator, the events will arrive in order.

Source

pub async fn send_phone( &mut self, request: impl IntoRequest<PhoneCall>, ) -> Result<Response<PhoneResponse>, Status>

Make a phone call.

Source

pub async fn send_sms( &mut self, request: impl IntoRequest<SmsMessage>, ) -> Result<Response<PhoneResponse>, Status>

Sends an sms message to the emulator.

Source

pub async fn set_phone_number( &mut self, request: impl IntoRequest<PhoneNumber>, ) -> Result<Response<PhoneResponse>, Status>

Sends an sms message to the emulator.

Source

pub async fn get_status( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<EmulatorStatus>, Status>

Retrieve the status of the emulator. This will contain general hardware information, and whether the device has booted or not.

Source

pub async fn get_screenshot( &mut self, request: impl IntoRequest<ImageFormat>, ) -> Result<Response<Image>, Status>

Gets an individual screenshot in the desired format.

The image will be scaled to the desired ImageFormat, while maintaining the aspect ratio. The returned image will never exceed resolution of the device display. Not setting the width or height (i.e. they are 0) will result in using the display width and height.

The resulting image will be properly oriented and can be displayed directly without post processing. For example, if the device has a 1080x1920 screen and is in landscape mode and called with no width or height parameter, it will return a 1920x1080 image.

The dimensions of the returned image will never exceed the corresponding display dimensions. For example, this method will return a 1920x1080 screenshot, if the display resolution is 1080x1920 and a screenshot of 2048x2048 is requested when the device is in landscape mode.

This method will return an empty image if the display is not visible.

Source

pub async fn stream_screenshot( &mut self, request: impl IntoRequest<ImageFormat>, ) -> Result<Response<Streaming<Image>>, Status>

Streams a series of screenshots in the desired format.

A new frame will be delivered whenever the device produces a new frame. Beware that this can produce a significant amount of data and that certain translations can be very costly. For example, streaming a series of png images is very cpu intensive.

Images are produced according to the getScreenshot API described above.

If the display is inactive, or becomes inactive, an empty image will be delivered. Images will be delived again if the display becomes active and new frames are produced.

Source

pub async fn stream_audio( &mut self, request: impl IntoRequest<AudioFormat>, ) -> Result<Response<Streaming<AudioPacket>>, Status>

Streams a series of audio packets in the desired format. A new frame will be delivered whenever the emulated device produces a new audio frame. You can expect packets to be delivered in intervals of 20-30ms.

Be aware that this can block when the emulator does not produce any audio whatsoever!

Source

pub async fn inject_audio( &mut self, request: impl IntoStreamingRequest<Message = AudioPacket>, ) -> Result<Response<()>, Status>

Injects a series of audio packets to the android microphone. A new frame will be delivered whenever the emulated device requests a new audio frame. Audio is usually delivered at a rate that the emulator is requesting frames. Audio will be stored in a temporary buffer that can hold 300ms of audio.

Notes:

  • Only the first audio format packet that is delivered will be honored. There is no need to send the audio format multiple times.

  • Real time audio currently immediately overrides the buffer. This means you must provide a constant rate of audio packets. The real time mode is experimental. Timestamps of audio packets might be used in the future to improve synchronization.

  • INVALID_ARGUMENT (code 3) The sampling rate was too high/low

  • INVALID_ARGUMENT (code 3) The audio packet was too large to handle.

  • FAILED_PRECONDITION (code 9) If there was a microphone registered already.

Source

pub async fn get_logcat( &mut self, request: impl IntoRequest<LogMessage>, ) -> Result<Response<LogMessage>, Status>

👎Deprecated

Deprecated, please use the streamLogcat method instead.

Source

pub async fn stream_logcat( &mut self, request: impl IntoRequest<LogMessage>, ) -> Result<Response<Streaming<LogMessage>>, Status>

Streams the logcat output from the emulator. Note that parsed logcat messages are only available after L (Api >23)

Source

pub async fn set_vm_state( &mut self, request: impl IntoRequest<VmRunState>, ) -> Result<Response<()>, Status>

Transition the virtual machine to the desired state. Note that some states are only observable. For example you cannot transition to the error state.

Source

pub async fn get_vm_state( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<VmRunState>, Status>

Gets the state of the virtual machine.

Source

pub async fn set_display_configurations( &mut self, request: impl IntoRequest<DisplayConfigurations>, ) -> Result<Response<DisplayConfigurations>, Status>

Atomically changes the current multi-display configuration. After this call the given display configurations will be activated. You can only update secondary displays. Displays with id 0 will be ignored.

This call can result in the removal or addition of secondary displays, the final display state can be observed by the returned configuration.

The following gRPC error codes can be returned:

  • FAILED_PRECONDITION (code 9) if the AVD does not support a configurable secondary display.
  • INVALID_ARGUMENT (code 3) if:
  • The same display id is defined multiple times.
  • The display configurations are outside valid ranges. See DisplayConfiguration for details on valid ranges.
  • INTERNAL (code 13) if there was an internal emulator failure.
Source

pub async fn get_display_configurations( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<DisplayConfigurations>, Status>

Returns all currently valid logical displays.

The gRPC error code FAILED_PRECONDITION (code 9) is returned if the AVD does not support a configurable secondary display.

Source

pub async fn stream_notification( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<Streaming<Notification>>, Status>

Notifies client of the following changes:

  • Virtual scene camera status change.
  • Display configuration changes from extended ui. This will only be fired if the user makes modifications the extended displays through the extended control tab.

Note that this method will send the initial virtual scene state immediately.

Source

pub async fn rotate_virtual_scene_camera( &mut self, request: impl IntoRequest<RotationRadian>, ) -> Result<Response<()>, Status>

Rotation angles are relative to the camera’s current orientation. The coordinate system is right-handed and is defined as follows: x axis is pointing right y axis is pointing up z axis is pointing towards the viewer The z component of rotation is not used when calling this method.

Source

pub async fn set_virtual_scene_camera_velocity( &mut self, request: impl IntoRequest<Velocity>, ) -> Result<Response<()>, Status>

Velocity is absolute and is measured in meters per second. The coordinate system is right-handed and is defined as follows: x axis is pointing right y axis is pointing up z axis is pointing towards the viewer

Source

pub async fn set_posture( &mut self, request: impl IntoRequest<Posture>, ) -> Result<Response<()>, Status>

Set foldable posture

Source

pub async fn get_brightness( &mut self, request: impl IntoRequest<BrightnessValue>, ) -> Result<Response<BrightnessValue>, Status>

Get the backlight brightness. The following gRPC error codes can be returned:

  • FAILED_PRECONDITION (code 9) if the AVD does not support hw-control.
Source

pub async fn set_brightness( &mut self, request: impl IntoRequest<BrightnessValue>, ) -> Result<Response<()>, Status>

Set the backlight brightness. The following gRPC error codes can be returned:

  • FAILED_PRECONDITION (code 9) if the AVD does not support hw-control.
  • INVALID_ARGUMENT (code 3) The brightness exceeds the valid range.
Source

pub async fn get_display_mode( &mut self, request: impl IntoRequest<()>, ) -> Result<Response<DisplayMode>, Status>

Returns the current mode of the primary display of a resizable AVD. The following gRPC error codes can be returned:

  • FAILED_PRECONDITION (code 9) if the AVD is not resizable.
Source

pub async fn set_display_mode( &mut self, request: impl IntoRequest<DisplayMode>, ) -> Result<Response<()>, Status>

Sets the size of the primary display of a resizable AVD. Fails if the AVD is not resizable. The following gRPC error codes can be returned:

  • FAILED_PRECONDITION (code 9) if the AVD is not resizable.

Trait Implementations§

Source§

impl<T: Clone> Clone for EmulatorControllerClient<T>

Source§

fn clone(&self) -> EmulatorControllerClient<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for EmulatorControllerClient<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more