UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA enables user to specify
${codename}.${sha} as min_sdk_version and target_sdk_version in order to
support mainline train building into android build.
Test: TH
Bug: 295905124
Change-Id: I032d464aaa7314520f98b8eafa53d962940075ce
Bug:278905106
Test: go test ./java --run TestManifestValuesApplicationIdSetsPackageName
and locally built a module and checked manifest pacakge_name
Change-Id: I5c8fd27c177b9e255dce197706f62580894008cb
Currently, target_sdk_version of MTS tests were being set to 10000 even
in release branches. This should only happen in active branches.
Test: Unit test
Test: aapt2 on CtsContentTestCases in udc-dev and verified
targetSdkVersion is 34
Bug: 279507428
Change-Id: Ib79318febc0f6e771b3679c0281a97357930ec56
target_sdk_version signifies device version and does not need an sdkKind to
describe it fully. Update the type and cleanup existing usages. As a
side benefit, we also get better error handling since users can no
longer enter something like `public_30` as a valid target_sdk_version in bp
files
Test: m nothing
Test: no change in ninja files (this should be a no-op)
Bug: 208456999
Change-Id: I3c19245e29184bd9e5660ad8981966f64dfa9424
Change https://r.android.com/1959021 introduced a regression in the
handling of the `targetSdkVersion` when using the API fingerprint.
Prior to that change, when `UseApiFingerprint(ctx)` returned true that
would cause all APKs (apart from `framework-res`) that were built to
use a `targetSdkVersion` that included the API fingerprint SHA. After
that change the `UseApiFingerprint(ctx)` had no effect on the setting
of `targetSdkVersion`.
This change corrects that.
Bug: 266899206
Test: UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true TARGET_BUILD_APPS="NetworkStack" m
aapt2 dump badging out/target/product/generic/system/priv-app/NetworkStack/NetworkStack.apk
# Run above before and after this change and see that the targetSdkVersion
# has changed to `UpsideDownCake.<SHA>`.
Change-Id: Ic6e1da552c565cc4bd75cc734b3acb7faec67981
Due to GMS target SDK requirements (https://docs.partner.android.com/gms/policies/preview/mba#min-target-sdk)
we need to ensure all the mainline packages to target latest API
level. Currently, the team chases each module to bump their target
API level.
Updating the build code to make sure that mainline modules
(i.e updatable modules) target the latest sdk version by default.
It would be by default set to 10000 before SDK finalization and updated to the new API level after finalization.
Effectively it would mean:
1. '10000' in aosp and internal master
2. Finalized number in development branches like "33" in "tm-dev"
3. As sdk hasn't been finalised in "udc-dev", it would be "10000"
which would be automatically updated to finalized version after sdk finalization.
For local development if the target sdk version is required to be set,
users would need to set Updatable flag to false.
Enforce_default_target_sdk_version flag needs to be used in bp file,
if this feature needs to be tested locally when updatable: false.
Bug: b/227460469
Test: m nothing
Change-Id: I05e0ae74ae44fd73df75e91b926bcc924446253f
MTS tests built on unstable branches (e.g. git_master) should be testable on
old system images (e.g. S). However, they run into an error during installation
on older images:
`Requires development platform $<current_codename>, but this is a
release platform`
This CL fixes this issue by updating the target_sdk_version of MTS test apps
targeting current to the magical sdk_version 10000
Bug: 227473065
Test: go build ./java
Test: TH
Change-Id: Ic0358a48a19dc239defbb4ee8ec99225cce75584
If max_sdk_version is included in Android.bp that value will now be
propagated to manifest_fixer.py. This value will then be used to
override any maxSdkVersion attribute set on permission or
uses-permission tags in the android manifest if maxSdkVersion="-1".
Bug: 223902327
Test: add max_sdk_version to Android.bp for test app
Test: create permission in test app manifest with maxSdkVersion="-1"
Test: run test to check maxSdkVersion=max_sdk_version
Change-Id: Ic533ef2a41b9ecc9ee68c69399026df47ee945b7
This reverts commit 0b1c70efbc.
The reverted commit was based on the idea that uses-libraries that are
explicitly specified in build files should not be implicitly added to
the manifest, as that would mean that anything added to the build files
will flow to the manifest.
Although this logic is correct, it prevents propagation of
uses-libraries from dependencies, which is wrong: if a library has an
explicit uses-library property in Android.bp, this property is expected
to be propagated to the library's dependencies. Failing to do so would
mean that every user of that library has to add uses-library property to
their build files, which doesn't scale (see b/214255490 for example).
Bug: 214255490
Test: lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd \
&& adb wait-for-device && adb root \
&& adb logcat | grep -E 'ClassLoaderContext [a-z ]+ mismatch'
# empty output, no errors at boot
Change-Id: I6f420e76a89aa2f37be99f877711736640f2c361
This CL refactors the code related to ManifestFixer parameters.
The required parameters android.ModuleContext, manifest android.Path are
passed separately as the parameters and the optional parameters are
kept as part of the ManifestFixerParams struct.
By default, the member variable of struct have the zero (nil, false,
empty string) values. Hence, it is only required to pass the
parameters of interest at the time of function call to
ManifestFixer.
Manual testing done to check the working of the code.
Test: m nothing && m test_com.android.sdkext
Test: manually tested the generation of AndroidManifest in the out
directory with the testOnly attribute
Test: atest manifest_fixer_test --host
To test the existing unittests are not breaking.
Change-Id: I20cb6c06c57f8fe7811050288bcb03945dc0425b
If the build file contains the apex_test module, add the
testOnly attribute to the application element of the
corresponding AndroidManifest file and set its value to true.
If the testOnly attribute is already present and has value
false, then do nothing.
Tests added in manifest_fixer_test.py to check if the updated
AndroidManifest file has the testOnly attribute set to true or not.
Bug: 213310150
Test: atest --host manifest_fixer_test
Test: m nothing
Test: manually checked the AndroidManifest file generated
Change-Id: I36247dbe0261c342d451a4422c314fd8fe0c2369
sdk
Previously in aosp/1907152, targetSdkVersion for all modules would be
10000 in release builds. This would cause sdk compatibility errors like
b/209301265#3 for modules that were targeting a released SDK
This CL adds an additional check to set targetSdkVersion to 10000 only
if a module's apilevel is in preview (i.e. unreleased SDK)
Bug: 209301265
Test: Built various apk combinations locally, and used aapt2 to check
targetSdkVersion
Test: TARGET_BUILD_APPS=xyz m CaptivePortalLoginTests #
targetSdkVersion: 30
Test: m CaptivePortalLoginTests #targetSdkVersion: 30
Test: (internal) TARGET_BUILD_APPS=xyz m MediaProviderGoogle #
targetSdkVersion: 10000
Test: (internal) m MediaProviderGoogle #targetSdkVersion: Tiramisu
Change-Id: Id2901f23d4e1b436f8906940e47edd606a93657d
manifest_fixer transforms an AndroidManifest.xml file for use in aapt2.
For TARGET_BUILD_APPS builds, set targetSdkVersion to a FutureApiLevel
Test: In build/soong, go test ./java
Test: TH
Test: In internal, TARGET_BUILD_APPS=xyz m
out/soong/.intermediates/packages/providers/MediaProvider/MediaProvider/android_common_MediaProviderGoogle_apex30/package-res.apk
&& aapt2 dump badging
out/soong/.intermediates/packages/providers/MediaProvider/MediaProvider/android_common_MediaProviderGoogle_apex30/package-res.apk
| grep targetSdkVersion # targetSdkVersion:'10000'
Test: In internal, m
out/soong/.intermediates/packages/providers/MediaProvider/MediaProvider/android_common_MediaProviderGoogle_apex30/package-res.apk
&& aapt2 dump badging
out/soong/.intermediates/packages/providers/MediaProvider/MediaProvider/android_common_MediaProviderGoogle_apex30/package-res.apk
| grep targetSdkVersion # targetSdkVersion:'Tiramisu'
Bug: 204107787
Change-Id: Ic6f21111d5a8c61ae789a7a3a001f669257a39b2
These properties specify libraries that cannot be implicitly inferred by
Soong. If these properties are added to Android.bp, this can only be for
the reason that there is a <uses-library> tag in the manifest which is
unknown to the build system. Adding them to the manifest_fixer doesn't
make sense: if they are not in the manifest, they should be removed from
Android.bp as well.
Bug: 132357300
Test: $ lunch aosp_cf_x86_64_phone-userdebug && m && launch_cvd
$ adb wait-for-device && adb root && adb logcat \
| grep -E 'ClassLoaderContext [a-z ]+ mismatch'
# empty grep output, no errors
Change-Id: Ic6eb5268a954ef3be7f06a181ec72af99000c547
Previously manifest_fixer used a naive way to distiniguish optional libs
from required ones: it checked if a library is on the list of optional
compatibility libraries. This works for compatibility libs, but not for
other libs.
Now we properly track optionality through all stages of the build,
starting with the addition of the library as a dependency (here's where
the `uses_libs`/`optional_uses_libs` distinction kicks in), store it in
dependency tag and propagate to class loader context, and from there to
the manifest_fixer.
The tests have been updated accordingly.
Bug: 196377222
Test: lunch bertha_x86_64-userdebug && m droid dist cts mts
Change-Id: I3631ce59ebe47116ce7a9b3d33a86f636846ef0f
Previously, SdkSpec was constructed only from the user string. It didn't
make use of the Config struct where information about the latest stable
SDK version, etc. is recorded. As a result, the build system couldn't
check if the sdk version "current" is referring to the in-development
(i.e. not-yet-frozen) SDK version or the latest stable version.
"current" was always assumed to be in-development (IsPreview() returns
true) even when Platform_sdk_final == true.
As the first step for fixing that, this change requires
android.EarlyModuleContext to be passed when constructing SdkSpec from
the user string.
In the following changes, "current" will be mapped to either
FutureApiLevel (10000) or one of the FinalApiLevels() depending on
whether the platform SDK was finalized or not.
Bug: 175678607
Test: m
Change-Id: Ifea12ebf147ecccf12e7266dd382819806571543
SdkSpec.Version was an int type. Now it becomes ApiLevel type which
is a better abstraction of the version (or api level).
Bug: 1655587
Test: m
Change-Id: I4d67b9b9eae45f653b6af4f5b73da9e091b3dfab
... in preparation for making the handling of sdk versions consistent
across java and cc modules.
Bug: 175678607
Test: m
Change-Id: I598f0454bce9b7320621022115412fbe97403945
Generating the API fingerpring depends on framework-res, so the
fingerprint cannot be embedded into framework-res. Hardcode an
exemption to UseApiFingerprint.
Bug: 181978889
Test: TARGET_BUILD_VARIANT=user UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true vendor/google/build/build_mainline_modules.sh
Change-Id: I621f36d5eb157dd97baa132ff109b4df791eedcc
The old representation consisted of a list of libraries (UsesLibraries),
a list of optional libraries (OptionalUsesLibraries) and a mapping from
library name to its build/install paths (LibraryPaths). The separation
into lists and map was necessary because of special handling of
compatibility libraries, which is now unified with normal libraries.
The new representation is a mapping from target SDK version to a tree
structure ClassLoaderContext. Each node of the tree represents a library
and contains library name, build/install paths and a slice of
subcontexts for dependencies. The same library may occur in the tree
multiple times in case it is a dependency of multiple libraries. The
order in which libraries are added matters (the resulting tree shape may
be different).
Test results have to be updated, as the resulting <uses-library> list is
reodered (previously it was a sorted list of map keys, and now it is
formed by a depth-first preorder traversal of the class loader tree).
Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Bug: 168686456
Change-Id: I11be8cd2967f004fd58753d7c5fb99fed179cd63
Previously default install path was provided only for comatibility
libraries that are added explicitly via `uses_libs`/`optional_uses_libs`
properties. This didn't take into account compatibility libraries that
are added by Soong when it computes transitive closure of SDK library
dependencies. As a result, install path in such cases remained unknown,
and the corresponding compatibility library was omitted from class
loader context, which caused 'ClassLoaderContext shared library size
mismatch' errors at first boot on device.
Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: If661272f46803299c8640f7f5ef161c8217d07e4
Previously only the names were collected, and later used in the
manifest_fixer to add missing <uses-library> entries to the manifest.
Now we also need to collect build-time and on-device paths, to be used
in class loader context for dexpreopt. This commit only collects paths,
but does not pass them to dexpreopt yet.
Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I34b229ee68f16ba215ba03770feadb4d890ec2bf
Package a slightly modified copy of the robolectric tests with
the dependencies statically included into the testcases directory
and into a robolectric-tests.zip.
Test: m robolectric-tests
Change-Id: I73f51727695136d2a849d36af1683e93f7e156a3
Unit test: go test ./... -test.v -run TestOverrideAndroidApp
Unit test: python manifest_fixer_test.py
BUG: 148198056
Change-Id: Ib5ff235d2a93e88b86aec1c0b16327ea938a094d
The value format that sdk_version (and min_sdk_version, etc.) can have
has consistently evolved and is quite complicated. Furthermore, with the
Mainline module effort, we are expected to have more sdk_versions like
'module-app-current', 'module-lib-current', etc.
The goal of this change is to abstract the various sdk versions, which
are currently represented in string and is parsed in various places,
into a type called sdkSpec, so that adding new sdk veresions becomes
easier than before.
The sdk_version string is now parsed in only one place 'SdkSpecFrom', in
which it is converted into the sdkSpec struct. The struct type provides
several methods that again converts sdkSpec into context-specific
information such as the effective version number, etc.
Bug: 146757305
Bug: 147879031
Test: m
Change-Id: I252f3706544f00ea71c61c23460f07561dd28ab0
This reverts commit 230e241f58.
Reason for revert: This is a revert of a revert. Downstream problem has been fixed and have been validated locally and via Forrest build.
Change-Id: I89c51d25b3adb818ea44a983d0ac681a88790d8c
This reverts commit 014a85712d.
Reason for revert: Caused vendor/google/build/build_mainline_modules.sh to fail with `Error: minSdkVersion (10000) is greater than maxSdkVersion (30)`.
Bug: 130541924
Change-Id: Ifa233bf40a674481d21b61ee816c5fdde8201080
Use codename.fingerprint format for minSdkVersion if it is unset
in the manifest and
UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true.
Using a utility function in sdk.go to check whether to apply
api.fingerprint.
BUG: 130541924
Change-Id: I748a25c419033bf54b63171d334644fcd0ecc78f
The new package manager behavior requires packages without source code
to have an application element with hasCode attribute set to false in
their manifest. With this change, Soong can now automatically insert one
for codeless apps.
Test: app_test.go, manifest_fixer_test.py
Fixes: 124375490
Change-Id: Ied89a8d07c63805ab910859a4f7c45fc1c60bb73
Port I4e7a9bdc5bf845af85168abf55f8063900bacc72 and
Ieb7c1429077aaf6899e214a217d9455d95dbfea6 from Make to Soong to
support adding <uses-library> tags to AndroidManifest.xml for
transitive java_sdk_library dependencies and android.test.base
and android.test.mock.
Fixes: 133306356
Test: m checkbuild
Change-Id: I23763bb689c474d25d04a418df1c46e7f0d807af
`use_embedded_native_libs: true` should cause
`--extract-native-libs=false` be added to the manifest_fixer invocation,
and it was not happening.
There are also minor naming improvements.
Bug: 117618214
Test: treehugger and 'atest CtsDynamicLinkerTestCases' after
cts/tests/tests/dynamic_linker has been converted to Android.bp.
Change-Id: I93ec2aed3f3b185d320e56b1b4eebb71339b81ee
Manifest merger needs --remove-tools-declarations to match
Gradle behavior.
Bug: 112607039
Test: m checkbuild
Change-Id: Id93bcaeaf03770a4acd2e1fdf44e418f55540dd3
Don't use the merged manifest for android_library modules. We
still have to run manifest merger for android_library modules
because Make can't handle transitive dependencies, so it will
continue to merge the manifests at each library, and then merge
the manifests of direct dependencies into the final application.
Bug: 113294940
Test: m checkbuild
Change-Id: Ia8f9f910bd0a134730ddf2d542460eeddbc0a075
Target SDK version is used for targeting an APEX to a specific set of
platform builds. Usually, the targeting is unrestricted (in case the
APEX can run on all platforms), or based on platform SDK version (e.g.
28 for P). However, when the platform is under development and SDK is
not finalized, the targeting should be much more fine-grained; the
APEX should be targeted to a very specific build that supports the same
set of APIs that the APEX was built against.
To support that, target sdk version is automatically set by the build
system. When the platform is released or SDK is finalized, the target sdk
version set to the SDK version number. If not, it is set to
<version_code>.<fingerprint> (e.g., Q.123456).
Note that the target sdk version set by the build system is used only
when the target sdk version is not explicitly set in
AndroidManifest.xml.
Bug: 130541924
Test: UNBUNDLED_BUILD_SDKS_FROM_SOURCE=true \
UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true \
TARGET_BUILD_APPS=com.android.tzdata m
build.ninja has --target_sdk_version Q.$$(cat out/soong/api_fingerprint.txt)
Test: aapt dump badging out/dist/com.android.tzdata.apex | grep \
targetSdkVersion shows:
targetSdkVersion:'Q.6ee443d9ad5f0cca7a43cfa97b7fc62a'
Change-Id: I086230d787f01075c28fc3f0163550300fa00212
Use codename.fingerprint format for targetSdkVersion if it is unset
in the manifest and UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT=true.
Test: manual
Bug: 130541924
Change-Id: I4e3b1274cc32038b00b292dc6d67559eb320e9e4
Manifest merger is now a java_binary instead of a collection of jars,
it can use the single binary as the dependency.
Bug: 112607039
Test: m checkbuild
Change-Id: Iea6c97c99a3bb09952fed2b25437b644f4e863f8
The Platform_apis field in CompilerDeviceProperties currently has no
effect. Unify the behaviour with make and run manifest_fixer.py to
encode the information in the manifest. This is used to exempt
bundled apps and platform tests from hidden API access checks without
having a fixed whitelist of packages.
Bug: 113315999
Bug: 124671117
Test: m UbSystemUiJankTests && \
aapt d xmltree \
target/product/taimen/data/app/UbSystemUiJankTests/UbSystemUiJankTests.apk \
AndroidManifest.xml | grep usesNonSdkApi
Change-Id: I20c392d91ee6275ef8139fbeb5b9700385abbc80
When use_embedded_dex is set, store the dex uncompressed in the
APK and set the android:useEmbeddedDex="true" attribute in the
manifest.
Test: m checkbuild
Change-Id: Iea6e7ed19599830ac72392ef93f9c98957df1cce
Only put uncompressed native libs in an APK if the min_sdk_version
supports it (>= 23, Marshmallow), and set
android:extractNativeLibs="false" in the AndroidManifest.xml so
that the platform won't extract them anyways.
Bug: 117618214
Test: m checkbuild
Change-Id: I760017e48bf3c6b618aabde0982df45995765d48
Before this change, if targetSdkVersion wasn't set in the
AndroidManifest.xml, we'd set it to the sdk_version from the Android.bp.
But there are cases where you want to compile against a later SDK, but
target an earlier one (especially if you depend on libraries that need
to be compiled against more recent SDKs, like androidx).
Test: build APK with different target_sdk_version.
Change-Id: Iaed36b522955a374a049ef331158cc8fc5798ad2
targetSdkVersion should stay as "current" when min_sdk_version
is set but sdk_version is not.
Bug: 112438448
Test: atest CtsTelecomTestCases
Change-Id: I11dc27eccd31200d1ce27c7e332106bb825651b4
library manifests were just being dropped on the ground.
Bug: 112467584
Test: build
Change-Id: I61c2efca37aa3fdb9c944260f4a276d1d3c26f6c
Merged-In: I61c2efca37aa3fdb9c944260f4a276d1d3c26f6c
(cherry picked from commit b7c147efec)