Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: src/org/adblockplus/android/ProxySettings.java

Issue 6002714978811904: Line endings, whitespace, imports and casts cleanup (Closed)
Patch Set: Created March 31, 2014, 1:52 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 28 matching lines...) Expand all
39 Method method = connectivityManager.getClass().getMethod("getActiveLinkPrope rties"); 39 Method method = connectivityManager.getClass().getMethod("getActiveLinkPrope rties");
40 Object lp = method.invoke(connectivityManager); 40 Object lp = method.invoke(connectivityManager);
41 41
42 Object pp = ProxySettings.getLinkProxy(lp); 42 Object pp = ProxySettings.getLinkProxy(lp);
43 return pp; 43 return pp;
44 } 44 }
45 45
46 /** 46 /**
47 * Reads proxy settings from link properties on Android 3.1+ using Java 47 * Reads proxy settings from link properties on Android 3.1+ using Java
48 * reflection. 48 * reflection.
49 * 49 *
50 * @param linkProperties 50 * @param linkProperties
51 * android.net.LinkProperties 51 * android.net.LinkProperties
52 * @return ProxyProperties 52 * @return ProxyProperties
53 * @throws Exception 53 * @throws Exception
54 */ 54 */
55 public static Object getLinkProxy(Object linkProperties) throws Exception 55 public static Object getLinkProxy(Object linkProperties) throws Exception
56 { 56 {
57 /* 57 /*
58 * linkProperties.getHttpProxy(); 58 * linkProperties.getHttpProxy();
59 */ 59 */
60 Method method = linkProperties.getClass().getMethod("getHttpProxy"); 60 Method method = linkProperties.getClass().getMethod("getHttpProxy");
61 Object pp = method.invoke(linkProperties); 61 Object pp = method.invoke(linkProperties);
62 return pp; 62 return pp;
63 } 63 }
64 64
65 /** 65 /**
66 * Reads system proxy settings on Android 3.1+ using Java reflection. 66 * Reads system proxy settings on Android 3.1+ using Java reflection.
67 * 67 *
68 * @return string array of host, port and exclusion list 68 * @return string array of host, port and exclusion list
69 */ 69 */
70 public static String[] getUserProxy(Context context) 70 public static String[] getUserProxy(Context context)
71 { 71 {
72 Method method = null; 72 Method method = null;
73 try 73 try
74 { 74 {
75 /* 75 /*
76 * ProxyProperties proxyProperties = ConnectivityManager.getProxy(); 76 * ProxyProperties proxyProperties = ConnectivityManager.getProxy();
77 */ 77 */
(...skipping 23 matching lines...) Expand all
101 catch (Exception e) 101 catch (Exception e)
102 { 102 {
103 // This should not happen 103 // This should not happen
104 Log.e(TAG, "getProxy failure", e); 104 Log.e(TAG, "getProxy failure", e);
105 return null; 105 return null;
106 } 106 }
107 } 107 }
108 108
109 /** 109 /**
110 * Reads system proxy settings on Android 3.1+ using Java reflection. 110 * Reads system proxy settings on Android 3.1+ using Java reflection.
111 * 111 *
112 * @param pp 112 * @param pp
113 * ProxyProperties object 113 * ProxyProperties object
114 * @return string array of host, port and exclusion list 114 * @return string array of host, port and exclusion list
115 * @throws Exception 115 * @throws Exception
116 */ 116 */
117 protected static String[] getUserProxy(Object pp) throws Exception 117 protected static String[] getUserProxy(Object pp) throws Exception
118 { 118 {
119 String[] userProxy = new String[3]; 119 String[] userProxy = new String[3];
120 120
121 String className = "android.net.ProxyProperties"; 121 String className = "android.net.ProxyProperties";
122 Class<?> c = Class.forName(className); 122 Class<?> c = Class.forName(className);
123 Method method; 123 Method method;
124 124
125 /* 125 /*
126 * String proxyHost = pp.getHost() 126 * String proxyHost = pp.getHost()
127 */ 127 */
128 method = c.getMethod("getHost"); 128 method = c.getMethod("getHost");
129 userProxy[0] = (String) method.invoke(pp); 129 userProxy[0] = (String) method.invoke(pp);
130 130
131 /* 131 /*
132 * int proxyPort = pp.getPort(); 132 * int proxyPort = pp.getPort();
133 */ 133 */
134 method = c.getMethod("getPort"); 134 method = c.getMethod("getPort");
135 userProxy[1] = String.valueOf((Integer) method.invoke(pp)); 135 userProxy[1] = String.valueOf(method.invoke(pp));
136 136
137 /* 137 /*
138 * String proxyEL = pp.getExclusionList() 138 * String proxyEL = pp.getExclusionList()
139 */ 139 */
140 method = c.getMethod("getExclusionList"); 140 method = c.getMethod("getExclusionList");
141 userProxy[2] = (String) method.invoke(pp); 141 userProxy[2] = (String) method.invoke(pp);
142 142
143 if (userProxy[0] != null) 143 if (userProxy[0] != null)
144 return userProxy; 144 return userProxy;
145 else 145 else
146 return null; 146 return null;
147 } 147 }
148 148
149 /** 149 /**
150 * Tries to set local proxy in system settings via native call on Android 3.1+ 150 * Tries to set local proxy in system settings via native call on Android 3.1+
151 * devices using Java reflection. 151 * devices using Java reflection.
152 * 152 *
153 * @return true if device supports native proxy setting 153 * @return true if device supports native proxy setting
154 */ 154 */
155 public static boolean setConnectionProxy(Context context, String host, int por t, String excl) 155 public static boolean setConnectionProxy(Context context, String host, int por t, String excl)
156 { 156 {
157 Method method = null; 157 Method method = null;
158 try 158 try
159 { 159 {
160 /* 160 /*
161 * android.net.LinkProperties lp = 161 * android.net.LinkProperties lp =
162 * ConnectivityManager.getActiveLinkProperties(); 162 * ConnectivityManager.getActiveLinkProperties();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 return false; 239 return false;
240 } 240 }
241 catch (Exception e) 241 catch (Exception e)
242 { 242 {
243 // This should not happen 243 // This should not happen
244 Log.e(TAG, "setHttpProxy failure", e); 244 Log.e(TAG, "setHttpProxy failure", e);
245 return false; 245 return false;
246 } 246 }
247 } 247 }
248 } 248 }
OLDNEW
« no previous file with comments | « src/org/adblockplus/android/ProxyService.java ('k') | src/org/adblockplus/android/Subscription.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld