Commit 0f71a543 authored by Torne (Richard Coles)'s avatar Torne (Richard Coles) Committed by Commit Bot

Mark ProxyChangeListener as @UsedByReflection.

A number of WebView applications in the wild use reflection to call the
proxy change broadcast receiver directly as a hack to allow them to set
an application-local proxy setting. The reflection code used searches
for ProxyChangeListener by name, so fails with proguard obfuscation
enabled for the monochrome APK. Mark the relevant classes/methods as
@UsedByReflection to ensure they don't get renamed, because while it's
not good that applications do this, there is no supported API to achieve
the same thing either, and it appears to be a commonly repeated piece of
code.

Bug: 851995
Change-Id: I6174181491f57fd71fece91c98ae8b96f36b425f
Reviewed-on: https://chromium-review.googlesource.com/1112564Reviewed-by: default avatarPaul Jensen <pauljensen@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570479}
parent 66c0789b
......@@ -21,6 +21,7 @@ import org.chromium.base.ContextUtils;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeClassQualifiedName;
import org.chromium.base.annotations.UsedByReflection;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
......@@ -28,7 +29,12 @@ import java.lang.reflect.Method;
/**
* This class partners with native ProxyConfigServiceAndroid to listen for
* proxy change notifications from Android.
*
* Unfortunately this is called directly via reflection in a number of WebView applications
* to provide a hacky way to set per-application proxy settings, so it must not be mangled by
* Proguard.
*/
@UsedByReflection("WebView embedders call this to override proxy settings")
@JNINamespace("net")
public class ProxyChangeListener {
private static final String TAG = "ProxyChangeListener";
......@@ -99,8 +105,10 @@ public class ProxyChangeListener {
unregisterReceiver();
}
@UsedByReflection("WebView embedders call this to override proxy settings")
private class ProxyReceiver extends BroadcastReceiver {
@Override
@UsedByReflection("WebView embedders call this to override proxy settings")
public void onReceive(Context context, final Intent intent) {
if (intent.getAction().equals(Proxy.PROXY_CHANGE_ACTION)) {
runOnThread(new Runnable() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment