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

Commit b1edaae8 authored by Ted Bauer's avatar Ted Bauer
Browse files

Add flag for enabling only new storage and use in aflags

Change-Id: I73218de38d005d77987d5103364a102cec3abc07
Test: m && cargo t
Bug: 324436145
parent b5484c4b
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

rust_library {
    name: "libaconfig_flags",
    crate_name: "aconfig_flags",
    srcs: [
        "src/lib.rs",
    ],
    rustlibs: [
        "libaconfig_flags_rust",
    ],
    host_supported: true,
}

aconfig_declarations {
    name: "aconfig_flags",
    package: "com.android.aconfig.flags",
    container: "system",
    srcs: ["flags.aconfig"],
}

rust_aconfig_library {
    name: "libaconfig_flags_rust",
    crate_name: "aconfig_flags_rust",
    aconfig_declarations: "aconfig_flags",
    host_supported: true,
}

cc_aconfig_library {
    name: "libaconfig_flags_cc",
    aconfig_declarations: "aconfig_flags",
}
+10 −0
Original line number Diff line number Diff line
[package]
name = "aconfig_flags"
version = "0.1.0"
edition = "2021"

[features]
default = ["cargo"]
cargo = []

[dependencies]
 No newline at end of file
+9 −0
Original line number Diff line number Diff line
package: "com.android.aconfig.flags"
container: "system"

flag {
  name: "enable_only_new_storage"
  namespace: "core_experiments_team_internal"
  bug: "312235596"
  description: "When enabled, aconfig flags are read from the new aconfig storage only."
}
+47 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

//! `aconfig_flags` is a crate for reading aconfig flags from Rust
// When building with the Android tool-chain
//
//   - the flag functions will read from aconfig_flags_inner
//   - the feature "cargo" will be disabled
//
// When building with cargo
//
//   - the flag functions will all return some trivial value, like true
//   - the feature "cargo" will be enabled
//
// This module hides these differences from the rest of aconfig.

/// Module used when building with the Android tool-chain
#[cfg(not(feature = "cargo"))]
pub mod auto_generated {
    /// Returns the value for the enable_only_new_storage flag.
    pub fn enable_only_new_storage() -> bool {
        aconfig_flags_rust::enable_only_new_storage()
    }
}

/// Module used when building with cargo
#[cfg(feature = "cargo")]
pub mod auto_generated {
    /// Returns a placeholder value for the enable_only_new_storage flag.
    pub fn enable_only_new_storage() -> bool {
        // Used only to enable typechecking and testing with cargo
        true
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ rust_defaults {
    srcs: ["src/main.rs"],
    rustlibs: [
        "libaconfig_device_paths",
        "libaconfig_flags",
        "libaconfig_protos",
        "libaconfigd_protos",
        "libaconfig_storage_read_api",
@@ -24,6 +25,7 @@ rust_defaults {

rust_binary {
    name: "aflags",
    host_supported: true,
    defaults: ["aflags.defaults"],
}

Loading