Search in sources :

Example 1 with ReflectException

use of com.lody.virtual.helper.utils.ReflectException in project VirtualApp by asLody.

the class ContextFixer method fixContext.

/**
     * Fuck AppOps
     *
     * @param context Context
     */
public static void fixContext(Context context) {
    try {
        context.getPackageName();
    } catch (Throwable e) {
        return;
    }
    PatchManager.getInstance().checkEnv(GraphicsStatsPatch.class);
    int deep = 0;
    while (context instanceof ContextWrapper) {
        context = ((ContextWrapper) context).getBaseContext();
        deep++;
        if (deep >= 10) {
            return;
        }
    }
    ContextImpl.mPackageManager.set(context, null);
    try {
        context.getPackageManager();
    } catch (Throwable e) {
        e.printStackTrace();
    }
    if (!VirtualCore.get().isVAppProcess()) {
        return;
    }
    DropBoxManager dm = (DropBoxManager) context.getSystemService(Context.DROPBOX_SERVICE);
    HookBinderDelegate boxBinder = PatchManager.getInstance().getHookObject(DropBoxManagerPatch.class);
    if (boxBinder != null) {
        try {
            Reflect.on(dm).set("mService", boxBinder.getProxyInterface());
        } catch (ReflectException e) {
            e.printStackTrace();
        }
    }
    String hostPkg = VirtualCore.get().getHostPkg();
    ContextImpl.mBasePackageName.set(context, hostPkg);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        ContextImplKitkat.mOpPackageName.set(context, hostPkg);
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        ContentResolverJBMR2.mPackageName.set(context.getContentResolver(), hostPkg);
    }
}
Also used : DropBoxManager(android.os.DropBoxManager) ContextWrapper(android.content.ContextWrapper) ReflectException(com.lody.virtual.helper.utils.ReflectException) HookBinderDelegate(com.lody.virtual.client.hook.base.HookBinderDelegate)

Aggregations

ContextWrapper (android.content.ContextWrapper)1 DropBoxManager (android.os.DropBoxManager)1 HookBinderDelegate (com.lody.virtual.client.hook.base.HookBinderDelegate)1 ReflectException (com.lody.virtual.helper.utils.ReflectException)1