дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
A bottom tool window lists the connected Android devices (adb devices -l) and streams the selected one's log (adb logcat -v threadtime, the last 200 lines first), parsed into time, pid, level, tag and message in a virtualised list that follows the end until scrolled up. The filter box takes Android Studio's logcat expressions (tag:, message:, pid:, level:, -term, |, parentheses, regex) and remembers recent ones. The new ide-android crate runs adb, which it finds through ANDROID_HOME / ANDROID_SDK_ROOT, the usual SDK locations or PATH; the stream goes over a Channel in batches (300 lines, or once the oldest waiting line is 60 ms old) and stops with its request. The window is listed under the stripe's overflow until first opened. Co-authored-by: payailk <[email protected]>
41 рядки
1.2 KiB
Rust
41 рядки
1.2 KiB
Rust
//! Logcat tool window: Android devices and their logs (`ide-android`).
|
|
|
|
use crate::state::AppState;
|
|
use ide_android::{AndroidDevice, LogcatLine};
|
|
use ide_core::{IdeError, IdeResult, RequestId};
|
|
use tauri::State;
|
|
use tauri::ipc::Channel;
|
|
|
|
async fn blocking<T: Send + 'static>(f: impl FnOnce() -> IdeResult<T> + Send + 'static) -> IdeResult<T> {
|
|
tauri::async_runtime::spawn_blocking(f).await.map_err(|e| IdeError::internal(e.to_string()))?
|
|
}
|
|
|
|
/// Devices `adb` knows about, online ones first.
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub async fn android_devices() -> IdeResult<Vec<AndroidDevice>> {
|
|
blocking(ide_android::devices).await
|
|
}
|
|
|
|
/// Follows `serial`'s log until the request is cancelled, in batches of lines.
|
|
/// `clear` empties the device's buffers first.
|
|
#[tauri::command]
|
|
#[specta::specta]
|
|
pub async fn android_logcat(
|
|
state: State<'_, AppState>,
|
|
request: RequestId,
|
|
serial: String,
|
|
clear: bool,
|
|
on_lines: Channel<Vec<LogcatLine>>,
|
|
) -> IdeResult<()> {
|
|
let cancel = state.begin_request(request);
|
|
let result = blocking(move || {
|
|
ide_android::logcat(&serial, clear, &cancel, &mut |batch| {
|
|
let _ = on_lines.send(batch);
|
|
})
|
|
})
|
|
.await;
|
|
state.end_request(request);
|
|
result
|
|
}
|