Merge "Remove srcs_lib_whitelist_dirs"
diff --git a/cc/fuzz.go b/cc/fuzz.go
index c1754b2..d44c02d 100644
--- a/cc/fuzz.go
+++ b/cc/fuzz.go
@@ -17,6 +17,7 @@
 import (
 	"android/soong/android"
 	"android/soong/cc/config"
+	"github.com/google/blueprint/proptools"
 )
 
 func init() {
@@ -120,5 +121,16 @@
 		ctx.AppendProperties(&disableDarwinAndLinuxBionic)
 	})
 
+	// Statically link the STL. This allows fuzz target deployment to not have to
+	// include the STL.
+	android.AddLoadHook(module, func(ctx android.LoadHookContext) {
+		staticStlLinkage := struct {
+			Stl *string
+		}{}
+
+		staticStlLinkage.Stl = proptools.StringPtr("libc++_static")
+		ctx.AppendProperties(&staticStlLinkage)
+	})
+
 	return module
 }
diff --git a/java/app.go b/java/app.go
index 31f07d3..f5a5da0 100644
--- a/java/app.go
+++ b/java/app.go
@@ -751,14 +751,18 @@
 	// A prebuilt apk to import
 	Apk *string
 
-	// The name of a certificate in the default certificate directory, blank to use the default
-	// product certificate, or an android_app_certificate module name in the form ":module".
+	// The name of a certificate in the default certificate directory or an android_app_certificate
+	// module name in the form ":module". Should be empty if presigned or default_dev_cert is set.
 	Certificate *string
 
 	// Set this flag to true if the prebuilt apk is already signed. The certificate property must not
 	// be set for presigned modules.
 	Presigned *bool
 
+	// Sign with the default system dev certificate. Must be used judiciously. Most imported apps
+	// need to either specify a specific certificate or be presigned.
+	Default_dev_cert *bool
+
 	// Specifies that this app should be installed to the priv-app directory,
 	// where the system will grant it additional privileges not available to
 	// normal apps.
@@ -862,11 +866,18 @@
 }
 
 func (a *AndroidAppImport) GenerateAndroidBuildActions(ctx android.ModuleContext) {
-	if String(a.properties.Certificate) == "" && !Bool(a.properties.Presigned) {
-		ctx.PropertyErrorf("certificate", "No certificate specified for prebuilt")
+	numCertPropsSet := 0
+	if String(a.properties.Certificate) != "" {
+		numCertPropsSet++
 	}
-	if String(a.properties.Certificate) != "" && Bool(a.properties.Presigned) {
-		ctx.PropertyErrorf("certificate", "Certificate can't be specified for presigned modules")
+	if Bool(a.properties.Presigned) {
+		numCertPropsSet++
+	}
+	if Bool(a.properties.Default_dev_cert) {
+		numCertPropsSet++
+	}
+	if numCertPropsSet != 1 {
+		ctx.ModuleErrorf("One and only one of certficate, presigned, and default_dev_cert properties must be set")
 	}
 
 	_, certificates := collectAppDeps(ctx)
@@ -907,7 +918,9 @@
 	// Sign or align the package
 	// TODO: Handle EXTERNAL
 	if !Bool(a.properties.Presigned) {
-		certificates = processMainCert(a.ModuleBase, *a.properties.Certificate, certificates, ctx)
+		// If the certificate property is empty at this point, default_dev_cert must be set to true.
+		// Which makes processMainCert's behavior for the empty cert string WAI.
+		certificates = processMainCert(a.ModuleBase, String(a.properties.Certificate), certificates, ctx)
 		if len(certificates) != 1 {
 			ctx.ModuleErrorf("Unexpected number of certificates were extracted: %q", certificates)
 		}
diff --git a/java/app_test.go b/java/app_test.go
index 564211c..be1ff29 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -1164,6 +1164,35 @@
 	}
 }
 
+func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
+	ctx, _ := testJava(t, `
+		android_app_import {
+			name: "foo",
+			apk: "prebuilts/apk/app.apk",
+			default_dev_cert: true,
+			dex_preopt: {
+				enabled: true,
+			},
+		}
+		`)
+
+	variant := ctx.ModuleForTests("foo", "android_common")
+
+	// Check dexpreopt outputs.
+	if variant.MaybeOutput("dexpreopt/oat/arm64/package.vdex").Rule == nil ||
+		variant.MaybeOutput("dexpreopt/oat/arm64/package.odex").Rule == nil {
+		t.Errorf("can't find dexpreopt outputs")
+	}
+
+	// Check cert signing flag.
+	signedApk := variant.Output("signed/foo.apk")
+	signingFlag := signedApk.Args["certificates"]
+	expected := "build/make/target/product/security/testkey.x509.pem build/make/target/product/security/testkey.pk8"
+	if expected != signingFlag {
+		t.Errorf("Incorrect signing flags, expected: %q, got: %q", expected, signingFlag)
+	}
+}
+
 func TestAndroidAppImport_DpiVariants(t *testing.T) {
 	bp := `
 		android_app_import {
@@ -1177,7 +1206,7 @@
 					apk: "prebuilts/apk/app_xxhdpi.apk",
 				},
 			},
-			certificate: "PRESIGNED",
+			presigned: true,
 			dex_preopt: {
 				enabled: true,
 			},
@@ -1307,7 +1336,7 @@
 							apk: "prebuilts/apk/app_arm64.apk",
 						},
 					},
-					certificate: "PRESIGNED",
+					presigned: true,
 					dex_preopt: {
 						enabled: true,
 					},
@@ -1326,7 +1355,7 @@
 							apk: "prebuilts/apk/app_arm.apk",
 						},
 					},
-					certificate: "PRESIGNED",
+					presigned: true,
 					dex_preopt: {
 						enabled: true,
 					},
diff --git a/java/droiddoc.go b/java/droiddoc.go
index 5c51479..db679f0 100644
--- a/java/droiddoc.go
+++ b/java/droiddoc.go
@@ -458,6 +458,7 @@
 	return strings.Join(flags, " "), deps
 }
 
+// TODO: remove the duplication between this and the one in gen.go
 func (j *Javadoc) genSources(ctx android.ModuleContext, srcFiles android.Paths,
 	flags droiddocBuilderFlags) android.Paths {
 
@@ -473,6 +474,9 @@
 		case ".sysprop":
 			javaFile := genSysprop(ctx, srcFile)
 			outSrcFiles = append(outSrcFiles, javaFile)
+		case ".logtags":
+			javaFile := genLogtags(ctx, srcFile)
+			outSrcFiles = append(outSrcFiles, javaFile)
 		default:
 			outSrcFiles = append(outSrcFiles, srcFile)
 		}
diff --git a/ui/build/cleanbuild.go b/ui/build/cleanbuild.go
index 8e7f96a..bfe2c36 100644
--- a/ui/build/cleanbuild.go
+++ b/ui/build/cleanbuild.go
@@ -99,6 +99,7 @@
 		productOut("*.img"),
 		productOut("*.zip"),
 		productOut("android-info.txt"),
+		productOut("apex"),
 		productOut("kernel"),
 		productOut("data"),
 		productOut("skin"),