Skip to content

Commit 796e5ec

Browse files
author
维术
committed
[Exposed] disable the inline feature of compiler to hook short method.
1 parent fec4e5f commit 796e5ec

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

VirtualApp/app/src/main/java/io/virtualapp/home/repo/AppRepository.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ private List<AppInfo> convertPackageInfoToAppData(Context context, List<PackageI
150150
@Override
151151
public InstallResult addVirtualApp(AppInfoLite info) {
152152
int flags = InstallStrategy.COMPARE_VERSION | InstallStrategy.SKIP_DEX_OPT;
153+
info.fastOpen = false; // disable fast open for compile.
153154
if (info.fastOpen) {
154155
flags |= InstallStrategy.DEPEND_SYSTEM_IF_EXIST;
155156
}

VirtualApp/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ buildscript {
1919
allprojects {
2020
repositories {
2121
jcenter()
22+
mavenLocal()
2223
maven {
2324
url "https://jitpack.io"
2425
}

VirtualApp/lib/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ android {
3535

3636
dependencies {
3737
compile fileTree(include: ['*.jar'], dir: 'libs')
38-
compile 'me.weishu.exposed:exposed-core:0.2.2'
38+
compile 'me.weishu.exposed:exposed-core:0.2.4'
3939
}

VirtualApp/lib/src/main/java/com/lody/virtual/helper/ArtDexOptimizer.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
public class ArtDexOptimizer {
1919

2020
/**
21-
* Optimize the dex in interpret mode.
21+
* Optimize the dex in compile mode.
2222
*
2323
* @param dexFilePath dex file path
2424
* @param oatFilePath oat file path
2525
* @throws IOException
2626
*/
27-
public static void interpretDex2Oat(String dexFilePath, String oatFilePath) throws IOException {
27+
public static void compileDex2Oat(String dexFilePath, String oatFilePath) throws IOException {
2828
final File oatFile = new File(oatFilePath);
2929
if (!oatFile.exists()) {
3030
oatFile.getParentFile().mkdirs();
@@ -42,10 +42,13 @@ public static void interpretDex2Oat(String dexFilePath, String oatFilePath) thro
4242
commandAndParams.add("--dex-file=" + dexFilePath);
4343
commandAndParams.add("--oat-file=" + oatFilePath);
4444
commandAndParams.add("--instruction-set=" + VMRuntime.getCurrentInstructionSet.call());
45+
commandAndParams.add("--compiler-filter=speed");
4546
if (Build.VERSION.SDK_INT > 25) {
46-
commandAndParams.add("--compiler-filter=quicken");
47+
// commandAndParams.add("--compiler-filter=quicken");
48+
commandAndParams.add("--inline-max-code-units=0");
4749
} else {
48-
commandAndParams.add("--compiler-filter=interpret-only");
50+
// commandAndParams.add("--compiler-filter=interpret-only");
51+
commandAndParams.add("--inline-depth-limit=0");
4952
}
5053

5154
final ProcessBuilder pb = new ProcessBuilder(commandAndParams);

VirtualApp/lib/src/main/java/com/lody/virtual/server/pm/VAppManagerService.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import com.lody.virtual.client.core.InstallStrategy;
1010
import com.lody.virtual.client.core.VirtualCore;
11+
import com.lody.virtual.client.env.VirtualRuntime;
12+
import com.lody.virtual.helper.ArtDexOptimizer;
1113
import com.lody.virtual.helper.collection.IntArray;
1214
import com.lody.virtual.helper.compat.NativeLibraryHelperCompat;
1315
import com.lody.virtual.helper.utils.ArrayUtils;
@@ -236,17 +238,17 @@ public synchronized InstallResult installPackage(String path, int flags, boolean
236238
PackageCacheManager.put(pkg, ps);
237239
mPersistenceLayer.save();
238240
if (!dependSystem) {
239-
boolean runDexOpt = true;
240-
// if (VirtualRuntime.isArt()) {
241-
// try {
242-
// ArtDexOptimizer.interpretDex2Oat(ps.apkPath, VEnvironment.getOdexFile(ps.packageName).getPath());
243-
// } catch (IOException e) {
244-
// e.printStackTrace();
245-
// runDexOpt = true;
246-
// }
247-
// } else {
248-
// runDexOpt = true;
249-
// }
241+
boolean runDexOpt = false;
242+
if (VirtualRuntime.isArt()) {
243+
try {
244+
ArtDexOptimizer.compileDex2Oat(ps.apkPath, VEnvironment.getOdexFile(ps.packageName).getPath());
245+
} catch (IOException e) {
246+
e.printStackTrace();
247+
runDexOpt = true;
248+
}
249+
} else {
250+
runDexOpt = true;
251+
}
250252
if (runDexOpt) {
251253
try {
252254
DexFile.loadDex(ps.apkPath, VEnvironment.getOdexFile(ps.packageName).getPath(), 0).close();

0 commit comments

Comments
 (0)