LEFT | RIGHT |
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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.android.configurators; | 18 package org.adblockplus.android.configurators; |
19 | 19 |
20 import java.net.InetAddress; | 20 import java.net.InetAddress; |
21 import java.util.concurrent.Semaphore; | 21 import java.util.concurrent.Semaphore; |
22 import java.util.concurrent.locks.ReentrantLock; | 22 import java.util.concurrent.locks.ReentrantLock; |
23 | 23 |
24 import org.adblockplus.android.BridgeCommand; | |
25 import org.adblockplus.android.ConfigurationActivity; | 24 import org.adblockplus.android.ConfigurationActivity; |
26 import org.adblockplus.android.ProxyService; | 25 import org.adblockplus.android.ProxyService; |
27 import org.adblockplus.android.R; | 26 import org.adblockplus.android.R; |
28 import org.adblockplus.android.compat.ProxyProperties; | 27 import org.adblockplus.android.compat.ProxyProperties; |
29 import org.adblockplus.brazil.RequestHandler; | 28 import org.adblockplus.brazil.RequestHandler; |
30 | 29 |
31 import android.app.NotificationManager; | 30 import android.app.NotificationManager; |
32 import android.app.PendingIntent; | 31 import android.app.PendingIntent; |
33 import android.content.Context; | 32 import android.content.Context; |
34 import android.content.Intent; | 33 import android.content.Intent; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 { | 152 { |
154 this.isRegistered = true; | 153 this.isRegistered = true; |
155 this.abortNoTrafficCheck(); | 154 this.abortNoTrafficCheck(); |
156 | 155 |
157 this.uiHandler.post(new Runnable() | 156 this.uiHandler.post(new Runnable() |
158 { | 157 { |
159 @Override | 158 @Override |
160 public void run() | 159 public void run() |
161 { | 160 { |
162 ManualProxyConfigurator.this.removeErrorNotification(); | 161 ManualProxyConfigurator.this.removeErrorNotification(); |
163 ProxyService.sendBridgeCommand(ManualProxyConfigurator.this.context, Bri
dgeCommand.STATE_CHANGED); | 162 ManualProxyConfigurator.this.context.sendBroadcast(new Intent(ProxyServi
ce.PROXY_STATE_CHANGED_ACTION)); |
164 } | 163 } |
165 }); | 164 }); |
166 } | 165 } |
167 | 166 |
168 private synchronized void noTrafficReceived() | 167 private synchronized void noTrafficReceived() |
169 { | 168 { |
170 this.isRegistered = false; | 169 this.isRegistered = false; |
171 this.abortNoTrafficCheck(); | 170 this.abortNoTrafficCheck(); |
172 | 171 |
173 this.uiHandler.post(new Runnable() | 172 this.uiHandler.post(new Runnable() |
(...skipping 16 matching lines...) Expand all Loading... |
190 .setSmallIcon(R.drawable.ic_stat_warning) | 189 .setSmallIcon(R.drawable.ic_stat_warning) |
191 .setWhen(System.currentTimeMillis()) | 190 .setWhen(System.currentTimeMillis()) |
192 .setAutoCancel(true) | 191 .setAutoCancel(true) |
193 .setContentIntent(contentIntent) | 192 .setContentIntent(contentIntent) |
194 .setContentTitle(context.getText(R.string.app_name)) | 193 .setContentTitle(context.getText(R.string.app_name)) |
195 .setContentText(context.getText(R.string.notif_notraffic)); | 194 .setContentText(context.getText(R.string.notif_notraffic)); |
196 | 195 |
197 final NotificationManager notificationManager = (NotificationManager) co
ntext.getSystemService(Context.NOTIFICATION_SERVICE); | 196 final NotificationManager notificationManager = (NotificationManager) co
ntext.getSystemService(Context.NOTIFICATION_SERVICE); |
198 notificationManager.notify(NOTRAFFIC_NOTIFICATION_ID, builder.getNotific
ation()); | 197 notificationManager.notify(NOTRAFFIC_NOTIFICATION_ID, builder.getNotific
ation()); |
199 | 198 |
200 ProxyService.sendBridgeCommand(context, BridgeCommand.STATE_CHANGED); | 199 context.sendBroadcast(new Intent(ProxyService.PROXY_STATE_CHANGED_ACTION
)); |
201 } | 200 } |
202 }); | 201 }); |
203 } | 202 } |
204 | 203 |
205 private static class NoTrafficWorker implements Runnable | 204 private static class NoTrafficWorker implements Runnable |
206 { | 205 { |
207 private volatile boolean running = true; | 206 private volatile boolean running = true; |
208 private final Semaphore finished = new Semaphore(1); | 207 private final Semaphore finished = new Semaphore(1); |
209 private final ManualProxyConfigurator manualProxyConfigurator; | 208 private final ManualProxyConfigurator manualProxyConfigurator; |
210 | 209 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 public synchronized void stop() | 259 public synchronized void stop() |
261 { | 260 { |
262 if (this.running) | 261 if (this.running) |
263 { | 262 { |
264 this.running = false; | 263 this.running = false; |
265 this.finished.acquireUninterruptibly(); | 264 this.finished.acquireUninterruptibly(); |
266 } | 265 } |
267 } | 266 } |
268 } | 267 } |
269 } | 268 } |
LEFT | RIGHT |