• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ServiceManagerCompat类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中com.morgoo.helper.compat.ServiceManagerCompat的典型用法代码示例。如果您正苦于以下问题:Java ServiceManagerCompat类的具体用法?Java ServiceManagerCompat怎么用?Java ServiceManagerCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ServiceManagerCompat类属于com.morgoo.helper.compat包,在下文中一共展示了ServiceManagerCompat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onInstall

点赞 3

import com.morgoo.helper.compat.ServiceManagerCompat; //导入依赖的package包/类
@Override
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 {
            sCache.remove(mServiceName);
            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);
            }
        }
    }
}
 

开发者ID:amikey,
项目名称:DroidPlugin,
代码行数:26,
代码来源:ServiceManagerCacheBinderHook.java

示例2: onInstall

点赞 2

import com.morgoo.helper.compat.ServiceManagerCompat; //导入依赖的package包/类
@Override
protected void onInstall(ClassLoader classLoader) throws Throwable {
    Object sServiceManager = FieldUtils.readStaticField(ServiceManagerCompat.Class(), "sServiceManager");
    if (sServiceManager == null) {
        MethodUtils.invokeStaticMethod(ServiceManagerCompat.Class(), "getIServiceManager");
        sServiceManager = FieldUtils.readStaticField(ServiceManagerCompat.Class(), "sServiceManager");
    }
    setOldObj(sServiceManager);

    Class<?> clazz = mOldObj.getClass();
    List<Class<?>> interfaces = Utils.getAllInterfaces(clazz);
    Class[] ifs = interfaces != null && interfaces.size() > 0 ? interfaces.toArray(new Class[interfaces.size()]) : new Class[0];
    Object proxiedObj = MyProxy.newProxyInstance(clazz.getClassLoader(), ifs, this);
    FieldUtils.writeStaticField(ServiceManagerCompat.Class(), "sServiceManager", proxiedObj);
}
 

开发者ID:amikey,
项目名称:DroidPlugin,
代码行数:16,
代码来源:ServiceManagerBinderHook.java

示例3: fixZTESecurity

点赞 2

import com.morgoo.helper.compat.ServiceManagerCompat; //导入依赖的package包/类
/**适配ZTE S2005机型ZTESecurity*/
private void fixZTESecurity() {
    try {
        Object proxyServiceIBinder =  MyServiceManager.getProxiedObj(getServiceName());
        IBinder serviceIBinder = ServiceManagerCompat.getService(getServiceName());
        if (serviceIBinder != null && proxyServiceIBinder != null && "com.zte.ZTESecurity.ZTEWifiService".equals(serviceIBinder.getClass().getName())) {
            Object obj = FieldUtils.readField(serviceIBinder, "mIWifiManager");
            setOldObj(obj);
            FieldUtils.writeField(serviceIBinder, "mIWifiManager", proxyServiceIBinder);
        }
    } catch (Exception e) {
        Log.i(TAG, "fixZTESecurity FAIL", e);
    }
}
 

开发者ID:amikey,
项目名称:DroidPlugin,
代码行数:15,
代码来源:IWifiManagerBinderHook.java

示例4: onInstall

点赞 2

import com.morgoo.helper.compat.ServiceManagerCompat; //导入依赖的package包/类
@Override
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 {
            sCache.remove(mServiceName);
            IBinder mServiceIBinder = ServiceManagerCompat.getService(mServiceName);
            if (mServiceIBinder == null) {
                if (Obj != null && Obj instanceof IBinder && !Proxy.isProxyClass(Obj.getClass())) {
                    mServiceIBinder = ((IBinder) Obj);
                }
            }
            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);
            }
        }
    }
}
 

开发者ID:weijianfeng,
项目名称:DynamicAppLoader,
代码行数:31,
代码来源:ServiceManagerCacheBinderHook.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)