Now the read api lib no longer owns the memory mapped file. The rust lib
aconfig_storage_read_api api to get memory mapped file just returns an
Mmap rust struct. However cxx does not support Mmap data type, so we
cannot export the api to get memory mapped file from rust to c++. This
means we have to implement c++ apis to get memory mapped files.
This change is basically implementing c++ api to get memory mapped files,
mirroring the rust implementation. In addition, the integration test is
also updated to lock down the new c++ api implementation.
Bug: b/321077378
Test: atest aconfig_storage_read_api.test.cpp
Change-Id: I5e93a220cdd05cc0e5b0eb441284ac3e9dc34da7
Right now, aconfig_storage_read_api rust lib would own mapped files. So
individual flag lib does not need to. The original intent is that all
these flag lib can dynamically link against this lib. So say we have
different variants of flag lib for one flag package, there is just one
unique memory mapped file. In addition, the exposed rust apis hides the
memory mapped files. So when exporting these apis to c++/java, we don't
have to implement memory mapping in c++/java flag read api lib.
However, this design has its own downside. The biggest being that these
memory mapped files are stored in a mutable static hash map. For rust,
it must be protected by a mutex lock. The real effect on the lock is
mostly minimal as it immediately unlocks when the clone of memory
mapping is returned. But still we could get more performance out of it
in exchange of having more c++/java side implementation of mapping
files. (Note, apis that interpret mapped files are still exported by
Rust, so no c++/java implementation needed).
In this change, aconfig_storage_read_api give away its ownership of
memory mapped file in its api to get memory mapped file. The memory
mapped file is supposed to be owned by generated flag lib. By doing so,
no more mutex lock is needed. Also, since each flag lib has one flag
package, which maps to a single owning container. The flag lib can have
the memory mapped files as non mutable static variables. So no mutex
lock penalty on flag lib side.
Bug: b/321077378
Test: atest aconfig_storage_read_api.test; atest
aconfig_storage_read_api.test.rust
Change-Id: I29060bae90db6f7d296252ed73f7e312143f4b7e
Lines now have a new column, and look like this:
com.android.example.flag1 enabled - server read-write system
com.android.example.flag2 enabled (->disabled) server read-write system
The dash represents no change on boot, the (->value) represents a change
to value on the next boot.
Test: adb shell device_config put staged multitasking*com.android.wm.shell.enable_taskbar_navbar_unification true && adb shell aflags list | grep navbar_unification
Bug: 324436145
Change-Id: I022460bc69fcb2ccd9c6db8f060fcbd0337d1ea6
1, add storage file type into storage files serialization
2, update aconfig_storage_read_api integration tests to not rely on
soong to produce read only storage files. Instead, have the test process
create temp read only storage file copies.
Bug: b/312444587
Test: atest aconfig.test; atest.aconfig_storage_file.test
Change-Id: I1607fb000b48e8acffc966b16a5136578911ab3e
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
UnsupportedAppUsage was added to support cts test access issue. For new
exported mode, if the cts tests code with exported flag, there won't be access issue. So this annotation is not needed. Removing this annotation also removes the dependency on this annotation in google3 code.
Test: atest aconfig.test
Bug: 311152507
Bug: 303773055
Change-Id: I8c190e69cdb514af7992ccca7fea152c917047dc
To keep things consistent and to reduce the risk of confusion, aconfig
flags are "enabled" or "disabled", not "true" or "false".
Do not represent flag states via a String. Instead, introduce a new
FlagValue enum and use this enum instead. FlagValue implements ToString
which returns "enabled" or "disabled".
Bug: N/A
Test: adb shell aflags list # verify that flags are "enabled" or "disabled"
Test: atest aflags.test
Change-Id: I9be998d7891656d118b7cc971449da58e17d5031
Add android.bp target for the binary. Change the binary name to
aconfig-storage. And a number of small updates.
Bug: b/321077378
Test: m aconfig-stoarge; atest aconfig_storage_file.test
Change-Id: I9f560a031433407800ded1c2f4f2bdab459f5df7
Reduce the number of allocations by removing superfluous calls to
to_string: use a &str where possible, and avoid converting a String to a
String.
Bug: N/A
Test: adb shell aflags list
Change-Id: I373018e9ecb393137d11e039ca2c73c0ca5308d7
Print the fully qualified name instead of splitting flag package and
flag name into separate columns. This aligns the output with the
expected input to `aflags enable <fully-qualified-name>` and makes it
easier to copy-and-paste the flag names.
Before this change:
$ adb shell aflags list | head -n4
android.app.admin.flags cross_user_suspension_enabled false default read-write system
android.app.admin.flags dedicated_device_control_enabled false default read-write system
android.app.admin.flags device_policy_size_tracking_enabled false default read-write system
android.app.admin.flags dumpsys_policy_engine_migration_enabled false default read-write system
After this change:
$ adb shell aflags list | head -n4
android.app.admin.flags.cross_user_suspension_enabled false default read-write system
android.app.admin.flags.dedicated_device_control_enabled false default read-write system
android.app.admin.flags.device_policy_size_tracking_enabled false default read-write system
android.app.admin.flags.dumpsys_policy_engine_migration_enabled false default read-write system
Bug: N/A
Test: adb shell aflags list
Change-Id: I3227c9c9c7355b5b0c1b75ada73b1a8f87d1be55
Previously, checkvintf read only vendor apexes. Now, we support vintf
from other apexes.
Bug: 327365139
Test: m check-vintf-all
Change-Id: I46dc04ccdbe7d3f035ea9f63b1e45358ab31021b
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
To help debug storage files. We need a binary to parse the storage
binary files and print out the flag values like device_config list
command. In addition, aconfig_storage_file needs to provide a public api
to allow flag cli to call to get the flag values. Therefore creating
this change.
This change includes the following changes:
1, Implement debug print trait for package table, flag table, and flag
value struct. So the debug dump is more readable.
2, Add a list flag api to create a vector of flag name and value tuples
given the storage file names. This api will be used by
aconfig_storage_file binary as well as aconfig flag cli.
3, Add a main.rs to create aconfig_storage_file binary to debug print
storage files or list all the flags in storage files. It has two
subcommands.
3.1 print command:
aconfig_storage_file print --file <storage file> --type
<package_map|flag_map|flag_val>
This command produce a debug print of a single the storage file content
3.2 list command:
aconfig_storage_file list --package_map <package map file> --flag_map
<flag map file> --flag_val <flag value file>
This command parses all storage files to print out list of flag values
in the following form:
<package>/<flag>, <value>
...
<package>/<flag>, <value>
Bug: b/321077378
Test: manual test of the binary command
Change-Id: I000e216d13854f853cbd9b63cabb6db3a47dbece
1, Add unit tests in aconfig_storage_file crate to lock down that the
first four bytes of serialized storage files must be the version number.
2, Add a storage file read api to read version number directly from a
file without mmapping the file. This api is need by aconfig storage
daemon.
3, Update integration tests (rust and c++) to include this api.
Bug: b/321077378
Test: atest aconfig_storage_file; atest aconfig_storage_read_api; atest
aconfig_storage_read_api.test.rust; atest
aconfig_storage_read_api.test.cpp
Change-Id: I432893d43895ad5022fcb614aa14de89acd9d220