Snap for 10447354 from 5ba9115da292a2527e8aeac19cef35d468173f85 to mainline-wifi-release

Change-Id: I19060353a5e6355cc3c7950b148c5f91f61f6690
diff --git a/CompoundType.cpp b/CompoundType.cpp
index aa12c10..8b26df6 100644
--- a/CompoundType.cpp
+++ b/CompoundType.cpp
@@ -1751,7 +1751,7 @@
     }
 
     out.unindent();
-    out << "};\n\n";
+    out << "}\n\n";
 }
 
 void CompoundType::emitStructReaderWriter(
diff --git a/Coordinator.cpp b/Coordinator.cpp
index 9c7c13f..4342d03 100644
--- a/Coordinator.cpp
+++ b/Coordinator.cpp
@@ -472,8 +472,8 @@
             if ((sb.st_mode & S_IFMT) != S_IFREG) {
                 continue;
             }
-        } else if (ent->d_type != DT_REG) {
-             continue;
+        } else if (ent->d_type != DT_REG && ent->d_type != DT_LNK) {
+            continue;
         }
 
         const auto suffix = ".hal";
@@ -1042,6 +1042,10 @@
             // something downstream should handle these cases
             default: { handleArg(res, optarg); }
         }
+        // glibc sets optarg to NULL for options without an argument, but POSIX doesn't
+        // require it musl libc does not.  Reset it here so that the next call to
+        // handleArg doesn't pass a stale value.
+        optarg = nullptr;
     }
 
     if (getRootPath().empty()) {
diff --git a/HidlTypeAssertion.cpp b/HidlTypeAssertion.cpp
index 6e4822a..c684054 100644
--- a/HidlTypeAssertion.cpp
+++ b/HidlTypeAssertion.cpp
@@ -18,6 +18,7 @@
 
 #include <hidl-util/Formatter.h>
 
+#include <algorithm>
 #include <string>
 #include <vector>
 
diff --git a/Interface.cpp b/Interface.cpp
index 9be88e9..e9950d2 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -307,9 +307,15 @@
         } } }, /* cppImpl */
         { { IMPL_INTERFACE, [this, digestType, chainType](auto &out) {
             std::vector<const Interface *> chain = typeChain();
-            out << "return new "
-                << chainType->getJavaType(false /* forInitializer */)
-                << "(java.util.Arrays.asList(\n";
+            out << "return new " << chainType->getJavaType(false /* forInitializer */);
+            if (chain.size() == 1) {
+                // https://errorprone.info/bugpattern/ArraysAsListPrimitiveArray
+                // To avoid an ArraysAsListPrimitiveArray errorprone error, use
+                // singletonList when there's only 1 element in the chain.
+                out << "(java.util.Collections.singletonList(\n";
+            } else {
+                out << "(java.util.Arrays.asList(\n";
+            }
             out.indent(2, [&] {
                 // No need for dimensions when elements are explicitly provided.
                 emitDigestChain(out, "new " + digestType->getJavaType(false /* forInitializer */),
diff --git a/OWNERS b/OWNERS
index b65cda0..9a555f8 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,5 @@
+# Bug component: 164731
+
 smoreland@google.com
 maco@google.com
 elsk@google.com
diff --git a/build/Android.bp b/build/Android.bp
index 963a690..bebdd9d 100644
--- a/build/Android.bp
+++ b/build/Android.bp
@@ -28,6 +28,7 @@
         "blueprint",
         "soong",
         "soong-android",
+        "soong-bp2build",
         "soong-cc",
         "soong-genrule",
         "soong-java",
@@ -39,6 +40,9 @@
         "properties.go",
         "utils.go",
     ],
+    testSrcs: [
+        "hidl_interface_conversion_test.go",
+    ],
     pluginFor: ["soong_build"],
 }
 
diff --git a/build/go.mod b/build/go.mod
new file mode 100644
index 0000000..2d75c6e
--- /dev/null
+++ b/build/go.mod
@@ -0,0 +1,27 @@
+module android/soong/hidl
+
+require (
+	android/soong v0.0.0
+	github.com/google/blueprint v0.0.0
+)
+
+require (
+	golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect
+	google.golang.org/protobuf v0.0.0 // indirect
+)
+
+replace google.golang.org/protobuf v0.0.0 => ../../../../external/golang-protobuf
+
+replace github.com/google/blueprint v0.0.0 => ../../../../build/blueprint
+
+replace android/soong v0.0.0 => ../../../../build/soong
+
+// Indirect deps from golang-protobuf
+exclude github.com/golang/protobuf v1.5.0
+
+replace github.com/google/go-cmp v0.5.5 => ../../../../external/go-cmp
+
+// Indirect dep from go-cmp
+exclude golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543
+
+go 1.18
diff --git a/build/hidl_interface.go b/build/hidl_interface.go
index fa770d1..a408734 100644
--- a/build/hidl_interface.go
+++ b/build/hidl_interface.go
@@ -22,6 +22,7 @@
 	"github.com/google/blueprint/proptools"
 
 	"android/soong/android"
+	"android/soong/bazel"
 	"android/soong/cc"
 	"android/soong/genrule"
 	"android/soong/java"
@@ -63,9 +64,11 @@
 	}, "output", "options", "fqName")
 
 	zipLintRule = pctx.StaticRule("zipLintRule", blueprint.RuleParams{
-		Command:     "rm -f ${output} && ${soong_zip} -o ${output} -C ${intermediatesDir} ${files}",
-		CommandDeps: []string{"${soong_zip}"},
-		Description: "Zipping hidl-lints into ${output}",
+		Rspfile:        "$out.rsp",
+		RspfileContent: "$files",
+		Command:        "rm -f ${output} && ${soong_zip} -o ${output} -C ${intermediatesDir} -l ${out}.rsp",
+		CommandDeps:    []string{"${soong_zip}"},
+		Description:    "Zipping hidl-lints into ${output}",
 	}, "output", "files")
 
 	inheritanceHierarchyRule = pctx.StaticRule("inheritanceHierarchyRule", blueprint.RuleParams{
@@ -94,7 +97,7 @@
 
 func init() {
 	android.RegisterModuleType("prebuilt_hidl_interfaces", prebuiltHidlInterfaceFactory)
-	android.RegisterModuleType("hidl_interface", hidlInterfaceFactory)
+	android.RegisterModuleType("hidl_interface", HidlInterfaceFactory)
 	android.RegisterSingletonType("all_hidl_lints", allHidlLintsFactory)
 	android.RegisterModuleType("hidl_interfaces_metadata", hidlInterfacesMetadataSingletonFactory)
 	pctx.Import("android/soong/android")
@@ -187,7 +190,7 @@
 		Output: outPath,
 		Args: map[string]string{
 			"output": outPath.String(),
-			"files":  strings.Join(wrap("-f ", hidlLintOutputs.Strings(), ""), " "),
+			"files":  strings.Join(hidlLintOutputs.Strings(), " "),
 		},
 	})
 }
@@ -431,6 +434,7 @@
 
 type hidlInterface struct {
 	android.ModuleBase
+	android.BazelModuleBase
 
 	properties hidlInterfaceProperties
 }
@@ -555,7 +559,12 @@
 	mctx.CreateModule(android.FileGroupFactory, &fileGroupProperties{
 		Name: proptools.StringPtr(name.fileGroupName()),
 		Srcs: i.properties.Srcs,
-	})
+	},
+		&bazelProperties{
+			&Bazel_module{
+				Bp2build_available: proptools.BoolPtr(false),
+			}},
+	)
 
 	mctx.CreateModule(hidlGenFactory, &nameProperties{
 		Name: proptools.StringPtr(name.sourcesName()),
@@ -609,7 +618,14 @@
 			Export_generated_headers: []string{name.headersName()},
 			Apex_available:           i.properties.Apex_available,
 			Min_sdk_version:          getMinSdkVersion(name.string()),
-		}, &i.properties.VndkProperties)
+		}, &i.properties.VndkProperties,
+			// TODO(b/237810289): We need to disable/enable based on if a module has
+			// been converted or not, otherwise mixed build will fail.
+			&bazelProperties{
+				&Bazel_module{
+					Bp2build_available: proptools.BoolPtr(false),
+				}},
+		)
 	}
 
 	if shouldGenerateJava {
@@ -714,17 +730,86 @@
 	ctx.AddDependency(ctx.Module(), nil, h.properties.Root)
 }
 
-func hidlInterfaceFactory() android.Module {
+func HidlInterfaceFactory() android.Module {
 	i := &hidlInterface{}
 	i.AddProperties(&i.properties)
 	android.InitAndroidModule(i)
 	android.AddLoadHook(i, func(ctx android.LoadHookContext) { hidlInterfaceMutator(ctx, i) })
+	android.InitBazelModule(i)
 
 	return i
 }
 
+type hidlInterfaceAttributes struct {
+	Srcs                bazel.LabelListAttribute
+	Deps                bazel.LabelListAttribute
+	Root                string
+	Root_interface_file bazel.LabelAttribute
+	Min_sdk_version     *string
+	Tags                []string
+}
+
+func (m *hidlInterface) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
+	srcs := bazel.MakeLabelListAttribute(
+		android.BazelLabelForModuleSrc(ctx, m.properties.Srcs))
+
+	// The interface dependencies are added earlier with the suffix of "_interface",
+	// so we need to look for them with the hidlInterfaceSuffix added to the names.
+	// Later we trim the "_interface" suffix. Here is an example:
+	// hidl_interface(
+	//    name = "android.hardware.nfc@1.1",
+	//    deps = [
+	//        "//hardware/interfaces/nfc/1.0:android.hardware.nfc@1.0",
+	//        "//system/libhidl/transport/base/1.0:android.hidl.base@1.0",
+	//    ],
+	// )
+	deps := android.BazelLabelForModuleDeps(ctx, wrap("", m.properties.Interfaces, hidlInterfaceSuffix))
+	var dep_labels []bazel.Label
+	for _, label := range deps.Includes {
+		dep_labels = append(dep_labels,
+			bazel.Label{Label: strings.TrimSuffix(label.Label, hidlInterfaceSuffix)})
+	}
+
+	var root string
+	var root_interface_file bazel.LabelAttribute
+	if module, exists := ctx.ModuleFromName(m.properties.Root); exists {
+		if pkg_root, ok := module.(*hidlPackageRoot); ok {
+			var path string
+			if pkg_root.properties.Path != nil {
+				path = *pkg_root.properties.Path
+			} else {
+				path = ctx.OtherModuleDir(pkg_root)
+			}
+			// The root and root_interface come from the hidl_package_root module that
+			// this module depends on, we don't convert hidl_package_root module
+			// separately since all the other properties of that module are deprecated.
+			root = pkg_root.Name()
+			if path == ctx.ModuleDir() {
+				root_interface_file = *bazel.MakeLabelAttribute(":" + "current.txt")
+			} else {
+				root_interface_file = *bazel.MakeLabelAttribute("//" + path + ":" + "current.txt")
+			}
+		}
+	}
+
+	attrs := &hidlInterfaceAttributes{
+		Srcs:                srcs,
+		Deps:                bazel.MakeLabelListAttribute(bazel.MakeLabelList(dep_labels)),
+		Root:                root,
+		Root_interface_file: root_interface_file,
+		Min_sdk_version:     getMinSdkVersion(m.Name()),
+		Tags:                android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, m.properties.Apex_available),
+	}
+
+	props := bazel.BazelTargetModuleProperties{
+		Rule_class:        "hidl_interface",
+		Bzl_load_location: "//build/bazel/rules/hidl:hidl_interface.bzl",
+	}
+
+	ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: strings.TrimSuffix(m.Name(), hidlInterfaceSuffix)}, attrs)
+}
+
 var minSdkVersion = map[string]string{
-	"android.frameworks.bufferhub@1.0":             "29",
 	"android.hardware.audio.common@5.0":            "30",
 	"android.hardware.audio.common@6.0":            "31",
 	"android.hardware.automotive.audiocontrol@1.0": "31",
@@ -736,28 +821,8 @@
 	"android.hardware.bluetooth.audio@2.2":         "30",
 	"android.hardware.bluetooth@1.0":               "30",
 	"android.hardware.bluetooth@1.1":               "30",
-	"android.hardware.cas.native@1.0":              "29",
-	"android.hardware.cas@1.0":                     "29",
-	"android.hardware.graphics.allocator@2.0":      "29",
-	"android.hardware.graphics.allocator@3.0":      "29",
-	"android.hardware.graphics.allocator@4.0":      "29",
-	"android.hardware.graphics.bufferqueue@1.0":    "29",
-	"android.hardware.graphics.bufferqueue@2.0":    "29",
-	"android.hardware.graphics.common@1.0":         "29",
-	"android.hardware.graphics.common@1.1":         "29",
-	"android.hardware.graphics.common@1.2":         "29",
-	"android.hardware.graphics.mapper@2.0":         "29",
-	"android.hardware.graphics.mapper@2.1":         "29",
-	"android.hardware.graphics.mapper@3.0":         "29",
-	"android.hardware.graphics.mapper@4.0":         "29",
 	"android.hardware.health@1.0":                  "31",
 	"android.hardware.health@2.0":                  "31",
-	"android.hardware.media.bufferpool@2.0":        "29",
-	"android.hardware.media.c2@1.0":                "29",
-	"android.hardware.media.c2@1.1":                "29",
-	"android.hardware.media.c2@1.2":                "29",
-	"android.hardware.media.omx@1.0":               "29",
-	"android.hardware.media@1.0":                   "29",
 	"android.hardware.neuralnetworks@1.0":          "30",
 	"android.hardware.neuralnetworks@1.1":          "30",
 	"android.hardware.neuralnetworks@1.2":          "30",
@@ -778,21 +843,25 @@
 	"android.hardware.wifi.supplicant@1.2":         "30",
 	"android.hardware.wifi.supplicant@1.3":         "30",
 	"android.hardware.wifi.supplicant@1.4":         "30",
-	"android.hidl.allocator@1.0":                   "29",
 	"android.hidl.manager@1.0":                     "30",
 	"android.hidl.manager@1.1":                     "30",
 	"android.hidl.manager@1.2":                     "30",
-	"android.hidl.memory.token@1.0":                "29",
-	"android.hidl.memory@1.0":                      "29",
-	"android.hidl.safe_union@1.0":                  "29",
-	"android.hidl.token@1.0":                       "29",
 }
 
 func getMinSdkVersion(name string) *string {
 	if ver, ok := minSdkVersion[name]; ok {
 		return proptools.StringPtr(ver)
 	}
-	return nil
+	// legacy, as used
+	if name == "android.hardware.tetheroffload.config@1.0" ||
+		name == "android.hardware.tetheroffload.control@1.0" ||
+		name == "android.hardware.tetheroffload.control@1.1" ||
+		name == "android.hardware.radio@1.0" ||
+		name == "android.hidl.base@1.0" {
+
+		return nil
+	}
+	return proptools.StringPtr("29")
 }
 
 var doubleLoadablePackageNames = []string{
@@ -863,76 +932,76 @@
 }
 
 var allAospHidlInterfaces = map[string]bool{
-	"android.frameworks.automotive.display@1.0":         true,
-	"android.frameworks.bufferhub@1.0":                  true,
-	"android.frameworks.cameraservice.common@2.0":       true,
-	"android.frameworks.cameraservice.device@2.0":       true,
-	"android.frameworks.cameraservice.device@2.1":       true,
-	"android.frameworks.cameraservice.service@2.0":      true,
-	"android.frameworks.cameraservice.service@2.1":      true,
-	"android.frameworks.cameraservice.service@2.2":      true,
-	"android.frameworks.displayservice@1.0":             true,
-	"android.frameworks.schedulerservice@1.0":           true,
-	"android.frameworks.sensorservice@1.0":              true,
-	"android.frameworks.stats@1.0":                      true,
-	"android.frameworks.vr.composer@1.0":                true,
-	"android.frameworks.vr.composer@2.0":                true,
-	"android.hardware.atrace@1.0":                       true,
-	"android.hardware.audio@2.0":                        true,
-	"android.hardware.audio@4.0":                        true,
-	"android.hardware.audio@5.0":                        true,
-	"android.hardware.audio@6.0":                        true,
-	"android.hardware.audio@7.0":                        true,
-	"android.hardware.audio@7.1":                        true,
-	"android.hardware.audio.common@2.0":                 true,
-	"android.hardware.audio.common@4.0":                 true,
-	"android.hardware.audio.common@5.0":                 true,
-	"android.hardware.audio.common@6.0":                 true,
-	"android.hardware.audio.common@7.0":                 true,
-	"android.hardware.audio.effect@2.0":                 true,
-	"android.hardware.audio.effect@4.0":                 true,
-	"android.hardware.audio.effect@5.0":                 true,
-	"android.hardware.audio.effect@6.0":                 true,
-	"android.hardware.audio.effect@7.0":                 true,
-	"android.hardware.authsecret@1.0":                   true,
-	"android.hardware.automotive.audiocontrol@1.0":      true,
-	"android.hardware.automotive.audiocontrol@2.0":      true,
-	"android.hardware.automotive.can@1.0":               true,
-	"android.hardware.automotive.evs@1.0":               true,
-	"android.hardware.automotive.evs@1.1":               true,
-	"android.hardware.automotive.sv@1.0":                true,
-	"android.hardware.automotive.vehicle@2.0":           true,
-	"android.hardware.biometrics.face@1.0":              true,
-	"android.hardware.biometrics.fingerprint@2.1":       true,
-	"android.hardware.biometrics.fingerprint@2.2":       true,
-	"android.hardware.biometrics.fingerprint@2.3":       true,
-	"android.hardware.bluetooth@1.0":                    true,
-	"android.hardware.bluetooth@1.1":                    true,
-	"android.hardware.bluetooth.a2dp@1.0":               true,
-	"android.hardware.bluetooth.audio@2.0":              true,
-	"android.hardware.bluetooth.audio@2.1":              true,
-	"android.hardware.bluetooth.audio@2.2":              true,
-	"android.hardware.boot@1.0":                         true,
-	"android.hardware.boot@1.1":                         true,
-	"android.hardware.boot@1.2":                         true,
-	"android.hardware.broadcastradio@1.0":               true,
-	"android.hardware.broadcastradio@1.1":               true,
-	"android.hardware.broadcastradio@2.0":               true,
-	"android.hardware.camera.common@1.0":                true,
-	"android.hardware.camera.device@1.0":                true,
-	"android.hardware.camera.device@3.2":                true,
-	"android.hardware.camera.device@3.3":                true,
-	"android.hardware.camera.device@3.4":                true,
-	"android.hardware.camera.device@3.5":                true,
-	"android.hardware.camera.device@3.6":                true,
-	"android.hardware.camera.device@3.7":                true,
-	"android.hardware.camera.device@3.8":                true,
-	"android.hardware.camera.metadata@3.2":              true,
-	"android.hardware.camera.metadata@3.3":              true,
-	"android.hardware.camera.metadata@3.4":              true,
-	"android.hardware.camera.metadata@3.5":              true,
-	"android.hardware.camera.metadata@3.6":              true,
-        // TODO: Remove metadata@3.8 after AIDL migration b/196432585
+	"android.frameworks.automotive.display@1.0":    true,
+	"android.frameworks.bufferhub@1.0":             true,
+	"android.frameworks.cameraservice.common@2.0":  true,
+	"android.frameworks.cameraservice.device@2.0":  true,
+	"android.frameworks.cameraservice.device@2.1":  true,
+	"android.frameworks.cameraservice.service@2.0": true,
+	"android.frameworks.cameraservice.service@2.1": true,
+	"android.frameworks.cameraservice.service@2.2": true,
+	"android.frameworks.displayservice@1.0":        true,
+	"android.frameworks.schedulerservice@1.0":      true,
+	"android.frameworks.sensorservice@1.0":         true,
+	"android.frameworks.stats@1.0":                 true,
+	"android.frameworks.vr.composer@1.0":           true,
+	"android.frameworks.vr.composer@2.0":           true,
+	"android.hardware.atrace@1.0":                  true,
+	"android.hardware.audio@2.0":                   true,
+	"android.hardware.audio@4.0":                   true,
+	"android.hardware.audio@5.0":                   true,
+	"android.hardware.audio@6.0":                   true,
+	"android.hardware.audio@7.0":                   true,
+	"android.hardware.audio@7.1":                   true,
+	"android.hardware.audio.common@2.0":            true,
+	"android.hardware.audio.common@4.0":            true,
+	"android.hardware.audio.common@5.0":            true,
+	"android.hardware.audio.common@6.0":            true,
+	"android.hardware.audio.common@7.0":            true,
+	"android.hardware.audio.effect@2.0":            true,
+	"android.hardware.audio.effect@4.0":            true,
+	"android.hardware.audio.effect@5.0":            true,
+	"android.hardware.audio.effect@6.0":            true,
+	"android.hardware.audio.effect@7.0":            true,
+	"android.hardware.authsecret@1.0":              true,
+	"android.hardware.automotive.audiocontrol@1.0": true,
+	"android.hardware.automotive.audiocontrol@2.0": true,
+	"android.hardware.automotive.can@1.0":          true,
+	"android.hardware.automotive.evs@1.0":          true,
+	"android.hardware.automotive.evs@1.1":          true,
+	"android.hardware.automotive.sv@1.0":           true,
+	"android.hardware.automotive.vehicle@2.0":      true,
+	"android.hardware.biometrics.face@1.0":         true,
+	"android.hardware.biometrics.fingerprint@2.1":  true,
+	"android.hardware.biometrics.fingerprint@2.2":  true,
+	"android.hardware.biometrics.fingerprint@2.3":  true,
+	"android.hardware.bluetooth@1.0":               true,
+	"android.hardware.bluetooth@1.1":               true,
+	"android.hardware.bluetooth.a2dp@1.0":          true,
+	"android.hardware.bluetooth.audio@2.0":         true,
+	"android.hardware.bluetooth.audio@2.1":         true,
+	"android.hardware.bluetooth.audio@2.2":         true,
+	"android.hardware.boot@1.0":                    true,
+	"android.hardware.boot@1.1":                    true,
+	"android.hardware.boot@1.2":                    true,
+	"android.hardware.broadcastradio@1.0":          true,
+	"android.hardware.broadcastradio@1.1":          true,
+	"android.hardware.broadcastradio@2.0":          true,
+	"android.hardware.camera.common@1.0":           true,
+	"android.hardware.camera.device@1.0":           true,
+	"android.hardware.camera.device@3.2":           true,
+	"android.hardware.camera.device@3.3":           true,
+	"android.hardware.camera.device@3.4":           true,
+	"android.hardware.camera.device@3.5":           true,
+	"android.hardware.camera.device@3.6":           true,
+	"android.hardware.camera.device@3.7":           true,
+	"android.hardware.camera.device@3.8":           true,
+	"android.hardware.camera.metadata@3.2":         true,
+	"android.hardware.camera.metadata@3.3":         true,
+	"android.hardware.camera.metadata@3.4":         true,
+	"android.hardware.camera.metadata@3.5":         true,
+	"android.hardware.camera.metadata@3.6":         true,
+	// TODO: Remove metadata@3.8 after AIDL migration b/196432585
 	"android.hardware.camera.metadata@3.7":              true,
 	"android.hardware.camera.metadata@3.8":              true,
 	"android.hardware.camera.provider@2.4":              true,
diff --git a/build/hidl_interface_conversion_test.go b/build/hidl_interface_conversion_test.go
new file mode 100644
index 0000000..6cc5df8
--- /dev/null
+++ b/build/hidl_interface_conversion_test.go
@@ -0,0 +1,117 @@
+// Copyright 2022 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package hidl
+
+import (
+	"testing"
+
+	"android/soong/android"
+	"android/soong/bp2build"
+	"android/soong/cc"
+)
+
+func runHidlInterfaceTestCase(t *testing.T, tc bp2build.Bp2buildTestCase) {
+	t.Helper()
+	bp2build.RunBp2BuildTestCase(
+		t,
+		func(ctx android.RegistrationContext) {
+			ctx.RegisterModuleType("cc_defaults", func() android.Module { return cc.DefaultsFactory() })
+			ctx.RegisterModuleType("hidl_interface", HidlInterfaceFactory)
+			ctx.RegisterModuleType("hidl_package_root", HidlPackageRootFactory)
+		},
+		tc,
+	)
+}
+
+func TestHidlInterface(t *testing.T) {
+	runHidlInterfaceTestCase(t, bp2build.Bp2buildTestCase{
+		Description: `hidl_interface with common usage of properties`,
+		Blueprint: `
+hidl_package_root {
+		name: "android.hardware",
+		use_current: true,
+}
+cc_defaults {
+		name: "hidl-module-defaults",
+}
+hidl_interface {
+		name: "android.hardware.nfc@1.0",
+		srcs: ["types.hal", "IBase.hal"],
+		root: "android.hardware",
+		gen_java: false,
+}
+hidl_interface {
+		name: "android.hardware.nfc@1.1",
+		srcs: ["types.hal", "INfc.hal"],
+		interfaces: ["android.hardware.nfc@1.0"],
+		root: "android.hardware",
+		gen_java: false,
+}`,
+		ExpectedBazelTargets: []string{
+			bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.nfc@1.0", bp2build.AttrNameToString{
+				"min_sdk_version":     `"29"`,
+				"root":                `"android.hardware"`,
+				"root_interface_file": `":current.txt"`,
+				"srcs": `[
+        "types.hal",
+        "IBase.hal",
+    ]`,
+			}),
+			bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.nfc@1.1", bp2build.AttrNameToString{
+				"deps":                `[":android.hardware.nfc@1.0"]`,
+				"min_sdk_version":     `"29"`,
+				"root":                `"android.hardware"`,
+				"root_interface_file": `":current.txt"`,
+				"srcs": `[
+        "types.hal",
+        "INfc.hal",
+    ]`,
+			}),
+		},
+	})
+}
+
+func TestHidlInterfacePackageRootInAnotherBp(t *testing.T) {
+	runHidlInterfaceTestCase(t, bp2build.Bp2buildTestCase{
+		Description: `hidl_interface with common usage of properties`,
+		Filesystem: map[string]string{
+			"foo/bar/Android.bp": `
+hidl_package_root {
+		name: "android.hardware",
+		use_current: true,
+}`},
+		Blueprint: `
+cc_defaults {
+		name: "hidl-module-defaults",
+}
+hidl_interface {
+		name: "android.hardware.nfc@1.0",
+		srcs: ["types.hal", "IBase.hal"],
+		root: "android.hardware",
+		gen_java: false,
+}`,
+		ExpectedBazelTargets: []string{
+			bp2build.MakeBazelTargetNoRestrictions("hidl_interface", "android.hardware.nfc@1.0", bp2build.AttrNameToString{
+				"min_sdk_version":     `"29"`,
+				"root":                `"android.hardware"`,
+				"root_interface_file": `"//foo/bar:current.txt"`,
+				"srcs": `[
+        "types.hal",
+        "IBase.hal",
+    ]`,
+			}),
+		},
+	})
+}
diff --git a/build/hidl_package_root.go b/build/hidl_package_root.go
index fc58597..628c210 100644
--- a/build/hidl_package_root.go
+++ b/build/hidl_package_root.go
@@ -45,7 +45,7 @@
 }
 
 func init() {
-	android.RegisterModuleType("hidl_package_root", hidlPackageRootFactory)
+	android.RegisterModuleType("hidl_package_root", HidlPackageRootFactory)
 }
 
 type hidlPackageRoot struct {
@@ -121,7 +121,7 @@
 var packageRootsMutex sync.Mutex
 var packageRoots []*hidlPackageRoot
 
-func hidlPackageRootFactory() android.Module {
+func HidlPackageRootFactory() android.Module {
 	r := &hidlPackageRoot{}
 	r.AddProperties(&r.properties)
 	android.InitAndroidModule(r)
diff --git a/build/properties.go b/build/properties.go
index 6d67033..c6cc13e 100644
--- a/build/properties.go
+++ b/build/properties.go
@@ -66,3 +66,10 @@
 	Data        []string
 	Fuzz_config *fuzzConfig
 }
+
+type Bazel_module struct {
+	Bp2build_available *bool
+}
+type bazelProperties struct {
+	*Bazel_module
+}
diff --git a/hidl2aidl/AidlInterface.cpp b/hidl2aidl/AidlInterface.cpp
index 5fb56ca..93317f2 100644
--- a/hidl2aidl/AidlInterface.cpp
+++ b/hidl2aidl/AidlInterface.cpp
@@ -176,7 +176,7 @@
     interface.emitDocComment(out);
     if (interface.superType() && interface.superType()->fqName() != gIBaseFqName) {
         out << "// Interface inherits from " << interface.superType()->fqName().string()
-            << " but AIDL does not support interface inheritance.\n";
+            << " but AIDL does not support interface inheritance (methods have been flattened).\n";
     }
 
     out << "@VintfStability\n";
diff --git a/hidl2aidl/main.cpp b/hidl2aidl/main.cpp
index 5d48860..297b411 100644
--- a/hidl2aidl/main.cpp
+++ b/hidl2aidl/main.cpp
@@ -220,6 +220,8 @@
     out << "aidl_interface {\n";
     out << "    name: \"" << AidlHelper::getAidlPackage(fqName) << "\",\n";
     out << "    vendor_available: true,\n";
+    out << "    host_supported: true,\n";
+    out << "    frozen: false,\n";
     out << "    srcs: [\"" << AidlHelper::getAidlPackagePath(fqName) << "/*.aidl\"],\n";
     out << "    stability: \"vintf\",\n";
     out << "    backend: {\n";
@@ -231,12 +233,7 @@
     out << "            enabled: true,\n";
     out << "        },\n";
     out << "        java: {\n";
-    out << "            sdk_version: \"module_current\",\n";
-    out << "        },\n";
-    out << "        ndk: {\n";
-    out << "            vndk: {\n";
-    out << "                enabled: true,\n";
-    out << "            },\n";
+    out << "            sdk_version: \"system_current\",\n";
     out << "        },\n";
     out << "    },\n";
     out << "}\n\n";
@@ -265,7 +262,7 @@
     emitAidlSharedLibs(out, fqName, AidlBackend::JAVA);
     emitHidlSharedLibs(out, targets, AidlBackend::JAVA);
     out << "    ],\n";
-    out << "    sdk_version: \"module_current\",\n";
+    out << "    sdk_version: \"system_current\",\n";
     out << "}\n\n";
 }
 
diff --git a/hidl2aidl/test/Android.bp b/hidl2aidl/test/Android.bp
index d780c9a..408baef 100644
--- a/hidl2aidl/test/Android.bp
+++ b/hidl2aidl/test/Android.bp
@@ -128,7 +128,7 @@
     srcs: [":hidl2aidl_test_gen_aidl"],
     backend: {
         java: {
-            sdk_version: "module_current",
+            sdk_version: "system_current",
         },
     },
     flags: [
diff --git a/test/hidl_test/hidl_test.py b/test/hidl_test/hidl_test.py
index 1a58e5d..802ddeb 100644
--- a/test/hidl_test/hidl_test.py
+++ b/test/hidl_test/hidl_test.py
@@ -49,12 +49,12 @@
     servers = []
 
     if has_bitness(32):
-        clients += ["/data/nativetest/hidl_test_client/hidl_test_client"]
-        servers += ["/data/nativetest/hidl_test_servers/hidl_test_servers"]
+        clients += ["/data/nativetest/hidl_test_client/hidl_test_client32"]
+        servers += ["/data/nativetest/hidl_test_servers/hidl_test_servers32"]
 
     if has_bitness(64):
-        clients += ["/data/nativetest64/hidl_test_client/hidl_test_client"]
-        servers += ["/data/nativetest64/hidl_test_servers/hidl_test_servers"]
+        clients += ["/data/nativetest64/hidl_test_client/hidl_test_client64"]
+        servers += ["/data/nativetest64/hidl_test_servers/hidl_test_servers64"]
 
     assert len(clients) > 0
     assert len(servers) > 0
diff --git a/test/hidl_test/hidl_test.xml b/test/hidl_test/hidl_test.xml
index 586adc4..778b63f 100644
--- a/test/hidl_test/hidl_test.xml
+++ b/test/hidl_test/hidl_test.xml
@@ -23,11 +23,11 @@
       <!-- We would like to abort, but currently there is not a simple way to specify installation of both bitnesses of targets. -->
       <option name="abort-on-push-failure" value="false"/>
 
-      <option name="push" value="hidl_test_client32->/data/nativetest/hidl_test_client/hidl_test_client" />
-      <option name="push" value="hidl_test_client64->/data/nativetest64/hidl_test_client/hidl_test_client" />
+      <option name="push" value="hidl_test_client32->/data/nativetest/hidl_test_client/hidl_test_client32" />
+      <option name="push" value="hidl_test_client64->/data/nativetest64/hidl_test_client/hidl_test_client64" />
 
-      <option name="push" value="hidl_test_servers32->/data/nativetest/hidl_test_servers/hidl_test_servers" />
-      <option name="push" value="hidl_test_servers64->/data/nativetest64/hidl_test_servers/hidl_test_servers" />
+      <option name="push" value="hidl_test_servers32->/data/nativetest/hidl_test_servers/hidl_test_servers32" />
+      <option name="push" value="hidl_test_servers64->/data/nativetest64/hidl_test_servers/hidl_test_servers64" />
 
       <option name="cleanup" value="true" />
     </target_preparer>
diff --git a/test/hidl_test/hidl_test_client.cpp b/test/hidl_test/hidl_test_client.cpp
index eff40a5..d82dab6 100644
--- a/test/hidl_test/hidl_test_client.cpp
+++ b/test/hidl_test/hidl_test_client.cpp
@@ -960,41 +960,45 @@
     const uint64_t kBatchSize = 2;
     hidl_vec<hidl_memory> batchCopy;
 
-    EXPECT_OK(ashmemAllocator->batchAllocate(1024, kBatchSize,
-        [&](bool success, const hidl_vec<hidl_memory>& batch) {
-            ASSERT_TRUE(success);
-            EXPECT_EQ(kBatchSize, batch.size());
+    ASSERT_TRUE(ashmemAllocator
+                        ->batchAllocate(1024, kBatchSize,
+                                        [&](bool success, const hidl_vec<hidl_memory>& batch) {
+                                            ASSERT_TRUE(success);
+                                            EXPECT_EQ(kBatchSize, batch.size());
 
-            for (uint64_t i = 0; i < batch.size(); i++) {
-                sp<IMemory> memory = mapMemory(batch[i]);
+                                            for (uint64_t i = 0; i < batch.size(); i++) {
+                                                sp<IMemory> memory = mapMemory(batch[i]);
 
-                EXPECT_NE(nullptr, memory.get());
+                                                EXPECT_NE(nullptr, memory.get());
 
-                uint8_t* data = static_cast<uint8_t*>(static_cast<void*>(memory->getPointer()));
-                EXPECT_NE(nullptr, data);
+                                                uint8_t* data = static_cast<uint8_t*>(
+                                                        static_cast<void*>(memory->getPointer()));
+                                                EXPECT_NE(nullptr, data);
 
-                EXPECT_EQ(memory->getSize(), batch[i].size());
+                                                EXPECT_EQ(memory->getSize(), batch[i].size());
 
-                memory->update();
-                memset(data, kValue, memory->getSize());
-                memory->commit();
-            }
+                                                memory->update();
+                                                memset(data, kValue, memory->getSize());
+                                                memory->commit();
+                                            }
 
-            batchCopy = batch;
-        }));
+                                            batchCopy = batch;
+                                        })
+                        .isOk());
 
     for (uint64_t i = 0; i < batchCopy.size(); i++) {
         // Test the memory persists after the call
         sp<IMemory> memory = mapMemory(batchCopy[i]);
 
-        EXPECT_NE(memory, nullptr);
+        ASSERT_NE(memory, nullptr);
 
         uint8_t* data = static_cast<uint8_t*>(static_cast<void*>(memory->getPointer()));
-        EXPECT_NE(data, nullptr);
+        ASSERT_NE(data, nullptr);
 
         memory->read();
-        for (size_t i = 0; i < batchCopy[i].size(); i++) {
-            EXPECT_EQ(kValue, data[i]);
+
+        for (size_t k = 0; k < batchCopy[i].size(); k++) {
+            EXPECT_EQ(kValue, data[k]);
         }
         memory->commit();
     }
diff --git a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
index a0311fe..47adad8 100644
--- a/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
+++ b/test/java_test/src/com/android/commands/hidl_test_java/HidlTestJava.java
@@ -930,8 +930,7 @@
             ExpectTrue(java.util.Objects.deepEquals(outArray, expectedOutArray));
 
             ArrayList<Integer> outVec = proxy.mapThisVector(paramVec);
-            java.util.Objects.equals(outVec, expectedOutVec);
-
+            ExpectTrue(java.util.Objects.equals(outVec, expectedOutVec));
         }
 
         Expect(proxy.doStuffAndReturnAString(), "Hello, world!");
@@ -1273,7 +1272,7 @@
         }
 
         public IBase.Foo[] someMethodWithFooArrays(IBase.Foo[] fooInput) {
-            Log.d(TAG, "Baz someMethodWithFooArrays " + fooInput.toString());
+            Log.d(TAG, "Baz someMethodWithFooArrays " + Arrays.toString(fooInput));
 
             IBase.Foo[] fooOutput = new IBase.Foo[2];
             fooOutput[0] = fooInput[1];
@@ -1333,7 +1332,7 @@
         }
 
         public String[][] transpose2(String[][] in) {
-            Log.d(TAG, "Baz transpose2 " + in.toString());
+            Log.d(TAG, "Baz transpose2 " + Arrays.deepToString(in));
 
             String[][] out = new String[3][5];
             for (int i = 0; i < 3; ++i) {
@@ -1352,8 +1351,7 @@
         }
 
         public boolean[] someBoolArrayMethod(boolean[] x) {
-            Log.d(TAG, "Baz someBoolArrayMethod("
-                    + x.toString() + ")");
+            Log.d(TAG, "Baz someBoolArrayMethod(" + Arrays.toString(x) + ")");
 
             boolean[] out = new boolean[4];
             out[0] = !x[0];
@@ -1390,7 +1388,7 @@
         }
 
         public int[] doSomethingElse(int[] param) {
-            Log.d(TAG, "Baz doSomethingElse " + param.toString());
+            Log.d(TAG, "Baz doSomethingElse " + Arrays.toString(param));
 
             int[] something = new int[32];
             for (int i = 0; i < 15; ++i) {
@@ -1422,8 +1420,7 @@
 
         public void takeAMask(byte bf, byte first, IBase.MyMask second, byte third,
                 takeAMaskCallback cb) {
-            cb.onValues(bf, (byte)(bf | first),
-                    (byte)(second.value & bf), (byte)((bf | bf) & third));
+            cb.onValues(bf, (byte) (bf | first), (byte) (second.value & bf), (byte) (bf & third));
         }
 
         public LotsOfPrimitiveArrays testArrays(LotsOfPrimitiveArrays in) {
@@ -1566,7 +1563,7 @@
 
         @Override
         public LargeSafeUnion setE(LargeSafeUnion safeUnion, byte[/* 13 */] e) {
-            Log.d(TAG, "SERVER: setE(" + e + ")");
+            Log.d(TAG, "SERVER: setE(" + Arrays.toString(e) + ")");
             safeUnion.e(e);
 
             return safeUnion;
@@ -1574,7 +1571,7 @@
 
         @Override
         public LargeSafeUnion setF(LargeSafeUnion safeUnion, long[/* 5 */] f) {
-            Log.d(TAG, "SERVER: setF(" + f + ")");
+            Log.d(TAG, "SERVER: setF(" + Arrays.toString(f) + ")");
             safeUnion.f(f);
 
             return safeUnion;
@@ -1661,7 +1658,7 @@
         @Override
         public InterfaceTypeSafeUnion setInterfaceB(
             InterfaceTypeSafeUnion safeUnion, byte[/* 7 */] b) {
-            Log.d(TAG, "SERVER: setInterfaceB(" + b + ")");
+            Log.d(TAG, "SERVER: setInterfaceB(" + Arrays.toString(b) + ")");
             safeUnion.b(b);
 
             return safeUnion;
@@ -1727,7 +1724,7 @@
 
         @Override
         public HandleTypeSafeUnion setHandleB(HandleTypeSafeUnion safeUnion, NativeHandle[] b) {
-            Log.d(TAG, "SERVER: setHandleB(" + b + ")");
+            Log.d(TAG, "SERVER: setHandleB(" + Arrays.toString(b) + ")");
             safeUnion.b(b);
 
             return safeUnion;
diff --git a/test/lazy_test/hidl_lazy_test.cpp b/test/lazy_test/hidl_lazy_test.cpp
index 6bbb161..4f27463 100644
--- a/test/lazy_test/hidl_lazy_test.cpp
+++ b/test/lazy_test/hidl_lazy_test.cpp
@@ -179,6 +179,10 @@
     FqInstance fqInstance;
     ASSERT_TRUE(fqInstance.setTo(fqInstanceName));
 
+    // b/251244025 - this service logic is coupled with this test, but other
+    // things may have started it
+    (void)android::base::SetProperty("ctl.stop", "hidl_lazy_cb_test_server");
+
     ASSERT_FALSE(isServiceRunning(fqInstance)) << "Lazy service already running.";
 
     sp<IBase> hal = getHal(fqInstance);
diff --git a/test/vendor/1.0/Android.bp b/test/vendor/1.0/Android.bp
index cdb613a..9fe46f4 100644
--- a/test/vendor/1.0/Android.bp
+++ b/test/vendor/1.0/Android.bp
@@ -23,9 +23,6 @@
     gen_java: true,
     gen_java_constants: true,
 
-    // tests that license is copied
-    notice: "FAKE_NOTICE_FILE",
-
     // test apex_available resolves
     apex_available: [
         "//apex_available:anyapex",