libbinder: RPC use 'status_t' over 'bool'
For ease of debugging/handling errors (I realized that binderRpcTest
currently crashes on Pixel 3 because of some missing kernel patches -
this would have been easier with this, and one potential (even if
temporary) solution would be to check the return code).
Bug: 167966510
Test: binderRpcTest, binderRpcBenchmark, binder_parcel_fuzzer,
binder_rpc_fuzzer, binderHostDeviceTest
Change-Id: I1baa2e9380e0ec8f82f8ceb250f3eeb632dc5fbc
diff --git a/libs/binder/libbinder_rpc_unstable.cpp b/libs/binder/libbinder_rpc_unstable.cpp
index 68ec669..bcb13ae 100644
--- a/libs/binder/libbinder_rpc_unstable.cpp
+++ b/libs/binder/libbinder_rpc_unstable.cpp
@@ -19,16 +19,20 @@
#include <binder/RpcServer.h>
#include <binder/RpcSession.h>
+using android::OK;
using android::RpcServer;
using android::RpcSession;
+using android::status_t;
+using android::statusToString;
extern "C" {
bool RunRpcServer(AIBinder* service, unsigned int port) {
auto server = RpcServer::make();
server->iUnderstandThisCodeIsExperimentalAndIWillNotUseItInProduction();
- if (!server->setupVsockServer(port)) {
- LOG(ERROR) << "Failed to set up vsock server with port " << port;
+ if (status_t status = server->setupVsockServer(port); status != OK) {
+ LOG(ERROR) << "Failed to set up vsock server with port " << port
+ << " error: " << statusToString(status).c_str();
return false;
}
server->setRootObject(AIBinder_toPlatformBinder(service));
@@ -41,8 +45,9 @@
AIBinder* RpcClient(unsigned int cid, unsigned int port) {
auto session = RpcSession::make();
- if (!session->setupVsockClient(cid, port)) {
- LOG(ERROR) << "Failed to set up vsock client with CID " << cid << " and port " << port;
+ if (status_t status = session->setupVsockClient(cid, port); status != OK) {
+ LOG(ERROR) << "Failed to set up vsock client with CID " << cid << " and port " << port
+ << " error: " << statusToString(status).c_str();
return nullptr;
}
return AIBinder_fromPlatformBinder(session->getRootObject());