Merge cherrypicks of [3276508, 3277765, 3277766, 3277904, 3276473, 3278009, 3278010, 3277767, 3277768, 3277769, 3277770, 3276509, 3276510, 3278011, 3278012, 3278013, 3278014, 3278099, 3278100, 3278101, 3278102, 3278103, 3278104, 3278105, 3278106, 3277800, 3276474, 3278015, 3278016, 3278017, 3278118, 3278119, 3278120, 3278121, 3278122, 3277946, 3277905, 3277947, 3277906, 3277751, 3278123, 3277752, 3278110, 3277771, 3277907, 3278095, 3277908, 3278111, 3277772, 3276475, 3276476] into oc-mr1-release

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