Commit Graph

449 Commits

Author SHA1 Message Date
Ted Bauer
71287f5e6b Merge "aflags: only permit enable/disable with root access." into main 2024-03-08 15:51:57 +00:00
Dennis Shen
760d21d991 Merge "aconfig: update aconfig_storage_file crate" into main 2024-03-08 13:33:37 +00:00
Mårten Kongstad
f0c594d66d aflags: list flags as "enabled|disabled" instead of raw bool value
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
2024-03-08 10:27:14 +01:00
Zhi Dou
5f1a854b11 Merge "aconfig_proto: add document for container filed" into main 2024-03-07 19:42:56 +00:00
Ted Bauer
a98448f4e7 aflags: only permit enable/disable with root access.
Bug: 324436145
Test: adb unroot && adb shell aflags enable com.android.window.flags.sync_window_config_update_flag # Fails
Test: adb root && adb shell aflags enable com.android.window.flags.sync_window_config_update_flag # Succeeds
Change-Id: I88db174b51462199a234eeb3b6fb70c4da538700
2024-03-07 17:55:27 +00:00
Dennis Shen
12705d46be aconfig: update aconfig_storage_file crate
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
2024-03-07 15:03:27 +00:00
Mårten Kongstad
b47f7bae6d aflags: remove unnecessary String conversions
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
2024-03-07 15:29:00 +01:00
Mårten Kongstad
d408e96505 aflags: list: merge package and name into fully qualified name
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
2024-03-07 14:58:14 +01:00
Mårten Kongstad
2243581535 aconfig: remove reference to non-existent workspace member "aconfig_storage_write_api"
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
2024-03-07 09:18:33 +01:00
Dennis Shen
bca2f3c28c aconfig: move aconfig_storage_metadata proto and its apis to
aconfig_storage_file crate

Bug: b/321077378
Test: m aconfig_storage_file.test; m aconfig_storage_read_api.test
Change-Id: Ifeeeff62dc09e172b7e88c45860d2febccc29570
2024-03-06 22:05:02 +00:00
Dennis Shen
190304985c aconfig: create aconfig_storage_file binary to print the storage files
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
2024-03-06 17:46:18 +00:00
Zhi Dou
2d2610c787 aconfig_proto: add document for container filed
Test: n/a
Bug: 328027300
Change-Id: Ieec2c24cb9024f429fcd7888ef6c7c89d212ff63
2024-03-06 15:36:34 +00:00
Dennis Shen
cdde8f39f8 Merge "aconfig: add a storage file read api to get file version number" into main 2024-03-06 13:39:23 +00:00
Treehugger Robot
07c3faa081 Merge "set exportable to true for aconfig.test.exported.flags" into main 2024-03-06 01:10:49 +00:00
Zhi Dou
8320380d55 set exportable to true for aconfig.test.exported.flags
Test: m aconfig_test_java_library_exported
Bug: 310504781
Change-Id: Ib405febc739c49dff7340d43c65a7ec2b314d7de
2024-03-05 22:27:09 +00:00
Ted Bauer
ee09882e54 Merge "aflags: add initial enable and disable commands" into main 2024-03-05 22:23:57 +00:00
Ted Bauer
84883bd7a4 aflags: add initial enable and disable commands
Bug: 324436145
Test: adb shell aflags enable --help
Change-Id: I6b4af4bccbbc6000a9dcb78c3130f836b0f85bd0
2024-03-05 19:33:39 +00:00
Dennis Shen
05cf662dbe aconfig: add a storage file read api to get file version number
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
2024-03-05 16:18:12 +00:00
Dennis Shen
c54c841ebe Merge "aconfig: split aconfig_storage_file crate" into main 2024-03-05 15:57:00 +00:00
Zhi Dou
040dc611f3 Merge "printflags: print flags declared in mainline module" into main 2024-03-05 14:49:34 +00:00
Zhi Dou
5c912f481e printflags: print flags declared in mainline module
This change adds flag files in mainline module into the read path of
printflags.

Bug: 327466668
Test: build image, flash device with new image, and adb shell printflags
Change-Id: I3c88019086b17ce2eed3c00afff651b1ebd55353
2024-03-04 22:03:05 +00:00
Dennis Shen
61d8c5a799 aconfig: split aconfig_storage_file crate
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
2024-03-04 21:12:43 +00:00
Dennis Shen
dbbda1eeb7 aconfig: update storage file records file name
Bug: b/312444587
Test: atest aconfig.test
Change-Id: Ib26ab5d50099a7038e161ef59517fad9dca744d5
2024-03-04 15:01:36 +00:00
Zhi Dou
036cdbe92f aconfig: disable export mode for generated native flag libraries
Currently the default flag values are not loaded into sysprop. Since the
current requirements for export flag are for flagged api in java and the
new storage system will load default values for all, there won't be
changes to make the default value loaded into sysprop. Thus this change
disable export mode for generated native flag libraries for now. It will
be enabled once the new storage is landed.

Test: m libaconfig_test_rust_library_with_exported_mode and expect build
failure
Bug: 327392334

Change-Id: I2db814d015cdb533778822f7417d055b251ed589
2024-02-29 12:57:24 +00:00
Ted Bauer
4dbf58a187 aconfig: introduce new aflags CLI
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
2024-02-21 13:23:49 -05:00
Dennis Shen
9c080e7544 aconfig: add storage flag read api integration tests to test mapping
Bug: b/321077378
Test: atest aconfig_storage.test.rust; atest aconfig_storage.test.cpp
Change-Id: I6920b45e4f968efedcdd6afb8c68314baa02327f
2024-02-21 18:18:04 +00:00
Dennis Shen
c670bae629 Merge "aconfig: aconfig storage cpp api on device integration test" into main 2024-02-14 22:36:22 +00:00
Jihoon Kang
c7521afdc5 Merge "Modify dependencies of fake_device_config" into main 2024-02-14 17:38:15 +00:00
Ivan Lozano
6a04d1e5de Merge "Revert "aconfig: remove libcxx dependency for now"" into main 2024-02-14 14:17:13 +00:00
Treehugger Robot
ae025131ba Merge "Test modules should always be last" into main 2024-02-13 22:04:05 +00:00
Ivan Lozano
4304694312 Revert "aconfig: remove libcxx dependency for now"
This reverts commit 248510a659.

Reason for revert: aosp/2959366

Change-Id: Ib3a0e584f24f2a3ab51ca0b48e4c4897ed0d8174
Bug: 324826914
Test: SANITIZE_HOST=address m aconfig
2024-02-13 19:02:06 +00:00
Jihoon Kang
9c1450e0d2 Modify dependencies of fake_device_config
This change modifes the dependencies of fake_device_config by setting
the sdk_version to none instead of core_current, and setting the
appropriate system_modules in order to resolve circular dependencies.

Test: m fake_device_config && BUILD_FROM_SOURCE_STUB m fake_device_config
Change-Id: I497e2db9ea3456057a1e3f5c624cbd2042da6837
2024-02-13 06:54:49 +00:00
Dennis Shen
248510a659 aconfig: remove libcxx dependency for now
Contenxt: b/324826914, libcxx is the culprit of the linking failure.
Remove libcxx dependency for now.

Bug: b/324826914
Test: atest aconfig_storage_file.test
Change-Id: I55b1a41efbf4486715f465a8d56a4e2e6ab0254a
2024-02-12 20:09:51 +00:00
Stephen Hines
68a4bdb3eb Test modules should always be last
```
error: items after a test module
   --> build/make/tools/aconfig/aconfig/src/test.rs:18:1
    |
18  | pub mod test_utils {
    | ^^^^^^^^^^^^^^^^^^
...
345 | pub use test_utils::*;
    |         ^^^^^^^^^^
    |
    = help: for further information visit
https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
    = note: `-D clippy::items-after-test-module` implied by `-D
warnings`
    = help: to override `-D warnings` add
`#[allow(clippy::items_after_test_module)]`
```

Bug: http://b/321303117
Test: toolchain/android_rust/test_compiler.py --prebuilt-path dist/rust-dev.tar.xz --target aosp_cf_x86_64_phone --all-rust
Change-Id: I2c95af50a5d389fc37e1abc677e9b4d34b6562b4
2024-02-09 16:46:48 -08:00
Dennis Shen
8b5244c841 aconfig: aconfig storage cpp api on device integration test
Bug: 321077378
Test: atest aconfig_storage.test.cpp
Change-Id: I99532e9288f411d6025868341883fdbef600cfd7
2024-02-09 21:10:43 +00:00
Dennis Shen
91ba7d56ea Merge "aconfig: add storage api rust test on the host" into main 2024-02-09 21:00:16 +00:00
Dennis Shen
2ea228ef70 Merge "aosp: reenable the filtered out test point in atest" into main 2024-02-09 20:09:28 +00:00
Dennis Shen
997e65779a Merge "aconfig: create c++ interlop from rust flag apis" into main 2024-02-09 16:53:53 +00:00
Dennis Shen
4f6f12841c aosp: reenable the filtered out test point in atest
A more systematic fix. Now for each test point, we create temp file
copies at temp dir and explicitly set the file permission of these temp
files. This should bypass the issue that test build artifact file
permission are not guaranteed. Because we will generate these test
storage files on the fly at run time.

Bug: b/324459233
Test: atest aconfig_storage_file.test
Change-Id: Iaa7083be6cc49421090ab4c74e54c4bcf8e35801
2024-02-09 16:51:17 +00:00
Dennis Shen
213dbb71a5 aconfig: add storage api rust test on the host
Bug: 321077378
Test: atest aconfig_storage.test.rust
Change-Id: I3301834909441dea471c0d4b1aae0a117af7dc29
2024-02-09 15:54:22 +00:00
Dennis Shen
2f0929d867 aconfig: turn off the offending test point
Bug: b/324459233
Test: atest aconfig_storage_file.test and the test point is no longer executed.
Change-Id: I34b5da7a1b152f213926cc2e1f9511785e9d384f
2024-02-09 12:48:52 +00:00
Dennis Shen
618e66a28b aconfig: create c++ interlop from rust flag apis
Using cxx to generate c++ code for the apis that are marked to exported
in the ffi mod in src/lib.rs. For generated code simplicity, it returns
a new flag struct for each rust api.

Create a cc_library to wrap around generated c++ code. See the created
aconfig_storage.hpp for the exported header. Note there is a nested
aconfig_storage::test_only_api namespace, where we place test only apis.
The production apis are placed under aconfig_storage namespace.

Bug: 321077378
Test: m libaconfig_storage_cc
Change-Id: I73a85a26d3749908abc461362f5e0bfc3f85bf4d
2024-02-09 02:51:08 +00:00
Dennis Shen
e7fde3a86f Merge "aconfig: add top level flag read lib api" into main 2024-02-08 18:17:27 +00:00
Dennis Shen
1452104995 aconfig: add top level flag read lib api
1, update android build soong targets as now libmemmap2 has been
introduced to android code base.

2, add three public apis for package offset query, flag offset query,
and flag value query. These apis assume the stoarge location pb file is
at /metadata/aconfig/aconfig_storage.pb. This file will be created by
storage daemon. For testing purposes, we also expose impl version of
these apis that accept a custom storage location pb file.

Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: I91b284e2dfcdb8ff3674d463ed1c13696d9ae020
2024-02-08 14:57:51 +00:00
Mårten Kongstad
36402f1c35 aconfig: move all tests to presubmit
The tests added to TEST_MAPPING in aosp/2870454 have now soaked in
postsubmit long enough to be allowed to advance to presubmit.

Bug: N/A
Test: atest --test-mapping $(gettop)/build/tools/aconfig
Test: Treehugger
Change-Id: Ia75c76ae114c16a57c26aafa159560639baea707
2024-02-06 08:21:32 +01:00
Oriol Prieto Gascó
0151f72e00 Merge "Set the container field of aconfig flags" into main 2024-02-06 00:38:04 +00:00
Zhi Dou
d43b446ebb aconfig_proto: add doc in aconfig.proto file
This change adds docs in aconfig.proto file and adds more detail in the
error message for bad package, name and namespace.

Bug: 318759389
Test: atest aconfig.test
Change-Id: I0d45495cd864506b2fcc06ad47e3ffbd6caca9fb
2024-02-05 16:41:56 +00:00
Oriol Prieto Gasco
c6343b169b Set the container field of aconfig flags
Test: atest aconfig.test
Bug: 312769710
Change-Id: Ia4e3f97e23d6113446d567db6bc1410c300ea667
2024-02-05 16:30:04 +00:00
Dennis Shen
7bb9cda6c4 aconfig: update mapped_file
Minor change to mapped_file module, create utility function to verify
file is readonly and map. Also, update the unit test to create temp pb
file instead of writing to the test dir.

Bug: 321077378
Test: atest aconfig_storage_file.test
Change-Id: Id903ed458613e4aac8d2cbb1664fd8293de1a494
2024-01-31 19:01:56 +00:00
Dennis Shen
c4cb665612 Merge "aconfig: create memory map file module" into main 2024-01-31 17:10:35 +00:00