Android QS
Android QS

Reputation: 416

Android service AIDL data types

I have a Service in a system app. I would like client apps without system permissions to be able to call functions in the Service to do things that does require system permissions. Since the Service is in its own app, I am using AIDL to define an interface for IPC between the Service and the client apps.

I want the people making the client apps to be able to write their own code requiring system permissions and provide me the code to include with my service. So my service will receive a generic request indicating where to pass the request on to, and the request itself.

Since I don't know what data the client will need passed in/out to their own code, I would like to use a generic interface to handle any types of data they may need. Do I need to add a function to the AIDL interface for every data type:

void doStuff(in String inStr, out String outStr);
void doStuff(in int inInt, out int outInt);

etc...

Would it be better to make my own parcelable object? What's the best way to handle this with AIDL?

Upvotes: 2

Views: 5165

Answers (1)

Munish Katoch
Munish Katoch

Reputation: 517

Your question have two parts:

a.) Service ( indicating where to pass the request) :

You can get the caller UID and then then use it as job/request indicator.

b) AIDL type:

By default, AIDL supports the following data types:

1.) All primitive types in the Java programming language (such as int, long, char, boolean, and so on) 2.) String 3.) CharSequence 4.) List

If you have any other Object, then you need to create your own parcelable object.

Upvotes: 2

Related Questions