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

Commit 8a3969cf authored by Yun-Hao Chung's avatar Yun-Hao Chung
Browse files

Floss: Fix Rust bluetooth logging on initialization

When applying Rust log level on initializing BluetoothLogging, we can't
directly call |is_debug_enabled| since |self.initialized| is not yet
set.

This refactors some of the functions to fix the issue.

Bug: 371889111
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: Verified manually
Flag: EXEMPT, Floss-only changes

Change-Id: I2fcaf73ea120d3a7e98edf7ef5bfde1b00f59c2c
parent abb6c474
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -85,8 +85,12 @@ impl BluetoothLogging {
        Ok(())
    }

    fn should_enable_debug_mode(&self) -> bool {
        self.log_level == Level::Debug || self.log_level == Level::Verbose
    }

    fn get_log_level_filter(&self) -> LevelFilter {
        match self.is_debug_enabled() {
        match self.should_enable_debug_mode() {
            true => LevelFilter::Debug,
            false => LevelFilter::Info,
        }
@@ -116,7 +120,7 @@ impl BluetoothLogging {

impl IBluetoothLogging for BluetoothLogging {
    fn is_debug_enabled(&self) -> bool {
        self.is_initialized && (self.log_level == Level::Debug || self.log_level == Level::Verbose)
        self.is_initialized && self.should_enable_debug_mode()
    }

    fn set_debug_logging(&mut self, enabled: bool) {