Merge "Forbit extra quotes in tidy flag lists"
diff --git a/androidmk/androidmk/androidmk.go b/androidmk/androidmk/androidmk.go
index 2d1bbb4..b8316a3 100644
--- a/androidmk/androidmk/androidmk.go
+++ b/androidmk/androidmk/androidmk.go
@@ -48,6 +48,22 @@
 	"-": "_dash_",
 }
 
+// Fix steps that should only run in the androidmk tool, i.e. should only be applied to
+// newly-converted Android.bp files.
+var fixSteps = bpfix.FixStepsExtension{
+	Name: "androidmk",
+	Steps: []bpfix.FixStep{
+		{
+			Name: "RewriteRuntimeResourceOverlay",
+			Fix:  bpfix.RewriteRuntimeResourceOverlay,
+		},
+	},
+}
+
+func init() {
+	bpfix.RegisterFixStepExtension(&fixSteps)
+}
+
 func (f *bpFile) insertComment(s string) {
 	f.comments = append(f.comments, &bpparser.CommentGroup{
 		Comments: []*bpparser.Comment{
diff --git a/bloaty/bloaty.go b/bloaty/bloaty.go
index 0bff8aa..21bf4ac 100644
--- a/bloaty/bloaty.go
+++ b/bloaty/bloaty.go
@@ -23,6 +23,7 @@
 )
 
 const bloatyDescriptorExt = "bloaty.csv"
+const protoFilename = "binary_sizes.pb"
 
 var (
 	fileSizeMeasurerKey blueprint.ProviderKey
@@ -87,6 +88,10 @@
 	ctx.Build(pctx, android.BuildParams{
 		Rule:   bloatyMerger,
 		Inputs: android.SortedUniquePaths(deps),
-		Output: android.PathForOutput(ctx, "binary_sizes.pb"),
+		Output: android.PathForOutput(ctx, protoFilename),
 	})
 }
+
+func (singleton *sizesSingleton) MakeVars(ctx android.MakeVarsContext) {
+	ctx.DistForGoalWithFilename("checkbuild", android.PathForOutput(ctx, protoFilename), protoFilename)
+}
diff --git a/bpfix/bpfix/bpfix.go b/bpfix/bpfix/bpfix.go
index 94b8252..fae6101 100644
--- a/bpfix/bpfix/bpfix.go
+++ b/bpfix/bpfix/bpfix.go
@@ -670,6 +670,26 @@
 	return nil
 }
 
+func RewriteRuntimeResourceOverlay(f *Fixer) error {
+	for _, def := range f.tree.Defs {
+		mod, ok := def.(*parser.Module)
+		if !(ok && mod.Type == "runtime_resource_overlay") {
+			continue
+		}
+		// runtime_resource_overlays are always product specific in Make.
+		if _, ok := mod.GetProperty("product_specific"); !ok {
+			prop := &parser.Property{
+				Name: "product_specific",
+				Value: &parser.Bool{
+					Value: true,
+				},
+			}
+			mod.Properties = append(mod.Properties, prop)
+		}
+	}
+	return nil
+}
+
 // Removes library dependencies which are empty (and restricted from usage in Soong)
 func removeEmptyLibDependencies(f *Fixer) error {
 	emptyLibraries := []string{
diff --git a/bpfix/bpfix/bpfix_test.go b/bpfix/bpfix/bpfix_test.go
index ef9814f..61dfe1a 100644
--- a/bpfix/bpfix/bpfix_test.go
+++ b/bpfix/bpfix/bpfix_test.go
@@ -1056,3 +1056,71 @@
 		})
 	}
 }
+
+func TestRewriteRuntimeResourceOverlay(t *testing.T) {
+	tests := []struct {
+		name string
+		in   string
+		out  string
+	}{
+		{
+			name: "product_specific runtime_resource_overlay",
+			in: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+					product_specific: true,
+				}
+			`,
+			out: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+					product_specific: true,
+				}
+			`,
+		},
+		{
+			// It's probably wrong for runtime_resource_overlay not to be product specific, but let's not
+			// debate it here.
+			name: "non-product_specific runtime_resource_overlay",
+			in: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+					product_specific: false,
+				}
+			`,
+			out: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+					product_specific: false,
+				}
+			`,
+		},
+		{
+			name: "runtime_resource_overlay without product_specific value",
+			in: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+				}
+			`,
+			out: `
+				runtime_resource_overlay {
+					name: "foo",
+					resource_dirs: ["res"],
+					product_specific: true,
+				}
+			`,
+		},
+	}
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			runPass(t, test.in, test.out, func(fixer *Fixer) error {
+				return RewriteRuntimeResourceOverlay(fixer)
+			})
+		})
+	}
+}
diff --git a/cc/snapshot_prebuilt.go b/cc/snapshot_prebuilt.go
index 69b9948..f9aea0c 100644
--- a/cc/snapshot_prebuilt.go
+++ b/cc/snapshot_prebuilt.go
@@ -280,41 +280,36 @@
 	// Nothing, the snapshot module is only used to forward dependency information in DepsMutator.
 }
 
-func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
-	collectSnapshotMap := func(variations []blueprint.Variation, depTag blueprint.DependencyTag,
-		names []string, snapshotSuffix, moduleSuffix string) map[string]string {
+func getSnapshotNameSuffix(moduleSuffix, version, arch string) string {
+	versionSuffix := version
+	if arch != "" {
+		versionSuffix += "." + arch
+	}
+	return moduleSuffix + versionSuffix
+}
 
+func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
+	collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string {
 		snapshotMap := make(map[string]string)
 		for _, name := range names {
 			snapshotMap[name] = name +
-				snapshotSuffix + moduleSuffix +
-				s.baseSnapshot.version() +
-				"." + ctx.Arch().ArchType.Name
+				getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
+					s.baseSnapshot.version(), ctx.Arch().ArchType.Name)
 		}
-
 		return snapshotMap
 	}
 
 	snapshotSuffix := s.image.moduleNameSuffix()
-	headers := collectSnapshotMap(nil, HeaderDepTag(), s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
-	binaries := collectSnapshotMap(nil, nil, s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
-	objects := collectSnapshotMap(nil, nil, s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
-
-	staticLibs := collectSnapshotMap([]blueprint.Variation{
-		{Mutator: "link", Variation: "static"},
-	}, StaticDepTag(), s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)
-
-	sharedLibs := collectSnapshotMap([]blueprint.Variation{
-		{Mutator: "link", Variation: "shared"},
-	}, SharedDepTag(), s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)
-
-	vndkLibs := collectSnapshotMap([]blueprint.Variation{
-		{Mutator: "link", Variation: "shared"},
-	}, SharedDepTag(), s.properties.Vndk_libs, "", vndkSuffix)
-
+	headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
+	binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
+	objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
+	staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)
+	sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)
+	vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
 	for k, v := range vndkLibs {
 		sharedLibs[k] = v
 	}
+
 	ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{
 		HeaderLibs: headers,
 		Binaries:   binaries,
@@ -386,12 +381,7 @@
 }
 
 func (p *baseSnapshotDecorator) NameSuffix() string {
-	versionSuffix := p.version()
-	if p.arch() != "" {
-		versionSuffix += "." + p.arch()
-	}
-
-	return p.baseProperties.ModuleSuffix + versionSuffix
+	return getSnapshotNameSuffix(p.moduleSuffix(), p.version(), p.arch())
 }
 
 func (p *baseSnapshotDecorator) version() string {
diff --git a/cc/vendor_snapshot_test.go b/cc/vendor_snapshot_test.go
index 4b76f51..0833277 100644
--- a/cc/vendor_snapshot_test.go
+++ b/cc/vendor_snapshot_test.go
@@ -421,6 +421,7 @@
 		shared_libs: [
 			"libvendor_without_snapshot",
 			"libvendor_available",
+			"libvndk",
 		],
 		arch: {
 			arm64: {