2

Is it possible to implement AIDL without the implementation of remote service? After some investigation of google play services I notice that some AIDL calls executed with the following way

  1. Obtain the remote context with the following way

    Context c = context.createPackageContext("com.google.android.gms", 3)    
    
  2. Get class loader and load class which implements IBinder

     ClassLoader localClassLoader = c.getClassLoader();
     IBinder localIBinder = (IBinder)localClass.newInstance();
     IInterface localIInterface = paramIBinder.queryLocalInterface("com.google.android.gms.plus.internal.IPlusOneButtonCreator");
    

And we can communicate with it!

I wonder why this is allowed and why there is no Service on other side? Where do the whole data lives? Does this call starts a new process?

Onik
  • 19,396
  • 14
  • 68
  • 91
Jurius
  • 316
  • 3
  • 9
  • why do you think there is no remote service? – pskink May 08 '15 at 11:59
  • I've mock it. No service. really. Or may be it generated somewhere... I don't know. – Jurius May 08 '15 at 12:07
  • ok i believe you, you should read more about Binder, AIDL is just another layer on top of Binder, basically all the communication is done by two methods `transact` and `onTransact`, for example your activity can somehow return a Binder and thus you could "talk" to that Binder, it doesn't have to be a Service that returns a Binder to talk to – pskink May 08 '15 at 12:12
  • 1
    Ok, but, what is the lifecycle of remote process in that case? I can't see any new process in object dispatcher. Really strange... – Jurius May 08 '15 at 12:44
  • i don't know what you mean... – pskink May 08 '15 at 12:50
  • I mean that in case of Remote Service implementaition Service lives as long as it has active connections (someone binded) and shut down when everybody disconnects. Process lives as long as Service live. But how this could be in case of no Servcie.... I don't understand – Jurius May 08 '15 at 13:20
  • `IBinder#linkToDeath(android.os.IBinder.DeathRecipient, int)` also read this: http://www.androiddesignpatterns.com/2013/08/binders-death-recipients.html – pskink May 08 '15 at 13:30

0 Answers0