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

Commit 997745dc authored by Dennis Shen's avatar Dennis Shen
Browse files

aconfig: add aconfig_storage_metadata proto

Introduce a new proto to capture storage file location for each
container. This proto file will appeara as
/metadata/aconfig/storage_file_location.pb. Storage service daemon is
responsible for writing entires to it when a new storage file set is
available. The flag read lib will use this file to find the
corresponding storage file and mmap them.

Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I226e76be895805dce52a075050dcd5b42d337be8
parent c7a1c76e
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -9,6 +9,9 @@ rust_defaults {
    srcs: ["src/lib.rs"],
    rustlibs: [
        "libanyhow",
        "libaconfig_storage_protos",
        "libonce_cell",
        "libprotobuf",
    ],
}

@@ -24,3 +27,11 @@ rust_test_host {
    test_suites: ["general-tests"],
    defaults: ["aconfig_storage_file.defaults"],
}

rust_protobuf {
    name: "libaconfig_storage_protos",
    protos: ["protos/aconfig_storage_metadata.proto"],
    crate_name: "aconfig_storage_protos",
    source_stem: "aconfig_storage_protos",
    host_supported: true,
}
+4 −0
Original line number Diff line number Diff line
@@ -9,3 +9,7 @@ cargo = []

[dependencies]
anyhow = "1.0.69"
protobuf = "3.2.0"

[build-dependencies]
protobuf-codegen = "3.2.0"
+17 −0
Original line number Diff line number Diff line
use protobuf_codegen::Codegen;

fn main() {
    let proto_files = vec!["protos/aconfig_storage_metadata.proto"];

    // tell cargo to only re-run the build script if any of the proto files has changed
    for path in &proto_files {
        println!("cargo:rerun-if-changed={}", path);
    }

    Codegen::new()
        .pure()
        .include("protos")
        .inputs(proto_files)
        .cargo_out_dir("aconfig_storage_protos")
        .run_from_script();
}
+34 −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

// This is the schema definition for aconfig files. Modifications need to be
// either backwards compatible, or include updates to all aconfig files in the
// Android tree.

syntax = "proto2";

package android.aconfig_storage_metadata;

message storage_file_info {
  optional uint32 version = 1;
  optional string container = 2;
  optional string package_map = 3;
  optional string flag_map = 4;
  optional string flag_val = 5;
  optional int64 timestamp = 6;
}

message storage_files {
  repeated storage_file_info files = 1;
};
+4 −0
Original line number Diff line number Diff line
@@ -21,6 +21,10 @@ pub mod flag_table;
pub mod flag_value;
pub mod package_table;

mod protos;
#[cfg(test)]
mod test_utils;

use anyhow::{anyhow, Result};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
Loading