Search in sources :

Example 1 with MyTaskDescDelegate

use of io.virtualapp.delegate.MyTaskDescDelegate in project VirtualXposed by android-hacker.

the class XApp method onCreate.

@Override
public void onCreate() {
    gApp = this;
    super.onCreate();
    VirtualCore virtualCore = VirtualCore.get();
    virtualCore.initialize(new VirtualCore.VirtualInitializer() {

        @Override
        public void onMainProcess() {
            Once.initialise(XApp.this);
            Fabric.with(XApp.this, new Crashlytics());
            boolean isXposedInstalled = false;
            try {
                isXposedInstalled = VirtualCore.get().isAppInstalled(XPOSED_INSTALLER_PACKAGE);
                File oldXposedInstallerApk = getFileStreamPath("XposedInstaller_1_24.apk");
                if (oldXposedInstallerApk.exists()) {
                    VirtualCore.get().uninstallPackage(XPOSED_INSTALLER_PACKAGE);
                    oldXposedInstallerApk.delete();
                    isXposedInstalled = false;
                    Log.d(TAG, "remove xposed installer success!");
                }
            } catch (Throwable e) {
                VLog.d(TAG, "remove xposed install failed.", e);
            }
            if (!isXposedInstalled) {
                File xposedInstallerApk = getFileStreamPath("XposedInstaller_1_31.apk");
                if (!xposedInstallerApk.exists()) {
                    InputStream input = null;
                    OutputStream output = null;
                    try {
                        input = getApplicationContext().getAssets().open("XposedInstaller_3.1.5.apk_");
                        output = new FileOutputStream(xposedInstallerApk);
                        byte[] buffer = new byte[1024];
                        int length;
                        while ((length = input.read(buffer)) > 0) {
                            output.write(buffer, 0, length);
                        }
                    } catch (Throwable e) {
                        VLog.e(TAG, "copy file error", e);
                    } finally {
                        FileUtils.closeQuietly(input);
                        FileUtils.closeQuietly(output);
                    }
                }
                if (xposedInstallerApk.isFile() && !DeviceUtil.isMeizuBelowN()) {
                    try {
                        VirtualCore.get().installPackage(xposedInstallerApk.getPath(), InstallStrategy.TERMINATE_IF_EXIST);
                    } catch (Throwable ignored) {
                    }
                }
            }
        }

        @Override
        public void onVirtualProcess() {
            Fabric.with(XApp.this, new Crashlytics());
            // listener components
            virtualCore.setComponentDelegate(new MyComponentDelegate());
            // fake phone imei,macAddress,BluetoothAddress
            virtualCore.setPhoneInfoDelegate(new MyPhoneInfoDelegate());
            // fake task description's icon and title
            virtualCore.setTaskDescriptionDelegate(new MyTaskDescDelegate());
            virtualCore.setCrashHandler(new MyCrashHandler());
            // ensure the logcat service alive when every virtual process start.
            LogcatService.start(XApp.this, VEnvironment.getDataUserPackageDirectory(0, XPOSED_INSTALLER_PACKAGE));
        }

        @Override
        public void onServerProcess() {
            virtualCore.setAppRequestListener(new MyAppRequestListener(XApp.this));
            virtualCore.addVisibleOutsidePackage("com.tencent.mobileqq");
            virtualCore.addVisibleOutsidePackage("com.tencent.mobileqqi");
            virtualCore.addVisibleOutsidePackage("com.tencent.minihd.qq");
            virtualCore.addVisibleOutsidePackage("com.tencent.qqlite");
            virtualCore.addVisibleOutsidePackage("com.facebook.katana");
            virtualCore.addVisibleOutsidePackage("com.whatsapp");
            virtualCore.addVisibleOutsidePackage("com.tencent.mm");
            virtualCore.addVisibleOutsidePackage("com.immomo.momo");
        }
    });
}
Also used : InputStream(java.io.InputStream) MyCrashHandler(io.virtualapp.delegate.MyCrashHandler) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) MyComponentDelegate(io.virtualapp.delegate.MyComponentDelegate) VirtualCore(com.lody.virtual.client.core.VirtualCore) MyPhoneInfoDelegate(io.virtualapp.delegate.MyPhoneInfoDelegate) MyAppRequestListener(io.virtualapp.delegate.MyAppRequestListener) Crashlytics(com.crashlytics.android.Crashlytics) FileOutputStream(java.io.FileOutputStream) MyTaskDescDelegate(io.virtualapp.delegate.MyTaskDescDelegate) File(java.io.File)

Aggregations

Crashlytics (com.crashlytics.android.Crashlytics)1 VirtualCore (com.lody.virtual.client.core.VirtualCore)1 MyAppRequestListener (io.virtualapp.delegate.MyAppRequestListener)1 MyComponentDelegate (io.virtualapp.delegate.MyComponentDelegate)1 MyCrashHandler (io.virtualapp.delegate.MyCrashHandler)1 MyPhoneInfoDelegate (io.virtualapp.delegate.MyPhoneInfoDelegate)1 MyTaskDescDelegate (io.virtualapp.delegate.MyTaskDescDelegate)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1