From d334cb401b0244621e1fb2ef19d8a02d644153b8 Mon Sep 17 00:00:00 2001 From: tiann <923551233@qq.com> Date: Wed, 21 Mar 2018 00:49:40 +0800 Subject: [PATCH] [VA]: fix exception on samsung Oreo. --- .../client/hook/proxies/clipboard/ClipBoardStub.java | 11 +++++++++-- .../proxies/notification/NotificationManagerStub.java | 3 ++- .../com/lody/virtual/helper/utils/DeviceUtil.java | 4 ++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/clipboard/ClipBoardStub.java b/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/clipboard/ClipBoardStub.java index 3e2889aa2..c94ca87f5 100644 --- a/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/clipboard/ClipBoardStub.java +++ b/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/clipboard/ClipBoardStub.java @@ -8,6 +8,7 @@ import com.lody.virtual.client.hook.base.BinderInvocationProxy; import com.lody.virtual.client.hook.base.ReplaceLastPkgMethodProxy; import com.lody.virtual.helper.compat.BuildCompat; +import com.lody.virtual.helper.utils.DeviceUtil; import mirror.android.content.ClipboardManager; import mirror.android.content.ClipboardManagerOreo; @@ -23,7 +24,7 @@ public ClipBoardStub() { } private static IInterface getInterface() { - if (BuildCompat.isOreo() || ClipboardManager.getService == null) { + if (isOreo()) { android.content.ClipboardManager cm = (android.content.ClipboardManager) VirtualCore.get().getContext().getSystemService(Context.CLIPBOARD_SERVICE); return ClipboardManagerOreo.mService.get(cm); @@ -49,7 +50,7 @@ protected void onBindMethods() { @Override public void inject() throws Throwable { super.inject(); - if (BuildCompat.isOreo()) { + if (isOreo()) { android.content.ClipboardManager cm = (android.content.ClipboardManager) VirtualCore.get().getContext().getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManagerOreo.mService.set(cm, getInvocationStub().getProxyInterface()); @@ -57,4 +58,10 @@ public void inject() throws Throwable { ClipboardManager.sService.set(getInvocationStub().getProxyInterface()); } } + + private static boolean isOreo() { + return BuildCompat.isOreo() && + !DeviceUtil.isSamsung() + || ClipboardManager.getService == null; + } } diff --git a/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/notification/NotificationManagerStub.java b/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/notification/NotificationManagerStub.java index 47de45f35..6704b1f4e 100644 --- a/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/notification/NotificationManagerStub.java +++ b/VirtualApp/lib/src/main/java/com/lody/virtual/client/hook/proxies/notification/NotificationManagerStub.java @@ -7,6 +7,7 @@ import com.lody.virtual.client.hook.base.MethodInvocationProxy; import com.lody.virtual.client.hook.base.MethodInvocationStub; import com.lody.virtual.client.hook.base.ReplaceCallingPkgMethodProxy; +import com.lody.virtual.helper.utils.DeviceUtil; import mirror.android.app.NotificationManager; import mirror.android.widget.Toast; @@ -47,7 +48,7 @@ protected void onBindMethods() { addMethodProxy(new ReplaceCallingPkgMethodProxy("getNotificationChannel")); addMethodProxy(new ReplaceCallingPkgMethodProxy("deleteNotificationChannel")); } - if ("samsung".equalsIgnoreCase(Build.BRAND) || "samsung".equalsIgnoreCase(Build.MANUFACTURER)) { + if (DeviceUtil.isSamsung()) { addMethodProxy(new ReplaceCallingPkgMethodProxy("removeEdgeNotification")); } } diff --git a/VirtualApp/lib/src/main/java/com/lody/virtual/helper/utils/DeviceUtil.java b/VirtualApp/lib/src/main/java/com/lody/virtual/helper/utils/DeviceUtil.java index 5aba0ebce..9b12985fe 100644 --- a/VirtualApp/lib/src/main/java/com/lody/virtual/helper/utils/DeviceUtil.java +++ b/VirtualApp/lib/src/main/java/com/lody/virtual/helper/utils/DeviceUtil.java @@ -18,4 +18,8 @@ public static boolean isMeizuBelowN() { String display = Build.DISPLAY; return display.toLowerCase().contains("flyme"); } + + public static boolean isSamsung() { + return "samsung".equalsIgnoreCase(Build.BRAND) || "samsung".equalsIgnoreCase(Build.MANUFACTURER); + } }