fix protos in another dir + a module that uses it

Protos in another directory were using import prefix, which was
prepending the repository-relative path with the value, instead, we want
to strip the prefix of the directory of the module the protos were used
in such that they can be referenced at the appropriate relative path.

Reference on import_prefix:
https://bazel.build/reference/be/protocol-buffer#proto_library.import_prefix

Test: b build //packages/modules/adb:libfastdeploy_host
Change-Id: If050b0f5fc5103bd9cc5a99703bd604325aa4204
diff --git a/android/proto.go b/android/proto.go
index aad521b..49b3733 100644
--- a/android/proto.go
+++ b/android/proto.go
@@ -230,6 +230,7 @@
 	name := m.Name() + "_proto"
 
 	depsFromFilegroup := protoLibraries
+	var canonicalPathFromRoot bool
 
 	if len(directProtoSrcs.Includes) > 0 {
 		pkgToSrcs := partitionSrcsByPackage(ctx.ModuleDir(), directProtoSrcs)
@@ -250,7 +251,8 @@
 					if axis == bazel.NoConfigAxis {
 						info.Type = props.Proto.Type
 
-						if !proptools.BoolDefault(props.Proto.Canonical_path_from_root, canonicalPathFromRootDefault) {
+						canonicalPathFromRoot = proptools.BoolDefault(props.Proto.Canonical_path_from_root, canonicalPathFromRootDefault)
+						if !canonicalPathFromRoot {
 							// an empty string indicates to strips the package path
 							path := ""
 							attrs.Strip_import_prefix = &path
@@ -271,11 +273,14 @@
 
 			tags := ApexAvailableTagsWithoutTestApexes(ctx.(TopDownMutatorContext), ctx.Module())
 
-			// Since we are creating the proto_library in a subpackage, create an import_prefix relative to the current package
-			if rel, err := filepath.Rel(ctx.ModuleDir(), pkg); err != nil {
-				ctx.ModuleErrorf("Could not get relative path for %v %v", pkg, err)
-			} else if rel != "." {
-				attrs.Import_prefix = &rel
+			moduleDir := ctx.ModuleDir()
+			if !canonicalPathFromRoot {
+				// Since we are creating the proto_library in a subpackage, set the import_prefix relative to the current package
+				if rel, err := filepath.Rel(moduleDir, pkg); err != nil {
+					ctx.ModuleErrorf("Could not get relative path for %v %v", pkg, err)
+				} else if rel != "." {
+					attrs.Import_prefix = &rel
+				}
 			}
 
 			ctx.CreateBazelTargetModule(
@@ -285,7 +290,7 @@
 			)
 
 			l := ""
-			if pkg == ctx.ModuleDir() { // same package that the original module lives in
+			if pkg == moduleDir { // same package that the original module lives in
 				l = ":" + name
 			} else {
 				l = "//" + pkg + ":" + name