Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5a96763 authored by Jooyung Han's avatar Jooyung Han
Browse files

use_vndk_as_stable APEX shouldn't include VNDK lib

Even though a vendor APEX sets use_vndk_as_stable:true it was possible
to include a VNDK lib by directly depending on it with
native_shared_libs.

But it's contradictory to have a VNDK lib while declaring not to include
VNDK libs. It was missing since pruning dependencies on VNDK libs was
done only for transitive deps.

Added a check to reject this.

Bug: 216847402
Test: m nothing(running soong tests)
Change-Id: I8d79a434b1bfe8e563cf8968fa76830b0e582f66
parent 99a81c8d
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -888,10 +888,19 @@ func (a *apexBundle) ApexInfoMutator(mctx android.TopDownMutatorContext) {
	// APEX, but shared across APEXes via the VNDK APEX.
	useVndk := a.SocSpecific() || a.DeviceSpecific() || (a.ProductSpecific() && mctx.Config().EnforceProductPartitionInterface())
	excludeVndkLibs := useVndk && proptools.Bool(a.properties.Use_vndk_as_stable)
	if !useVndk && proptools.Bool(a.properties.Use_vndk_as_stable) {
	if proptools.Bool(a.properties.Use_vndk_as_stable) {
		if !useVndk {
			mctx.PropertyErrorf("use_vndk_as_stable", "not supported for system/system_ext APEXes")
		}
		mctx.VisitDirectDepsWithTag(sharedLibTag, func(dep android.Module) {
			if c, ok := dep.(*cc.Module); ok && c.IsVndk() {
				mctx.PropertyErrorf("use_vndk_as_stable", "Trying to include a VNDK library(%s) while use_vndk_as_stable is true.", dep.Name())
			}
		})
		if mctx.Failed() {
			return
		}
	}

	continueApexDepsWalk := func(child, parent android.Module) bool {
		am, ok := child.(android.ApexModule)
+17 −0
Original line number Diff line number Diff line
@@ -2713,6 +2713,23 @@ func TestVendorApex(t *testing.T) {
	ensureListNotContains(t, requireNativeLibs, ":vndk")
}

func TestVendorApex_use_vndk_as_stable_TryingToIncludeVNDKLib(t *testing.T) {
	testApexError(t, `Trying to include a VNDK library`, `
		apex {
			name: "myapex",
			key: "myapex.key",
			native_shared_libs: ["libc++"], // libc++ is a VNDK lib
			vendor: true,
			use_vndk_as_stable: true,
			updatable: false,
		}
		apex_key {
			name: "myapex.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}`)
}

func TestVendorApex_use_vndk_as_stable(t *testing.T) {
	ctx := testApex(t, `
		apex {