pub struct DeviceInfo { /* private fields */ }
Expand description
Corresponds to android.hardware.usb.UsbDevice
.
Its fields and the InterfaceInfo
list are read on creation and will not
be updated automatically; however, PartialEq
depends on these fields.
Implementations§
Source§impl DeviceInfo
impl DeviceInfo
Sourcepub fn has_permission(&self) -> Result<bool, Error>
pub fn has_permission(&self) -> Result<bool, Error>
Returns true if the caller has permission to access the device.
Sourcepub fn check_connection(&self) -> bool
pub fn check_connection(&self) -> bool
Checks if the device is still in the list of connected devices. Note: The implementation can be optimized.
Sourcepub fn request_permission(&self) -> Result<Option<PermissionRequest>, Error>
pub fn request_permission(&self) -> Result<Option<PermissionRequest>, Error>
Performs a permission request for the device.
Returns Ok(None)
if the permission is already granted. Otherwise it returns a
PermissionRequest
handler.
The activity might be paused by requestPermission()
here, but resumed on receving result.
The state of PermissionRequest
can be checked on android_activity::MainEvent::Resume
,
Otherwise block in a background thread (it wouldn’t be paused/resumed automatically).
Sourcepub fn open_device(&self) -> Result<Device, Error>
pub fn open_device(&self) -> Result<Device, Error>
Opens the device. Returns error PermissionDenied
if the permission is not granted.
Source§impl DeviceInfo
impl DeviceInfo
Source§impl DeviceInfo
impl DeviceInfo
Sourcepub fn manufacturer_string(&self) -> &Option<String>
pub fn manufacturer_string(&self) -> &Option<String>
Vendor name.
Sourcepub fn product_string(&self) -> &Option<String>
pub fn product_string(&self) -> &Option<String>
Product name.
Sourcepub fn serial_number(&self) -> &Option<String>
pub fn serial_number(&self) -> &Option<String>
Device serial ID string. FIXME: On Android 10 and above, this is always None
if this struct is created before gaining permission for the device. To read it,
call list_devices()
and find the device again after the permission is granted.
Source§impl DeviceInfo
impl DeviceInfo
Sourcepub fn interfaces(&self) -> impl Iterator<Item = &InterfaceInfo>
pub fn interfaces(&self) -> impl Iterator<Item = &InterfaceInfo>
Iterator over the device’s interfaces.
Trait Implementations§
Source§impl Clone for DeviceInfo
impl Clone for DeviceInfo
Source§fn clone(&self) -> DeviceInfo
fn clone(&self) -> DeviceInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more