Merge "Remove unused include in MQDescriptor.h of utils/Log.h." into oc-dev
diff --git a/base/Android.bp b/base/Android.bp
index 321f499..25b2a80 100644
--- a/base/Android.bp
+++ b/base/Android.bp
@@ -21,12 +21,10 @@
         "libhidl-gen-utils",
         "liblog",
         "libutils",
-        "libvintf",
     ],
     export_shared_lib_headers: [
         "libbase",
         "libutils",
-        "libvintf",
     ],
     local_include_dirs: ["include"],
     export_include_dirs: ["include"],
diff --git a/base/HidlSupport.cpp b/base/HidlSupport.cpp
index 91c9717..8223599 100644
--- a/base/HidlSupport.cpp
+++ b/base/HidlSupport.cpp
@@ -21,58 +21,10 @@
 
 #include <android-base/logging.h>
 #include <android-base/parseint.h>
-#include <hidl-util/FQName.h>
-#include <vintf/VintfObject.h>
-#include <vintf/parse_string.h>
 
 namespace android {
 namespace hardware {
 
-vintf::Transport getTransportFromManifest(
-        const FQName &fqName, const std::string &instanceName,
-        const vintf::HalManifest *vm) {
-    if (vm == nullptr) {
-        return vintf::Transport::EMPTY;
-    }
-    return vm->getTransport(fqName.package(),
-            vintf::Version{fqName.getPackageMajorVersion(), fqName.getPackageMinorVersion()},
-            fqName.name(), instanceName);
-}
-
-vintf::Transport getTransport(const std::string &interfaceName, const std::string &instanceName) {
-    FQName fqName(interfaceName);
-    if (!fqName.isValid()) {
-        LOG(ERROR) << "getTransport: " << interfaceName << " is not a valid fully-qualified name.";
-        return vintf::Transport::EMPTY;
-    }
-    if (!fqName.hasVersion()) {
-        LOG(ERROR) << "getTransport: " << fqName.string()
-                   << " does not specify a version. Using default transport.";
-        return vintf::Transport::EMPTY;
-    }
-    if (fqName.name().empty()) {
-        LOG(ERROR) << "getTransport: " << fqName.string()
-                   << " does not specify an interface name. Using default transport.";
-        return vintf::Transport::EMPTY;
-    }
-
-    vintf::Transport tr = getTransportFromManifest(fqName, instanceName,
-            vintf::VintfObject::GetFrameworkHalManifest());
-    if (tr != vintf::Transport::EMPTY) {
-        return tr;
-    }
-    tr = getTransportFromManifest(fqName, instanceName,
-            vintf::VintfObject::GetDeviceHalManifest());
-    if (tr != vintf::Transport::EMPTY) {
-        return tr;
-    }
-
-    LOG(WARNING) << "getTransportFromManifest: Cannot find entry "
-                 << fqName.string()
-                 << " in either framework or device manifest, using default transport.";
-    return vintf::Transport::EMPTY;
-}
-
 namespace details {
 bool debuggable() {
 #ifdef LIBHIDL_TARGET_DEBUGGABLE
@@ -257,8 +209,9 @@
     return std::string(mBuffer, mSize);
 }
 
-hidl_string::operator const char *() const {
-    return mBuffer;
+std::ostream& operator<<(std::ostream& os, const hidl_string& str) {
+    os << str.c_str();
+    return os;
 }
 
 void hidl_string::copyFrom(const char *data, size_t size) {
diff --git a/base/include/hidl/HidlSupport.h b/base/include/hidl/HidlSupport.h
index a8eae8c..d7c3b83 100644
--- a/base/include/hidl/HidlSupport.h
+++ b/base/include/hidl/HidlSupport.h
@@ -31,7 +31,6 @@
 #include <utils/Errors.h>
 #include <utils/RefBase.h>
 #include <utils/StrongPointer.h>
-#include <vintf/Transport.h>
 #include <vector>
 
 namespace android {
@@ -56,13 +55,6 @@
 
 namespace hardware {
 
-// Get transport method from vendor interface manifest.
-// interfaceName has the format "android.hardware.foo@1.0::IFoo"
-// instanceName is "default", "ashmem", etc.
-// If it starts with "android.hidl.", a static map is looked up instead.
-vintf::Transport getTransport(const std::string &interfaceName,
-                              const std::string &instanceName);
-
 namespace details {
 // Return true on userdebug / eng builds and false on user builds.
 bool debuggable();
@@ -157,9 +149,6 @@
     hidl_string &operator=(hidl_string &&other);
     // cast to std::string.
     operator std::string() const;
-    // cast to C-style string. Caller is responsible
-    // to maintain this hidl_string alive.
-    operator const char *() const;
 
     void clear();
 
@@ -203,6 +192,10 @@
 
 #undef HIDL_STRING_OPERATOR
 
+// Send our content to the output stream
+std::ostream& operator<<(std::ostream& os, const hidl_string& str);
+
+
 // hidl_memory is a structure that can be used to transfer
 // pieces of shared memory between processes. The assumption
 // of this object is that the memory remains accessible as
diff --git a/manifest.xml b/manifest.xml
index db83d63..d3a6e66 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -1,4 +1,4 @@
-<manifest version="1.0">
+<manifest version="1.0" type="framework">
     <hal>
         <name>android.hidl.manager</name>
         <transport>hwbinder</transport>
diff --git a/test_main.cpp b/test_main.cpp
index 658a7eb..4be2eb9 100644
--- a/test_main.cpp
+++ b/test_main.cpp
@@ -62,7 +62,7 @@
     hidl_string s2("s2"); // copy constructor from cstr
     EXPECT_STREQ(s2.c_str(), "s2");
     hidl_string s2a(nullptr); // copy constructor from null cstr
-    EXPECT_STREQ("", s2a);
+    EXPECT_STREQ("", s2a.c_str());
     s2a = nullptr; // = from nullptr cstr
     EXPECT_STREQ(s2a.c_str(), "");
     hidl_string s3 = hidl_string("s3"); // move =
@@ -72,34 +72,44 @@
     hidl_string s5(hidl_string(hidl_string("s5"))); // move constructor
     EXPECT_STREQ(s5.c_str(), "s5");
     hidl_string s6(std::string("s6")); // copy constructor from std::string
-    EXPECT_STREQ(s6, "s6");
+    EXPECT_STREQ(s6.c_str(), "s6");
     hidl_string s7 = std::string("s7"); // copy = from std::string
-    EXPECT_STREQ(s7, "s7");
+    EXPECT_STREQ(s7.c_str(), "s7");
     hidl_string s8(s7); // copy constructor
-    EXPECT_STREQ(s8, "s7");
+    EXPECT_STREQ(s8.c_str(), "s7");
     hidl_string s9 = s8; // copy =
-    EXPECT_STREQ(s9, "s7");
+    EXPECT_STREQ(s9.c_str(), "s7");
     char myCString[20] = "myCString";
     s.setToExternal(&myCString[0], strlen(myCString));
-    EXPECT_STREQ(s, "myCString");
+    EXPECT_STREQ(s.c_str(), "myCString");
     myCString[2] = 'D';
-    EXPECT_STREQ(s, "myDString");
+    EXPECT_STREQ(s.c_str(), "myDString");
     s.clear(); // should not affect myCString
     EXPECT_STREQ(myCString, "myDString");
 
     // casts
     s = "great";
     std::string myString = s;
-    const char *anotherCString = s;
+    const char *anotherCString = s.c_str();
     EXPECT_EQ(myString, "great");
     EXPECT_STREQ(anotherCString, "great");
 
     const hidl_string t = "not so great";
     std::string myTString = t;
-    const char * anotherTCString = t;
+    const char * anotherTCString = t.c_str();
     EXPECT_EQ(myTString, "not so great");
     EXPECT_STREQ(anotherTCString, "not so great");
 
+    // Assignment from hidl_string to std::string
+    std::string tgt;
+    hidl_string src("some stuff");
+    tgt = src;
+    EXPECT_STREQ(tgt.c_str(), "some stuff");
+
+    // Stream output operator
+    hidl_string msg("hidl_string works with operator<<");
+    std::cout << msg;
+
     // Comparisons
     const char * cstr1 = "abc";
     std::string string1(cstr1);
diff --git a/transport/ServiceManagement.cpp b/transport/ServiceManagement.cpp
index 5ba3ec3..ecd64b2 100644
--- a/transport/ServiceManagement.cpp
+++ b/transport/ServiceManagement.cpp
@@ -196,7 +196,7 @@
                     continue;
                 }
 
-                IBase *interface = (*generator)(name);
+                IBase *interface = (*generator)(name.c_str());
 
                 if (interface == nullptr) {
                     dlclose(handle);
@@ -218,6 +218,12 @@
         return false;
     }
 
+    Return<Transport> getTransport(const hidl_string& /* fqName */,
+                                   const hidl_string& /* name */) {
+        LOG(FATAL) << "Cannot getTransport with passthrough service manager.";
+        return Transport::EMPTY;
+    }
+
     Return<void> list(list_cb /* _hidl_cb */) override {
         LOG(FATAL) << "Cannot list services with passthrough service manager.";
         return Void();
diff --git a/transport/manager/1.0/IServiceManager.hal b/transport/manager/1.0/IServiceManager.hal
index 9e1c2fc..1a37c54 100644
--- a/transport/manager/1.0/IServiceManager.hal
+++ b/transport/manager/1.0/IServiceManager.hal
@@ -73,6 +73,22 @@
      */
     add(string name, interface service) generates (bool success);
 
+    enum Transport : uint8_t {
+        EMPTY,
+        HWBINDER,
+        PASSTHROUGH,
+    };
+
+    /**
+     * Get the transport of a service.
+     *
+     * @param fqName     Fully-qualified interface name.
+     * @param name       Instance name. Same as in IServiceManager::add
+     *
+     * @return transport Transport of service if known.
+     */
+    getTransport(string fqName, string name) generates (Transport transport);
+
     /**
      * List all registered services. Must be sorted.
      *