Merge "Bump "experimental" C++ to C++2a."
diff --git a/android/config.go b/android/config.go
index c737b70..abb07ce 100644
--- a/android/config.go
+++ b/android/config.go
@@ -900,6 +900,10 @@
 	return Bool(c.productVariables.Ndk_abis)
 }
 
+func (c *config) ExcludeDraftNdkApis() bool {
+	return Bool(c.productVariables.Exclude_draft_ndk_apis)
+}
+
 func (c *config) FlattenApex() bool {
 	return Bool(c.productVariables.FlattenApex)
 }
diff --git a/android/variable.go b/android/variable.go
index 0b344f9..4534774 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -258,7 +258,8 @@
 
 	VendorVars map[string]map[string]string `json:",omitempty"`
 
-	Ndk_abis *bool `json:",omitempty"`
+	Ndk_abis               *bool `json:",omitempty"`
+	Exclude_draft_ndk_apis *bool `json:",omitempty"`
 
 	FlattenApex *bool `json:",omitempty"`
 }
diff --git a/cc/ndk_headers.go b/cc/ndk_headers.go
index 8177ff1..504a6a0 100644
--- a/cc/ndk_headers.go
+++ b/cc/ndk_headers.go
@@ -77,6 +77,11 @@
 
 	// Path to the NOTICE file associated with the headers.
 	License *string
+
+	// True if this API is not yet ready to be shipped in the NDK. It will be
+	// available in the platform for testing, but will be excluded from the
+	// sysroot provided to the NDK proper.
+	Draft bool
 }
 
 type headerModule struct {
@@ -182,6 +187,11 @@
 
 	// Path to the NOTICE file associated with the headers.
 	License *string
+
+	// True if this API is not yet ready to be shipped in the NDK. It will be
+	// available in the platform for testing, but will be excluded from the
+	// sysroot provided to the NDK proper.
+	Draft bool
 }
 
 // Like ndk_headers, but preprocesses the headers with the bionic versioner:
@@ -309,6 +319,11 @@
 
 	// Path to the NOTICE file associated with the headers.
 	License *string
+
+	// True if this API is not yet ready to be shipped in the NDK. It will be
+	// available in the platform for testing, but will be excluded from the
+	// sysroot provided to the NDK proper.
+	Draft bool
 }
 
 type preprocessedHeadersModule struct {
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 63d9f29..53fe314 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -91,6 +91,11 @@
 
 	// Private property for use by the mutator that splits per-API level.
 	ApiLevel string `blueprint:"mutated"`
+
+	// True if this API is not yet ready to be shipped in the NDK. It will be
+	// available in the platform for testing, but will be excluded from the
+	// sysroot provided to the NDK proper.
+	Draft bool
 }
 
 type stubDecorator struct {
diff --git a/cc/ndk_sysroot.go b/cc/ndk_sysroot.go
index 80b5c6a..9265bff 100644
--- a/cc/ndk_sysroot.go
+++ b/cc/ndk_sysroot.go
@@ -104,22 +104,38 @@
 		}
 
 		if m, ok := module.(*headerModule); ok {
+			if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+				return
+			}
+
 			installPaths = append(installPaths, m.installPaths...)
 			licensePaths = append(licensePaths, m.licensePath)
 		}
 
 		if m, ok := module.(*versionedHeaderModule); ok {
+			if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+				return
+			}
+
 			installPaths = append(installPaths, m.installPaths...)
 			licensePaths = append(licensePaths, m.licensePath)
 		}
 
 		if m, ok := module.(*preprocessedHeadersModule); ok {
+			if ctx.Config().ExcludeDraftNdkApis() && m.properties.Draft {
+				return
+			}
+
 			installPaths = append(installPaths, m.installPaths...)
 			licensePaths = append(licensePaths, m.licensePath)
 		}
 
 		if m, ok := module.(*Module); ok {
 			if installer, ok := m.installer.(*stubDecorator); ok {
+				if ctx.Config().ExcludeDraftNdkApis() &&
+					installer.properties.Draft {
+					return
+				}
 				installPaths = append(installPaths, installer.installPath)
 			}
 
diff --git a/scripts/build-ndk-prebuilts.sh b/scripts/build-ndk-prebuilts.sh
index 81f8564..947458a 100755
--- a/scripts/build-ndk-prebuilts.sh
+++ b/scripts/build-ndk-prebuilts.sh
@@ -48,7 +48,8 @@
     "Malloc_not_svelte": false,
     "Safestack": false,
 
-    "Ndk_abis": true
+    "Ndk_abis": true,
+    "Exclude_draft_ndk_apis": true
 }
 EOF
 m --skip-make ${SOONG_OUT}/ndk.timestamp