droid_wrap::android::os

Struct SystemProperties

Source
pub struct SystemProperties { /* private fields */ }
Expand description

授予对系统属性存储的访问权限。系统属性存储包含字符串键值对列表。仅将此类用于本地系统属性。 例如,在应用、分区或模块内。对于跨边界使用的系统属性,请在 *.sysprop 文件中正式定义它们并使用自动生成的方法。有关更多信息,请参阅将系统属性实现为 API。

Implementations§

Source§

impl SystemProperties

Source

pub const PROP_NAME_MAX: i32 = 2_147_483_647i32

Android O 删除了属性名称长度限制,但 com.amazon.kindle 7.8.1.5 在每次选择文本时都会使用反射来读取该属性名称长度限制(http://b/36095274)。

Source

pub fn get(key: String) -> String

获取给定键的字符串值。 key 查找的钥匙如果找不到键,则一个空字符串

Source

pub fn get_with_default(key: String, def: String) -> String

获取给定键的字符串值。 返回:如果未找到键,则返回 def(如果它不为空),否则返回空字符串 key 要查找的键 def 如果属性未设置或为空,则返回默认值

Source

pub fn get_int(key: String, def: i32) -> i32

获取给定键的值,并以整数形式返回。 返回:解析为整数的键,如果未找到或无法解析键,则返回 def key 要查找的键 def 要返回的默认值

Source

pub fn get_long(key: String, def: i64) -> i64

获取给定键的值,并以长整型返回。 返回:解析为长整型的键,如果未找到或无法解析键,则返回 def key 要查找的键 def 要返回的默认值

Source

pub fn get_boolean(key: String, def: bool) -> bool

获取给定键的值,以布尔值形式返回。值“n”、“no”、“0”、“false”或“off”被视为假。值“y”、“yes”、“1”、“true”或“on”被视为真。(区分大小写)。如果键不存在或具有任何其他值,则返回默认结果。 返回:解析为布尔值的键,如果未找到键或无法解析为布尔值,则返回 def。 key 要查找的键 def 要返回的默认值

Source

pub fn set(key: String, val: Option<String>)

将给定键的值设置为 val。 抛出: IllegalArgumentException – 对于非只读属性,如果 val 超过 91 个字符 RuntimeException – 如果无法设置该属性,例如,如果它被 SELinux 阻止。libc 将记录根本原因。 key 要设置的key。 val 要设置的值。

Source

pub fn add_change_callback<R: Runnable>(callback: &R)

添加一个回调,该回调将在系统属性发生任何变化时运行。 callback 系统属性发生改变时应执行的 Runnable。

Source

pub fn remove_change_callback<R: Runnable>(callback: &R)

删除目标回调。 callback 应删除的 Runnable。

Source

pub fn report_sysprop_changed()

通知侦听器系统属性已发生改变

Source

pub fn find(name: String) -> Option<SystemProperties_Handle>

按名称查找属性位置。 返回:属性句柄,如果未设置属性,则返回 null name 属性的名称

Methods from Deref<Target = GlobalRef>§

Source

pub fn as_obj(&self) -> &JObject<'static>

Get the object from the global ref

This borrows the ref and prevents it from being dropped as long as the JObject sticks around.

Methods from Deref<Target = JObject<'static>>§

Source

pub fn as_raw(&self) -> *mut _jobject

Returns the raw JNI pointer.

Trait Implementations§

Source§

impl Debug for SystemProperties

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for SystemProperties

Source§

type Target = GlobalRef

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl From<&GlobalRef> for SystemProperties

Source§

fn from(obj: &GlobalRef) -> Self

Converts to this type from the input type.
Source§

impl Into<GlobalRef> for &SystemProperties

Source§

fn into(self) -> GlobalRef

Converts this type into the (usually inferred) input type.
Source§

impl JObjNew for SystemProperties

Source§

type Fields = ()

字段类型
Source§

fn _new(this: &GlobalRef, fields: Self::Fields) -> Self

从java对象创建本地对象。 this java对象引用。
Source§

fn null() -> Self
where Self: Sized, Self::Fields: Default,

创建空对象。
Source§

impl JObjRef for SystemProperties

Source§

fn java_ref(&self) -> GlobalRef

获取java对象引用。
Source§

impl JType for SystemProperties

Source§

const CLASS: &'static str = "android/os/SystemProperties"

java类的名称。
Source§

const OBJECT_SIG: &'static str = "Landroid/os/SystemProperties;"

对象的签名描述。
Source§

type Error = Error

错误类型。
Source§

const DIM: u8 = 0u8

数组维度,0表示不是数组
Source§

impl PartialEq for SystemProperties

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToString for SystemProperties

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.