Merge cherrypicks of [3287457, 3287458, 3286978, 3286979, 3287477, 3287478, 3287479, 3287480, 3287517, 3287518, 3287537, 3287538, 3287539, 3287540, 3287481, 3287482, 3287483, 3287484, 3287485, 3287486, 3287487, 3287488, 3287359, 3287459, 3287360, 3287361, 3287362, 3287363, 3287364, 3287365, 3287366, 3287367, 3287489, 3287490, 3287491, 3287557, 3287577, 3287558, 3287492, 3287493, 3287597, 3287617, 3286980, 3287460, 3287494] into oc-m3-release

Change-Id: I36329ddeebe1a28522b7413a93471177f54350de
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) {