Commit graph

8133 commits

Author SHA1 Message Date
mrziwang
e2346b87d9 PrebuildEtcModule no longer implements OutputFiles method
In the context of incremental soong, the output files
inter-module-communication will be through OutputFilesProvider.
The OutputFileProducer interface will be deprecated.

These module types are included in this change:
linker_config
llndk_libraries_txt
sanitizer_libraries_txt
java_sdk_library_xml
vndksp_libraries_txt
vndkcore_libraries_txt
vndkprivate_libraries_txt
vndkpublic_libraries_txt

Test: CI
Bug: 339477385
Change-Id: I35575bbad137df5ff8001db9a61ba5b3d13eaa6d
2024-06-10 15:17:07 -07:00
Jihoon Kang
0030148fcb Merge "Remove exportable modules when generating snapshots targeting older platform" into main 2024-06-10 20:46:09 +00:00
Paul Duffin
b679bdd997 Hide some noisy Metalava issues
Changes https://r.android.com/3106478 and https://r.android.com/3110137
unintentionally started reporting some previously hidden issues as
error when new. This change hides those issues again.

Bug: 343157584
Test: m checkapi before and after
Change-Id: I2e04c919ce5c4f2b39fab65afd13bc31725031f0
2024-06-10 20:46:05 +01:00
Jihoon Kang
98aa8fa840 Remove exportable modules when generating snapshots targeting older platform
This change modifies the contents of the generated Android.bp files so
that when generating a snapshot on a older platform, the "exportable"
modules are removed from the bp files, as the "exportable" modules are
first introduced in V and do not exist in older platforms.

Bug: 345162614
Test: ABTD
Change-Id: I2dba51b98deec7805bd796647a66981f237c55a9
2024-06-10 18:12:35 +00:00
Spandan Das
7fd531f5d1 Identify profile providing apexes using ApexInfo
`com.android.art` and its overrides include a `etc/boot-image.prof`
which is used on device for profile guided dexopt.
```
$ deapexer list <path_in_product_out>/com.android.art.apex | grep
boot-image
$ deapexer list <path_in_product_out>/com.google.android.art.apex | grep
boot-image
```

To identify that we should include a boot-image.prof in the override
apexes, we currently look at ApexInfo.InApexVariants in the context of
art's bootclasspath fragment module. InApexVariants are colated based on
the min_sdk_version of the top-level apex. At ToT, we have a single
variant of `art-bootlcasspath-fragment` for aosp art apex, google art
apex and google go art apex.

When google go art apex overrides the min_sdk_version, ApexInfo is
cleaved, and two distinct variants of art-bootclasspath-fragment are
created. The one corresponding to go art apex does not know we should
include boot-image.prof

To fix this, use AllApexInfoProvider instead. If any of the apexInfos
corresponds to com.android.art, include etc/boot-image.prof

Test: Added a unit test
Test: With https://b.corp.google.com/issues/345173231#comment2 reverted,
m com.google.android.go.art && deapexer list <apex> # verified that
boot-image.prof exists

Bug: 345173231
Bug: 295311875

Change-Id: I5a0e8f74725388f05343c64f268260b1eb139ae5
2024-06-05 21:32:23 +00:00
mrziwang
e6c8581fbe Use OutputFilesProvider on bpf
This changes makes bpf module type uses OutputFilesProvider,
instead of current OutputFileProducer for inter-module-
communication.

Test: CI
Bug: 339477385
Bug: 342406930
Change-Id: I85d1141e9f6583cc5427756107da99f56b0c7ea1
2024-06-04 22:09:13 -07:00
Ronald Braunstein
01d31bdc98 Reapply "Change test_module_config from copying files to symlink ..."
This reverts commit c6a321e4de.

Original commit broke whe building sdk/ndk in postsubmit because of
missing target arch.

See: https://android-build.corp.google.com/artifact/submitted/11914755/mainline_modules_sdks-trunk_staging-userdebug/latest/view/logs%2Fbuild_error.log

Reapplying originaly commit and adding fix in patchest.

Test: DIST_DIR=/usr/local/google/dist/bug TARGET_RELEASE=trunk_staging TARGET_BUILD_VARIANT=userdebug UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true packages/modules/common/build/mainline_modules_sdks.sh
Test: m general-tests
Change-Id: Id844feb7ff9750bcd5af890a9fd26f7342344965
2024-06-02 07:24:51 -07:00
Priyanka Advani
d5e16ac52b Merge "Revert "Change test_module_config from copying files to symlink ..."" into main 2024-05-31 23:39:49 +00:00
Priyanka Advani
c6a321e4de Revert "Change test_module_config from copying files to symlink ..."
Revert submission 3060229-ron-tmc-symlinks

Reason for revert: Droidmonitor created revert due to b/344045516

Reverted changes: /q/submissionid:3060229-ron-tmc-symlinks

Change-Id: If5045366677163560cdae95c0ab74256b4b49b9a
2024-05-31 23:31:13 +00:00
Ronald Braunstein
fb9191bcfe Merge "Change test_module_config from copying files to symlink files." into main 2024-05-31 22:58:10 +00:00
Treehugger Robot
1d903eb078 Merge "Update exportable to handle documentation issues being errors" into main 2024-05-31 18:02:54 +00:00
Paul Duffin
71527b76f6 Update exportable to handle documentation issues being errors
Follow-up to https://r.android.com/3106478 to have exportable handle
documentation issues being errors in the same way as everything does.

Bug: 343157584
Test: ./gradlew
Change-Id: Iba490e46e2ff202e2ef78f49389319ee8549fe3f
2024-05-31 17:41:10 +01:00
Ronald Braunstein
f216af5653 Change test_module_config from copying files to symlink files.
Now the derived modules will have symlink's to base's testcase dir
rather than copyfile files from base's intermediates dir.

I also removed storing the "base" module as dependency and only use
data from the provider in GenerateAndroidBuildActions and
AndroidMkEntries.
I did have to add two fields to the provider for this.

To ensure the symlinks always resolve to a physical file, I also added
goals such that building `derived-target` will also build `build-target`

Create new Make variable: LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES
for tasks/general-tests.mk,device-tests.mk to read.
This allows "support" files that are installed with soong rules rather
than make rules to still end up in the zips.

Sample dir structure:
% tree -ls testcases                                                                                                                                                                                                                                                   aosp_cf_x86_64_phone[4:31:54]/0
[       4096]  testcases
├── [       4096]  FrameworksServicesTests
│   ├── [       4096]  data
│   │   └── [        851]  broken_shortcut.xml
│   ├── [       2800]  FrameworksServicesTests.config
│   ├── [      12695]  JobTestApp.apk
│   ├── [       8599]  MediaButtonReceiverHolderTestHelperApp.apk
│   ├── [      16791]  SimpleServiceTestApp1.apk
│   ├── [      16791]  SimpleServiceTestApp2.apk
│   ├── [      16791]  SimpleServiceTestApp3.apk
│   ├── [    1017763]  SuspendTestApp.apk
│   └── [       4096]  x86_64
│       └── [   79827767]  FrameworksServicesTests.apk
└── [       4096]  FrameworksServicesTests_contentprotection
    ├── [       4096]  data
    │   └── [         54]  broken_shortcut.xml -> ../../FrameworksServicesTests/data/broken_shortcut.xml
    ├── [       3005]  FrameworksServicesTests_contentprotection.config
    ├── [         41]  JobTestApp.apk -> ../FrameworksServicesTests/JobTestApp.apk
    ├── [         69]  MediaButtonReceiverHolderTestHelperApp.apk -> ../FrameworksServicesTests/MediaButtonReceiverHolderTestHelperApp.apk
    ├── [         52]  SimpleServiceTestApp1.apk -> ../FrameworksServicesTests/SimpleServiceTestApp1.apk
    ├── [         52]  SimpleServiceTestApp2.apk -> ../FrameworksServicesTests/SimpleServiceTestApp2.apk
    ├── [         52]  SimpleServiceTestApp3.apk -> ../FrameworksServicesTests/SimpleServiceTestApp3.apk
    ├── [         45]  SuspendTestApp.apk -> ../FrameworksServicesTests/SuspendTestApp.apk
    ├── [         36]  test_module_config.manifest
    └── [       4096]  x86_64
        ├── [         64]  FrameworksServicesTests.apk -> ../../FrameworksServicesTests/x86_64/FrameworksServicesTests.apk
        └── [         36]  UNUSED-FrameworksServicesTests.apk

Test: m clean && atest FrameworksServicesTests_contentprotection
Test: m clean && atest CtsDevicePolicyManagerTestCases_ParentProfileApiDisabled

Bug: b/332320956
Change-Id: I8466f253fa559bc74cef4533edf263650e96bbfb
2024-05-31 08:24:11 -07:00
Spandan Das
15a67111f8 Make dex_preopt.enable_prof_rewrite=false an error for optimized apps
If profile guided dexpreopt _and_ optimization/obfuscation is true, then
apps must use the rewritten profile created by r8/d8

Bug: 335418838
Test: m nothing --no-skip-soong-tests
Change-Id: Iac45b614f43e52ac40ad1d13df0338bcafa788c3
2024-05-30 20:44:44 +00:00
Spandan Das
3dbda18e80 Use r8/d8 optimized profile for dexpreopt
Currently, dexpreopt supports profile guided optimization. This does not
work well with r8/d8 optimization, since the checked-in profile will not
match the dex signatures after r8/d8 has optimized the dex code.

This CL introduces a new property `dex_preopt.enable_profile_rewrting`.
If set, the checked-in profile will passed as `input` to r8 via
`--art-profile <input> <output>`. The <output> from the previous command
will be used as the profile for dexpreopt.

Test: m nothing --no-skip-soong-tests
Test: m CredentialManager with https://ag.corp.google.com/27448930
and obfuscation turned on
Test: nm -U symbol.odex # contains obfuscated methods

Bug: 335418838

Change-Id: I53beed9ed76f013262f1c503de0f2b74997c2a7f
2024-05-29 01:05:05 +00:00
Paul Duffin
baf34783a4 Update build to handle documentation issues being errors
Previously, documentation issues had `lint` severity (which was between
`warning` and `hide`) by default. However, a recent change in Metalava
switched documentation issues to `error`. That broke some `droidstubs`
modules that either did not specify `api_lint` or were previously allow
listed to not use `--lints-as-errors`.

This change adds `--error-when-new-category Documentation` to the
Metalava arguments on any use of `droidstubs` that did not previously
specify `--lints-as-errors` to prevent the build breakage while still
warning developers of the problem and preventing new cases being added.

Bug: 343157584
Test: ./gradlew
Change-Id: Id80bc05e2dade580b2f3ac6416aeeed6b64ba22a
2024-05-28 17:37:20 +01:00
Jihoon Kang
d02bd377da Merge "Propagate DirectlyInAnyApex to transitive dependencies" into main 2024-05-24 00:58:05 +00:00
Jihoon Kang
46d66de1c1 Propagate DirectlyInAnyApex to transitive dependencies
`UpdateDirectlyInAnyApex` is used to propagate the ApexProperties
`DirectlyInAnyApex` and `InAnyApex` to the direct dependencies of the
direct dependencies of an apex bundle. In other words, this will be
propagated only to two-levels max dependency from the apex bundle.

However, the implementation library of the sdk library can have longer
dependency chain from the apex bundle than two levels:
e.g. apex -> bcpf -> sdk_lib -> sdk_lib impl lib

Therefore, even if the implementation library of the sdk library is
registered as a dependency using the "CopyDirectlyInAnyApexTag"
dependency tag, the ApexProperties would not be propagated to the
implementation library. In order to resolve this issue and recognize
the implementation library to be directly in apex and allow
instrumentation for the implementation library, this change proposes
propagating `DirectlyInAnyApex` and `InAnyApex` to transitive
dependencies on top of direct dependencies.

Test: DIST_DIR=dist_dir TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86_64 COVERAGE_MODULES="uwb" ./vendor/google/build/build_unbundled_coverage_mainline_module.sh && \
unzip -l out/target/product/module_x86_64/jacoco-report-classes-all.jar and ensure that framework-uwb is included
Bug: 341170242

Change-Id: I27d7a74f6e5bc3e0a044d13c619f4897b6b2eb57
2024-05-23 22:40:35 +00:00
Treehugger Robot
bc44eb03db Merge "Allow experimental Java target 21 by default" into main 2024-05-23 16:37:21 +00:00
Sorin Basca
253f8c045a Allow experimental Java target 21 by default
Bug: 342332820
Test: EXPERIMENTAL_TARGET_JAVA_VERSION_21=true m
Change-Id: I6cc21bf191385df91c2446b7cd6291a0e3532bea
2024-05-23 10:28:24 +01:00
Treehugger Robot
b07e7fd542 Merge "Instrument impl library belonging to apexes" into main 2024-05-22 19:01:41 +00:00
Jihoon Kang
690df2e31b Instrument impl library belonging to apexes
https://r.android.com/3094444 has removed instrumentation from the
implementation library of the java sdk library. However, given that the
top level java sdk library was not being instrumented before removing
the compilation action, there is no way to get the coverage data for the
java sdk library included in the mainline modules with the
aforementioned change.

As seen in b/340174053, instrumenting all impl libraries by default
may lead to double instrumentation execution time error in some edge
cases (especially with make to soong dependency).

Given the above two conditions, this change allows instrumentation for
the implementation library of the java sdk library that belongs to
apex(es).

Test: lunch husky-trunk_staging-userdebug && EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true m droid dist
Test: DIST_DIR=dist_dir TARGET_BUILD_VARIANT=userdebug PRODUCT=mainline_modules_x86_64 COVERAGE_MODULES="uwb" ./vendor/google/build/build_unbundled_coverage_mainline_module.sh
Bug: 341170242
Change-Id: I175e02f61e139296f5a177e6fc1c3ded760ac028
2024-05-22 04:27:38 +00:00
Treehugger Robot
1bd60b7c79 Merge "implement InstallDepNeeded for sdkLibraryComponentTag" into main 2024-05-22 01:15:52 +00:00
Joe Onorato
30f6e28295 Merge "Fix the problem of resource integration confusion caused by not adding regional configuration tailoring." into main 2024-05-22 00:02:04 +00:00
Jeongik Cha
aaa6dcdabb implement InstallDepNeeded for sdkLibraryComponentTag
To include a sdk library impl and a permission xml for that.

Bug: 340365498
Test: m aosp_cf_system_x86_64 && check if there is a sdk lib impl and
permission xml

Change-Id: I10190fb9d398b6249efd6fe50b204e328250f23f
2024-05-22 00:43:20 +09:00
Treehugger Robot
652824c8d6 Merge changes from topic "revert-3094658-revert-3088867-QEHDREAABY-IOPVAUIKWL" into main
* changes:
  Revert^2 "Refactor how jni_libs dependencies are added"
  Revert^2 "Add make java.dependencyTag installable or not"
  Revert "Revert "APK-in-APEX should set use_embedded_native_libs:..."
  Revert^2 "Install jni symlinks in Soong"
2024-05-20 23:00:05 +00:00
Treehugger Robot
766a156fac Merge "Create empty monolithic hiddenapi flags files for non java devices." into main 2024-05-20 22:21:29 +00:00
Treehugger Robot
58dace8454 Merge "Do not instrument the implementation library of sdk_library" into main 2024-05-20 21:45:27 +00:00
Jiyong Park
92d8404bc5 Revert^2 "Refactor how jni_libs dependencies are added"
562d9054e5

Change-Id: Ib9e6efc736bd0ba20637afb0a8d05b9b0266586f
2024-05-21 06:41:37 +09:00
Jiyong Park
c1e5b1848a Revert^2 "Add make java.dependencyTag installable or not"
f14b5ba863

Change-Id: I0638d4997cb8e5178f869ea0f469a1a5c141611e
2024-05-21 06:41:36 +09:00
Jiyong Park
970c524ab5 Revert "Revert "APK-in-APEX should set use_embedded_native_libs:..."
Revert submission 3094658-revert-3088867-QEHDREAABY

Reason for revert: not a regression
Reverted changes: /q/submissionid:3094658-revert-3088867-QEHDREAABY

Change-Id: Ie1e4a196f181643a3e64e573b132d52d7455461b
2024-05-21 06:41:36 +09:00
Jiyong Park
25b9222a43 Revert^2 "Install jni symlinks in Soong"
b7646e4d4f

This is a relanding of I0930cb1ebb8ca8a6efd64b1ce2cdfd1c47fe19ef plus
some forward fix described below:

Export non-embedded JNI lib names via LOCAL_REQUIRED_MODULES

The non-embedded JNI libs are installed as the dependencies of the APK.
However, that dependency is not revealed to the Make world and as a
result, the JNI libs are dropped from the file_list.txt file which Make
uses to filter files to include in the image file.

Adding the lib names to LOCAL_REQUIRED_MODULES fixes it.

Bug: 341335305
Bug: 330276359
Test: m out/target/product/vsoc_x86_64_only/obj/PACKAGING/system_intermediates/file_list.txt
and check if libcarservicejni.so is there
Test: go test ./... under soong/java

Change-Id: If915a05909129c92fab7a6cbbd0c4c55f5ced598
2024-05-21 06:40:14 +09:00
优秀
d75e99859b Fix the problem of resource integration confusion caused by not adding regional configuration tailoring.
An android app is automatically creating a corresponding "product
characteristics" RRO. The app's resources are filtered by the aapt
product config, but the rro resources are not. This cl makes the RRO
resources also filtered.

When building the CN version, it was expected that only the resources
corresponding to the CN version would be retained, but the actual result
was that other unexpected areas appeared on the region setting interface
in boot interface. After investigation, it was found that the
framework-res__nosdcard__auto_generated_characteristics_rro.apk apk
integrated resources other than the CN version that caused this problem,
and the integration of this apk was not filtered by aaptconfig.
The purpose of this modification is to add aaptconfig filtering, and it
has been verified that this problem can be fixed.

Change-Id: I85d5d07397bd2b0759d35b9f3a07f015346af4e9
Signed-off-by: wybxyx <wybxyx@gmail.com>
2024-05-20 21:35:12 +00:00
Jihoon Kang
34155e3363 Do not instrument the implementation library of sdk_library
Currently, the implementation library of the java_sdk_library is always
being instrumented due to the issue described in b/159241638.

With https://r.android.com/3079425, all compilation actions of the
java_sdk_library is delegated to the implementation library.
Consequently, this has caused all java_sdk_library to be instrumented,
leading to coverage builds failing due to double instrumentation (i.e.
instrumenting an already instrumented class file). In order to prevent
such error, this change modifies the property of the implementation
library to not instrument during coverage builds.

This change also copies some additional java library properties from
that of the implementation library to the top level sdk library, in
order to ensure that all non-null androidmk entries are correctly
reflected in that of the sdk library.

Test: lunch husky-trunk_staging-userdebug && EMMA_INSTRUMENT=true EMMA_INSTRUMENT_FRAMEWORK=true m droid dist
Bug: 340174053
Bug: 341170242
Change-Id: I9d8f1c190205fa7a827649961ba5222293a945ad
2024-05-20 19:08:49 +00:00
Spandan Das
a90db96bb9 Create empty monolithic hiddenapi flags files for non java devices.
This is a followup https://r.android.com/3089366 that disabled the
creation of out/soong/hiddenapi/hiddenapi* files for non java device
builds. This works fine for `m`, but `m dist` runs issues since
`f/b/boot/Android.bp` dists these files. For non java devices, the
previous implementation would report missing files during ninja
excecution (https://b.corp.google.com/issues/338363444#comment5)

This CL creates empty files for these so that the dist tags can always
be resolved.

Bug: 338363444
Test: lunch aosp_cf_x86_64_minidroid-trunk_staging-userdebug && m dist
Change-Id: Ice2d970a164246753da89a6a06dfd28a627a272d
2024-05-20 18:56:28 +00:00
Treehugger Robot
8298134503 Merge changes Ifbe123d1,Ie2e738a6 into main
* changes:
  Support min_sdk_version overrides in apexes
  Support min_sdk_version overrides in apps
2024-05-20 17:38:11 +00:00
Spandan Das
50801e20a3 Support min_sdk_version overrides in apexes
The use case for this are go apexes which are only installed in T and
above, even though the base AOSP apexes might be installable on < T
devices.

If provided, the overridden min_sdk_version will be
1. Used as the `min_sdk_version` in the manifest file of the
   top-level override apex binary
2. Used to build the transitive closure of its dependency with that
   min_sdk_version, i.e. with a different apex variant.

(2) requires some special handling. At ToT, the outgoing transition
value is the base apex name (e.g. com.android.foo). Since
min_sdk_version of the overridding apex can be different than the
overridden apex, the base apex name is no longer sufficient. Instead,
transition to the name of the overriding apex com.mycompany.android.foo.
If deduping is possible, transitive deps will get deduped to
`apex_<min_sdk_version>` later.

Test: added a unit test
Test: in internal, modified min_sdk_version of com.google.android.go.art
locally, built BA and Go apexes, and used `aapt2 dump badging` to verify
that BA has minSdkVersion of 31 and Go has minSdkVersion of 33

Bug: 295311875

Change-Id: Ifbe123d1517fccbc0c058042b8a6eeb3609b6787
2024-05-20 16:24:52 +00:00
Yu Shan
4978080b1d Merge changes from topic "revert-3088867-QEHDREAABY" into main
* changes:
  Revert "Install jni symlinks in Soong"
  Revert "APK-in-APEX should set use_embedded_native_libs: true"
  Revert "Add make java.dependencyTag installable or not"
  Revert "Refactor how jni_libs dependencies are added"
2024-05-17 22:55:51 +00:00
Spandan Das
b9c58350ca Support min_sdk_version overrides in apps
This replaces the global override of min_sdk_version (via
`APEX_GLOBAL_MIN_SDK_VERSION_OVERRIDE`) with an min_sdk_version override
that can be set by each individual soong override_app.

The use case for this are go apps which are only installed in T and
above, even though the base AOSP apexes might be installable on < T
devices.

Test: added a unit test

Bug: 295311875
Change-Id: Ie2e738a6786bb24417c675617f7c78358017c96c
2024-05-17 21:15:04 +00:00
Spandan Das
d700486907 Merge "Disable monolithic hiddenapi flags generation for non java devices." into main 2024-05-17 21:11:31 +00:00
Yu Shan
b7646e4d4f Revert "Install jni symlinks in Soong"
Revert submission 3088867

Reason for revert: On cf_auto build, we are seeing a symlink of jni lib pointing to lib64/libcarservicejni.so, which does not exist on the device.

Reverted changes: /q/submissionid:3088867
Bug: b/341335305

Change-Id: Ie4ff26fe47e1a0ab5e97b185c61cb94473cc5fb8
2024-05-17 13:37:37 -07:00
Yu Shan
d5e435d749 Revert "APK-in-APEX should set use_embedded_native_libs: true"
Revert submission 3088867

Reason for revert: On cf_auto build, we are seeing a symlink of jni lib pointing to lib64/libcarservicejni.so, which does not exist on the device.

Reverted changes: /q/submissionid:3088867
Bug: b/341335305

Change-Id: I3064caef0cb55d1594951835a1173c667f58e607
2024-05-17 13:37:30 -07:00
Yu Shan
f14b5ba863 Revert "Add make java.dependencyTag installable or not"
Revert submission 3088867

Reason for revert: On cf_auto build, we are seeing a symlink of jni lib pointing to lib64/libcarservicejni.so, which does not exist on the device.

Reverted changes: /q/submissionid:3088867
Bug: b/341335305

Change-Id: I60052dbb004df58fdfaf93be6089769ab2a670fc
2024-05-17 13:37:20 -07:00
Yu Shan
562d9054e5 Revert "Refactor how jni_libs dependencies are added"
Revert submission 3088867

Reason for revert: On cf_auto build, we are seeing a symlink of jni lib pointing to lib64/libcarservicejni.so, which does not exist on the device.

Reverted changes: /q/submissionid:3088867
Bug: b/341335305

Change-Id: Ibda68b268e74ffca1840faae01a2f3fe2e00be30
2024-05-17 13:37:07 -07:00
Jiyong Park
4e8ab4e103 Merge changes I1bc9ceb8,I9b1c7809,I836171aa,I0930cb1e into main
* changes:
  Refactor how jni_libs dependencies are added
  Add make java.dependencyTag installable or not
  APK-in-APEX should set use_embedded_native_libs: true
  Install jni symlinks in Soong
2024-05-17 02:44:31 +00:00
Jiyong Park
cf68460114 Refactor how jni_libs dependencies are added
This CL brings three changes in how jni_libs are depended on.

1. SDK variants of the jni_libs are depended on only when they can be
   embedded. This is because SDK variants are not installable.
Previously, app could depend on SDK variants without embedding them, but
this didn't cause a problem because the installation of the jni libs was
done in Make. However, as it's done in Soong, we need to depend on a
correct variant.

2. Non-SDK variants of the jni_libs are now tagged with jniInstallTag.
   This automatically installs the libraries along with the app. The
installation of the jni libs is no longer done in app.

3. checking of the sdk version of the jni libs is done only when they
   are embedded. Doing the check even when the libs are not embedded
triggers a lot of false alarms. Note that with #1, many platform apps
have started depending on non-SDK variants.

Bug: 330276359
Test: m
Change-Id: I1bc9ceb8f79b102caeb23476c3fb03989e184a91
2024-05-16 23:31:55 +09:00
Jiyong Park
4384d294c3 Add make java.dependencyTag installable or not
java.dependencyTag now has a new field installable which contols whether
the dependency should be added as the install dep of the app or not.

This allows us to model all the dependency tags for Java using the same
struct.

Bug: N/A
Test: m
Change-Id: I9b1c7809a0bde3f15579aefd9bb34d828764b84b
2024-05-16 19:40:01 +09:00
Jiyong Park
5f0943f33f APK-in-APEX should set use_embedded_native_libs: true
So far, we automatically have embedded JNI libs for APKs in APEX, even
if use_embedded_native_libs was not set or set to false.

With this change, such APKs should explicitly set the property.

This is in preparation for an upcoming change for using different
dependency tags to JNI deps depending on whether they are embedded (thus
no install is needed), or not (thus installation to the partition is
needed).

shouldEmbedJni function now doesn't make use of the ApexInfoProvider
which is not available during deps mutator.

Bug: N/A
Test: m
Change-Id: I836171aacba19dbfa0e09f16a773ae498c56d60b
2024-05-16 19:40:00 +09:00
Jiyong Park
4f487c5b56 Install jni symlinks in Soong
The installation of the symlink
(<partition>/app/MyApp/lib/<arch>/libfoo.so) and its target
(/system/lib64/libfoo.so) are now done int Soong.

I gave up the idea of always embedding jni libs to apps, due to a
hard-to-fix regression in storage usage. Specifically, consider this
case.

app --(jni_lib)--> libfoo
    --(jni_lib)--> libbar

libfoo --(shared_lib)--> libbar

Ideally, with the embedding idea, both libfoo and libbar should be
embedded into the app and there should be no libfoo or libbar outside of
the apk, unless there's no dependency to any of them from outside of the
apk.

However, the previous implementation installed libbar to /system/lib64,
leading two copies of the lib; one in /system/lib64, the other in the
apk.

This was happening because libbar was also considered as a transitive
dep of libfoo, and therefore a dependency to its installation path is
added to the apk. The problem here is that the app doesn't know that
libfoo depends on libbar. We in theory can write a very delicate
dependency traverse routine which filters libbar out of the transitive
deps, but that looked too complicated.

Bug: 339923078
Bug: 330276359
Test: Build and watch any bloatbuster warning
Test: m aosp_cf_system_x86_64
The following three files are found
* system/lib64/libnfc_nci_jni.so
* system/etc/libnfc-nci.conf
* system/priv-app/NfcNci/lib/arm64/libnfc_nci_jni.so

Change-Id: I0930cb1ebb8ca8a6efd64b1ce2cdfd1c47fe19ef
2024-05-16 19:40:00 +09:00
Spandan Das
3d0d31a8c6 Align boot jar exclusion with apex_contributions
During trunk stable development, it is possible that a new boot jar is
added to the source apex, but not available in prebuilt apex yet.
Thefore we need to conditionally check the `contents` of the respective
bootclasspath_fragment modules. https://r.android.com/2822393 did this
using isActiveModule. This function relies on soong config namespaces to
"hide" the source bootclasspath_fragment module when
<module>.source_build is false.

Soong config namespaces for mainline source vs prebuilt selection is no
longer in use, so this CL replaces `isActiveModule`. The CL cleaves the
implementation
1. For source builds, the check will run in the context of the
   bootclasspath_fragment module. `disableSourceApexVariant` will be
used to skip the check if prebuilts are selected.
2. For prebuilt builds, the prebuilt bootclasspath_fragment module sets
   a provider, and the top-level apex will do the check.

(2) is necessary to handle the edge case of multiple versioned mainline
prebuilts and possible skew in apex boot jars across them. In case of
prebuilt builds, the unselected mainline prebuilts will have
HideFromMake called on them, so the check will only run on the apex that
is actually used during the build.

Bug: 328578801
Test: go test ./apex

Change-Id: I6eec603397eea926f3a481b79ca938245064d809
Merged-In: I6eec603397eea926f3a481b79ca938245064d809
2024-05-16 00:35:28 +00:00