I am trying to invoke a Service method that expects another Interface as a parameter. I must point out that I need to make this using Reflection without actually knowing the source code. So, using Reflection I got the Interface corresponding to the Service whose methods I need to call. Then I managed to create an object for that Interface. After that I am able to call the functions and for most of them this works, but I have a problem when a parameter is another Interface. For example let`s say we have the following method in IPermissionService:
public void addPermissionRevokedListener(IPermissionRevokedListener listener)
While generating the parameter for this method my code finds 2 possible classes:
IPermissionRevokedListener$Default
IPermissionRevokedListener$Stub$Proxy
Currently it takes the first one and calls the constructor to create the object. Everything seems fine till this point, but then when the call is performed an Exception is thrown:
java.lang.IllegalArgumentException:
method addPermissionRevokedListener argument 1 has type IPermissionRevokedListener,
got IPermissionRevokedListener$Default
I have been digging around and trying some combinations but I could not find a solution for this. Is there a way to solve this?
For those not familiar with AIDL, this is how usually the Interface part looks like:
public interface IPermissionRevokedListener extends android.os.IInterface
{
public static class Default implements IPermissionRevokedListener
{...}
public static abstract class Stub extends android.os.Binder implements IPermissionRevokedListener
{
private static class Proxy implements IPermissionRevokedListener
{...}
}
}
Also, one possibility would be to try to connect to the other service and acquire the Interface object, similar to the way the first one was done, but I am not sure how to figure out which Service it is just based on the Interface information. Also, I might end up with pretty much the same problem with the only difference being IPermissionRevokedListener$Stub$Proxy instead of IPermissionRevokedListener$Default since IPermissionRevokedListener$Stub$Proxy is given when acquiring Interface from a bound Service). But, I would like to know if there is the possibility find the Service based on the Interface as well.
Anyway, currently I would be happy if the $Default object can somehow be used.
Aucun commentaire:
Enregistrer un commentaire