MCPcopy Create free account
hub / github.com/deviceplug/btleplug / start_scan

Method start_scan

src/droidplug/adapter.rs:141–171  ·  view source on GitHub ↗
(&self, filter: ScanFilter)

Source from the content-addressed store, hash-verified

139 }
140
141 async fn start_scan(&self, filter: ScanFilter) -> Result<()> {
142 let env = global_jvm().get_env()?;
143 let filter = JScanFilter::new(&env, filter)?;
144 try_block(&env, || {
145 env.call_method(
146 &self.internal,
147 "startScan",
148 "(Lcom/nonpolynomial/btleplug/android/impl/ScanFilter;)V",
149 &[filter.into()],
150 )?;
151 Ok(Ok(()))
152 })
153 .catch(
154 JClass::from(
155 super::jni_utils::classcache::get_class(
156 "com/nonpolynomial/btleplug/android/impl/NoBluetoothAdapterException",
157 )
158 .unwrap()
159 .as_obj(),
160 ),
161 |_ex| Ok(Err(Error::NoAdapterAvailable)),
162 )
163 .catch("java/lang/RuntimeException", |ex| {
164 let msg = env
165 .call_method(ex, "getMessage", "()Ljava/lang/String;", &[])?
166 .l()?;
167 let msgstr: String = env.get_string(msg.into())?.into();
168 Ok(Err(Error::RuntimeError(msgstr)))
169 })
170 .result()?
171 }
172
173 async fn stop_scan(&self) -> Result<()> {
174 let env = global_jvm().get_env()?;

Callers

nothing calls this directly

Calls 5

global_jvmFunction · 0.85
try_blockFunction · 0.85
get_classFunction · 0.85
resultMethod · 0.80
catchMethod · 0.80

Tested by

no test coverage detected