Break ::android::hardware namespace assumption.

Test: make test.vendor@1.0
Bug: 32579492
Change-Id: I7afd1d83af5f4c0d1c49b828b9e489c111937dcd
diff --git a/ArrayType.cpp b/ArrayType.cpp
index 268b090..6c610ff 100644
--- a/ArrayType.cpp
+++ b/ArrayType.cpp
@@ -62,7 +62,8 @@
     const std::string base = mElementType->getCppType(extra, specifyNamespaces);
     CHECK(extra->empty());
 
-    std::string arrayType = "hidl_array<" + base;
+    std::string space = specifyNamespaces ? "::android::hardware::" : "";
+    std::string arrayType = space + "hidl_array<" + base;
 
     for (size_t i = 0; i < mSizes.size(); ++i) {
         arrayType += ", ";
diff --git a/generateCpp.cpp b/generateCpp.cpp
index 380f21d..f17025c 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -1492,7 +1492,7 @@
     out.indent();
     out << "explicit "
         << klassName
-        << "(const sp<"
+        << "(const ::android::sp<"
         << ifaceName
         << "> impl);\n";
 
@@ -1507,7 +1507,7 @@
     out.unindent();
     out << "private:\n";
     out.indent();
-    out << "const sp<" << ifaceName << "> mImpl;\n";
+    out << "const ::android::sp<" << ifaceName << "> mImpl;\n";
 
     if (supportOneway) {
         out << "::android::hardware::TaskRunner mOnewayQueue;\n";
@@ -1601,7 +1601,7 @@
     out << klassName
         << "::"
         << klassName
-        << "(const sp<"
+        << "(const ::android::sp<"
         << iface->fullName()
         << "> impl) : ::android::hardware::HidlInstrumentor(\""
         << iface->fqName().string()
diff --git a/test/Android.bp b/test/Android.bp
index d01f152..96b16c3 100644
--- a/test/Android.bp
+++ b/test/Android.bp
@@ -1,3 +1,7 @@
+subdirs = [
+    "vendor/1.0",
+]
+
 cc_test {
     name: "hidl_test",
     gtest: false,
diff --git a/test/vendor/1.0/Android.bp b/test/vendor/1.0/Android.bp
new file mode 100644
index 0000000..cabe733
--- /dev/null
+++ b/test/vendor/1.0/Android.bp
@@ -0,0 +1,47 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+    name: "tests.vendor@1.0_genc++",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -rtests:system/tools/hidl/test/ tests.vendor@1.0",
+    srcs: [
+        "IVendor.hal",
+    ],
+    out: [
+        "tests/vendor/1.0/VendorAll.cpp",
+    ],
+}
+
+genrule {
+    name: "tests.vendor@1.0_genc++_headers",
+    tool: "hidl-gen",
+    cmd: "$tool -o $genDir -Lc++ -rtests:system/tools/hidl/test/ tests.vendor@1.0",
+    srcs: [
+        "IVendor.hal",
+    ],
+    out: [
+        "tests/vendor/1.0/IVendor.h",
+        "tests/vendor/1.0/IHwVendor.h",
+        "tests/vendor/1.0/BnVendor.h",
+        "tests/vendor/1.0/BpVendor.h",
+        "tests/vendor/1.0/BsVendor.h",
+    ],
+}
+
+cc_library_shared {
+    name: "tests.vendor@1.0",
+    generated_sources: ["tests.vendor@1.0_genc++"],
+    generated_headers: ["tests.vendor@1.0_genc++_headers"],
+    export_generated_headers: ["tests.vendor@1.0_genc++_headers"],
+    shared_libs: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+        "libcutils",
+    ],
+    export_shared_lib_headers: [
+        "libhidl",
+        "libhwbinder",
+        "libutils",
+    ],
+}
diff --git a/test/vendor/1.0/IVendor.hal b/test/vendor/1.0/IVendor.hal
new file mode 100644
index 0000000..1ccaa0d
--- /dev/null
+++ b/test/vendor/1.0/IVendor.hal
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * 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 tests.vendor@1.0;
+
+interface IVendor {
+
+    struct StructTest {
+        handle a;
+        vec<uint8_t> b;
+        MQDescriptorSync c;
+        string d;
+        uint8_t[4][4] e;
+    };
+
+    fun1(handle a) generates(handle b);
+    fun2(vec<uint8_t> a) generates(vec<uint8_t> b);
+    fun3(MQDescriptorSync a) generates(MQDescriptorSync b);
+    fun4(string a) generates(string b);
+    fun5(uint8_t[4][4] a) generates(uint8_t[4][4] b);
+
+};
\ No newline at end of file
diff --git a/test/vendor/1.0/update-makefile.sh b/test/vendor/1.0/update-makefile.sh
new file mode 100755
index 0000000..e286c22
--- /dev/null
+++ b/test/vendor/1.0/update-makefile.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+hidl-gen -Lmakefile -r tests:system/tools/hidl/test/ tests.vendor@1.0;
+hidl-gen -Landroidbp -r tests:system/tools/hidl/test/ tests.vendor@1.0;
\ No newline at end of file