Create one library for reading protos from all containers, instead of
having numerous libraries perform the same logic. For Java, we will
create a similar library reusing the same
partition_aconfig_flags_paths.txt.
Bug: 324436145
Test: adb shell aflags list # Confirm that various containers appear
Change-Id: I924e281a50f9a609e1c07c03267eebe3dce52752
aconfig_storage_write_api crate is the lib to be used by aconfig storage
daemon to update flag value at a given offset.
Note that mmap api is unsafe from memmap2 crate. This is due to the
possibility of other code write to the file after mmaping the file into
memory. Therefore the api to write to storage value file is also marked
as unsafe. In reality, the persistent storage value file is protected by
SELinux policy to allow write access only to aconfig storage daemon. In
addition, aconfig storage daemon is single threaded. So at any time,
only one thread is writing to a storage file, and only thru the mmapped
file in memory (not thru direct file write). So it would safe for
storage daemon to call this api.
Bug: b/312444587
Test: m libaconfig_storage_write_api; atest
aconfig_storage_write_api.test
Change-Id: I93cffea0d94e4c40e711d809418c0b18b6d9bfe1
Commit bca2f3c28c incorrectly added "aconfig_storage_write_api" as a
workspace member even though that project has not yet been created. This
broke cargo.
Unbreak cargo by removing "aconfig_storage_write_api".
Bug: N/A
Test: croot build/make/tools/aconfig && cargo c
Change-Id: Ic0f71a53d49736228a376f64808aea24c2ec8ce5
Current aconfig_storage_file crate contains two things: 1,
aconfig storage file definition (which is used by aconfig crate for
storage file creation) and 2, flag storage file read api. With this
change, we are splitting 2 into its own crate aconfig_storage_read_api
In the long run, there will be 3 crates for aconfig_storage
1, aconfig_storage_file
It contains aconfig storage file definition, as well as a binary to help
print/dump aconfig storage binary files into some readable format.
2, aconfig_storage_read_api
This crate contains flag read apis. This crate depends on
aconfig_storge_file crate. This crate will be used by codegen.
3, aconfig_storage_write_api
This crate contains flag write apis. This crate depends on
aconfig_storage_file crate. This crate will only be used by aconfig
daemon to update flag values.
Bug: b/321077378
Test: atest aconfig_storage_read_api.test; atest
aconfig_storage_file.test; atest aconfig_storage_read_api.test.rust;
atest aconfig_storage_read_api.test.cpp
Change-Id: Ia6afdc40a45c7c59652fbfd123c2b77bf6666dd9
Add a new CLI binary that we can use as the officially recommended CLI
for reading and writing flags. For now, the CLI invokes commands to
interact with DeviceConfig and aconfig protos, but we will switch it to
interact with the forthcoming mmap-file-based aconfig storage. In the
meantime, we can add improved formatting and error reporting in a
separate layer.
This CL starts with the list command, which outputs a table of the
flags when you type `adb shell aflags list`.
Bug: 324436145
Test: atest aflags.test
Change-Id: Idd8aa78ccaace22a7e490014d410ad741f8f6fc6
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
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
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
This reverts commit efda207c09.
Reason for revert: this unrevert contains the fix for b/311187402
Test: cargo test
Change-Id: I210aebd30edd864a7c141ede336c12aebf4f1fcd
By caching flag values directly in member variables instead of caching
a HashMap and accessing that, flag reads avoid `hashCode()`, map
lookup, and Boolean.parse runtime costs. Flag reads are turning out
to have performance problems in hot paths, so this should help to
alleviate that.
Bug: 309625014
Test: m
Change-Id: I923bf6af2ae3fcbbf2fee7126b492a47cd6049ad
Add a `bug` field on the flag_declaration and parsed_flag proto
messages. This field is optional in the sense that it can occur zero or
more times, and aconfig will simply pass any value through.
Bug fields are included in the aconfig dump format, which can be
processed by other tools.
Also unify how protos.rs checks that fields marked 'optional' in the
proto file, but in practice are 'required', are actually set.
Test: atest aconfig.test aconfig.test.java
Bug: 288261336
Change-Id: I93de0005674822c6ff4d699bdc2c6509763a7f7f
Implement a helper function to make it easier for unit tests to diff
(and find the first difference) generated code and expected code.
Bug: 283910447
Test: atest aconfig.test
Change-Id: I460e8fbf05e8f33e8a62ecef67b2d9d77051e876
Introduce the Cache struct to represent parsed and verified aconfig and
override content. Most commands in aconfig will work of an existing
cache file, eliminating the need to re-read the input every time.
Restructure main.rs to use clap to create a proper command line
interface with support for sub-commands. main.rs is responsible for
parsing the command line, performing disk I/O and calling the correct
subcommand implementation (in commands.rs).
To simplify unit tests, subcommands never perform explicit I/O; instead
they only work with Read and Write traits.
Also add dependencies on clap, serde and serde_json.
Bug: 279485059
Test: atest aconfig.test
Change-Id: Ib6abf2eabd264009804f253874b6fba924fc391b
Fill in aconfig.proto. Define Aconfig definitions (for introducing flags
and setting their values) and Overrides (for overriding flags regardless
of what their definitions say). More changes to the proto schema are
expected when more of the aconfig project is outlined.
Use proto2 instead of proto3: this will cause the protobuf text parser
to error on missing fields instead of returning a default value which is
ambiguous, especially for booleans. (Also, the text protobuf parser
doesn't provide good error messages: if the input is missing a field,
the error is always "1:1: Message not initialized").
Unfortunately the generated Rust wrappers around the proto structs land
in an external crate, which prevents aconfig from adding new impl
blocks. Circumvent this by converting the data read from proto into
structs defined in the aconfig crate.
Change main.rs to parse (static) text proto.
Also add dependency on anyhow.
Bug: 279485059
Test: atest aconfig.test
Change-Id: I512e3b61ef20e2f55b7699a178d466d2a9a89eac
Officially, aconfig is build using the Android tool-chain. However, to
speed up the local development cycle, add support for building with
cargo.
While it is possible to tell cargo to place the build artifacts outside
the source tree, there is no way to tell it to not generate the cargo
lock file in the same directory as Cargo.toml. Add a .gitignore to
ignore Cargo.lock and the target directory.
The way the Android build system and cargo generates code from the
protobuf files is slightly different. Tell cargo to enable the "cargo"
feature and introduce src/protos.rs to hide this difference from the
rest of the aconfig source.
Bug: 279485059
Test: m aconfig && aconfig
Test: atest aconfig.test
Test: cargo build
Test: cargo test
Change-Id: I85741f58cadae353ed95c124f566e4f4a7484186