Build toString + operator== in client libraries.

This is Phase I of a three phase plan to remove toString + operator==
from sources since the VNDK is currently not in place.

Phase I: functions in client and source libraries
Phase II: rebuild prebuilts with the functions in the clients
  across all targets and vendors.
Phase III: remove functions from the source libraries

Test: hidl_test
Bug: 65200821
Change-Id: I4f2b10c088b1c1663a7a10d479e2607311dc462c
diff --git a/Interface.cpp b/Interface.cpp
index e9e1c8f..3d9786f 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -822,9 +822,24 @@
     if (status != OK) {
         return status;
     }
+
+    // TODO(b/65200821): remove these ifndefs
+    out << "#ifdef REALLY_IS_HIDL_INTERNAL_LIB" << gCurrentCompileName << "\n";
     out << "std::string toString("
         << getCppArgumentType()
         << ");\n";
+    out << "#else\n";
+    out << "static inline std::string toString(" << getCppArgumentType() << " o) ";
+
+    out.block([&] {
+        out << "std::string os = \"[class or subclass of \";\n"
+            << "os += " << fullName() << "::descriptor;\n"
+            << "os += \"]\";\n"
+            << "os += o->isRemote() ? \"@remote\" : \"@local\";\n"
+            << "return os;\n";
+    }).endl().endl();
+    out << "#endif  // REALLY_IS_HIDL_INTERNAL_LIB\n";
+
     return OK;
 }
 
@@ -835,6 +850,7 @@
         return err;
     }
 
+    // TODO(b/65200821): remove toString from .cpp once all prebuilts are rebuilt
     out << "std::string toString("
         << getCppArgumentType()
         << " o) ";