Skip to content

Commit

Permalink
Avoid calling WebView class in the entry point
Browse files Browse the repository at this point in the history
It might cause errors due to WebView settings. See #140
  • Loading branch information
JingMatrix committed Dec 24, 2023
1 parent 0dc7bb1 commit b895d16
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions app/src/main/java/org/matrix/chromext/MainHook.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,33 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
return
}

WebViewHook.WebView = WebView::class.java
WebView.setWebContentsDebuggingEnabled(true)

WebViewClient::class.java.declaredConstructors[0].hookAfter {
if (it.thisObject::class != WebViewClient::class) {
WebViewHook.ViewClient = it.thisObject::class.java
if (WebViewHook.ChromeClient != null) {}
hookWebView()
}
}

WebChromeClient::class.java.declaredConstructors[0].hookAfter {
if (it.thisObject::class != WebChromeClient::class) {
WebViewHook.ChromeClient = it.thisObject::class.java
if (WebViewHook.ViewClient != null) {
initHooks(WebViewHook, ContextMenuHook)
}
hookWebView()
}
}
}
}

private fun hookWebView() {
if (WebViewHook.ChromeClient == null || WebViewHook.ViewClient == null) return
if (WebViewHook.WebView == null) {
runCatching {
WebViewHook.WebView = WebView::class.java
WebView.setWebContentsDebuggingEnabled(true)
}
}
initHooks(WebViewHook, ContextMenuHook)
}

override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
Resource.init(startupParam.modulePath)
}
Expand Down

0 comments on commit b895d16

Please sign in to comment.