Enforce dependencies have right architecture

ctx.AddDependency will succeed if the named dependency only has a
single variant, even if that variant is the wrong architecture.
Use ctx.AddVariationDependency(nil, ...) instead, which requires
that all variations of the calling module match the dependency.

Bug: 112707915
Test: no change to out/soong/build.ninja
Test: using a device dependency in a host java module is an error
Change-Id: I70b661a57d4412eb63b8c9841febfb756e9e025d
diff --git a/java/proto.go b/java/proto.go
index 58b039e..8028039 100644
--- a/java/proto.go
+++ b/java/proto.go
@@ -73,14 +73,14 @@
 func protoDeps(ctx android.BottomUpMutatorContext, p *android.ProtoProperties) {
 	switch String(p.Proto.Type) {
 	case "micro":
-		ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-micro")
+		ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-micro")
 	case "nano":
-		ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-nano")
+		ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-nano")
 	case "lite", "":
-		ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-lite")
+		ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-lite")
 	case "full":
 		if ctx.Host() {
-			ctx.AddDependency(ctx.Module(), staticLibTag, "libprotobuf-java-full")
+			ctx.AddVariationDependencies(nil, staticLibTag, "libprotobuf-java-full")
 		} else {
 			ctx.PropertyErrorf("proto.type", "full java protos only supported on the host")
 		}