GpuService: fix shellCommand result protocol
The "cmd" shell command at some point separated transport vs. command
results: transport errors should be returned as the Binder transaction
result, but in the absence of a transport error, the command result
(success or failure) should be sent to a IResultReceiver object
provided as a command parameter.
GpuService wasn't doing this, returning the command result from the
Binder transaction and never sending anything to the IResultReceiver.
This caused cmd to wait forever for an IResultReceiver result to
become available. This change properly handles transport errors vs.
command results.
Test: for cmd in "" help vkjson foo; do adb shell cmd gpu $cmd; done
Change-Id: Id2f78593a27d35a88ffa96182de0ef75c3e33599
diff --git a/services/surfaceflinger/GpuService.cpp b/services/surfaceflinger/GpuService.cpp
index dc1d3f0..71052fb 100644
--- a/services/surfaceflinger/GpuService.cpp
+++ b/services/surfaceflinger/GpuService.cpp
@@ -16,6 +16,7 @@
#include "GpuService.h"
+#include <binder/IResultReceiver.h>
#include <binder/Parcel.h>
#include <utils/String8.h>
#include <vkjson.h>
@@ -35,6 +36,7 @@
status_t BnGpuService::onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags)
{
+ status_t status;
switch (code) {
case SHELL_COMMAND_TRANSACTION: {
int in = data.readFileDescriptor();
@@ -45,7 +47,16 @@
for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
args.add(data.readString16());
}
- return shellCommand(in, out, err, args);
+ sp<IBinder> unusedCallback;
+ sp<IResultReceiver> resultReceiver;
+ if ((status = data.readNullableStrongBinder(&unusedCallback)) != OK)
+ return status;
+ if ((status = data.readNullableStrongBinder(&resultReceiver)) != OK)
+ return status;
+ status = shellCommand(in, out, err, args);
+ if (resultReceiver != nullptr)
+ resultReceiver->send(status);
+ return OK;
}
default: