Java Code Examples for android.os.IBinder.getClass()

The following are Jave code examples for showing how to use getClass() of the android.os.IBinder class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: DroidPlugin   File:   Source Code and License Vote up 6 votes
protected void onInstall(ClassLoader classLoader) throws Throwable {
    Object sCacheObj = FieldUtils.readStaticField(ServiceManagerCompat.Class(), "sCache");
    if (sCacheObj instanceof Map) {
        Map sCache = (Map) sCacheObj;
        Object Obj = sCache.get(mServiceName);
        if (Obj != null && false) {
            //FIXME 已经有了怎么处理?这里我们只是把原来的给remove掉,再添加自己的。程序下次取用的时候就变成我们hook过的了。
            throw new RuntimeException("Can not install binder hook for " + mServiceName);
        } else {
            IBinder mServiceIBinder = ServiceManagerCompat.getService(mServiceName);
            if (mServiceIBinder != null) {
                MyServiceManager.addOriginService(mServiceName, mServiceIBinder);
                Class clazz = mServiceIBinder.getClass();
                List<Class<?>> interfaces = Utils.getAllInterfaces(clazz);
                Class[] ifs = interfaces != null && interfaces.size() > 0 ? interfaces.toArray(new Class[interfaces.size()]) : new Class[0];
                IBinder mProxyServiceIBinder = (IBinder) MyProxy.newProxyInstance(clazz.getClassLoader(), ifs, this);
                sCache.put(mServiceName, mProxyServiceIBinder);
                MyServiceManager.addProxiedServiceCache(mServiceName, mProxyServiceIBinder);