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

会自动移除annotation,导致网页调用本地方法不可用 #23

Closed
qinlili23333 opened this issue Feb 26, 2020 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@qinlili23333
Copy link

处理前的smali

.method public print()V
.registers 10
.annotation runtime Landroid/webkit/JavascriptInterface;
.end annotation

.annotation runtime Lqinlili/Dex2C;
.end annotation

const-string v1, "正在准备打印..."

const/4 v2, 0x0

invoke-static {p0, v1, v2}, Landroid/widget/Toast;->makeText(Landroid/content/Context;Ljava/lang/CharSequence;I)Landroid/widget/Toast;

move-result-object v1

invoke-virtual {v1}, Landroid/widget/Toast;->show()V

iget-object v3, p0, Lqinlili/Saya/Saya;->w:Landroid/webkit/WebView;

new-instance v0, Landroid/os/Handler;

invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;

move-result-object v1

invoke-direct {v0, v1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V

new-instance v1, Lqinlili/Saya/Saya$WebPrint;

invoke-direct {v1, p0, v3}, Lqinlili/Saya/Saya$WebPrint;-><init>(Landroid/app/Activity;Landroid/webkit/WebView;)V

invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z

return-void

.end method

处理后变成
.method public native print()V
.end method
网页js调用失效

必须自己手动修改成
.method public native print()V
.annotation runtime Landroid/webkit/JavascriptInterface;
.end annotation
.end method
这样才能生效

@amimo
Copy link
Owner

amimo commented Feb 27, 2020

我周末看下

@amimo amimo added the bug Something isn't working label Feb 27, 2020
@amimo
Copy link
Owner

amimo commented Mar 1, 2020

@qinlili23333 hi, 你测试下这个分支fix-lost-annotation

@qinlili23333
Copy link
Author

这个分支没毛病了.正常调用了

@amimo amimo closed this as completed Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants