Skip to content

Commit 6978d7b

Browse files
committed
Android 12: make component lazy load
Signed-off-by: tiann <twsxtd@gmail.com>
1 parent 5c9a95f commit 6978d7b

File tree

3 files changed

+41
-26
lines changed

3 files changed

+41
-26
lines changed

VirtualApp/lib/src/main/java/com/lody/virtual/client/VClientImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ private void bindApplicationNoCheck(String packageName, String processName, Cond
322322
mirror.android.app.ActivityThread.AppBindData.info.set(boundApp, data.info);
323323
VMRuntime.setTargetSdkVersion.call(VMRuntime.getRuntime.call(), data.appInfo.targetSdkVersion);
324324

325-
boolean conflict = SpecialComponentList.isConflictingInstrumentation(packageName);
325+
boolean conflict = SpecialComponentList.ConflictInstrumentation.isConflictingInstrumentation(packageName);
326326
if (!conflict) {
327327
InvocationStubManager.getInstance().checkEnv(AppInstrumentation.class);
328328
}
@@ -361,6 +361,7 @@ private void bindApplicationNoCheck(String packageName, String processName, Cond
361361

362362
mirror.android.app.ActivityThread.mInitialApplication.set(mainThread, mInitialApplication);
363363
ContextFixer.fixContext(mInitialApplication);
364+
364365
if (Build.VERSION.SDK_INT >= 24 && "com.tencent.mm:recovery".equals(processName)) {
365366
fixWeChatRecovery(mInitialApplication);
366367
}

VirtualApp/lib/src/main/java/com/lody/virtual/client/env/SpecialComponentList.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,47 @@
2222
*/
2323
public final class SpecialComponentList {
2424

25+
public static class ConflictInstrumentation {
26+
private static final HashSet<String> INSTRUMENTATION_CONFLICTING = new HashSet<>(2);
27+
28+
static {
29+
INSTRUMENTATION_CONFLICTING.add("com.qihoo.magic");
30+
INSTRUMENTATION_CONFLICTING.add("com.qihoo.magic_mutiple");
31+
INSTRUMENTATION_CONFLICTING.add("com.facebook.katana");
32+
}
33+
34+
public static boolean isConflictingInstrumentation(String packageName) {
35+
return INSTRUMENTATION_CONFLICTING.contains(packageName);
36+
}
37+
}
38+
39+
public static class SpecSystemComponent {
40+
41+
private static final HashSet<String> SPEC_SYSTEM_APP_LIST = new HashSet<>(3);
42+
43+
static {
44+
SPEC_SYSTEM_APP_LIST.add("android");
45+
SPEC_SYSTEM_APP_LIST.add("com.google.android.webview");
46+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
47+
try {
48+
String webViewPkgN = IWebViewUpdateService.getCurrentWebViewPackageName.call(WebViewFactory.getUpdateService.call());
49+
if (webViewPkgN != null) {
50+
SPEC_SYSTEM_APP_LIST.add(webViewPkgN);
51+
}
52+
} catch (Throwable e) {
53+
e.printStackTrace();
54+
}
55+
}
56+
}
57+
58+
public static boolean isSpecSystemPackage(String pkg) {
59+
return SPEC_SYSTEM_APP_LIST.contains(pkg);
60+
}
61+
}
62+
2563
private static final List<String> ACTION_BLACK_LIST = new ArrayList<String>(1);
2664
private static final Map<String, String> PROTECTED_ACTION_MAP = new HashMap<>(5);
2765
private static final HashSet<String> WHITE_PERMISSION = new HashSet<>(3);
28-
private static final HashSet<String> INSTRUMENTATION_CONFLICTING = new HashSet<>(2);
29-
private static final HashSet<String> SPEC_SYSTEM_APP_LIST = new HashSet<>(3);
3066
private static final Set<String> SYSTEM_BROADCAST_ACTION = new HashSet<>(7);
3167
private static String PROTECT_ACTION_PREFIX = "_VA_protected_";
3268

@@ -66,31 +102,9 @@ public final class SpecialComponentList {
66102
PROTECTED_ACTION_MAP.put("android.intent.action.USER_ADDED", Constants.ACTION_USER_ADDED);
67103
PROTECTED_ACTION_MAP.put("android.intent.action.USER_REMOVED", Constants.ACTION_USER_REMOVED);
68104

69-
INSTRUMENTATION_CONFLICTING.add("com.qihoo.magic");
70-
INSTRUMENTATION_CONFLICTING.add("com.qihoo.magic_mutiple");
71-
INSTRUMENTATION_CONFLICTING.add("com.facebook.katana");
72-
73-
SPEC_SYSTEM_APP_LIST.add("android");
74-
SPEC_SYSTEM_APP_LIST.add("com.google.android.webview");
75-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
76-
try {
77-
String webViewPkgN = IWebViewUpdateService.getCurrentWebViewPackageName.call(WebViewFactory.getUpdateService.call());
78-
if (webViewPkgN != null) {
79-
SPEC_SYSTEM_APP_LIST.add(webViewPkgN);
80-
}
81-
} catch (Throwable e) {
82-
e.printStackTrace();
83-
}
84-
}
85105
}
86106

87-
public static boolean isSpecSystemPackage(String pkg) {
88-
return SPEC_SYSTEM_APP_LIST.contains(pkg);
89-
}
90107

91-
public static boolean isConflictingInstrumentation(String packageName) {
92-
return INSTRUMENTATION_CONFLICTING.contains(packageName);
93-
}
94108

95109
/**
96110
* Check if the action in the BlackList.

VirtualApp/lib/src/main/java/com/lody/virtual/helper/utils/ComponentUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public static ComponentName toComponentName(ComponentInfo componentInfo) {
9696
public static boolean isSystemApp(ApplicationInfo applicationInfo) {
9797
return !GmsSupport.isGmsFamilyPackage(applicationInfo.packageName)
9898
&& ((ApplicationInfo.FLAG_SYSTEM & applicationInfo.flags) != 0
99-
|| SpecialComponentList.isSpecSystemPackage(applicationInfo.packageName));
99+
|| SpecialComponentList.SpecSystemComponent.isSpecSystemPackage(applicationInfo.packageName));
100100
}
101101

102102
public static boolean isStubComponent(Intent intent) {

0 commit comments

Comments
 (0)