|
3 | 3 | import android.content.Context; |
4 | 4 | import android.content.SharedPreferences; |
5 | 5 | import android.support.multidex.MultiDexApplication; |
| 6 | +import android.util.Log; |
6 | 7 |
|
7 | 8 | import com.flurry.android.FlurryAgent; |
| 9 | +import com.lody.virtual.client.core.InstallStrategy; |
8 | 10 | import com.lody.virtual.client.core.VirtualCore; |
9 | 11 | import com.lody.virtual.client.stub.VASettings; |
| 12 | +import com.lody.virtual.helper.utils.FileUtils; |
| 13 | + |
| 14 | +import java.io.File; |
| 15 | +import java.io.FileOutputStream; |
| 16 | +import java.io.InputStream; |
| 17 | +import java.io.OutputStream; |
10 | 18 |
|
11 | 19 | import io.virtualapp.delegate.MyAppRequestListener; |
12 | 20 | import io.virtualapp.delegate.MyComponentDelegate; |
@@ -55,6 +63,34 @@ public void onMainProcess() { |
55 | 63 | // nothing |
56 | 64 | }) |
57 | 65 | .build(VApp.this, "48RJJP7ZCZZBB6KMMWW5"); |
| 66 | + final String xposedPackageName = "de.robv.android.xposed.installer"; |
| 67 | + |
| 68 | + boolean isXposedInstalled = VirtualCore.get().isAppInstalled(xposedPackageName); |
| 69 | + if (!isXposedInstalled) { |
| 70 | + File xposedInstallerApk = getFileStreamPath("XposedInstaller.apk"); |
| 71 | + if (!xposedInstallerApk.exists()) { |
| 72 | + InputStream input = null; |
| 73 | + OutputStream output = null; |
| 74 | + try { |
| 75 | + input = getApplicationContext().getAssets().open("XposedInstaller_3.1.4.apk_"); |
| 76 | + output = new FileOutputStream(xposedInstallerApk); |
| 77 | + byte[] buffer = new byte[1024]; |
| 78 | + int length; |
| 79 | + while ((length = input.read(buffer)) > 0) { |
| 80 | + output.write(buffer, 0, length); |
| 81 | + } |
| 82 | + } catch (Throwable e) { |
| 83 | + Log.e("mylog", "copy file error", e); |
| 84 | + } finally { |
| 85 | + FileUtils.closeQuietly(input); |
| 86 | + FileUtils.closeQuietly(output); |
| 87 | + } |
| 88 | + } |
| 89 | + |
| 90 | + if (xposedInstallerApk.isFile()) { |
| 91 | + VirtualCore.get().installPackage(xposedInstallerApk.getPath(), InstallStrategy.TERMINATE_IF_EXIST); |
| 92 | + } |
| 93 | + } |
58 | 94 | } |
59 | 95 |
|
60 | 96 | @Override |
|
0 commit comments