Merge "Add tests for "unset" select statements" into main
diff --git a/android/apex_contributions.go b/android/apex_contributions.go
index c76d9c2..dd09fbf 100644
--- a/android/apex_contributions.go
+++ b/android/apex_contributions.go
@@ -115,10 +115,6 @@
 func (a *allApexContributions) SetPrebuiltSelectionInfoProvider(ctx BaseModuleContext) {
 	addContentsToProvider := func(p *PrebuiltSelectionInfoMap, m *apexContributions) {
 		for _, content := range m.Contents() {
-			// Skip any apexes that have been added to the product specific ignore list
-			if InList(content, ctx.Config().BuildIgnoreApexContributionContents()) {
-				continue
-			}
 			// Coverage builds for TARGET_RELEASE=foo should always build from source,
 			// even if TARGET_RELEASE=foo uses prebuilt mainline modules.
 			// This is necessary because the checked-in prebuilts were generated with
@@ -141,13 +137,19 @@
 	}
 
 	p := PrebuiltSelectionInfoMap{}
-	ctx.VisitDirectDepsWithTag(acDepTag, func(child Module) {
-		if m, ok := child.(*apexContributions); ok {
-			addContentsToProvider(&p, m)
-		} else {
-			ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name())
-		}
-	})
+	// Skip apex_contributions if BuildApexContributionContents is true
+	// This product config var allows some products in the same family to use mainline modules from source
+	// (e.g. shiba and shiba_fullmte)
+	// Eventually these product variants will have their own release config maps.
+	if !proptools.Bool(ctx.Config().BuildIgnoreApexContributionContents()) {
+		ctx.VisitDirectDepsWithTag(acDepTag, func(child Module) {
+			if m, ok := child.(*apexContributions); ok {
+				addContentsToProvider(&p, m)
+			} else {
+				ctx.ModuleErrorf("%s is not an apex_contributions module\n", child.Name())
+			}
+		})
+	}
 	SetProvider(ctx, PrebuiltSelectionInfoProvider, p)
 }
 
diff --git a/android/config.go b/android/config.go
index 651b6ea..f2f7d7d 100644
--- a/android/config.go
+++ b/android/config.go
@@ -2122,7 +2122,7 @@
 	return ret
 }
 
-func (c *config) BuildIgnoreApexContributionContents() []string {
+func (c *config) BuildIgnoreApexContributionContents() *bool {
 	return c.productVariables.BuildIgnoreApexContributionContents
 }
 
diff --git a/android/paths.go b/android/paths.go
index a40f482..61c1258 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -1831,13 +1831,17 @@
 	return base.Join(ctx, pathComponents...)
 }
 
-func PathForNdkInstall(ctx PathContext, paths ...string) OutputPath {
-	return PathForOutput(ctx, append([]string{"ndk"}, paths...)...)
+func pathForNdkOrSdkInstall(ctx PathContext, prefix string, paths []string) InstallPath {
+	base := pathForPartitionInstallDir(ctx, "", prefix, false)
+	return base.Join(ctx, paths...)
+}
+
+func PathForNdkInstall(ctx PathContext, paths ...string) InstallPath {
+	return pathForNdkOrSdkInstall(ctx, "ndk", paths)
 }
 
 func PathForMainlineSdksInstall(ctx PathContext, paths ...string) InstallPath {
-	base := pathForPartitionInstallDir(ctx, "", "mainline-sdks", false)
-	return base.Join(ctx, paths...)
+	return pathForNdkOrSdkInstall(ctx, "mainline-sdks", paths)
 }
 
 func InstallPathToOnDevicePath(ctx PathContext, path InstallPath) string {
diff --git a/android/variable.go b/android/variable.go
index fc5ae23..b0afd5b 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -499,7 +499,7 @@
 
 	BuildFromSourceStub *bool `json:",omitempty"`
 
-	BuildIgnoreApexContributionContents []string `json:",omitempty"`
+	BuildIgnoreApexContributionContents *bool `json:",omitempty"`
 
 	HiddenapiExportableStubs *bool `json:",omitempty"`
 
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 57a3b3a..567cb7c 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -15,6 +15,7 @@
 package cc
 
 import (
+	"fmt"
 	"path/filepath"
 
 	"android/soong/android"
@@ -44,7 +45,7 @@
 }
 
 // Returns the NDK base include path for use with sdk_version current. Usable with -I.
-func getCurrentIncludePath(ctx android.ModuleContext) android.OutputPath {
+func getCurrentIncludePath(ctx android.ModuleContext) android.InstallPath {
 	return getNdkSysrootBase(ctx).Join(ctx, "usr/include")
 }
 
@@ -86,7 +87,7 @@
 }
 
 func getHeaderInstallDir(ctx android.ModuleContext, header android.Path, from string,
-	to string) android.OutputPath {
+	to string) android.InstallPath {
 	// Output path is the sysroot base + "usr/include" + to directory + directory component
 	// of the file without the leading from directory stripped.
 	//
@@ -128,12 +129,13 @@
 	for _, header := range m.srcPaths {
 		installDir := getHeaderInstallDir(ctx, header, String(m.properties.From),
 			String(m.properties.To))
+		installedPath := ctx.InstallFile(installDir, header.Base(), header)
 		installPath := installDir.Join(ctx, header.Base())
-		ctx.Build(pctx, android.BuildParams{
-			Rule:   android.Cp,
-			Input:  header,
-			Output: installPath,
-		})
+		if installPath != installedPath {
+			panic(fmt.Sprintf(
+				"expected header install path (%q) not equal to actual install path %q",
+				installPath, installedPath))
+		}
 		m.installPaths = append(m.installPaths, installPath)
 	}
 
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index b9e6bc4..64193b1 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -518,19 +518,19 @@
 
 // Returns the install path for unversioned NDK libraries (currently only static
 // libraries).
-func getUnversionedLibraryInstallPath(ctx ModuleContext) android.OutputPath {
+func getUnversionedLibraryInstallPath(ctx ModuleContext) android.InstallPath {
 	return getNdkSysrootBase(ctx).Join(ctx, "usr/lib", config.NDKTriple(ctx.toolchain()))
 }
 
 // Returns the install path for versioned NDK libraries. These are most often
 // stubs, but the same paths are used for CRT objects.
-func getVersionedLibraryInstallPath(ctx ModuleContext, apiLevel android.ApiLevel) android.OutputPath {
+func getVersionedLibraryInstallPath(ctx ModuleContext, apiLevel android.ApiLevel) android.InstallPath {
 	return getUnversionedLibraryInstallPath(ctx).Join(ctx, apiLevel.String())
 }
 
 func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
 	installDir := getVersionedLibraryInstallPath(ctx, stub.apiLevel)
-	stub.installPath = installDir.Join(ctx, path.Base())
+	stub.installPath = ctx.InstallFile(installDir, path.Base(), path)
 }
 
 func newStubLibrary() *Module {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index e815172..483d23b 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -69,12 +69,12 @@
 	ctx.RegisterParallelSingletonType("ndk", NdkSingleton)
 }
 
-func getNdkInstallBase(ctx android.PathContext) android.OutputPath {
+func getNdkInstallBase(ctx android.PathContext) android.InstallPath {
 	return android.PathForNdkInstall(ctx)
 }
 
 // Returns the main install directory for the NDK sysroot. Usable with --sysroot.
-func getNdkSysrootBase(ctx android.PathContext) android.OutputPath {
+func getNdkSysrootBase(ctx android.PathContext) android.InstallPath {
 	return getNdkInstallBase(ctx).Join(ctx, "sysroot")
 }
 
diff --git a/licenses/Android.bp b/licenses/Android.bp
index d045725..e4e5da7 100644
--- a/licenses/Android.bp
+++ b/licenses/Android.bp
@@ -1126,6 +1126,12 @@
 }
 
 license_kind {
+    name: "SPDX-license-identifier-Unicode-3.0",
+    conditions: ["notice"],
+    url: "https://spdx.org/licenses/Unicode-3.0.html",
+}
+
+license_kind {
     name: "SPDX-license-identifier-Unicode-DFS-2015",
     conditions: ["notice"],
     url: "https://spdx.org/licenses/Unicode-DFS-2015.html",