Skip to content

Commit fec4e5f

Browse files
author
维术
committed
[Exposed] make XposedInstaller a build-in module.
1 parent 6d8003f commit fec4e5f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
2.88 MB
Binary file not shown.

VirtualApp/app/src/main/java/io/virtualapp/VApp.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,18 @@
33
import android.content.Context;
44
import android.content.SharedPreferences;
55
import android.support.multidex.MultiDexApplication;
6+
import android.util.Log;
67

78
import com.flurry.android.FlurryAgent;
9+
import com.lody.virtual.client.core.InstallStrategy;
810
import com.lody.virtual.client.core.VirtualCore;
911
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;
1018

1119
import io.virtualapp.delegate.MyAppRequestListener;
1220
import io.virtualapp.delegate.MyComponentDelegate;
@@ -55,6 +63,34 @@ public void onMainProcess() {
5563
// nothing
5664
})
5765
.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+
}
5894
}
5995

6096
@Override

0 commit comments

Comments
 (0)