Skip to content

Commit 5961bd2

Browse files
committed
Android 10: getNotificationChannel api change
Signed-off-by: tiann <twsxtd@gmail.com>
1 parent 8c8cd50 commit 5961bd2

2 files changed

Lines changed: 32 additions & 2 deletions

File tree

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/notification/NotificationManagerStub.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
import com.lody.virtual.client.hook.base.MethodInvocationProxy;
88
import com.lody.virtual.client.hook.base.MethodInvocationStub;
99
import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy;
10+
import com.lody.virtual.client.hook.base.StaticMethodProxy;
11+
import com.lody.virtual.client.hook.utils.MethodParameterUtils;
1012
import com.lody.virtual.helper.utils.DeviceUtil;
1113

14+
import java.lang.reflect.Method;
15+
1216
import mirror.android.app.NotificationManager;
1317
import mirror.android.widget.Toast;
1418

@@ -44,8 +48,22 @@ protected void onBindMethods() {
4448
addMethodProxy(new ReplaceCallingPkgMethodProxy("getNotificationChannelGroups"));
4549
addMethodProxy(new ReplaceCallingPkgMethodProxy("deleteNotificationChannelGroup"));
4650
addMethodProxy(new ReplaceCallingPkgMethodProxy("createNotificationChannels"));
47-
addMethodProxy(new ReplaceCallingPkgMethodProxy("getNotificationChannels"));
48-
addMethodProxy(new ReplaceCallingPkgMethodProxy("getNotificationChannel"));
51+
addMethodProxy(new ReplaceCallingPkgMethodProxy("getNotificationChannels") {
52+
@Override
53+
public boolean beforeCall(Object who, Method method, Object... args) {
54+
MethodParameterUtils.replaceLastUid(args);
55+
return super.beforeCall(who, method, args);
56+
}
57+
});
58+
addMethodProxy(new StaticMethodProxy("getNotificationChannel") {
59+
@Override
60+
public boolean beforeCall(Object who, Method method, Object... args) {
61+
MethodParameterUtils.replaceLastUid(args);
62+
int sequence = Build.VERSION.SDK_INT >= 29 ? 2 : 1;
63+
MethodParameterUtils.replaceSequenceAppPkg(args, sequence);
64+
return super.beforeCall(who, method, args);
65+
}
66+
});
4967
addMethodProxy(new ReplaceCallingPkgMethodProxy("deleteNotificationChannel"));
5068
}
5169
if (DeviceUtil.isSamsung()) {

VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/utils/MethodParameterUtils.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.lody.virtual.client.hook.utils;
22

3+
import android.os.Process;
4+
35
import com.lody.virtual.client.core.VirtualCore;
46
import com.lody.virtual.helper.utils.ArrayUtils;
57

@@ -46,6 +48,16 @@ public static String replaceLastAppPkg(Object[] args) {
4648
return null;
4749
}
4850

51+
public static void replaceLastUid(Object[] args) {
52+
int index = ArrayUtils.indexOfLast(args, Integer.class);
53+
if (index != -1) {
54+
int uid = (int) args[index];
55+
if (uid == Process.myUid()) {
56+
args[index] = VirtualCore.get().myUid();
57+
}
58+
}
59+
}
60+
4961
public static String replaceSequenceAppPkg(Object[] args, int sequence) {
5062
int index = ArrayUtils.indexOf(args, String.class, sequence);
5163
if (index != -1) {

0 commit comments

Comments
 (0)