微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android.app.ActivityThread的实例源码

项目:VirtualAPK    文件PluginManager.java   
private void hookIContentProviderAsNeeded() {
    Uri uri = Uri.parse(PluginContentResolver.getUri(mContext));
    mContext.getContentResolver().call(uri,"wakeup",null,null);
    try {
        Field authority = null;
        Field mProvider = null;
        ActivityThread activityThread = (ActivityThread) ReflectUtil.getActivityThread(mContext);
        Map mProviderMap = (Map) ReflectUtil.getField(activityThread.getClass(),activityThread,"mProviderMap");
        Iterator iter = mProviderMap.entrySet().iterator();
        while (iter.hasNext()) {
            Map.Entry entry = (Map.Entry) iter.next();
            Object key = entry.getKey();
            Object val = entry.getValue();
            String auth;
            if (key instanceof String) {
                auth = (String) key;
            } else {
                if (authority == null) {
                    authority = key.getClass().getDeclaredField("authority");
                    authority.setAccessible(true);
                }
                auth = (String) authority.get(key);
            }
            if (auth.equals(PluginContentResolver.getAuthority(mContext))) {
                if (mProvider == null) {
                    mProvider = val.getClass().getDeclaredField("mProvider");
                    mProvider.setAccessible(true);
                }
                IContentProvider rawProvider = (IContentProvider) mProvider.get(val);
                IContentProvider proxy = IContentProviderProxy.newInstance(mContext,rawProvider);
                mIContentProvider = proxy;
                Log.d(TAG,"hookIContentProvider succeed : " + mIContentProvider);
                break;
            }
        }
    } catch (Exception e) {
        e.printstacktrace();
    }
}
项目:AppOpsX    文件ApiCompat.java   
static void sendbroadcast(Intent intent) {
  try {

    ActivityThread.currentApplication().sendbroadcast(intent);
  } catch (Exception e) {
    e.printstacktrace();
    FLog.log(e);
  }
}
项目:DeepInVirtualApp    文件DodoApplication.java   
@Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        //从PackageManager里拿取全部的Activity桩
        initStub();
        mainThread = ActivityThread.currentActivityThread();
// 主进程名
        mainProcessName = base.getApplicationInfo().processName;
        // 当前进程名
        processName = mainThread.getProcessName();
        if (processName.equals(mainProcessName)) {
            processtype = Processtype.Main;
        } else if (isAppProcess(processName)) {
            processtype = Processtype.VAppClient;
        } else {
            processtype = Processtype.CHILD;
        }
        mOriginPackageManager = this.getPackageManager();
        //此处注入补丁
        try {
            PatchManager.getInstance().injectAll();
            PatchManager.getInstance().checkEnv();
        } catch (Throwable throwable) {
            throwable.printstacktrace();
        }

    }
项目:AppOpsX    文件RemoteHandler.java   
private CallerResult callClass(ClassCaller caller){
  CallerResult result = new CallerResult();
  try {
    ActivityThread activityThread = ActivityThread.currentActivityThread();
    Context context = activityThread.getSystemContext();
    Context packageContext = null;

    //create or from cache get context
    WeakReference<Context> contextWeakReference = sLocalContext.get(caller.getPackageName());
    if (contextWeakReference != null && contextWeakReference.get() != null) {
      packageContext = contextWeakReference.get();
    }
    if (packageContext == null) {
      packageContext = context.createPackageContext(caller.getPackageName(),Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGnorE_Security);
      sLocalContext.put(caller.getPackageName(),new WeakReference<Context>(packageContext));
    }

    //load class
    Class<?> aClass = sClassCache.get(caller.getClassName());
    Constructor<?> aConstructor = sConstructorCache.get(caller.getClassName());
    if (aClass == null || aConstructor == null) {

      aClass = Class.forName(caller.getClassName(),false,packageContext.getClassLoader());
      Class<?> processer=Class.forName(ClassCallerProcessor.class.getName(),packageContext.getClassLoader());

      if (processer.isAssignableFrom(aClass)) {
        sClassCache.put(caller.getClassName(),aClass);
        sConstructorCache.put(caller.getClassName(),aClass.getConstructor(Context.class,Context.class,byte[].class));
      }else {
        throw new ClassCastException("class "+aClass.getName()+"  need extends ClassCallerProcessor !");
      }
    }

    //if found class,invoke proxyInvoke method
    if (aClass != null) {

      Object o = null;
      if(aConstructor != null){

        o = aConstructor.newInstance(packageContext,context,Parcelableutil.marshall(LifecycleAgent.serverRunInfo));
      }

      Object[] params = caller.getParams();
      if(params != null){
        for (Object param : params) {
          if(param instanceof Bundle){
            ((Bundle) param).setClassLoader(packageContext.getClassLoader());
          }
        }
      }

      FLog.log("------new object "+o+"  params "+Arrays.toString(params)+"    "+aClass);

      Object ret = MethodUtils.invokeExactMethod(o,"proxyInvoke",params,new Class[]{Bundle.class});
      if (ret != null && ret instanceof Bundle) {
        writeResult(result,ret);
      } else {
        writeResult(result,Bundle.EMPTY);
      }

    } else {
      throw new ClassNotFoundException("not found class " + caller.getClassName() + "  in package: " + caller.getPackageName());
    }

  } catch (Throwable e) {
    e.printstacktrace();
    FLog.log(e);
    result.setThrowable(e);
  }

  return result;
}
项目:AdBlocker_Reborn    文件ContextUtils.java   
public static Context getSystemContext() {
    return ActivityThread.currentActivityThread().getSystemContext();
}
项目:android_debuggable_tool    文件DebuggabletoolHelpers.java   
public static List<String> runcommand(boolean su,String command) {
    return runcommand(su,ActivityThread.currentActivityThread().getApplication().getPackageCodePath(),command);
}
项目:android_debuggable_tool    文件DebuggabletoolHelpers.java   
public static Thread runcommandInBackground(boolean su,String command) {
    return runcommandInBackground(su,int uid,uid,command);
}
项目:android_debuggable_tool    文件DebuggabletoolHelpers.java   
/**
 * Run a given command with the classpath from a given context
 * @param su should it be run with su?
 * @param uid user ID to run as
 * @param command command string {@see #getCommandLineForMainClass}
 * @return command output
 */
public static List<String> runcommand(boolean su,command);
}
项目:android_debuggable_tool    文件AbstractTool.java   
/**
 * Get the activity thread for the current process
 * @return
 */
protected ActivityThread getActivityThread() {
    return thisActivityThread;
}
项目:android_debuggable_tool    文件AbstractTool.java   
public void setActivityThread(ActivityThread thread) {thisActivityThread = thread;}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。