diff options
-rw-r--r-- | libs/binder/tests/IBinderRpcTest.aidl | 3 | ||||
-rw-r--r-- | libs/binder/tests/binderRpcTest.cpp | 11 |
2 files changed, 14 insertions, 0 deletions
diff --git a/libs/binder/tests/IBinderRpcTest.aidl b/libs/binder/tests/IBinderRpcTest.aidl index fdd02a4435..2deea82cf9 100644 --- a/libs/binder/tests/IBinderRpcTest.aidl +++ b/libs/binder/tests/IBinderRpcTest.aidl @@ -24,6 +24,9 @@ interface IBinderRpcTest { // number of known RPC binders to process, RpcState::countBinders by session int[] countBinders(); + // Return a null binder with a non-nullable return type. + IBinder getNullBinder(); + // Caller sends server, callee pings caller's server and returns error code. int pingMe(IBinder binder); @nullable IBinder repeatBinder(@nullable IBinder binder); diff --git a/libs/binder/tests/binderRpcTest.cpp b/libs/binder/tests/binderRpcTest.cpp index 51614698a0..141fa38114 100644 --- a/libs/binder/tests/binderRpcTest.cpp +++ b/libs/binder/tests/binderRpcTest.cpp @@ -202,6 +202,10 @@ public: } return Status::ok(); } + Status getNullBinder(sp<IBinder>* out) override { + out->clear(); + return Status::ok(); + } Status pingMe(const sp<IBinder>& binder, int32_t* out) override { if (binder == nullptr) { std::cout << "Received null binder!" << std::endl; @@ -802,6 +806,13 @@ TEST_P(BinderRpc, SendAndGetResultBackBig) { EXPECT_EQ(single + single, doubled); } +TEST_P(BinderRpc, InvalidNullBinderReturn) { + auto proc = createRpcTestSocketServerProcess({}); + + sp<IBinder> outBinder; + EXPECT_EQ(proc.rootIface->getNullBinder(&outBinder).transactionError(), UNEXPECTED_NULL); +} + TEST_P(BinderRpc, CallMeBack) { auto proc = createRpcTestSocketServerProcess({}); |