Skip to content

Commit 015764e

Browse files
committed
[Android 11]: Fix registerReceiverWithFeature on Android 11.
Signed-off-by: tiann <[email protected]>
1 parent 7c5a17a commit 015764e

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

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

+23-8
Original file line numberDiff line numberDiff line change
@@ -1228,14 +1228,14 @@ public boolean isEnable() {
12281228

12291229

12301230
static class RegisterReceiver extends MethodProxy {
1231-
private static final int IDX_IIntentReceiver = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
1231+
protected int mIIntentReceiverIndex = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
12321232
? 2
12331233
: 1;
12341234

1235-
private static final int IDX_RequiredPermission = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
1235+
protected int mRequiredPermissionIndex = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
12361236
? 4
12371237
: 3;
1238-
private static final int IDX_IntentFilter = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
1238+
protected int mIntentFilterIndex = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1
12391239
? 3
12401240
: 2;
12411241

@@ -1249,11 +1249,11 @@ public String getMethodName() {
12491249
@Override
12501250
public Object call(Object who, Method method, Object... args) throws Throwable {
12511251
MethodParameterUtils.replaceFirstAppPkg(args);
1252-
args[IDX_RequiredPermission] = null;
1253-
IntentFilter filter = (IntentFilter) args[IDX_IntentFilter];
1252+
args[mRequiredPermissionIndex] = null;
1253+
IntentFilter filter = (IntentFilter) args[mIntentFilterIndex];
12541254
SpecialComponentList.protectIntentFilter(filter);
1255-
if (args.length > IDX_IIntentReceiver && IIntentReceiver.class.isInstance(args[IDX_IIntentReceiver])) {
1256-
final IInterface old = (IInterface) args[IDX_IIntentReceiver];
1255+
if (args.length > mIIntentReceiverIndex && IIntentReceiver.class.isInstance(args[mIIntentReceiverIndex])) {
1256+
final IInterface old = (IInterface) args[mIIntentReceiverIndex];
12571257
if (!IIntentReceiverProxy.class.isInstance(old)) {
12581258
final IBinder token = old.asBinder();
12591259
if (token != null) {
@@ -1272,7 +1272,7 @@ public void binderDied() {
12721272
WeakReference mDispatcher = LoadedApk.ReceiverDispatcher.InnerReceiver.mDispatcher.get(old);
12731273
if (mDispatcher != null) {
12741274
LoadedApk.ReceiverDispatcher.mIIntentReceiver.set(mDispatcher.get(), proxyIIntentReceiver);
1275-
args[IDX_IIntentReceiver] = proxyIIntentReceiver;
1275+
args[mIIntentReceiverIndex] = proxyIIntentReceiver;
12761276
}
12771277
}
12781278
}
@@ -1762,4 +1762,19 @@ public GetPackageProcessState() {
17621762
super("getPackageProcessState");
17631763
}
17641764
}
1765+
1766+
// For Android 11
1767+
static class RegisterReceiverWithFeature extends RegisterReceiver {
1768+
public RegisterReceiverWithFeature() {
1769+
// http://aospxref.com/android-11.0.0_r21/xref/frameworks/base/core/java/android/app/IActivityManager.aidl?fi=IActivityManager#124
1770+
mIIntentReceiverIndex = 3;
1771+
mIntentFilterIndex = 4;
1772+
mRequiredPermissionIndex = 5;
1773+
}
1774+
1775+
@Override
1776+
public String getMethodName() {
1777+
return "registerReceiverWithFeature";
1778+
}
1779+
}
17651780
}

0 commit comments

Comments
 (0)