diff options
-rw-r--r-- | generateCpp.cpp | 21 | ||||
-rw-r--r-- | test/hidl_test_client.cpp | 31 |
2 files changed, 45 insertions, 7 deletions
diff --git a/generateCpp.cpp b/generateCpp.cpp index 397c09c2..05b282b4 100644 --- a/generateCpp.cpp +++ b/generateCpp.cpp @@ -1590,16 +1590,23 @@ status_t AST::generateStubSource( out << "default:\n{\n"; out.indent(); - out << "return onTransact(\n"; + if (iface->isIBase()) { + out << "(void)_hidl_flags;\n"; + out << "return ::android::UNKNOWN_TRANSACTION;\n"; + } else { + out << "return "; + out << gIBaseFqName.getInterfaceStubFqName().cppName(); + out << "::onTransact(\n"; - out.indent(); - out.indent(); + out.indent(); + out.indent(); - out << "_hidl_code, _hidl_data, _hidl_reply, " - << "_hidl_flags, _hidl_cb);\n"; + out << "_hidl_code, _hidl_data, _hidl_reply, " + << "_hidl_flags, _hidl_cb);\n"; - out.unindent(); - out.unindent(); + out.unindent(); + out.unindent(); + } out.unindent(); out << "}\n"; diff --git a/test/hidl_test_client.cpp b/test/hidl_test_client.cpp index 957e8024..e9868e8e 100644 --- a/test/hidl_test_client.cpp +++ b/test/hidl_test_client.cpp @@ -17,6 +17,8 @@ #include <android/hardware/tests/foo/1.0/BsSimple.h> #include <android/hardware/tests/foo/1.0/BpHwSimple.h> #include <android/hardware/tests/bar/1.0/IBar.h> +#include <android/hardware/tests/bar/1.0/BpHwBar.h> +#include <android/hardware/tests/bar/1.0/BnHwBar.h> #include <android/hardware/tests/bar/1.0/IComplicated.h> #include <android/hardware/tests/bar/1.0/IImportRules.h> #include <android/hardware/tests/baz/1.0/IBaz.h> @@ -1554,6 +1556,35 @@ TEST_F(HidlTest, EnumEqualTest) { EXPECT_TRUE(e1 != e3); } +TEST_F(HidlTest, InvalidTransactionTest) { + using ::android::hardware::tests::bar::V1_0::BnHwBar; + using ::android::hardware::tests::bar::V1_0::BpHwBar; + using ::android::hardware::IBinder; + using ::android::hardware::Parcel; + using ::android::status_t; + using ::android::OK; + + Parcel request, reply; + sp<IBinder> binder; + status_t status = request.writeInterfaceToken(::android::hardware::tests::bar::V1_0::IBar::descriptor); + + EXPECT_EQ(status, OK); + + if (mode == BINDERIZED) { + EXPECT_TRUE(bar->isRemote()); + binder = ::android::hardware::toBinder<IBar, BpHwBar>(bar); + } else { + // For a local test, just wrap the implementation with a BnHwBar + binder = new BnHwBar(bar); + } + + status = binder->transact(1234, request, &reply); + + EXPECT_EQ(status, ::android::UNKNOWN_TRANSACTION); + // Try another call, to make sure nothing is messed up + EXPECT_OK(bar->thisIsNew()); +} + #if HIDL_RUN_POINTER_TESTS TEST_F(HidlTest, PassAGraphTest) { |