Commit Graph

449 Commits

Author SHA1 Message Date
Zhi Dou
99023d6160 Remove local copy of the flag file
This change removes the local copy of the flag file in PackageTable, and
FlagValueList.

PackageTable copied the entire flag file into memory, and the
FlagValueList copied the entire flag value list into memory. In this
change FlagValueList directly access the flag value list in the memory.
PackageTable will iterate the file, and find the target package node.

Change-Id: Id766c28b71a54290b266cc5f3f404f5c82590da2
Test: atest aconfig_storage_file.test.java aconfig_storage_read_api.test.java
Bug: 352078117
2024-08-22 19:56:48 +00:00
Ted Bauer
91458b4cd4 Merge "Parse protos in library" into main 2024-08-15 22:15:19 +00:00
Ted Bauer
6f12acb0da Parse protos in library
Bug: 342636474
Test: m
Change-Id: I4934fa2332b00084f73453945d6b4743566f6e48
2024-08-15 21:04:28 +00:00
Jihoon Kang
0c26850dba Merge "Specify is_stubs_module property in selected aconfig library modules" into main 2024-08-15 16:45:16 +00:00
Jihoon Kang
48f2b22b45 Specify is_stubs_module property in selected aconfig library modules
"fake_device_config" and "strict_mode_stub" provide stubs and do not
contain any implementation details. Specifying the property
"is_stubs_module" to these modules allow inter-container dependency on
these modules.

Test: m nothing
Bug: 354029496
Change-Id: Ia65ad36ca02c0594fc753935f9cc7c0af6caa20d
2024-08-14 22:23:08 +00:00
Ted Bauer
f51e1dd28d Only read the use_new_storage_value flag once per process.
Change-Id: Ib088fbcc2283718a309097c7c45fb01d5a983a25
Test: m
Bug: 312235596
2024-08-13 17:16:04 +00:00
Zhi Dou
8ee1a5b785 DO NOT MERGE: manually cherry pick
Change-Id: I47b6d783f32b7c260dd806898ed880901b5f784b
Test: presubmit
Bug: n/a
2024-08-07 18:51:23 +00:00
Treehugger Robot
70270692d0 Merge "Read from new storage in Java codegen" into main 2024-08-06 21:16:42 +00:00
Ted Bauer
06560bed93 Read from new storage in Java codegen
Change-Id: I8baa089f37dcc496096e124d605f08727647053c
Test: m
Bug: 312235596
2024-08-06 19:34:33 +00:00
Zhi Dou
f5f5992893 change thread policy to allow read disk
Bug: 356614910
Test: presubmit
Change-Id: I65cc2cbd5e17b1ee93e64d8b20e53c42547c985a
2024-08-06 18:58:45 +00:00
Zhi Dou
8af83ccd50 change fileinputstream to filechannel
The restrict mode doesn't allow to have disk read from main thread. Some
apps enabled this check. The code in the dependencies of the
fileinputstream. This chagne switch to filechannel.

Test: presubmit
Bug: 356614910
Change-Id: Icf2175fe75ed1bfad4a048ead680b08e57d6c2ca
2024-08-03 00:08:40 +00:00
Zhi Dou
3d960c5638 Merge "aconfig: make java cached indicator volatile" into main 2024-07-30 23:35:45 +00:00
Zhi Dou
97d02148b9 close file stream
Close file stream, since the in the restrict mode the runtime will check
whether all the resource is closed when it is out of scope.

Test: ABTD ImsStackJavaTests
Bug: 349874828
Change-Id: Ib297622bae730bf99e4d5d1b3adeff3fee805a93
2024-07-30 19:05:14 +00:00
Zhi Dou
36589bc318 aconfig: make java cached indicator volatile
Test: atest aconfig.test.java
Bug: 356201402
Change-Id: I1127a4092536fe199f4a7256dea0c2b289e837da
2024-07-30 18:21:43 +00:00
Zhi Dou
5228a6f4a2 Merge "read new stoarge based on flag value" into main 2024-07-29 13:26:35 +00:00
Zhi Dou
66ff40c08a read new stoarge based on flag value
This change changes the logic to read the flag value from new storage.
Before it check the existence of a file. Not it will directly check the
flag value from DeviceConfig.

Test: m and presubmit
Bug: 349874828
Change-Id: I4a360564a3b48564057eede9bd893899136b3221
2024-07-26 22:46:47 +00:00
Zhi Dou
8add8e0c9b use smart pointer for fd
Test: presubmit
Bug: 348693143
Change-Id: Ibdb1e132a4840d0c3d82aa5f7546a0fc5f5f528b
2024-07-26 22:25:43 +00:00
Zhi Dou
0e5e128034 add sdk none version for core lib usage
Test: m
Bug: 349874828
Change-Id: I412bcf06ca38c862b026715a6a394350eda49b64
2024-07-26 14:03:50 +00:00
Zhi Dou
d6b37c1be7 make aconfig_storage_file.test.java use library from framework
Test: atest aconfig_storage_file.test.java
Bug: 349874828
Change-Id: If6fbf086e889a2c0068a1ca22979db39f5d86448
2024-07-25 19:30:13 +00:00
Zhi Dou
fa988f0a34 add hide and unsupportedadppusage annotation to read library
Test: presubmit
Bug: 349874828
Change-Id: I5b808d87fe7df2ba8a85c8c75ee7baa66ff22d6b
2024-07-25 16:56:48 +00:00
Zhi Dou
8a9a52d140 Merge "make java reader library availiable for mainline" into main 2024-07-22 13:59:28 +00:00
Zhi Dou
b88c3e638b make java reader library availiable for mainline
Test: atest aconfig.test.java
Bug: 349874828
Change-Id: I2cabfa9665e5c474ba64f5969e96e9dae2fdcb9b
2024-07-19 21:01:27 +00:00
Zhi Dou
1edd4485c6 only use new storage for read write
Test: atest aconfig.test.java
Bug: 349874828
Change-Id: I5af9fa6243b8b8a157f03242e6e5a411ced7be44
2024-07-19 20:37:53 +00:00
Ted Bauer
05fea28d9c feat: show if flag is locally overridden
Bug: 324436145
Test: adb shell aflags list
Change-Id: Id239a760e86e469f77d1e99f7a6f27d54cb87206
2024-07-19 13:11:42 +00:00
Ted Bauer
7e272b8bba Merge "Read from new storage in aflags" into main 2024-07-18 13:32:59 +00:00
Ted Bauer
bbbe092496 Read from new storage in aflags
Bug: 324436145
Test: adb shell aflags list --use-new-storage
Change-Id: Ib615e25bc0bc7f2b0362e286a45ce40ebf21f92d
2024-07-17 18:39:25 +00:00
Zhi Dou
9f8ed73934 Change java codegen to read from new storage
This change adds code in java code to read from new storage. However the
generated code won't geneerate code contains code for new storage, since
the build system won't pass `allow-instrumentation` to java codegen.

Test: atest aconfig.test.java
Bug: 349874828
Change-Id: I70983fa97de6633f467d968109d134d46f895a89
2024-07-15 19:08:33 +00:00
Zhi Dou
621323cfda add storage java reader
Test: atest aconfig_storage_read_api.test.java
Bug: 349874828
Change-Id: I4b1d5ccf4d48622a88712b6e8940ffe18e980927
2024-07-12 13:34:12 +00:00
Priyanka Advani
16c8d3c47a Revert "add storage java internal reader"
This reverts commit 70b9ac0ddd.

Reason for revert: Droidmonitor created revert due to build breakages in b/352582602.

Change-Id: I8a8e38ccf3e715e9b4746ac333aed0cc13d11969
2024-07-11 19:59:24 +00:00
Zhi Dou
70b9ac0ddd add storage java internal reader
Test: n/a
Bug: n/a
Change-Id: I852ab4080bee9240549dc4be0c09dbe1f72d06b0
2024-07-11 18:50:46 +00:00
Treehugger Robot
0d18be30ae Merge "fix: make device paths function static" into main 2024-07-11 13:48:51 +00:00
Ted Bauer
ba67436d0d fix: make device paths function static
Bug: 342636474
Test: m
Change-Id: Iea745c39f8ef90543015c365ead4c02ee4ff6653
2024-07-10 23:15:08 +00:00
Zhi Dou
af8a16adf0 Implement storage files in Java
This change implements storage files in java to remove the dependencies
on JNI.

Bug: 352078117
Test: atest aconfig_storage_file.test.java

Change-Id: I34438576d09d0aa31eabc60f472e71cebf1552a0
2024-07-10 22:29:47 +00:00
Liana Kazanova
d7343203b6 Merge "Revert "Mark FeatureFlags impl member as final"" into main 2024-07-03 18:15:27 +00:00
Liana Kazanova
8450f57c3e Revert "Mark FeatureFlags impl member as final"
This reverts commit fca73bcad3.

Reason for revert: Droidmonitor triggered revert due to build breakage in b/350978649. Will be verifying through ABTD before submission.

Change-Id: I65de159518597289f1e0e3902080f35970842afc
2024-07-03 17:56:12 +00:00
Treehugger Robot
8d3b98e1ca Merge "Mark FeatureFlags impl member as final" into main 2024-07-03 15:52:13 +00:00
Jared Duke
1006bfbae3 Merge "Reuse Java flag name constants in FeatureFlagsImpl" into main 2024-07-03 14:53:29 +00:00
Jared Duke
1b6d14296e Reuse Java flag name constants in FeatureFlagsImpl
This may not matter in practice due to string inlining and interning,
but might avoid any accidental name drift/bugs in the future.

Bug: 280833463
Test: atest aconfig.test
Change-Id: I53b5b3effb577493ba708800928553c04b2fdc54
2024-07-02 22:51:05 +00:00
Ivan Lozano
16266625cc Remove allow-multiple-definitions flag.
This is no longer necessary as static linkage in Rust has been fixed.

Bug: 254469782
Test: m aconfig_storage_write_api.test.cpp
Change-Id: I6b8b36882aa521eb0412fb7da03a5eec94df81d4
2024-07-01 18:28:32 +00:00
Jared Duke
fca73bcad3 Mark FeatureFlags impl member as final
Marking the member as final for non-test scenarios allows for
optimizations that may otherwise be unavailable, and avoids ambiguity
about mutability.

Bug: 280833463
Test: atest aconfig.test
Change-Id: Ia58a04c9a57ee06d68f4dd022ace5365c65f4cf5
2024-06-26 23:08:16 +00:00
Ivan Lozano
b6288a526e Replace static_rlibs usage.
static_rlibs has been folded into the normal static_libs and
whole_static_libs properties.

Bug: 254469782
Bug: 349129702
Test: m
Change-Id: I89d260f78947c3e0fe65148177c7f98d0d0c504d
2024-06-26 01:36:26 +00:00
Treehugger Robot
f8b7517b02 Merge "Switch to static_rlibs" into main 2024-06-25 21:57:39 +00:00
Ted Bauer
b64fdac839 Switch to static_rlibs
When a dependency takes multiple rust_ffi_static dependencies in its
static_libs, their symbols collide. Switch to static_rlibs, which
resolves the collisions. See b/349129702 for context.

Bug: 349129702
Test: m
Change-Id: I6cd2fe92629c7d44e22d113795b340e06175f008
2024-06-25 17:21:40 +00:00
Zhi Dou
436f1368cd flush mmap file to disk after updating
The change was applied in the file in memory. Without explicitly calling
msync, there is no guarantee that the changes are written back to disk.
Thus the flag value may not be changed.

Bug: b/348693143
Test: atest aconfig_storage_write_api.test.cpp
aconfig_storage_write_api.test.rust

Change-Id: I8b1e0cbbb90bcb3c2e5bbf418a6a1a9cd047c81b
2024-06-24 21:14:52 +00:00
Treehugger Robot
bb4e87008f Merge "aflags: Ensure <partition>/aconfig_flags.pb exists before reading" into main 2024-06-18 15:27:36 +00:00
Luca Stefani
bc962db1ea aflags: Ensure <partition>/aconfig_flags.pb exists before reading
In some build targets/combinations aconfig_flags.pb
may not be generated.

For example in GSI only system/aconfig_flags.pb exists
and system-only updates won't have vendor/aconfig_flags.pb.

Test: m, aflags
Change-Id: I136345a8748bc6d80bd98e673f90e0a2ab380ab1
2024-06-18 06:59:52 +00:00
Ted Bauer
6e11172c6b Add defaults target for shared linking
Add a defaults target that all targets linking to aconfig codegen with
the new storage API dependencies will need. The target takes the new
storage APIs conditionally behind a flag, so we can disable it easily.

In this topic, we add it to a single target to see that it builds and
adds the dependency. In follow-on CLs we can add it to the rest of the
targets.

Test: m audiopolicy_tests
Bug: 347701310
Change-Id: I67643205b283301f72c5466401060212b637388f
Merged-In: I67643205b283301f72c5466401060212b637388f
2024-06-17 21:16:51 +00:00
Ted Bauer
5223a70887 Add root check to aflags
aflags scans the apex/ dir, which requires root access to read.
Currently the command fails with "Error: Permission denied", which
doesn't tell the user how to fix the problem. This CL adds a more
descriptive error message.

Test: adb unroot && adb shell aflags list
Bug: 347692127
Change-Id: I98a7a1ba10ef52ec47035816fa66119ea84f281d
2024-06-17 15:25:02 +00:00
Dennis Shen
a8e28dfe87 aconfig: update java read api for performance
With this update, cold flag read (first flag in a namespace) is now 6x
faster compared to device config.

Bug: b/321077378
Test: atest -c
Change-Id: I52ffd897fdd487b2a44d07be50f2975f0ef5b9b3
2024-06-04 17:24:53 +00:00
Dennis Shen
e5dd91bca7 aconfig: create first implementation of aconfig storage java read api
1, See AconfigStorageReadAPI.java to see java APIs to map storage files
and read flag values. It is using fast native annotation, in theory it
should be faster than regular JNI without much of the overhead.

2, The java api calls into Rust wrapper in srcs/lib.rs, note that
MappedByteBuffer is not copied during JNI. In the rust side
implementation we get the underlying raw pointer and buffer size and
reconstruct a rust slice. However, at current implmentation, the string
input such as package name and flag name are most likely copied. They
are converted from JStirng to JavaStr first without copy, then the
into() call to convert it to Rust string. We could potentially optimize
it to without copy.

3, Add an android_test target to lock down the API behaviors.

Bug: b/321077378
Test: atest -c
Change-Id: I8915fe70e8eb341be563c70f85e19e644e8aa6be
2024-05-30 00:32:42 +00:00