OLD | NEW |
1 /* | 1 /* |
2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // Initiate no traffic check | 260 // Initiate no traffic check |
261 notrafficHandler = new Handler(); | 261 notrafficHandler = new Handler(); |
262 notrafficHandler.postDelayed(noTraffic, NO_TRAFFIC_TIMEOUT); | 262 notrafficHandler.postDelayed(noTraffic, NO_TRAFFIC_TIMEOUT); |
263 } | 263 } |
264 // Lock service | 264 // Lock service |
265 ongoingNotification = new Notification(); | 265 ongoingNotification = new Notification(); |
266 ongoingNotification.when = 0; | 266 ongoingNotification.when = 0; |
267 contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Preferen
ces.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TA
SK), 0); | 267 contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Preferen
ces.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TA
SK), 0); |
268 ongoingNotification.icon = R.drawable.ic_stat_blocking; | 268 ongoingNotification.icon = R.drawable.ic_stat_blocking; |
269 ongoingNotification.setLatestEventInfo(getApplicationContext(), getText(R.st
ring.app_name), msg, contentIntent); | 269 ongoingNotification.setLatestEventInfo(getApplicationContext(), getText(R.st
ring.app_name), msg, contentIntent); |
270 startForeground(ONGOING_NOTIFICATION_ID, ongoingNotification); | |
271 | 270 |
272 sendBroadcast(new Intent(BROADCAST_STATE_CHANGED).putExtra("enabled", true).
putExtra("port", port).putExtra("manual", isManual())); | 271 sendBroadcast(new Intent(BROADCAST_STATE_CHANGED).putExtra("enabled", true).
putExtra("port", port).putExtra("manual", isManual())); |
273 Log.i(TAG, "Service started"); | 272 Log.i(TAG, "Service started"); |
274 } | 273 } |
275 | 274 |
276 @Override | 275 @Override |
277 public void onDestroy() | 276 public void onDestroy() |
278 { | 277 { |
279 super.onDestroy(); | 278 super.onDestroy(); |
280 | 279 |
(...skipping 29 matching lines...) Expand all Loading... |
310 } | 309 } |
311 | 310 |
312 sendBroadcast(new Intent(BROADCAST_STATE_CHANGED).putExtra("enabled", false)
); | 311 sendBroadcast(new Intent(BROADCAST_STATE_CHANGED).putExtra("enabled", false)
); |
313 | 312 |
314 // Stop proxy server | 313 // Stop proxy server |
315 proxy.close(); | 314 proxy.close(); |
316 | 315 |
317 // Stop engine if not in interactive mode | 316 // Stop engine if not in interactive mode |
318 AdblockPlus.getApplication().stopEngine(false); | 317 AdblockPlus.getApplication().stopEngine(false); |
319 | 318 |
320 // Release service lock | |
321 stopForeground(true); | |
322 | |
323 Log.i(TAG, "Service stopped"); | 319 Log.i(TAG, "Service stopped"); |
324 } | 320 } |
325 | 321 |
326 /** | 322 /** |
327 * Restores system proxy settings via native call on Android 3.1+ devices usin
g | 323 * Restores system proxy settings via native call on Android 3.1+ devices usin
g |
328 * Java reflection. | 324 * Java reflection. |
329 */ | 325 */ |
330 private void clearConnectionProxy() | 326 private void clearConnectionProxy() |
331 { | 327 { |
332 String proxyHost = (String) proxy.props.getProperty("adblock.proxyHost"); | 328 String proxyHost = (String) proxy.props.getProperty("adblock.proxyHost"); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 @Override | 717 @Override |
722 public void log(int level, Object obj, String message) | 718 public void log(int level, Object obj, String message) |
723 { | 719 { |
724 if (level <= logLevel) | 720 if (level <= logLevel) |
725 { | 721 { |
726 Log.println(7 - level, obj != null ? obj.toString() : TAG, message); | 722 Log.println(7 - level, obj != null ? obj.toString() : TAG, message); |
727 } | 723 } |
728 } | 724 } |
729 } | 725 } |
730 } | 726 } |
OLD | NEW |