Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 629f1d63 authored by Ying Hsu's avatar Ying Hsu Committed by Gerrit Code Review
Browse files

Merge "floss: Output dumpsys to a fixed temp file" into main

parents 8ba92ede aa54cb51
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ num-traits = "0.2"
rand = { version = "0.8.3", features = ["small_rng"] }
serde_json = "1.0"
syslog = "6"
tempfile = "3.10"
tokio = { version = "1", features = ['bytes', 'fs', 'io-util', 'libc', 'macros', 'mio', 'net', 'num_cpus', 'rt', 'rt-multi-thread', 'sync', 'time', 'tokio-macros'] }

[lib]
+9 −4
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ use num_traits::cast::ToPrimitive;
use num_traits::pow;
use std::collections::{HashMap, HashSet};
use std::convert::TryInto;
use std::fs::File;
use std::fs::{File, OpenOptions};
use std::hash::Hash;
use std::io::Write;
use std::os::fd::AsRawFd;
@@ -39,7 +39,6 @@ use std::process;
use std::sync::{Arc, Condvar, Mutex};
use std::time::Duration;
use std::time::Instant;
use tempfile::NamedTempFile;
use tokio::sync::mpsc::Sender;
use tokio::task::JoinHandle;
use tokio::time;
@@ -70,6 +69,8 @@ const BTM_SUCCESS: i32 = 0;

const PID_DIR: &str = "/var/run/bluetooth";

const DUMPSYS_LOG: &str = "/tmp/dumpsys.log";

/// Represents various roles the adapter supports.
#[derive(Debug, FromPrimitive, ToPrimitive)]
#[repr(u32)]
@@ -3021,11 +3022,15 @@ impl IBluetooth for Bluetooth {
    }

    fn get_dumpsys(&self) -> String {
        NamedTempFile::new()
        OpenOptions::new()
            .write(true)
            .create(true)
            .truncate(true)
            .open(DUMPSYS_LOG)
            .and_then(|file| {
                let fd = file.as_raw_fd();
                self.intf.lock().unwrap().dump(fd);
                std::fs::read_to_string(file.path())
                Ok(format!("dump to {}", DUMPSYS_LOG))
            })
            .unwrap_or_default()
    }