Merge "Add checks for double_loadable dependencies" am: f14277fc3a am: 4b75790b30
am: ba30c798c9

Change-Id: I6b7be3f1d1fea09377db22f65ecc6e8aecfe1f0b
diff --git a/Android.bp b/Android.bp
index 94b4f7e..e8dd15d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -515,6 +515,7 @@
 kernel_headers {
     name: "device_kernel_headers",
     vendor: true,
+    recovery_available: true,
 }
 
 cc_genrule {
diff --git a/android/neverallow.go b/android/neverallow.go
index 18744e8..9881b4d 100644
--- a/android/neverallow.go
+++ b/android/neverallow.go
@@ -51,6 +51,7 @@
 	rules := []*rule{}
 	rules = append(rules, createTrebleRules()...)
 	rules = append(rules, createLibcoreRules()...)
+	rules = append(rules, createMediaRules()...)
 	return rules
 }
 
@@ -125,6 +126,14 @@
 	return rules
 }
 
+func createMediaRules() []*rule {
+	return []*rule{
+		neverallow().
+			with("libs", "updatable-media").
+			because("updatable-media includes private APIs. Use updatable_media_stubs instead."),
+	}
+}
+
 func neverallowMutator(ctx BottomUpMutatorContext) {
 	m, ok := ctx.Module().(Module)
 	if !ok {
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index 8d53087..8d9cd5f 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -148,6 +148,17 @@
 		},
 		expectedError: "Only core libraries projects can depend on core-libart",
 	},
+	{
+		name: "dependency on updatable-media",
+		fs: map[string][]byte{
+			"Blueprints": []byte(`
+				java_library {
+					name: "needs_updatable_media",
+					libs: ["updatable-media"],
+				}`),
+		},
+		expectedError: "updatable-media includes private APIs. Use updatable_media_stubs instead.",
+	},
 }
 
 func TestNeverallow(t *testing.T) {
diff --git a/cc/config/clang.go b/cc/config/clang.go
index 4ec787f..bfa7873 100644
--- a/cc/config/clang.go
+++ b/cc/config/clang.go
@@ -97,9 +97,8 @@
 	pctx.StaticVariable("ClangExtraCflags", strings.Join([]string{
 		"-D__compiler_offsetof=__builtin_offsetof",
 
-		// Make implicit fallthrough an error in the future.
+		// -Wimplicit-fallthrough is not enabled by -Wall.
 		"-Wimplicit-fallthrough",
-		"-Wno-error=implicit-fallthrough",
 
 		// Help catch common 32/64-bit errors.
 		"-Werror=int-conversion",
@@ -164,11 +163,6 @@
 		"-Wno-tautological-unsigned-enum-zero-compare",
 		"-Wno-tautological-unsigned-zero-compare",
 
-		// http://b/72330874 Disable -Wenum-compare until the instances detected by this new
-		// warning are fixed.
-		"-Wno-enum-compare",
-		"-Wno-enum-compare-switch",
-
 		// Disable c++98-specific warning since Android is not concerned with C++98
 		// compatibility.
 		"-Wno-c++98-compat-extra-semi",
@@ -177,9 +171,11 @@
 		"-Wno-return-std-move-in-c++11",
 	}, " "))
 
-	// Extra cflags for projects under external/ directory
+	// Extra cflags for projects under external/ directory to disable warnings that are infeasible
+	// to fix in all the external projects and their upstream repos.
 	pctx.StaticVariable("ClangExtraExternalCflags", strings.Join([]string{
-		// TODO(yikong): Move -Wno flags here
+		"-Wno-enum-compare",
+		"-Wno-enum-compare-switch",
 
 		// http://b/72331524 Allow null pointer arithmetic until the instances detected by
 		// this new warning are fixed.
diff --git a/java/config/config.go b/java/config/config.go
index 2762a4d..6495222 100644
--- a/java/config/config.go
+++ b/java/config/config.go
@@ -29,7 +29,7 @@
 
 	DefaultBootclasspathLibraries = []string{"core.platform.api.stubs", "core-lambda-stubs"}
 	DefaultSystemModules          = "core-platform-api-stubs-system-modules"
-	DefaultLibraries              = []string{"ext", "framework"}
+	DefaultLibraries              = []string{"ext", "framework", "updatable_media_stubs"}
 	DefaultLambdaStubsLibrary     = "core-lambda-stubs"
 	SdkLambdaStubsPath            = "prebuilts/sdk/tools/core-lambda-stubs.jar"
 
@@ -43,6 +43,7 @@
 		"android.car7",
 		"core-oj",
 		"core-libart",
+		"updatable-media",
 	}
 )
 
diff --git a/java/java_test.go b/java/java_test.go
index 952da11..3857ba8 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -906,7 +906,7 @@
 		checkPatchModuleFlag(t, ctx, "foo", "")
 		expected := "java.base=.:" + buildDir
 		checkPatchModuleFlag(t, ctx, "bar", expected)
-		expected = "java.base=" + strings.Join([]string{".", buildDir, moduleToPath("ext"), moduleToPath("framework")}, ":")
+		expected = "java.base=" + strings.Join([]string{".", buildDir, moduleToPath("ext"), moduleToPath("framework"), moduleToPath("updatable_media_stubs")}, ":")
 		checkPatchModuleFlag(t, ctx, "baz", expected)
 	})
 }
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 6924e26..a11ea2f 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -39,14 +39,14 @@
 		name:          "default",
 		bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
 		system:        "core-platform-api-stubs-system-modules",
-		classpath:     []string{"ext", "framework"},
+		classpath:     []string{"ext", "framework", "updatable_media_stubs"},
 	},
 	{
 		name:          "blank sdk version",
 		properties:    `sdk_version: "",`,
 		bootclasspath: []string{"core.platform.api.stubs", "core-lambda-stubs"},
 		system:        "core-platform-api-stubs-system-modules",
-		classpath:     []string{"ext", "framework"},
+		classpath:     []string{"ext", "framework", "updatable_media_stubs"},
 	},
 	{
 
diff --git a/java/testing.go b/java/testing.go
index 6febfa1..713eca1 100644
--- a/java/testing.go
+++ b/java/testing.go
@@ -40,6 +40,7 @@
 		"core-lambda-stubs",
 		"framework",
 		"ext",
+		"updatable_media_stubs",
 		"android_stubs_current",
 		"android_system_stubs_current",
 		"android_test_stubs_current",