private int parseVPid(String stubProcessName) { String prefix = VirtualCore.get().getHostPkg() + ":p"; if (stubProcessName != null && stubProcessName.startsWith(prefix)) { try { return Integer.parseInt(stubProcessName.substring(prefix.length())); } catch (NumberFormatException e) { // ignore } } return -1; }
@Override public Object call(Object who, Method method, Object... args) throws Throwable { args[0] = VirtualCore.get().getHostPkg(); return method.invoke(who, args); } }
public static String getHostPkg() { return VirtualCore.get().getHostPkg(); }
public static File getVirtualPrivateStorageDir(int userId) { String base = String.format(Locale.ENGLISH, "%s/Android/data/%s/%s/%d", Environment.getExternalStorageDirectory(), VirtualCore.get().getHostPkg(), "virtual", userId); File file = new File(base); return ensureCreated(file); }
public boolean dealNotification(int id, Notification notification, String packageName) { if(notification == null)return false; return VirtualCore.get().getHostPkg().equals(packageName) || mNotificationCompat.dealNotification(id, notification, packageName); }
private VJobSchedulerService() { mJobProxyComponent = new ComponentName(VirtualCore.get().getHostPkg(), VASettings.STUB_JOB); readJobs(); }
public static String replaceFirstAppPkg(Object[] args) { if (args == null) { return null; } int index = ArrayUtils.indexOfFirst(args, String.class); if (index != -1) { String pkg = (String) args[index]; args[index] = VirtualCore.get().getHostPkg(); return pkg; } return null; }
public static String replaceSequenceAppPkg(Object[] args, int sequence) { int index = ArrayUtils.indexOf(args, String.class, sequence); if (index != -1) { String pkg = (String) args[index]; args[index] = VirtualCore.get().getHostPkg(); return pkg; } return null; }
public static String replaceLastAppPkg(Object[] args) { int index = ArrayUtils.indexOfLast(args, String.class); if (index != -1) { String pkg = (String) args[index]; args[index] = VirtualCore.get().getHostPkg(); return pkg; } return null; }
public VPackageManagerService() { Intent intent = new Intent(); intent.setClassName(VirtualCore.get().getHostPkg(), VASettings.RESOLVER_ACTIVITY); mResolveInfo = VirtualCore.get().getUnHookPackageManager().resolveActivity(intent, 0); }
@Override public int checkPermission(String permName, String pkgName, int userId) { if ("android.permission.INTERACT_ACROSS_USERS".equals(permName) || "android.permission.INTERACT_ACROSS_USERS_FULL".equals(permName)) { return PackageManager.PERMISSION_DENIED; } return VirtualCore.get().getPackageManager().checkPermission(permName, VirtualCore.get().getHostPkg()); }
public static void enableIORedirect() { try { String soPath = String.format("/data/data/%s/lib/libva++.so", VirtualCore.get().getHostPkg()); if (!new File(soPath).exists()) { throw new RuntimeException("io redirect failed."); } redirectDirectory(VESCAPE, "/"); nativeEnableIORedirect(soPath, Build.VERSION.SDK_INT, BuildCompat.getPreviewSDKInt()); } catch (Throwable e) { VLog.e(TAG, VLog.getStackTraceString(e)); } }
public static boolean isStubComponent(Intent intent) { return intent != null && intent.getComponent() != null && VirtualCore.get().getHostPkg().equals(intent.getComponent().getPackageName()); }
@Override protected void processArgs(Method method, Object... args) { if (args != null && args.length > 0 && args[0] instanceof String) { String pkg = (String) args[0]; if (VirtualCore.get().isAppInstalled(pkg)) { args[0] = VirtualCore.get().getHostPkg(); } } } }
shortcutIntent.setClassName(getHostPkg(), Constants.SHORTCUT_PROXY_ACTIVITY_NAME); shortcutIntent.addCategory(Intent.CATEGORY_DEFAULT); if (splash != null) {
private Intent startActivityProcess(int userId, ActivityRecord sourceRecord, Intent intent, ActivityInfo info) { intent = new Intent(intent); ProcessRecord targetApp = mService.startProcessIfNeedLocked(info.processName, userId, info.packageName); if (targetApp == null) { return null; } Intent targetIntent = new Intent(); targetIntent.setClassName(VirtualCore.get().getHostPkg(), fetchStubActivity(targetApp.vpid, info)); ComponentName component = intent.getComponent(); if (component == null) { component = ComponentUtils.toComponentName(info); } targetIntent.setType(component.flattenToString()); StubActivityRecord saveInstance = new StubActivityRecord(intent, info, sourceRecord != null ? sourceRecord.component : null, userId); saveInstance.saveToIntent(targetIntent); return targetIntent; }
static void launchEngine() { if (sFlag) { return; } Method[] methods = {NativeMethods.gOpenDexFileNative, NativeMethods.gCameraNativeSetup, NativeMethods.gAudioRecordNativeCheckPermission}; try { nativeLaunchEngine(methods, VirtualCore.get().getHostPkg(), VirtualRuntime.isArt(), Build.VERSION.SDK_INT, NativeMethods.gCameraMethodType); } catch (Throwable e) { VLog.e(TAG, VLog.getStackTraceString(e)); } sFlag = true; }
@Override public Uri insert(MethodBox methodBox, Uri url, ContentValues initialValues) throws InvocationTargetException { if (initialValues.containsKey(COLUMN_NOTIFICATION_PACKAGE)) { initialValues.put(COLUMN_NOTIFICATION_PACKAGE, VirtualCore.get().getHostPkg()); } if (initialValues.containsKey(COLUMN_COOKIE_DATA)) { String cookie = initialValues.getAsString(COLUMN_COOKIE_DATA); initialValues.remove(COLUMN_COOKIE_DATA); // retrieve the next free INSERT_KEY_PREFIX int headerIndex = 0; while (initialValues.containsKey(INSERT_KEY_PREFIX + headerIndex)) { headerIndex++; } // add the cookie initialValues.put(INSERT_KEY_PREFIX + headerIndex, "Cookie" + ": " + cookie); } if (!initialValues.containsKey(COLUMN_IS_PUBLIC_API)) { initialValues.put(COLUMN_IS_PUBLIC_API, true); } for (String column : ENFORCE_REMOVE_COLUMNS) { if (initialValues.containsKey(column)) { initialValues.remove(column); } } return super.insert(methodBox, url, initialValues); }
private void realStartActivitiesLocked(IBinder resultTo, Intent[] intents, String[] resolvedTypes, Bundle options) { Class<?>[] types = IActivityManager.startActivities.paramList(); Object[] args = new Object[types.length]; if (types[0] == IApplicationThread.TYPE) { args[0] = ActivityThread.getApplicationThread.call(VirtualCore.mainThread()); } int pkgIndex = ArrayUtils.protoIndexOf(types, String.class); int intentsIndex = ArrayUtils.protoIndexOf(types, Intent[].class); int resultToIndex = ArrayUtils.protoIndexOf(types, IBinder.class, 2); int optionsIndex = ArrayUtils.protoIndexOf(types, Bundle.class); int resolvedTypesIndex = intentsIndex + 1; if (pkgIndex != -1) { args[pkgIndex] = VirtualCore.get().getHostPkg(); } args[intentsIndex] = intents; args[resultToIndex] = resultTo; args[resolvedTypesIndex] = resolvedTypes; args[optionsIndex] = options; ClassUtils.fixArgs(types, args); IActivityManager.startActivities.call(ActivityManagerNative.getDefault.call(), (Object[]) args); }
private void realStartActivityLocked(IBinder resultTo, Intent intent, String resultWho, int requestCode, Bundle options) { Class<?>[] types = mirror.android.app.IActivityManager.startActivity.paramList(); Object[] args = new Object[types.length]; if (types[0] == IApplicationThread.TYPE) { args[0] = ActivityThread.getApplicationThread.call(VirtualCore.mainThread()); } int intentIndex = ArrayUtils.protoIndexOf(types, Intent.class); int resultToIndex = ArrayUtils.protoIndexOf(types, IBinder.class, 2); int optionsIndex = ArrayUtils.protoIndexOf(types, Bundle.class); int resolvedTypeIndex = intentIndex + 1; int resultWhoIndex = resultToIndex + 1; int requestCodeIndex = resultToIndex + 2; args[intentIndex] = intent; args[resultToIndex] = resultTo; args[resultWhoIndex] = resultWho; args[requestCodeIndex] = requestCode; if (optionsIndex != -1) { args[optionsIndex] = options; } args[resolvedTypeIndex] = intent.getType(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { args[intentIndex - 1] = VirtualCore.get().getHostPkg(); } ClassUtils.fixArgs(types, args); mirror.android.app.IActivityManager.startActivity.call(ActivityManagerNative.getDefault.call(), (Object[]) args); }