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

Commit 6e795ab6 authored by Andrew Walbran's avatar Andrew Walbran Committed by Automerger Merge Worker
Browse files

Merge "Use std::sync::LazyLock rather than lazy_static." into main am: 4355f46e

parents 119b5663 4355f46e
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -9,4 +9,3 @@ clap = "4.0"
chrono = "0.4"
num-derive = "0.3"
num-traits = "0.2"
lazy_static = "1.0"
+12 −11
Original line number Diff line number Diff line
///! Rule group for tracking controller related issues.
use chrono::NaiveDateTime;
use lazy_static::lazy_static;
use std::collections::HashSet;
use std::convert::Into;
use std::io::Write;
use std::sync::LazyLock;

use crate::engine::{Rule, RuleGroup, Signal};
use crate::parser::{NewIndex, Packet, PacketChild};
@@ -23,16 +23,17 @@ impl Into<&'static str> for ControllerSignal {
    }
}

lazy_static! {
    static ref KNOWN_CONTROLLER_NAMES: [String; 6] = [
static KNOWN_CONTROLLER_NAMES: LazyLock<[String; 6]> = LazyLock::new(|| {
    [
        String::from("Bluemoon Universal Bluetooth Host Controller"), // AC7625
        String::from("MTK MT7961 #1"),                                // MT7921LE/MT7921LS
        String::from("MTK MT7922 #1"),                                // MT7922
        String::from("RTK_BT_5.0"),                                   // RTL8822CE
        String::from("RT_BT"),                                        // RTL8852AE
        String::from(""), // AC9260/AC9560/AX200/AX201/AX203/AX211/MVL8897/QCA6174A3/QCA6174A5/QC_WCN6856
    ];
}
    ]
});

const KNOWN_CONTROLLER_MANUFACTURERS: [u16; 5] = [
    2,  // Intel.
    29, // Qualcomm
+0 −3
Original line number Diff line number Diff line
@@ -11,7 +11,6 @@ rust_library {
    name: "libbt_common",
    defaults: ["libbt_common_defaults"],
    rustlibs: [
        "liblazy_static",
        "liblog_rust",
    ],
    target: {
@@ -38,7 +37,6 @@ rust_defaults {
    crate_name: "bt_common",
    srcs: ["src/lib.rs"],
    rustlibs: [
        "liblazy_static",
        "liblog_rust",
    ],
    proc_macros: [
@@ -55,7 +53,6 @@ rust_test_host {
    rustlibs: [
        "libbt_common",
        "libenv_logger",
        "liblazy_static",
        "liblog_rust",
    ],
    proc_macros: [
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ edition = "2018"
cxx = "1.0"
env_logger = "0.8"
futures = "0.3.13"
lazy_static = "1.4"
log = "0.4"
nix = { version = "0.27.1", features = ["time", "user"] }
tokio = { version = "1.0", features = ['bytes', 'macros', 'net', 'rt-multi-thread', 'time'] }
+19 −16
Original line number Diff line number Diff line
use lazy_static::lazy_static;
use log::{error, info};
use paste::paste;
use std::collections::{BTreeMap, HashMap};
use std::fmt;
use std::sync::LazyLock;
use std::sync::Mutex;

// Fallback to bool when type is not specified
@@ -78,14 +78,20 @@ macro_rules! init_flags_struct {
            $($flag : type_expand!($($type)?),)*
        }

        impl Default for $name {
            fn default() -> Self {
        impl $name {
            pub const fn new() -> Self {
                Self {
                    $($flag : default_value!($($type)? $(= $default)?),)*
                }
            }
        }

        impl Default for $name {
            fn default() -> Self {
                Self::new()
            }
        }

        impl FlagHolder for $name {
            fn get_defaults_for_test() -> Self {
                Self {
@@ -182,14 +188,12 @@ init_flags!(
    }
);

lazy_static! {
/// Store some flag values
    static ref FLAGS: Mutex<InitFlags> = Mutex::new(InitFlags::default());
static FLAGS: Mutex<InitFlags> = Mutex::new(InitFlags::new());
/// Store the uid of bluetooth
    pub static ref AID_BLUETOOTH: Mutex<u32> = Mutex::new(1002);
pub static AID_BLUETOOTH: Mutex<u32> = Mutex::new(1002);
/// Store the prefix for file system
    pub static ref MISC: Mutex<String> = Mutex::new("/data/misc/".to_string());
}
pub static MISC: LazyLock<Mutex<String>> = LazyLock::new(|| Mutex::new("/data/misc/".to_string()));

/// Loads the flag values from the passed-in vector of string values
pub fn load(raw_flags: Vec<String>) {
@@ -208,11 +212,10 @@ pub fn dump() -> BTreeMap<&'static str, String> {
#[cfg(test)]
mod tests {
    use super::*;
    lazy_static! {

    /// do not run concurrent tests as they all use the same global init_flag struct and
    /// accessor
        pub(super) static ref ASYNC_LOCK: Mutex<bool> = Mutex::new(false);
    }
    pub(super) static ASYNC_LOCK: Mutex<bool> = Mutex::new(false);

    pub(super) fn test_load(raw_flags: Vec<&str>) {
        let raw_flags = raw_flags.into_iter().map(|x| x.to_string()).collect();
Loading