Xposed 拦截获取已安装应用时出错,提示不能hook抽象方法。
E/Xposed: java.lang.IllegalArgumentException: Cannot hook abstract methods: public abstract java.util.List android.content.pm.PackageManager.getInstalledPackages(int)
public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags);
此方法具体实现在android.app.ApplicationPackageManager 类中
所以,正确的写法应该是
XposedHelpers.findAndHookMethod("android.app.ApplicationPackageManager", mClassLoader, "getInstalledPackages", int.class, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { } });
另外,PackageManager获取已安装应用还有另一个方法,也在ApplicationPackageManager中实现,需要同时处理
public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags);
参考 :https://blog.csdn.net/qq_34149335/article/details/81129139
发表评论