pub struct EmulatorConfig { /* private fields */ }Expand description
Configuration for starting an Android emulator
Implementations§
Source§impl EmulatorConfig
impl EmulatorConfig
Sourcepub fn with_grpc_auth(self, auth: GrpcAuthConfig) -> Self
pub fn with_grpc_auth(self, auth: GrpcAuthConfig) -> Self
Configure gRPC authentication
§Examples
No authentication:
use android_emulator::{EmulatorConfig, GrpcAuthConfig};
let config = EmulatorConfig::new("test")
.with_grpc_auth(GrpcAuthConfig::None);Basic authentication (console token as bearer):
use android_emulator::{EmulatorConfig, GrpcAuthConfig};
let config = EmulatorConfig::new("test")
.with_grpc_auth(GrpcAuthConfig::Basic)
.with_grpc_port(8554);JWT mode with custom issuer:
use android_emulator::{EmulatorConfig, GrpcAuthConfig};
let config = EmulatorConfig::new("test")
.with_grpc_auth(GrpcAuthConfig::Jwt {
issuer: Some("mytool".to_string()),
})
.with_grpc_port(8555);JWT mode with auto-derived issuer and auto-selected port:
use android_emulator::{EmulatorConfig, GrpcAuthConfig};
let config = EmulatorConfig::new("test")
.with_grpc_auth(GrpcAuthConfig::Jwt {
issuer: None, // Will be "emulator-{port}"
});Sourcepub fn with_grpc_port(self, port: u16) -> Self
pub fn with_grpc_port(self, port: u16) -> Self
Set the gRPC port
If not specified, a free port will be automatically selected.
§Example
use android_emulator::EmulatorConfig;
let config = EmulatorConfig::new("test")
.with_grpc_port(8554);Sourcepub fn with_window(self, show: bool) -> Self
pub fn with_window(self, show: bool) -> Self
Configure whether to show the emulator window
Default is false (headless). Set to true to show the window.
Sourcepub fn with_snapshot_load(self, load: bool) -> Self
pub fn with_snapshot_load(self, load: bool) -> Self
Configure whether to load snapshots
Default is true (load snapshots). Set to false to disable snapshot loading on startup.
Sourcepub fn with_snapshot_save(self, save: bool) -> Self
pub fn with_snapshot_save(self, save: bool) -> Self
Configure whether to save snapshots on exit
Default is true (save snapshots). Set to false to disable snapshot saving on exit.
Sourcepub fn with_boot_animation(self, show: bool) -> Self
pub fn with_boot_animation(self, show: bool) -> Self
Configure whether to show the boot animation
Default is true (show boot animation). Set to false to disable the boot animation for faster startup.
Sourcepub fn with_acceleration(self, enable: bool) -> Self
pub fn with_acceleration(self, enable: bool) -> Self
Configure whether to disable hardware acceleration (e.g., for running in CI without KVM)
Default is false (use hardware acceleration if available). Set to true to disable hardware acceleration
Sourcepub fn with_dalvik_vm_check_jni(self, enable: bool) -> Self
pub fn with_dalvik_vm_check_jni(self, enable: bool) -> Self
Configure whether to pass -dalvik-vm-checkjni flag to the emulator
This can be useful for testing JNI-related functionality and catching errors early. Default is false (don’t check JNI). Set to true to enable JNI checking.
Sourcepub fn with_read_only(self, read_only: bool) -> Self
pub fn with_read_only(self, read_only: bool) -> Self
Configure whether to allow running multiple instances of the same AVD (without support for snapshots)
Default is false (don’t allow multiple instances). Set to true to allow multiple instances of the same AVD, but note that snapshots will not work in this mode.
Sourcepub fn with_quit_after_boot(self, duration: Option<Duration>) -> Self
pub fn with_quit_after_boot(self, duration: Option<Duration>) -> Self
Configure the emulator to automatically quit after it has booted and been idle for the specified duration (for testing purposes)
This can be useful for testing emulator startup and shutdown in CI environments.
Default is None (don’t quit automatically). Set to Some(duration) to enable this behavior.
pub fn with_extra_args(self, args: Vec<String>) -> Self
Sourcepub fn with_grpc_allowlist(self, allowlist: GrpcAllowlist) -> Self
pub fn with_grpc_allowlist(self, allowlist: GrpcAllowlist) -> Self
Set a custom gRPC allowlist configuration for JWT authentication
This allows fine-grained control over which gRPC methods are accessible and under what conditions when using JWT authentication. The allowlist defines three categories of methods:
- Unprotected: Methods that can be invoked without any authentication token
- Allowed: Methods that can be called with a valid JWT token, even
without an
audclaim - Protected: Methods that require the specific method to be present
in the JWT token’s
audclaim
If you don’t specify a custom allowlist, a default one will be generated
using
GrpcAllowlist::default_for_issuer.
§Arguments
allowlist- AGrpcAllowlistconfiguration
§Example
use android_emulator::{EmulatorConfig, GrpcAuthConfig, auth::{GrpcAllowlist, AllowlistEntry}};
let allowlist = GrpcAllowlist {
unprotected: vec![], // No methods accessible without auth
allowlist: vec![
AllowlistEntry {
iss: "mytool".to_string(),
allowed: vec![
"/android.emulation.control.EmulatorController/.*".to_string(),
],
protected: vec![
"/android.emulation.control.SnapshotService/.*".to_string(),
],
},
],
};
let config = EmulatorConfig::new("test")
.with_grpc_auth(GrpcAuthConfig::Jwt {
issuer: Some("mytool".to_string()),
})
.with_grpc_allowlist(allowlist);§See Also
with_grpc_auth- For configuring authentication modeGrpcAllowlist::default_for_issuer- For the default allowlist
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EmulatorConfig
impl RefUnwindSafe for EmulatorConfig
impl Send for EmulatorConfig
impl Sync for EmulatorConfig
impl Unpin for EmulatorConfig
impl UnwindSafe for EmulatorConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request