2

I wanted to know what is the inout param in the AIDL is for?

I know what is in for and what out is for. (out does not marshal the object passing).

But I don't understand what is the inout for.

I have looked in the: "In/out/inout" in a AIDL interface parameter value? question but still did not understand.

From my testings the param is passed much like specifying it as in.

So if any1 can shed some light on what is inout It would be helpful.

Thanks

Community
  • 1
  • 1
ZiviMagic
  • 1,034
  • 2
  • 10
  • 25

2 Answers2

5

An in parameter is only transported from the caller to the callee. An out parameter is transported from the callee to the caller. And an inout parameter is transported both ways.

You would use an inout paramter when you pass an object to the callee and the callee changes it.

Henry
  • 42,982
  • 7
  • 68
  • 84
0

Here it my version of explaining the directional tags in AIDL,

  • Its only a directional tag indicating which way the data goes.
    • in - object is transferred from client to service only used for inputs
    • out - object is transferred from client to service only used for outputs.
    • inout - object is transferred from client to service used for both inputs and outputs.
  • All non-primitive parameters require a directional tag indicating which way the data goes. Either in, out, or inout.

  • Primitives are in by default, and cannot be otherwise

  • Please note, RPC calls from clients are synchronous.
  • You should limit the direction to what is truly needed, because marshaling parameters is expensive.

Example: Please check the below AIDL interface to understand it in a better way.

package com.hardian.sample.aidl;
import com.hardian.sample.aidl.TeamMember;

interface ITeamManageService {
void getTeamCaptian(out TeamMember member);
void updateTeamMember(inout TeamMember member, in boolean isLeader);
oneway void removeTeamMember(in TeamMember member);
}

Here we have used out, in, inout directional tags to indicate which way the data goes.

  1. getTeamCaptian(out TeamMember member) : Get the captain of the team. Here the "out" directional tag means, when the client calls this method, the "member" object has no relevant data, but the server shall make changes to the "member" object, so the client shall get the updated "member" object. In fact, the method call is synchronous.

  2. updateTeamMember(inout TeamMember member, in boolean isLeader) : Update the captian of the team. Here the "inout" directional tag means, when the client calls this method,the "member" object has relevant data in it. And the server shall use the input data and process it. Once the process completed, the client shall get the relevant data back. In fact, the method call is synchronous.

  3. removeTeamMember(in TeamMember member) Remove a member from the team. Here the "in" directional tag means, the "member" object is transferred from client to service only used for inputs. If any changes are made to the "member" object in the service then it won’t reflect in the client. The method call is asynchronous, we can put the "oneway" keyword to the method signature. Asynchronous methods must not have "out" and "inout" arguments, they must also return void.

Hardian
  • 1,922
  • 22
  • 23