Snap for 6596975 from 7b94c197afe92a2cccbcf97b989dc7b23a4dcc9f to rvc-release

Change-Id: I4d951bfdbd4bbe91fccaa76cd1493a36a549e2dd
diff --git a/build/aidl_interface.go b/build/aidl_interface.go
index c34245e..240a0c6 100644
--- a/build/aidl_interface.go
+++ b/build/aidl_interface.go
@@ -704,12 +704,19 @@
 	// "current" is checked against the latest version.
 	var dumps []apiDump
 	for _, ver := range m.properties.Versions {
-		apiDir := android.PathForModuleSrc(ctx, m.apiDir(), ver)
-		dumps = append(dumps, apiDump{
-			dir:      apiDir,
-			files:    ctx.Glob(filepath.Join(apiDir.String(), "**/*.aidl"), nil),
-			hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), ver, ".hash"),
-		})
+		apiDir := filepath.Join(ctx.ModuleDir(), m.apiDir(), ver)
+		apiDirPath := android.ExistentPathForSource(ctx, apiDir)
+		if apiDirPath.Valid() {
+			dumps = append(dumps, apiDump{
+				dir:      apiDirPath.Path(),
+				files:    ctx.Glob(filepath.Join(apiDirPath.String(), "**/*.aidl"), nil),
+				hashFile: android.ExistentPathForSource(ctx, ctx.ModuleDir(), m.apiDir(), ver, ".hash"),
+			})
+		} else if ctx.Config().AllowMissingDependencies() {
+			ctx.AddMissingDependencies([]string{apiDir})
+		} else {
+			ctx.ModuleErrorf("API version %s path %s does not exist", ver, apiDir)
+		}
 	}
 	if currentApiDir.Valid() {
 		dumps = append(dumps, currentApiDump)
diff --git a/build/aidl_test.go b/build/aidl_test.go
index 8d40040..c18098e 100644
--- a/build/aidl_test.go
+++ b/build/aidl_test.go
@@ -104,17 +104,7 @@
 			name: "aidl_metadata_json",
 		}
 	`
-	fs := map[string][]byte{
-		"a.java":              nil,
-		"AndroidManifest.xml": nil,
-		"build/make/target/product/security/testkey": nil,
-		"framework/aidl/a.aidl":                      nil,
-		"IFoo.aidl":                                  nil,
-		"libbinder_ndk.map.txt":                      nil,
-		"system/tools/aidl/build/message_check_compatibility.txt": nil,
-		"system/tools/aidl/build/message_check_equality.txt":      nil,
-		"system/tools/aidl/build/message_check_integrity.txt":     nil,
-	}
+	fs := map[string][]byte{}
 
 	cc.GatherRequiredFilesForTest(fs)
 
@@ -246,12 +236,10 @@
 	expectedError := `unstable-java is disallowed in release version because it is unstable.`
 	testAidlError(t, expectedError, unstableVersionUsageInJavaBp, setReleaseEnv(), withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 	}))
 
 	testAidl(t, unstableVersionUsageInJavaBp, withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 	}))
 
 	// A stable version can be used in release version
@@ -272,12 +260,10 @@
 
 	testAidl(t, stableVersionUsageInJavaBp, setReleaseEnv(), withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 	}))
 
 	testAidl(t, stableVersionUsageInJavaBp, withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 	}))
 }
 
@@ -395,7 +381,6 @@
 		}
 	`, withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 	}))
 
 	// For alias for the latest frozen version (=1)
@@ -457,9 +442,7 @@
 		}
 	`, withFiles(map[string][]byte{
 		"aidl_api/foo/1/foo.1.aidl": nil,
-		"aidl_api/foo/1/.hash":      nil,
 		"aidl_api/foo/2/foo.2.aidl": nil,
-		"aidl_api/foo/2/.hash":      nil,
 	}))
 
 	// alias for the latest frozen version (=2)
@@ -543,9 +526,7 @@
 				},
 			},
 		}
-	`, withFiles(map[string][]byte{
-		"IBar.aidl": nil,
-	}))
+	`)
 
 	testAidlError(t, `backend.cpp.enabled: C\+\+ backend not enabled in the imported AIDL interface "bar"`, `
 		aidl_interface {
@@ -568,9 +549,7 @@
 				},
 			},
 		}
-	`, withFiles(map[string][]byte{
-		"IBar.aidl": nil,
-	}))
+	`)
 
 	ctx, _ := testAidl(t, `
 		aidl_interface {
@@ -588,9 +567,7 @@
 				"IBar.aidl",
 			],
 		}
-	`, withFiles(map[string][]byte{
-		"IBar.aidl": nil,
-	}))
+	`)
 
 	ldRule := ctx.ModuleForTests("foo-cpp", nativeVariant).Rule("ld")
 	libFlags := ldRule.Args["libFlags"]