Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Set user agent before loadUrl
Browse files Browse the repository at this point in the history
Refs #825
  • Loading branch information
M66B committed Dec 4, 2013
1 parent 04050d8 commit ae56a24
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/biz/bokhorst/xprivacy/XWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ public static List<XHook> getInstances() {

@Override
protected void before(MethodHookParam param) throws Throwable {
// Do nothing
if (mMethod == Methods.WebView || mMethod == Methods.getSettings) {
// Do nothing
} else if (mMethod == Methods.loadUrl) {
if (isRestricted(param)) {
String ua = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
WebView webView = (WebView) param.thisObject;
webView.getSettings().setUserAgentString(ua);
}
} else
Util.log(this, Log.WARN, "Unknown method=" + param.method.getName());
}

@Override
Expand All @@ -68,11 +77,7 @@ protected void after(MethodHookParam param) throws Throwable {
}
}
} else if (mMethod == Methods.loadUrl) {
if (isRestricted(param)) {
String ua = (String) PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
WebView webView = (WebView) param.thisObject;
webView.getSettings().setUserAgentString(ua);
}
// Do nothing
} else if (mMethod == Methods.getSettings) {
if (param.getResult() != null) {
Class<?> clazz = param.getResult().getClass();
Expand Down

0 comments on commit ae56a24

Please sign in to comment.