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

Commit 3fb4c36c authored by Jeremy Wu's avatar Jeremy Wu Committed by Gerrit Code Review
Browse files

Merge "Floss: add util to use featured to query chrome flags" into main

parents 263debb6 54c8c292
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -35,3 +35,9 @@ members = [
  "system/gd/rust/linux/utils",
  "floss/hcidoc",
]

[patch.crates-io]
# When building out of ChromiumOS, we do not actually use featured.
# Stub it to avoid downloading the platform2 repository.
# See also: https://github.com/rust-lang/cargo/issues/4544
featured = { path = "system/gd/rust/linux/repositories/featured_stub" } # ignored by ebuild
+5 −0
Original line number Diff line number Diff line
[package]
name = "featured"
version = "0.1.0"
authors = ["The ChromiumOS Authors"]
edition = "2021"
+1 −0
Original line number Diff line number Diff line
// Copyright 2024 The ChromiumOS Authors
+5 −0
Original line number Diff line number Diff line
@@ -17,9 +17,14 @@ name = "bt_utils"
version = "0.0.1"
edition = "2021"

[features]
chromeos = ["featured"]

[dependencies]
bt_topshim = { path = "../../topshim" }

cfg-if = "1.0.0"
featured = { version = "0.1.0", optional = true }
libc = "0.2"
log = "0.4.14"
nix = "0.23"
+21 −0
Original line number Diff line number Diff line
//! This library provides Chrome feature query service.

#[cfg(feature = "chromeos")]
use featured::CheckFeature;

/// Queries whether the specified Chrome feature is enabled.
/// Returns false when the build is not for ChromeOS.
pub fn is_feature_enabled(name: &str) -> Result<bool, Box<dyn std::error::Error>> {
    cfg_if::cfg_if! {
        if #[cfg(feature = "chromeos")] {
            let feature = featured::Feature::new(&name, false)?;

            let resp = featured::PlatformFeatures::get()?
                .is_feature_enabled_blocking(&feature);

            Ok(resp)
        } else {
            Ok(false)
        }
    }
}
Loading