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

Commit

Permalink
WebClient: more logging
Browse files Browse the repository at this point in the history
Refs #825
  • Loading branch information
M66B committed Nov 26, 2013
1 parent ff5eed1 commit f8d0e44
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/biz/bokhorst/xprivacy/XWebView.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,36 @@ protected void after(MethodHookParam param) throws Throwable {
Class<?> clazzWebSettings = param.getResultOrThrowable().getClass();
if (!mWebSettings.contains(clazzWebSettings.getName())) {
mWebSettings.add(clazzWebSettings.getName());
Util.log(this, Log.INFO, "Hooking " + clazzWebSettings.getName());

// setUserAgent
// Hook setUserAgent
try {
Util.log(this, Log.INFO, "Hooking setUserAgent");
Util.log(this, Log.INFO, "Hooking " + clazzWebSettings.getName() + ".setUserAgent");
Method setUserAgent = clazzWebSettings.getDeclaredMethod("setUserAgent", int.class);
XposedBridge.hookMethod(setUserAgent, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (isRestricted(param))
if (isRestricted(param)) {
Util.log(XWebView.this, Log.INFO, "Restricting setUserAgent");
param.setResult(null);
}
}
});
} catch (NoSuchFieldError ex) {
Util.bug(this, ex);
}

// setUserAgentString
// Hook setUserAgentString
try {
Util.log(this, Log.INFO, "Hooking setUserAgentString");
Util.log(this, Log.INFO, "Hooking " + clazzWebSettings.getName() + ".setUserAgentString");
Method setUserAgentString = clazzWebSettings.getDeclaredMethod("setUserAgentString",
String.class);
XposedBridge.hookMethod(setUserAgentString, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
if (isRestricted(param))
if (isRestricted(param)) {
Util.log(XWebView.this, Log.INFO, "Restricting setUserAgentString");
param.args[0] = PrivacyManager.getDefacedProp(Binder.getCallingUid(), "UA");
}
}
});
} catch (NoSuchFieldError ex) {
Expand Down

0 comments on commit f8d0e44

Please sign in to comment.