Commit graph

8923 commits

Author SHA1 Message Date
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
Dennis Song
150fbac783 Merge "Allow merging target files without framework ab_partitions.txt" into main 2024-02-07 03:00:00 +00:00
Dennis Song
bc7e0a9f25 Allow merging target files without framework ab_partitions.txt
Introduce a new option `--allow-partial-ab` in merge_target_files,
which allows merging a non-AB framework with an AB vendor.

The reason for adding this option is to support merging a real
device framework with a cuttlefish vendor. Cuttlefish enables AB
partition by default; however, some real devices do not.

Bug: 318326532
Test: merge_target_files
Test: atest --host releasetools_test
Change-Id: Iaebd06796153fe82fbf56e86fcc8c500b6d60771
2024-02-06 14:40:57 +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
Treehugger Robot
639fde3a4d Merge "Determine GC type based on BUILT_KERNEL_VERSION_FILE." into main 2024-02-02 03:01:57 +00:00
Jiakai Zhang
53dd895407 Determine GC type based on BUILT_KERNEL_VERSION_FILE.
How it works:
1. build/make/core/Makefile generates a txt file with the kernel
   version, which is taken from an explicit BOARD_KERNEL_VERSION value,
   or extracted from the kernel image on the source tree, or extracted
   from the kernel image extracted from the prebuilt boot.img.
   The file is saved at
   $ANDROID_PRODUCT_OUT/obj/PACKAGING/check_vintf_all_intermediates/kernel_version.txt.
2. If PRODUCT_ENABLE_UFFD_GC is "default", meaning the GC type needs to
   be determined by the kernel version, build/make/core/Makefile copies
   kernel_version.txt to
   out/soong/dexpreopt/kernel_version_for_uffd_gc.txt.
3. build/soong/dexpreopt/config.go writes the the UFFD GC flag to
   out/soong/dexpreopt/uffd_gc_flag.txt. The flag is determined by an
   explicit PRODUCT_ENABLE_UFFD_GC value or by contruct_uffd_gc_flag.py,
   which reads kernel_version_for_uffd_gc.txt and determines the flag
   accordingly.
4. dex2oat takes the UFFD GC flag from uffd_gc_flag.txt.
5. post_process_props.py mangles ro.dalvik.vm.enable_uffd_gc based on
   the same logic.

Bug: 321751629
Bug: 319554951
Bug: 318763448
Bug: 319648491
Test: m --no-skip-soong-tests nothing
Test: atest uffd_gc_utils_test
Test: Build with `OVERRIDE_ENABLE_UFFD_GC=default m` for device with no
  UFFD support -
  1. Check the existence of `-Xgc:CMC` in
     out/soong/dexpreopt_arm64/dex_bootjars/android/system/framework/arm64/boot.invocation
     (dex2oat invocation for a boot image)
  2. Check the existence of `-Xgc:CMC` in
     out/soong/.intermediates/packages/apps/Settings/Settings/android_common/dexpreopt/Settings/oat/arm64/package.invocation
     (dex2oat invocation for an app defined in .bp)
  3. Check the existence of `-Xgc:CMC` in
     $ANDROID_PRODUCT_OUT/obj/APPS/Dialer_intermediates/oat/arm64/package.invocation
     (dex2oat invocation for an app defined in .mk)
  4. Check the value of ro.dalvik.vm.enable_uffd_gc in
     $ANDROID_PRODUCT_OUT/product/etc/build.prop
Test: Build with `OVERRIDE_ENABLE_UFFD_GC=default m` for device with
  UFFD support, and do the steps above.
Test: Build with `OVERRIDE_ENABLE_UFFD_GC=true m`, and do the steps
  above.
Test: Build with `OVERRIDE_ENABLE_UFFD_GC=false m`, and do the steps
  above.

Change-Id: I8df6e5be1644da05d2d5c57b3520f29601dfd7a4
2024-02-01 22:10:33 +08: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
Treehugger Robot
0296ef0081 Merge "Store metrics for each run of a benchmark." into main 2024-01-31 18:44:16 +00:00
Treehugger Robot
9918afcb1d Merge "Add benchmarks for lunch" into main 2024-01-31 18:44:16 +00:00
Dennis Shen
c4cb665612 Merge "aconfig: create memory map file module" into main 2024-01-31 17:10:35 +00:00
Liz Kammer
0b7bdeeb9b Store metrics for each run of a benchmark.
Enables a breakdown to understand where time is being spent on each CUJ.

Test: run ./build/make/tools/perf/benchmarks --store-metrics
Change-Id: I28f3f62b2b2c1fd810ecce9238c7177c1eb382d7
2024-01-31 09:49:47 -05:00
Liz Kammer
efb6650d45 Add benchmarks for lunch
Test: ./benchmarks --benchmark full_lunch
Change-Id: Id6be3b41a518d4ca9cad882a913f1dcc59f0d01a
2024-01-31 09:46:05 -05:00
Liz Kammer
898efbfb78 Merge "Update benchmarks to handle cog workflows" into main 2024-01-31 14:35:03 +00:00
Dennis Shen
19370a0a31 aconfig: create memory map file module
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
2024-01-31 13:54:16 +00:00
Mårten Kongstad
6fdaa11d7c aconfig: fix formatting warnings
Update the rust toolchain to 1.75.0 and run `cargo fmt`.

Bug: N/A
Test: cargo fmt --check
Test: atest :all
Change-Id: I718c350f4c346b85ff3608f3101278c2ee776b36
2024-01-31 09:40:21 +01:00
Treehugger Robot
f350b7afc7 Merge "Fix doing preroll for postroll" into main 2024-01-30 21:59:01 +00:00
Dennis Shen
eef9192987 aconfig: remove bucket_index from PackageTableNode/FlagTableNode struct
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
2024-01-30 15:16:29 +00:00
Dennis Shen
f39e4a2273 Merge "aconfig: add flag value query pub function" into main 2024-01-29 20:48:48 +00:00
Treehugger Robot
1cc902690e Merge "Fix ext4 size estimates" into main 2024-01-29 20:06:18 +00:00
Dennis Shen
9a76f645a2 Merge "aconfig: add flag table offset query function" into main 2024-01-29 19:47:23 +00:00
Dennis Shen
043a1eec4d Merge "aconfig: create package table query public function" into main 2024-01-29 19:47:15 +00:00
Liz Kammer
864dd43c07 Update benchmarks to handle cog workflows
Test: run ./build/make/tools/benchmarks in a cog workspace
Change-Id: I421d1d08b4e90a79b8416486025229d4f3263fbe
2024-01-29 14:13:57 -05:00
Liz Kammer
f67a6e8114 Fix doing preroll for postroll
Test: ./build/make/tools/perf/benchmarks
Change-Id: Ib64ddd53ea9234dc2934fd6dea988add02729d29
2024-01-29 14:09:43 -05:00
Dennis Shen
78bea3d66c aconfig: add flag value query pub function
Bug: b/321077378
Test: atest aconfig_storage_file.test
Change-Id: I83dd93c5f8d640ddbe85493a470af68df1e3e69d
2024-01-29 18:54:13 +00:00
Dennis Shen
9fd970198d aconfig: add flag table offset query function
Bug: b/321077378
Test: atest aconfig.test; atest aconfig_storage_file.test
Change-Id: Ib0ec1ec809c65d8f9f1284e4214cfbb683812f1d
2024-01-29 15:11:55 +00:00
Dennis Shen
8aa9bbeb99 aconfig: create package table query public function
Bug: b/321077378
Test: atest aconfig.test
Change-Id: I097e8ebecff6d5d9e73738a7f80a63cb482bcfbe
2024-01-29 14:43:19 +00:00
Mårten Kongstad
edd678063c aconfig: fix workspace resolver warning
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
2024-01-29 14:51:51 +01:00
Dennis Shen
997745dc13 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
2024-01-26 18:02:07 +00:00
Dennis Shen
c7a1c76e28 Merge "aconfig: create unit test targets for aconfig_protos and aconfig_storage_file crate" into main 2024-01-26 18:01:54 +00:00
Dennis Shen
a4294b0c6a aconfig: create unit test targets for aconfig_protos and
aconfig_storage_file crate

also added a bunch of comments to satisfy android lint requirements

Bug: b/321077378
Test: atest aconfig.test, atest aconfig_protos.test, atest aconfig_storage_files.test
Change-Id: I9bce302ac3bc98c5347e5334d915e77337ee89c4
2024-01-25 17:33:36 +00:00
Zhi Dou
b874ca75e4 aconfig: add isOptimizationEnabled in FakeFeatureFlagsImpl
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
2024-01-25 16:07:32 +00:00
Dennis Shen
11529aa52f Merge "aconfig: create aconfig_storage_file crate" into main 2024-01-25 15:28:34 +00:00
Yi-Yo Chiang
accdd3f087 Merge "Re-land: releasetools: Deprecate GKI build rules" into main 2024-01-25 05:29:11 +00:00
Yi-Yo Chiang
a4d5f4380b Re-land: releasetools: Deprecate GKI build rules
(Re-land of Ie882fccd864920289e48366e99a4ebd67e784d0d)

We no longer build GKIs from the platform tree.
These build commands were neither used nor maintained anymore, so clean
them up to reduce maintenance effort.
Keep the command line options as no-op, so existing scripts that still
specifies the deprecated options don't break.

Bug: 229701033
Test: presubmit
Change-Id: I0f7d05562dbc3eed29e902d6dc9a0f2e4083aaa6
2024-01-25 11:21:00 +08:00
Kelvin Zhang
158a5ebbc9 Fix ext4 size estimates
Currently, EXT4 image building is done in a 2 pass fashion:

First pass: build ext4 image with small margin/headroom, check the
number of block used in the output image

Second pass: Build ext4 image again with an estimated block count from
first pass

The two pass implementation is done to keep image size at a
minimum. Recently some failures in first pass invocation is observed due
to image being undersized. Since we will reduce the image size in 2nd
pass, it's OK to increase the image size estimate during first pass. Add
a headroom 10% of total file size to fix build failures.

Test: cherry pick r.android.com/q/topic:%22aosp_cf_system_x86_64%22 and
m aosp_cf_system_x86_64

Bug: 321003625
Change-Id: I254310c67a08b98b05d2c858d4ab59a48112a07b
2024-01-24 18:37:27 -08:00
Devin Moore
14d1d0b155 Merge "find_static_candidates.py: protect against missing keys in module" into main 2024-01-24 23:29:34 +00:00
Dennis Shen
cf9a752092 aconfig: create aconfig_storage_file crate
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
2024-01-24 21:33:42 +00:00
Devin Moore
621b02ab22 find_static_candidates.py: protect against missing keys in module
Looks like modules can now be missing "shared_libs" and "static_libs".
Use default values of empty sets where applicable, or check for the
existence of the keys before looking for them.

Test: python find_static_candidates.py --module audioserver
Bug: 322190716
Change-Id: I8be9bd2c1562975db57ffbf89d57ff2767f0b1f1
2024-01-24 19:28:21 +00:00
Dennis Shen
277e5dc36e Restructure aconfig repo to be a cargo workspace with many crates
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
2024-01-24 02:18:52 +00:00
Treehugger Robot
28007ce2e1 Merge "Add all apexes to apex_info" into main 2024-01-22 22:08:14 +00:00
Jooyung Han
750aad5c32 Add all apexes to apex_info
Previously, META/apex_info.pb contained only /system/apex apexes. Now,
it has all apexes from all possible partitions.

The main purpose of this file is to caculate the decompressed apex size
when applying OTA. Hence it should have all apexes, not just system
apexes.

Bug: 320228659
Test: m dist # check META/apex_info.pb
Change-Id: I3428dc502e4fe3336d1fc5ca941f1fbc332985cd
2024-01-23 05:52:51 +09:00
Dennis Shen
1ef905869f Merge "aconfig: create one file at each create-storage command invocation" into main 2024-01-22 20:49:36 +00:00
Treehugger Robot
3b7d46f4ca Merge "Fix signing failures on targets with >4GB target_files" into main 2024-01-19 20:06:07 +00:00
Kelvin Zhang
12ac11025e Fix signing failures on targets with >4GB target_files
An old python zipfile hack prevented zipfile module from decoding 64 bit
sizes correctly, remove the legacy hack to fix.

Test: check_target_files_signatures -v 5GB_target_files.zip
Bug: 319367048
Change-Id: I376c7b68f549ddf88680280d604548d1849cdfe2
2024-01-19 11:04:58 -08:00
Dennis Shen
bac87875fa aconfig: create one file at each create-storage command invocation
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
2024-01-19 19:02:07 +00:00
Treehugger Robot
1094ec1e81 Merge "Add the rebuilt modules to the benchmark formatting" into main 2024-01-19 17:38:02 +00:00