This module is repsonsible for finding the storage file location based on a
pb file and then map these storage files into memory using memmap2
crate. The mapped files are cached in a static hashmap in this module.
Note that memmap2 crate has not been introduced to AOSP yet as a 3p
crate. It is in the process of importing to AOSP ATM. So in src/lib.rs,
we only include this module if we are building the target using cargo.
Also, the test storage files: package.map, flag.map and flag.val are
generated based on the storage test aconfig files in
aconfig/aconfig/tests dir. With aconfig create-cache command first to
produce cache files, and then aconfig create-storage command to create
each storage file.
aconfig create-cache --package com.android.aconfig.storage.test_1 --container system --declarations ./storage_test_1.aconfig --cache com.android.aconfig.storage.test_1.cache
aconfig create-cache --package com.android.aconfig.storage.test_2 --container system --declarations ./storage_test_2.aconfig --cache com.android.aconfig.storage.test_2.cache
aconfig create-cache --package com.android.aconfig.storage.test_4 --container system --declarations ./storage_test_4.aconfig --cache com.android.aconfig.storage.test_4.cache
aconfig create-storage --container system --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file flag_val --out ./flag.value
aconfig create-storage --container system --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file package_map --out ./package.map
aconfig create-storage --container system --cache ./com.android.aconfig.storage.test_1.cache --cache ./com.android.aconfig.storage.test_2.cache --cache ./com.android.aconfig.storage.test_4.cache --file flag_map --out ./flag.map
Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: Id4bd26ce1a2513cdda201b479cec2b8c04faabfe
bucket index currently is a field in PackageTableNode/FlagTableNode, but this is
purely aux info that is never searilized or deserialized. Therefore we
should remove it from the struct definition. Instead aconfig should
define a wrapper struct that wraps around an instance PackageTableNode/FlagTableNode
as well as aux info like bucket_index.
Bug: 321077378
Test: atest aconfig.test && atest aconfig_storage_file.test
Change-Id: I20f2565d20b7feb5d39754e91cd6a9affb1f0e70
Fix the following warning:
warning: virtual workspace defaulting to `resolver = "1"` despite one or more workspace members being on edition 2021 which implies `resolver = "2"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
note: for more details see https://doc.rust-lang.org/cargo/reference/resolver.html#resolver-versions
Further info: https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html
Bug: N/A
Test: cargo c # no warnings related to the resolver
Change-Id: I5ee546e4f2ba9e854026bf4baee380e89cf4a01b
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
This change adds isOptimizationEnabled method in FakeFeatureFlagsImpl.
This method can help test to decide whether the code using flag is
optimized.
Bug: 309406391
Test: atest aconfig.test aconfig.test.java
Change-Id: I7e7109ac06ab44f9b8dee56c76be9479f60a9148
Move aconfig storage file definition into its own crate, as flag read
lib will need it as well. The new crate is placed under
aconfig_storage_file dir.
Bug: b/321077378
Test: atest aconfig.test, Cargo test at repo root level
Change-Id: I91e8ada2c9bab479ed81cf03824042f3fa460be5
Previously, aconfig repo is the root directory of aconfig binary crate,
but it also hosts printflags crate inside, and there is no cargo support
for printflags binary crate. In addition, with more aconfig development,
more crates are being added to this repo. Thus this repo should be
configured as a Cargo workspace with multiple crates rather than a
single crate.
Note the top level Cargo.toml file specifies the crates this workspace
carries:
(1) aconfig_protos: the proto library crate that will be used by many other
crates such as aconfig binary crate and printflags binary crate
(2) aconfig: the aconfig binary crate
(3) printflags: the printflags binary crate
(1) aconfig_protos crate setup:
Inside aconfig_protos dir we set up the aconfig_protos crate, the
previously src/proto.rs is now aconfig_protos/src/lib.rs, the build.rs
is carried over to this crate.
(2) aconfig binary crate setup:
Notice its Cargo.toml file claims package dependency on aconfig_protos
crate. It no longer carries proto related module and build.rs file.
(3) printflags binary crate setup:
Similary, notice that in its Cargo.toml file, it claims package
dependency on aconfig_protos crate.
With this setup, we can Cargo build/test each crate individually when
inside a specific crate dir. But we can also run Cargo build/test at
repo root level, which will build/test all the crates in this workplace.
This is the structuring cl. The next cl is to move storage modules into
its own library crate. This storage file library crate will be used by
both aconfig binary crate as well as flag read library crate (to be
created as another new crate here).
Bug: b/321984352
Test: top and individual crate dir level Cargo build/test, m each
individual targets
Change-Id: I75833f4997f7ee554ff6c1557df9ac87f62b2732
Merged-In: I75833f4997f7ee554ff6c1557df9ac87f62b2732
Based on the build system feedback, it is better to create storage file
individually per each aconfig command invocation in a makefile. Thus
updating the create-storage command to create one file at a time based
on passed in file selection.
Bug: b/321243743
Test: atest aconfig.test and manually invoke create-storage command
Change-Id: I53625c08e44d3ece4476835827c6b7d28ddd5a1b
Create flag_value module to create flag value file. Flag value file
contains a header section at the start of the file, followed by a
boolean array.
Bug: b/312243587
Test: atest aconfig.test
Change-Id: If76660189d63073fbd477e1e447240e0cd029604
array
1, add flag type to the flag table. Before flag table only stores the
mapping from (package id, flag name) to (flag id u32). The original
intent is to do bitmasking on the top byte of flag id to indicate flag
type. Now split the flag id u32 to two u16, the first represent flag
type, the second represent flag id. So after the change, the flag table
now shows the following mapping:
(package id, flag name) -> (flag type as u16, flag id as u16)
2, originally we plan to store a info byte together with each flag
value. The info byte is used by storage service damemon to mark up the
flag status, such as if it is accepting server side flag push. After
internal discussion, it is better to just create the info bytes as
another file by storage service damemon. So that the value file is
purely a flag value array.
Bug: b/312243587
test: atest aconfig.test
Change-Id: I7f953076b4269cf786bc23723078290e5ebe10bc
str::split always returns at least one item (the entire string) if the
delimiter is not found. Simplify the implementation of
is_valid_container accordingly.
Bug: N/A
Test: atest aconfig.test
Change-Id: I3e92035309a7b019912710e42e69f9bdfa538795
The itertools crate was initially added as a dev-dependency. A later CL
also added it as a regular dependency, rendering the dev-dependency
obsolete. Remove it.
Bug: N/A
Test: cargo b
Change-Id: I12099f672f865430cf1cef97f8b4a8bc3eb055ec
Add flag_table module for the creation of flag.map file. This is a hash
table in file similar to package.map hash table in file. This is created
per each container. It stores a mapping from a composite key (package id
and flag name) to its flag id (within package index of a flag).
This hash table allows us to look up the within package offset for a
specific flag. Along with the package offset obtained from package.map,
we will be able to find the global offset of a flag in the flag value
file.
Added unit tests to lock down the table creation and serialization.
Bug: b/312243587
Test: atest aconfig.test
Change-Id: I6e9d07bef05131cb06cfb4aa2ef29985578a6949
merge storage_test_1_part_1.aconfig and storage_test_1_part_2.aconfig
into one aconfig file: storage_test_1.aconfig
remove two flags from test_1 package so the total number of flags across
three aconfig package is now 8, which is easier to test in unit test.
Bug: b/312243587
Test: atest aconfig.test
Change-Id: Idd249a8dcddfbae09b211e6310d74697763618f4
The "force_read_only" mode is designed for libraries shared among
multiple containers for the following two scenarios where:
1. The library must be built with read_only flags or
2. Different containers requires different values for the same flags.
In this mode, the library includes only non-exported flags, adhering to
the concept that exported flags should maintain consistent values across
containers. Additionally, regardless of their original permissions, all
flags within this mode will be set to read_only.
Bug: 316357759
Test: atest aconfig.test
Change-Id: I65df39416c96404d84044a46bbcfe1bc8ce9ba8f
Add a function to assign flag id for flags in a package. We first assert
that the flags should have been sorted by its name, then assign a u32 id
to each flag in order. Note this cl adds the function, it will be used
in later cls.
Bug: b/312243116
Test: atest aconfig.test
Change-Id: I843433305abecbe0cc78988fe23dcf35c6a03358
Replace a call to Vec::retain_mut with a call to Vec::retain instead:
the predicate used doesn't require its parameter to be a *mutable*
reference.
Bug: N/A
Test: atest aconfig.test
Change-Id: Iacd5f2ebef358ebc92ae6a1a78dd3045e44196f4
With the introduction of a root release config, the
com.android.aconfig.test flags now have their values correctly assigned.
Update the integration tests accordingly.
Bug: 317178122
Test: atest :all
Merged-In: I1acdf9442a465f20f71bcda9b15eb69058aa4b3a
Change-Id: I1acdf9442a465f20f71bcda9b15eb69058aa4b3a
1, Add whole table serialization test to also lock down how the buckets
are serialized. Before this change, we are only locking down the header
and nodes serialization.
2, Switch over to the absolute offset in the file instead of relative
offset. Before we are using relative offset. For example, if a bucket is
Some(10), it means that it is pointing to 10 bytes over the start of the
node region of the table. Now it will be the absolute byte offset with
respect to the start of the table.
Bug: b/312243587
Test: atest aconfig.test
Change-Id: If7abc8c6b6687c0bc0c40bbfc6afbe0e46ece770
Add an additional package com.android.acondfig.storage.test_4 to test
so that the chaining in package.map can also be tested.
Bug: b/312243587
Test: atest aconfig.test
Change-Id: I8d0fad8941a20c7f6ed60caf529667549abdcdd7
This commit updates the error message in
modify_parsed_flags_based_on_mode, when there is no certain mode flags
in the corresponding library, and this change remove "." at the end of
the error message to conform to existing standard in this project.
Bug: 311152507
Test: atest aconfig.test
Change-Id: Ib120e7f7252981bbeb6ca1cf785da24f329507b4