fix clippy and globalref and android
This commit is contained in:
@@ -19,6 +19,13 @@ pub struct AndroidGlobals {
|
||||
pub ctx: GlobalRef,
|
||||
}
|
||||
|
||||
impl Drop for AndroidGlobals {
|
||||
fn drop(&mut self) {
|
||||
// Ensure we're attached before dropping GlobalRef
|
||||
self.vm.attach_current_thread_as_daemon().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
pub static ref ANDROID_GLOBALS: Arc<Mutex<Option<AndroidGlobals>>> = Arc::new(Mutex::new(None));
|
||||
}
|
||||
@@ -76,7 +83,7 @@ pub fn veilid_core_setup_android<'a>(
|
||||
pub fn get_android_globals() -> (JavaVM, GlobalRef) {
|
||||
let globals_locked = ANDROID_GLOBALS.lock();
|
||||
let globals = globals_locked.as_ref().unwrap();
|
||||
let env = globals.vm.attach_current_thread().unwrap();
|
||||
let env = globals.vm.attach_current_thread_as_daemon().unwrap();
|
||||
let vm = env.get_java_vm().unwrap();
|
||||
let ctx = globals.ctx.clone();
|
||||
(vm, ctx)
|
||||
|
Reference in New Issue
Block a user