Skip to content

Commit

Permalink
support new oplus methods
Browse files Browse the repository at this point in the history
  • Loading branch information
tehcneko committed May 27, 2024
1 parent c0f48f5 commit ee0bfdf
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public void onPackageLoaded(@NonNull PackageLoadedParam param) {
} catch (Throwable t) {
log("hook OPlus failed", t);
}
try {
hookOplusNew(classLoader);
} catch (Throwable t) {
if (!(t instanceof ClassNotFoundException)) {
log("hook OPlus failed", t);
}
}
break;
default:
try {
Expand Down Expand Up @@ -151,11 +158,16 @@ private void hookFlyme(ClassLoader classLoader) throws ClassNotFoundException, N
hook(method, ReturnFalseHooker.class);
}

private void hookOplus(ClassLoader classLoader) throws ClassNotFoundException, NoSuchMethodException {
private void hookOplus(ClassLoader classLoader) throws ClassNotFoundException {
var screenshotContextClazz = classLoader.loadClass("com.oplus.screenshot.screenshot.core.ScreenshotContext");
hookMethods(screenshotContextClazz, ReturnNullHooker.class, "setScreenshotReject", "setLongshotReject");
}

private void hookOplusNew(ClassLoader classLoader) throws ClassNotFoundException {
var screenshotContextClazz = classLoader.loadClass("com.oplus.screenshot.screenshot.core.ScreenshotContentContext");
hookMethods(screenshotContextClazz, ReturnNullHooker.class, "setScreenshotReject", "setLongshotReject");
}

private void hookMethods(Class<?> clazz, Class<? extends Hooker> hooker, String... names) {
var list = Arrays.asList(names);
Arrays.stream(clazz.getDeclaredMethods())
Expand Down

0 comments on commit ee0bfdf

Please sign in to comment.