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

Commit 84d76f6c authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Revert "Floss: Add dbus method to enable devcoredump"" into main

parents 143676c7 642584fb
Loading
Loading
Loading
Loading
+0 −5
Original line number Diff line number Diff line
@@ -21,9 +21,4 @@ impl IBluetoothExperimental for BluetoothExperimentalDBus {
    fn set_ll_privacy(&mut self, enabled: bool) -> bool {
        dbus_generated!()
    }

    #[dbus_method("SetDevCoredump")]
    fn set_devcoredump(&mut self, enabled: bool) -> bool {
        dbus_generated!()
    }
}
+0 −5
Original line number Diff line number Diff line
@@ -302,9 +302,4 @@ impl IBluetoothExperimental for BluetoothManager {

        true
    }

    fn set_devcoredump(&mut self, enabled: bool) -> bool {
        warn!("Set Floss DevCoreDump={}", enabled);
        config_util::write_coredump_state_to_file(enabled)
    }
}
+0 −34
Original line number Diff line number Diff line
@@ -17,12 +17,6 @@ const BTMANAGERD_CONF: &str = "/var/lib/bluetooth/btmanagerd.json";
/// Folder to keep files which override floss configuration
const FLOSS_SYSPROPS_OVERRIDE_DIR: &str = "/var/lib/bluetooth/sysprops.conf.d";

/// File to store bluetooth devcoredump configuration. This file is used by the
/// udev rule to copy the devcoredump state to .../device/coredump_enabled sysfs
/// entry. It is also used by the user-space crash reporter to enable/disable
/// parsing of the devcoredump.
const FLOSS_COREDUMP_CONF_PATH: &str = "/var/run/bluetooth/coredump_disabled";

/// Key used for default adapter entry.
const DEFAULT_ADAPTER_KEY: &str = "default_adapter";

@@ -252,34 +246,6 @@ pub fn write_floss_address_privacy_enabled(enabled: bool) -> std::io::Result<()>
    )
}

pub fn set_adapter_coredump_state(enabled: bool) -> std::io::Result<()> {
    let data = format!("{}\n", !enabled as i32);

    for hci in list_hci_devices_string() {
        let path = format!("{}/{}/device/coredump_disabled", HCI_DEVICES_DIR, hci);

        std::fs::write(path, &data)?;
    }

    Ok(())
}

pub fn write_coredump_state_to_file(enabled: bool) -> bool {
    let data = format!("{}\n", !enabled as i32);

    if let Err(e) = std::fs::write(FLOSS_COREDUMP_CONF_PATH, data) {
        log::error!("Failed to write devcoredump state (error: {})", e);
        return false;
    }

    if let Err(e) = set_adapter_coredump_state(enabled) {
        log::error!("Failed to set devcoredump state (error: {})", e);
        return false;
    }

    true
}

#[cfg(test)]
mod tests {
    use super::*;
+0 −3
Original line number Diff line number Diff line
@@ -2,7 +2,4 @@
pub trait IBluetoothExperimental {
    /// Set LL privacy status
    fn set_ll_privacy(&mut self, enabled: bool) -> bool;

    /// Set devcoredump status
    fn set_devcoredump(&mut self, enabled: bool) -> bool;
}