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

Lancet如何织入@hide的类 #61

Open
ZouYongpeng opened this issue May 25, 2022 · 1 comment
Open

Lancet如何织入@hide的类 #61

ZouYongpeng opened this issue May 25, 2022 · 1 comment

Comments

@ZouYongpeng
Copy link

如android原生View存在以下方法:

/** {@hide} */
@CallSuper
protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) {
    // ......
}

其传入参数 ViewHierarchyEncoder 也存在@hide注解

而我写了以下方法均不生效

@Insert(value = "encodeProperties")
@TargetClass(value = "android.view.View")
protected void _encodeProperties(ViewHierarchyEncoder stream) {
    Log.d(TAG, "_encodeProperties_1: android.view.View.encodeProperties(ViewHierarchyEncoder stream)");
    Origin.callVoid();
}

   @Insert(value = "encodeProperties")
//    @Proxy("encodeProperties")
  @TargetClass(value = "android.view.View", scope = Scope.ALL)
  protected void _encodeProperties(@ClassOf("android.view.ViewHierarchyEncoder") Object stream) {
      Log.d(TAG, "_encodeProperties_2: android.view.View.encodeProperties(ViewHierarchyEncoder stream)");
      Origin.callVoid();
  }

我的理解是@hide会使得类或者方法不参与编译,这种情况是不是就不能使用lancet进行代码织入了呢?

@Knight-ZXW
Copy link

跟是否hide无关, 因为Insert的方式 是直接修改目标类, 因此 对于 jdk 和android sdk的代码,因为它们并不参与apk的构建,并不会并打包到你的APK中,所以你的修改是无效的

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