androidandroid-serviceipcaidl

android returning a "live" object from an AIDL bound service


I'd like to create an AIDL service that returns, for lack of the correct terminology, "live" objects. that is, I would like something like this to work,

IFoo foo = myService.getFoo(x); // calls to myService service to get an IFoo
IBar bar = foo.getBar(y); // IPC to IFoo to get an IBar
IBaz baz = bar.getBaz(z); // IPC to IBar to get an IBaz

baz.setEnabled(false); // IPC to IBaz to modify the service's copy of IBaz

I expect this to be possible, but I can find a good example. The alternative is to do something like,

myService.setBazEnabled(x, y, z, false);

the former being a more OO approach, while the latter is more functional.


Solution

  • So long as IFoo, IBar, and IBaz are all defined via AIDL, that should work just fine.