Skip to content

Commit 3874cc9

Browse files
committed
[Android 11]: fix getIntentWithFeature & getAppTasks in AMS.
Signed-off-by: tiann <twsxtd@gmail.com>
1 parent 3fb999c commit 3874cc9

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/am/ActivityTaskManagerStub.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
import com.lody.virtual.client.hook.base.BinderInvocationProxy;
66
import com.lody.virtual.client.hook.base.Inject;
7+
import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy;
78
import com.lody.virtual.client.hook.base.StaticMethodProxy;
89
import com.lody.virtual.client.ipc.VActivityManager;
10+
import com.lody.virtual.helper.compat.BuildCompat;
911

1012
import java.lang.reflect.Method;
1113

@@ -49,5 +51,9 @@ public Object call(Object who, Method method, Object... args) throws Throwable {
4951
return super.call(who, method, args);
5052
}
5153
});
54+
55+
if (BuildCompat.isQ()) {
56+
addMethodProxy(new ReplaceCallingPkgMethodProxy("getAppTasks"));
57+
}
5258
}
5359
}

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/am/MethodProxies.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,10 @@ public boolean isEnable() {
289289

290290
static class GetIntentSender extends MethodProxy {
291291

292+
protected int mIntentIndex = 5;
293+
protected int mResolvedTypesIndex = 6;
294+
protected int mFlagsIndex = 7;
295+
292296
@Override
293297
public String getMethodName() {
294298
return "getIntentSender";
@@ -297,11 +301,11 @@ public String getMethodName() {
297301
@Override
298302
public Object call(Object who, Method method, Object... args) throws Throwable {
299303
String creator = (String) args[1];
300-
String[] resolvedTypes = (String[]) args[6];
304+
String[] resolvedTypes = (String[]) args[mResolvedTypesIndex];
301305
int type = (int) args[0];
302-
int flags = (int) args[7];
306+
int flags = (int) args[mFlagsIndex];
303307
if (args[5] instanceof Intent[]) {
304-
Intent[] intents = (Intent[]) args[5];
308+
Intent[] intents = (Intent[]) args[mIntentIndex];
305309
for (int i = 0; i < intents.length; i++) {
306310
Intent intent = intents[i];
307311
if (resolvedTypes != null && i < resolvedTypes.length) {
@@ -313,7 +317,7 @@ public Object call(Object who, Method method, Object... args) throws Throwable {
313317
}
314318
}
315319
}
316-
args[7] = flags;
320+
args[mFlagsIndex] = flags;
317321
args[1] = getHostPkg();
318322
// Force userId to 0
319323
if (args[args.length - 1] instanceof Integer) {
@@ -1777,4 +1781,19 @@ public String getMethodName() {
17771781
return "registerReceiverWithFeature";
17781782
}
17791783
}
1784+
1785+
static class GetIntentSenderWithFeature extends GetIntentSender {
1786+
1787+
public GetIntentSenderWithFeature() {
1788+
// http://aospxref.com/android-11.0.0_r21/xref/frameworks/base/core/java/android/app/IActivityManager.aidl?fi=IActivityManager#245
1789+
mIntentIndex = 6;
1790+
mResolvedTypesIndex = 7;
1791+
mFlagsIndex = 8;
1792+
}
1793+
1794+
@Override
1795+
public String getMethodName() {
1796+
return "getIntentSenderWithFeature";
1797+
}
1798+
}
17801799
}

0 commit comments

Comments
 (0)