| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 24 matching lines...) Expand all Loading... |
| 35 import org.adblockplus.libadblockplus.JsEngine; | 35 import org.adblockplus.libadblockplus.JsEngine; |
| 36 import org.adblockplus.libadblockplus.JsValue; | 36 import org.adblockplus.libadblockplus.JsValue; |
| 37 import org.adblockplus.libadblockplus.LogSystem; | 37 import org.adblockplus.libadblockplus.LogSystem; |
| 38 import org.adblockplus.libadblockplus.ShowNotificationCallback; | 38 import org.adblockplus.libadblockplus.ShowNotificationCallback; |
| 39 import org.adblockplus.libadblockplus.Subscription; | 39 import org.adblockplus.libadblockplus.Subscription; |
| 40 import org.adblockplus.libadblockplus.UpdateAvailableCallback; | 40 import org.adblockplus.libadblockplus.UpdateAvailableCallback; |
| 41 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 41 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
| 42 import org.adblockplus.libadblockplus.WebRequest; | 42 import org.adblockplus.libadblockplus.WebRequest; |
| 43 | 43 |
| 44 import android.content.Context; | 44 import android.content.Context; |
| 45 import android.content.pm.PackageInfo; | |
| 46 import android.content.pm.PackageManager.NameNotFoundException; | |
| 47 import android.os.Build.VERSION; | 45 import android.os.Build.VERSION; |
| 48 import android.os.Handler; | 46 import android.os.Handler; |
| 49 import android.os.Looper; | 47 import android.os.Looper; |
| 50 import android.util.Log; | 48 import android.util.Log; |
| 51 | 49 |
| 52 public final class AdblockEngine | 50 public final class AdblockEngine |
| 53 { | 51 { |
| 54 // default base path to store subscription files in android app | 52 // default base path to store subscription files in android app |
| 55 public static final String BASE_PATH_DIRECTORY = "adblock"; | 53 public static final String BASE_PATH_DIRECTORY = "adblock"; |
| 56 | 54 |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 | 253 |
| 256 private final Handler handler = new Handler(Looper.getMainLooper()); | 254 private final Handler handler = new Handler(Looper.getMainLooper()); |
| 257 | 255 |
| 258 private final Runnable forceUpdateRunnable = new Runnable() | 256 private final Runnable forceUpdateRunnable = new Runnable() |
| 259 { | 257 { |
| 260 public void run() { | 258 public void run() { |
| 261 // Filter Engine can be already disposed | 259 // Filter Engine can be already disposed |
| 262 if (filterEngine != null) | 260 if (filterEngine != null) |
| 263 { | 261 { |
| 264 Log.d(TAG, "Force update subscriptions"); | 262 Log.d(TAG, "Force update subscriptions"); |
| 265 List<Subscription> subscriptions = filterEngine.getListedSubscriptions
(); | 263 AdblockEngine.this.updateSubscriptions(); |
| 266 for (Subscription eachSubscription : subscriptions) | |
| 267 { | |
| 268 try | |
| 269 { | |
| 270 eachSubscription.updateFilters(); | |
| 271 } | |
| 272 finally | |
| 273 { | |
| 274 eachSubscription.dispose(); | |
| 275 } | |
| 276 } | |
| 277 } | 264 } |
| 278 } | 265 } |
| 279 }; | 266 }; |
| 280 | 267 |
| 281 @Override | 268 @Override |
| 282 public void onIntercepted(String url, int resourceId) | 269 public void onIntercepted(String url, int resourceId) |
| 283 { | 270 { |
| 284 // we need to force update subscriptions ASAP after preloaded one is retur
ned | 271 // we need to force update subscriptions ASAP after preloaded one is retur
ned |
| 285 // but we should note that multiple interceptions (for main easylist and A
A) and force update once only | 272 // but we should note that multiple interceptions (for main easylist and A
A) and force update once only |
| 286 | 273 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 sub.addToList(); | 475 sub.addToList(); |
| 489 } | 476 } |
| 490 finally | 477 finally |
| 491 { | 478 { |
| 492 sub.dispose(); | 479 sub.dispose(); |
| 493 } | 480 } |
| 494 } | 481 } |
| 495 } | 482 } |
| 496 } | 483 } |
| 497 | 484 |
| 498 public void refreshSubscriptions() | 485 public void updateSubscriptions() |
| 499 { | 486 { |
| 500 for (final Subscription s : this.filterEngine.getListedSubscriptions()) | 487 for (final Subscription s : this.filterEngine.getListedSubscriptions()) |
| 501 { | 488 { |
| 502 try | 489 try |
| 503 { | 490 { |
| 504 s.updateFilters(); | 491 s.updateFilters(); |
| 505 } | 492 } |
| 506 finally | 493 finally |
| 507 { | 494 { |
| 508 s.dispose(); | 495 s.dispose(); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 public void setWhitelistedDomains(List<String> domains) | 714 public void setWhitelistedDomains(List<String> domains) |
| 728 { | 715 { |
| 729 this.whitelistedDomains = domains; | 716 this.whitelistedDomains = domains; |
| 730 } | 717 } |
| 731 | 718 |
| 732 public List<String> getWhitelistedDomains() | 719 public List<String> getWhitelistedDomains() |
| 733 { | 720 { |
| 734 return whitelistedDomains; | 721 return whitelistedDomains; |
| 735 } | 722 } |
| 736 } | 723 } |
| OLD | NEW |