public static int onGetUid(int uid) { return VClientImpl.get().getBaseVUid(); } }
public static String getAppPkg() { return VClientImpl.get().getCurrentPackage(); }
protected static int getVUid() { return VClientImpl.get().getVUid(); }
public void connected(ComponentName name, IBinder service, boolean dead) throws RemoteException { IBinderDelegateService delegateService = IBinderDelegateService.Stub.asInterface(service); if (delegateService != null) { name = delegateService.getComponent(); service = delegateService.getService(); IBinder proxy = ProxyServiceFactory.getProxyService(VClientImpl.get().getCurrentApplication(), name, service); if (proxy != null) { service = proxy; } } if(Build.VERSION.SDK_INT>=26) { IServiceConnectionO.connected.call(mConn, name, service, dead); }else { mConn.connected(name, service); } } }
protected static VDeviceInfo getDeviceInfo() { return VClientImpl.get().getDeviceInfo(); }
public void setCrashHandler(CrashHandler handler) { VClientImpl.get().setCrashHandler(handler); }
/** * Returns the user id of the current process * @return user id of the current process * @hide */ public static int myUserId() { return getUserId(VClientImpl.get().getVUid()); }
protected static int getBaseVUid() { return VClientImpl.get().getBaseVUid(); }
protected static boolean isFakeLocationEnable() { return VirtualLocationManager.get().getMode(VUserHandle.myUserId(), VClientImpl.get().getCurrentPackage()) != 0; }
@Override protected void onCreate(Bundle savedInstanceState) { // The savedInstanceState's classLoader is not exist. super.onCreate(null); finish(); // It seems that we have conflict with the other Android-Plugin-Framework. Intent stubIntent = getIntent(); // Try to acquire the actually component information. StubActivityRecord r = new StubActivityRecord(stubIntent); if (r.intent != null) { if (TextUtils.equals(r.info.processName, VirtualRuntime.getProcessName()) && r.userId == VUserHandle.myUserId()) { // Retry to inject the HCallback to instead of the exist one. InvocationStubManager.getInstance().checkEnv(HCallbackStub.class); Intent intent = r.intent; intent.setExtrasClassLoader(VClientImpl.get().getCurrentApplication().getClassLoader()); startActivity(intent); } else { // Start the target Activity in other process. VActivityManager.get().startActivity(r.intent, r.userId); } } }
@Override public Bundle call(MethodBox methodBox, String method, String arg, Bundle extras) throws InvocationTargetException { if (!VClientImpl.get().isBound()) { return methodBox.call(); } int methodType = getMethodType(method); if (METHOD_GET == methodType) { String presetValue = PRE_SET_VALUES.get(arg); if (presetValue != null) { return wrapBundle(arg, presetValue); } if ("android_id".equals(arg)) { return wrapBundle("android_id", VClientImpl.get().getDeviceInfo().androidId); } } if (METHOD_PUT == methodType) { if (isSecureMethod(method)) { return null; } } try { return methodBox.call(); } catch (InvocationTargetException e) { if (e.getCause() instanceof SecurityException) { return null; } throw e; } }
private Bundle initProcess(Bundle extras) { ConditionVariable lock = VirtualCore.get().getInitLock(); if (lock != null) { lock.block(); } IBinder token = BundleCompat.getBinder(extras,"_VA_|_binder_"); int vuid = extras.getInt("_VA_|_vuid_"); VClientImpl client = VClientImpl.get(); client.initProcess(token, vuid); Bundle res = new Bundle(); BundleCompat.putBinder(res, "_VA_|_client_", client.asBinder()); res.putInt("_VA_|_pid_", Process.myPid()); return res; }
public static int myAppId() { return getAppId(VClientImpl.get().getVUid()); }
public static int onGetCallingUid(int originUid) { int callingPid = Binder.getCallingPid(); if (callingPid == Process.myPid()) { return VClientImpl.get().getBaseVUid(); } if (callingPid == VirtualCore.get().getSystemPid()) { return Process.SYSTEM_UID; } int vuid = VActivityManager.get().getUidByPid(callingPid); if (vuid != -1) { return VUserHandle.getAppId(vuid); } VLog.w(TAG, String.format("Unknown uid: %s", callingPid)); return VClientImpl.get().getBaseVUid(); }
/** * tell the ui that the activity has launched. * @param intent */ private void callUiCallback(Intent intent, boolean success) { IUiCallback callback = VirtualCore.getUiCallback(intent); if (callback != null) { try { if (success) { callback.onAppOpened(VClientImpl.get().getCurrentPackage(), VUserHandle.myUserId()); } else { callback.onOpenFailed(VClientImpl.get().getCurrentPackage(), VUserHandle.myUserId()); } } catch (RemoteException e) { e.printStackTrace(); } } } }
Application app = VClientImpl.get().getCurrentApplication(); if (app != null) { try {
private boolean accept(Intent intent) { int uid = intent.getIntExtra("_VA_|_uid_", -1); if (uid != -1) { return VClientImpl.get().getVUid() == uid; } int userId = intent.getIntExtra("_VA_|_user_id_", -1); return userId == -1 || userId == VUserHandle.myUserId(); }
@Override public IBinder acquireProviderClient(ProviderInfo info) { if (mTempLock != null) { mTempLock.block(); } if (!isBound()) { VClientImpl.get().bindApplication(info.packageName, info.processName); } IInterface provider = null; String[] authorities = info.authority.split(";"); String authority = authorities.length == 0 ? info.authority : authorities[0]; ContentResolver resolver = VirtualCore.get().getContext().getContentResolver(); ContentProviderClient client = null; try { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { client = resolver.acquireUnstableContentProviderClient(authority); } else { client = resolver.acquireContentProviderClient(authority); } } catch (Throwable e) { VLog.e(TAG, "", e); } if (client != null) { provider = mirror.android.content.ContentProviderClient.mContentProvider.get(client); client.release(); } return provider != null ? provider.asBinder() : null; }
@Override public Object afterCall(Object who, Method method, Object[] args, Object result) throws Throwable { if (result != null) { Reflect pwd = Reflect.on(result); int uid = pwd.get("pw_uid"); if (uid == VirtualCore.get().myUid()) { pwd.set("pw_uid", VClientImpl.get().getVUid()); } } return result; } }