Skip to content

Commit

Permalink
Temporary hack to get rid of new virtuals.
Browse files Browse the repository at this point in the history
Seems like it breaks some prebuilt binaries.

Change-Id: Ia5e35beb4538364b2ab3618fbf21b2e9c9ee2363
  • Loading branch information
Dianne Hackborn committed Oct 14, 2015
1 parent d9ecfe4 commit f2bf93b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
3 changes: 2 additions & 1 deletion cmds/cmd/cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int main(int argc, char* const argv[])
}

// TODO: block until a result is returned to MyResultReceiver.
service->shellCommand(STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, args, new MyResultReceiver());
IBinder::shellCommand(service, STDIN_FILENO, STDOUT_FILENO, STDERR_FILENO, args,
new MyResultReceiver());
return 0;
}
2 changes: 0 additions & 2 deletions include/binder/BpBinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class BpBinder : public IBinder
virtual bool isBinderAlive() const;
virtual status_t pingBinder();
virtual status_t dump(int fd, const Vector<String16>& args);
virtual status_t shellCommand(int in, int out, int err, Vector<String16>& args,
const sp<IResultReceiver>& resultReceiver);

virtual status_t transact( uint32_t code,
const Parcel& data,
Expand Down
3 changes: 2 additions & 1 deletion include/binder/IBinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class IBinder : public virtual RefBase
virtual bool isBinderAlive() const = 0;
virtual status_t pingBinder() = 0;
virtual status_t dump(int fd, const Vector<String16>& args) = 0;
virtual status_t shellCommand(int in, int out, int err, Vector<String16>& args,
static status_t shellCommand(const sp<IBinder>& target, int in, int out, int err,
Vector<String16>& args,
const sp<IResultReceiver>& resultReceiver);

virtual status_t transact( uint32_t code,
Expand Down
27 changes: 18 additions & 9 deletions libs/binder/Binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,21 @@ bool IBinder::checkSubclass(const void* /*subclassID*/) const
}


status_t IBinder::shellCommand(int /*in*/, int out, int /*err*/, Vector<String16>& /*args*/,
const sp<IResultReceiver>& resultReceiver)
status_t IBinder::shellCommand(const sp<IBinder>& target, int in, int out, int err,
Vector<String16>& args, const sp<IResultReceiver>& resultReceiver)
{
if (out >= 0) {
dprintf(out, "Shell commands not supported.\n");
Parcel send;
Parcel reply;
send.writeFileDescriptor(in);
send.writeFileDescriptor(out);
send.writeFileDescriptor(err);
const size_t numArgs = args.size();
send.writeInt32(numArgs);
for (size_t i = 0; i < numArgs; i++) {
send.writeString16(args[i]);
}
if (resultReceiver != NULL) {
resultReceiver->send(INVALID_OPERATION);
}
return NO_ERROR;
send.writeStrongBinder(resultReceiver != NULL ? IInterface::asBinder(resultReceiver) : NULL);
return target->transact(SHELL_COMMAND_TRANSACTION, send, &reply);
}

// ---------------------------------------------------------------------------
Expand Down Expand Up @@ -230,7 +235,11 @@ status_t BBinder::onTransact(
sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface(
data.readStrongBinder());

return shellCommand(in, out, err, args, resultReceiver);
// XXX can't add virtuals until binaries are updated.
//return shellCommand(in, out, err, args, resultReceiver);
if (resultReceiver != NULL) {
resultReceiver->send(INVALID_OPERATION);
}
}

case SYSPROPS_TRANSACTION: {
Expand Down
17 changes: 0 additions & 17 deletions libs/binder/BpBinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,6 @@ status_t BpBinder::dump(int fd, const Vector<String16>& args)
return err;
}

status_t BpBinder::shellCommand(int in, int out, int err, Vector<String16>& args,
const sp<IResultReceiver>& resultReceiver)
{
Parcel send;
Parcel reply;
send.writeFileDescriptor(in);
send.writeFileDescriptor(out);
send.writeFileDescriptor(err);
const size_t numArgs = args.size();
send.writeInt32(numArgs);
for (size_t i = 0; i < numArgs; i++) {
send.writeString16(args[i]);
}
send.writeStrongBinder(resultReceiver != NULL ? IInterface::asBinder(resultReceiver) : NULL);
return transact(SHELL_COMMAND_TRANSACTION, send, &reply);
}

status_t BpBinder::transact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
Expand Down

0 comments on commit f2bf93b

Please sign in to comment.