"In/out/inout" in a AIDL interface parameter value?

Theepan Karthigesan picture Theepan Karthigesan · Jan 15, 2011 · Viewed 19.7k times · Source

I'm programming a radio streaming app. I run the "radio playing" as a remote Service by using AIDL interface technique to communicate with the Service. But I don't really understand one thing.

What is the "out" in a AIDL interface parameter value?

Like this:

String doSomething(in String a, out String[] b);

I understand "in", that is sending data to the remote when the method is called from activity.

What is the "out", and why we need "in" and "out" in same method? In which case are they("out/inout") used? Why is the String[] "out"?

Please help..

Answer

gladed picture gladed · Mar 24, 2011

In AIDL, the out tag specifies an output-only parameter. In other words, it's a parameter that contains no interesting data on input, but will be filled with data during the method.

For example, a method that copies an array of bytes might be specified like this:

void copyArray(in byte[] source, out byte[] dest);

The inout tag indicates that the parameter has meaning on both input and output. For example:

void charsToUpper(inout char[] chars);

This is important because the contents of every parameter must be marshalled (serialized, transmitted, received, and deserialized). The in/out tags allow the Binder to skip the marshalling step for better performance.