Explicitly check processes are oneway

Otherwise the behavior is effectively undefined when an
interface is unexpectedly changed or malicious code tries
to change things.

Test: hidl's run_all_device_tests, boot + camera/YT sanity
Bug: 68217907
Merged-In: I4fe191a8a394441d24052efdb2f524801c80b7e5
Change-Id: I4fe191a8a394441d24052efdb2f524801c80b7e5
(cherry picked from commit 1f0d094186b1f0c4f77276c9045a2d159fb85b84)
diff --git a/generateCpp.cpp b/generateCpp.cpp
index eee5412..158402f 100644
--- a/generateCpp.cpp
+++ b/generateCpp.cpp
@@ -1672,6 +1672,10 @@
 
         out.indent();
 
+        out << "bool _hidl_is_oneway = _hidl_flags & ::android::hardware::IBinder::FLAG_ONEWAY;\n";
+        out << "if (_hidl_is_oneway != " << (method->isOneway() ? "true" : "false") << ") ";
+        out.block([&] { out << "return ::android::UNKNOWN_ERROR;\n"; }).endl().endl();
+
         status_t err = generateStubSourceForMethod(out, method, superInterface);
 
         if (err != OK) {