Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook abstract 抽象方法 #6

Closed
BoringBoy0515 opened this issue Sep 18, 2022 · 1 comment
Closed

hook abstract 抽象方法 #6

BoringBoy0515 opened this issue Sep 18, 2022 · 1 comment

Comments

@BoringBoy0515
Copy link

怎么做抽象方法的Proxy那?比如想hook android.content.pm.PackageManager中的函数

@Knight-ZXW
Copy link
Owner

@Proxy 可以实现,不过如果这个函数调用的地方比较多的话,生成的额外字节码也会比较多。

也可以考虑用 @RepalceInvoke 注解实现, 举个例子,比如想要代理应用内 调用 PackageManager.isInstantApp的函数的话,可以改成下面的写法。

@ReplaceInvoke(isStatic = false)
@TargetClass(value = "android.content.pm.PackageManager",scope = Scope.SELF)
@TargetMethod(methodName = "isInstantApp")
public static boolean isInstantApp(PackageManager packageManager){
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
boolean r = packageManager.isInstantApp();
}
return true;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants