Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/android/document_picker.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Android Storage Access Framework bridge returning readable local files.

use super::jni::{self as jni_helpers, JniExt};
use super::jni::{self as jni_helpers, JniExt, JniResultExt as _};
use anyhow::{anyhow, Result};
use futures::channel::oneshot;
use gpui::PathPromptOptions;
Expand Down Expand Up @@ -38,10 +38,7 @@ fn pick_files(multiple: bool) -> std::result::Result<Option<Vec<PathBuf>>, Strin
&[JValue::Object(&activity), JValue::Bool(multiple)],
)
.and_then(|value| value.l())
.map_err(|error| {
env.exception_clear();
error.to_string()
})?;
.or_clear(env)?;
if result.is_null() {
return Ok(None);
}
Expand Down
16 changes: 4 additions & 12 deletions src/android/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ use gpui::{App, Application, ApplicationHandle};
use jni::{objects::JObject, refs::Global};
use ndk::native_window::NativeWindow;

use super::jni::JniResultExt as _;
use super::platform::{AndroidPlatform, SharedPlatform};
use crate::android::{AndroidKeyEvent, TouchPoint};

Expand Down Expand Up @@ -577,18 +578,9 @@ pub fn set_activity(
if super::jni::android_app().is_some() {
return Ok(());
}
match env.new_global_ref(activity) {
Ok(activity) => {
ACTIVITIES.lock().expect("poisoned").insert(host, activity);
Ok(())
}
Err(err) => {
if env.exception_check() {
env.exception_clear();
}
Err(err.to_string())
}
}
let activity = env.new_global_ref(activity).or_clear(env)?;
ACTIVITIES.lock().expect("poisoned").insert(host, activity);
Ok(())
}

/// Run `f` with `host`'s own Activity (a global `jobject`), or with the newest one if
Expand Down
Loading
Loading