Skip to content

Commit

Permalink
[VA]: fix exception on samsung Oreo.
Browse files Browse the repository at this point in the history
  • Loading branch information
tiann committed Mar 20, 2018
1 parent 5ce98f9 commit d334cb4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -49,12 +50,18 @@ 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());
} else {
ClipboardManager.sService.set(getInvocationStub().getProxyInterface());
}
}

private static boolean isOreo() {
return BuildCompat.isOreo() &&
!DeviceUtil.isSamsung()
|| ClipboardManager.getService == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit d334cb4

Please sign in to comment.