Allow nullptr interfaces to be passed.
Bug: 32410513
Test: mma, hidl_test
Change-Id: I0ed27dc503f6b4d71b2106e03f70b1994800de52
diff --git a/Interface.cpp b/Interface.cpp
index d348101..f03f3aa 100644
--- a/Interface.cpp
+++ b/Interface.cpp
@@ -252,11 +252,21 @@
out.unindent();
out << "}\n\n";
} else {
+ out << "if (" << name << " == nullptr) {\n";
+ out.indent();
+ out << "_hidl_err = ";
+ out << parcelObjDeref
+ << "writeStrongBinder(nullptr);\n";
+ out.unindent();
+ out << "} else {\n";
+ out.indent();
out << "_hidl_err = "
<< parcelObjDeref
<< "writeStrongBinder("
<< name
<< "->toBinder());\n";
+ out.unindent();
+ out << "}\n";
handleError(out, mode);
}