1 //! Autogenerated system property accessors.
2 //!
3 //! This is an autogenerated module. The module contains methods for typed access to
4 //! Android system properties.
5
6 // Generated by the sysprop generator. DO NOT EDIT!
7
8 use std::fmt;
9 use rustutils::system_properties::{self, error::SysPropError, parsers_formatters};
10
11 /// Returns the value of the property 'persist.nfc.debug_enabled' if set.
debug_enabled() -> std::result::Result<Option<bool>, SysPropError>12 pub fn debug_enabled() -> std::result::Result<Option<bool>, SysPropError> {
13 let result = match system_properties::read("persist.nfc.debug_enabled") {
14 Err(e) => Err(SysPropError::FetchError(e)),
15 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
16 Ok(None) => Ok(None),
17 };
18 result
19 }
20
21 /// Sets the value of the property 'persist.nfc.debug_enabled', returns 'Ok' if successful.
set_debug_enabled(v: bool) -> std::result::Result<(), SysPropError>22 pub fn set_debug_enabled(v: bool) -> std::result::Result<(), SysPropError> {
23 let value = parsers_formatters::format_bool(&v);
24 system_properties::write("persist.nfc.debug_enabled", value.as_str()).map_err(SysPropError::SetError)
25 }
26
27 #[allow(missing_docs)]
28 #[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Hash, Ord)]
29 pub enum SnoopLogModeValues {
30 Full,
31 Filtered,
32 }
33
34 impl std::str::FromStr for SnoopLogModeValues {
35 type Err = String;
36
from_str(s: &str) -> std::result::Result<Self, Self::Err>37 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
38 match s {
39 "full" => Ok(SnoopLogModeValues::Full),
40 "filtered" => Ok(SnoopLogModeValues::Filtered),
41 _ => Err(format!("'{}' cannot be parsed for SnoopLogModeValues", s)),
42 }
43 }
44 }
45
46 impl fmt::Display for SnoopLogModeValues {
fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result47 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
48 match self {
49 SnoopLogModeValues::Full => write!(f, "full"),
50 SnoopLogModeValues::Filtered => write!(f, "filtered"),
51 }
52 }
53 }
54
55 /// Returns the value of the property 'persist.nfc.snoop_log_mode' if set.
snoop_log_mode() -> std::result::Result<Option<SnoopLogModeValues>, SysPropError>56 pub fn snoop_log_mode() -> std::result::Result<Option<SnoopLogModeValues>, SysPropError> {
57 let result = match system_properties::read("persist.nfc.snoop_log_mode") {
58 Err(e) => Err(SysPropError::FetchError(e)),
59 Ok(Some(val)) => parsers_formatters::parse(val.as_str()).map_err(SysPropError::ParseError).map(Some),
60 Ok(None) => Ok(None),
61 };
62 result
63 }
64
65 /// Sets the value of the property 'persist.nfc.snoop_log_mode', returns 'Ok' if successful.
set_snoop_log_mode(v: SnoopLogModeValues) -> std::result::Result<(), SysPropError>66 pub fn set_snoop_log_mode(v: SnoopLogModeValues) -> std::result::Result<(), SysPropError> {
67 let value = parsers_formatters::format(&v);
68 system_properties::write("persist.nfc.snoop_log_mode", value.as_str()).map_err(SysPropError::SetError)
69 }
70
71 /// Returns the value of the property 'persist.nfc.vendor_debug_enabled' if set.
vendor_debug_enabled() -> std::result::Result<Option<bool>, SysPropError>72 pub fn vendor_debug_enabled() -> std::result::Result<Option<bool>, SysPropError> {
73 let result = match system_properties::read("persist.nfc.vendor_debug_enabled") {
74 Err(e) => Err(SysPropError::FetchError(e)),
75 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
76 Ok(None) => Ok(None),
77 };
78 result
79 }
80
81 /// Sets the value of the property 'persist.nfc.vendor_debug_enabled', returns 'Ok' if successful.
set_vendor_debug_enabled(v: bool) -> std::result::Result<(), SysPropError>82 pub fn set_vendor_debug_enabled(v: bool) -> std::result::Result<(), SysPropError> {
83 let value = parsers_formatters::format_bool(&v);
84 system_properties::write("persist.nfc.vendor_debug_enabled", value.as_str()).map_err(SysPropError::SetError)
85 }
86
87 /// Returns the value of the property 'nfc.dta.skip_ndef_read' if set.
skip_ndef_read() -> std::result::Result<Option<bool>, SysPropError>88 pub fn skip_ndef_read() -> std::result::Result<Option<bool>, SysPropError> {
89 let result = match system_properties::read("nfc.dta.skip_ndef_read") {
90 Err(e) => Err(SysPropError::FetchError(e)),
91 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
92 Ok(None) => Ok(None),
93 };
94 if result.is_ok() { return result; }
95 log::debug!("Failed to fetch the original property 'nfc.dta.skip_ndef_read' ('{}'), falling back to the legacy one 'nfc.dta.skipNdefRead'.", result.unwrap_err());
96 match system_properties::read("nfc.dta.skipNdefRead") {
97 Err(e) => Err(SysPropError::FetchError(e)),
98 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
99 Ok(None) => Ok(None),
100 }
101 }
102
103 /// Returns the value of the property 'nfc.initialized' if set.
initialized() -> std::result::Result<Option<bool>, SysPropError>104 pub fn initialized() -> std::result::Result<Option<bool>, SysPropError> {
105 let result = match system_properties::read("nfc.initialized") {
106 Err(e) => Err(SysPropError::FetchError(e)),
107 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
108 Ok(None) => Ok(None),
109 };
110 result
111 }
112
113 /// Sets the value of the property 'nfc.initialized', returns 'Ok' if successful.
set_initialized(v: bool) -> std::result::Result<(), SysPropError>114 pub fn set_initialized(v: bool) -> std::result::Result<(), SysPropError> {
115 let value = parsers_formatters::format_bool(&v);
116 system_properties::write("nfc.initialized", value.as_str()).map_err(SysPropError::SetError)
117 }
118
119 /// Returns the value of the property 'ro.nfc.info.antpos.X' if set.
info_antpos_x() -> std::result::Result<Option<Vec<i32>>, SysPropError>120 pub fn info_antpos_x() -> std::result::Result<Option<Vec<i32>>, SysPropError> {
121 let result = match system_properties::read("ro.nfc.info.antpos.X") {
122 Err(e) => Err(SysPropError::FetchError(e)),
123 Ok(Some(val)) => parsers_formatters::parse_list(val.as_str()).map_err(SysPropError::ParseError).map(Some),
124 Ok(None) => Ok(None),
125 };
126 result
127 }
128
129 /// Returns the value of the property 'ro.nfc.info.antpos.Y' if set.
info_antpos_y() -> std::result::Result<Option<Vec<i32>>, SysPropError>130 pub fn info_antpos_y() -> std::result::Result<Option<Vec<i32>>, SysPropError> {
131 let result = match system_properties::read("ro.nfc.info.antpos.Y") {
132 Err(e) => Err(SysPropError::FetchError(e)),
133 Ok(Some(val)) => parsers_formatters::parse_list(val.as_str()).map_err(SysPropError::ParseError).map(Some),
134 Ok(None) => Ok(None),
135 };
136 result
137 }
138
139 /// Returns the value of the property 'ro.nfc.info.antpos.device_width' if set.
info_antpos_device_width() -> std::result::Result<Option<i32>, SysPropError>140 pub fn info_antpos_device_width() -> std::result::Result<Option<i32>, SysPropError> {
141 let result = match system_properties::read("ro.nfc.info.antpos.device_width") {
142 Err(e) => Err(SysPropError::FetchError(e)),
143 Ok(Some(val)) => parsers_formatters::parse(val.as_str()).map_err(SysPropError::ParseError).map(Some),
144 Ok(None) => Ok(None),
145 };
146 result
147 }
148
149 /// Returns the value of the property 'ro.nfc.info.antpos.device_height' if set.
info_antpos_device_height() -> std::result::Result<Option<i32>, SysPropError>150 pub fn info_antpos_device_height() -> std::result::Result<Option<i32>, SysPropError> {
151 let result = match system_properties::read("ro.nfc.info.antpos.device_height") {
152 Err(e) => Err(SysPropError::FetchError(e)),
153 Ok(Some(val)) => parsers_formatters::parse(val.as_str()).map_err(SysPropError::ParseError).map(Some),
154 Ok(None) => Ok(None),
155 };
156 result
157 }
158
159 /// Returns the value of the property 'ro.nfc.info.antpos.device_foldable' if set.
info_antpos_device_foldable() -> std::result::Result<Option<bool>, SysPropError>160 pub fn info_antpos_device_foldable() -> std::result::Result<Option<bool>, SysPropError> {
161 let result = match system_properties::read("ro.nfc.info.antpos.device_foldable") {
162 Err(e) => Err(SysPropError::FetchError(e)),
163 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
164 Ok(None) => Ok(None),
165 };
166 result
167 }
168
169 /// Returns the value of the property 'ro.nfc.observe_mode_supported' if set.
observe_mode_supported() -> std::result::Result<Option<bool>, SysPropError>170 pub fn observe_mode_supported() -> std::result::Result<Option<bool>, SysPropError> {
171 let result = match system_properties::read("ro.nfc.observe_mode_supported") {
172 Err(e) => Err(SysPropError::FetchError(e)),
173 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
174 Ok(None) => Ok(None),
175 };
176 result
177 }
178
179 /// Returns the value of the property 'ro.nfc.get_caps_supported' if set.
get_caps_supported() -> std::result::Result<Option<bool>, SysPropError>180 pub fn get_caps_supported() -> std::result::Result<Option<bool>, SysPropError> {
181 let result = match system_properties::read("ro.nfc.get_caps_supported") {
182 Err(e) => Err(SysPropError::FetchError(e)),
183 Ok(Some(val)) => parsers_formatters::parse_bool(val.as_str()).map_err(SysPropError::ParseError).map(Some),
184 Ok(None) => Ok(None),
185 };
186 result
187 }
188
189