| LEFT | RIGHT |
| (no file at all) | |
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 12 matching lines...) Expand all Loading... |
| 23 import org.adblockplus.libadblockplus.AppInfo; | 23 import org.adblockplus.libadblockplus.AppInfo; |
| 24 import org.adblockplus.libadblockplus.Filter; | 24 import org.adblockplus.libadblockplus.Filter; |
| 25 import org.adblockplus.libadblockplus.FilterChangeCallback; | 25 import org.adblockplus.libadblockplus.FilterChangeCallback; |
| 26 import org.adblockplus.libadblockplus.FilterEngine; | 26 import org.adblockplus.libadblockplus.FilterEngine; |
| 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; | 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; |
| 28 import org.adblockplus.libadblockplus.JsEngine; | 28 import org.adblockplus.libadblockplus.JsEngine; |
| 29 import org.adblockplus.libadblockplus.LogSystem; | 29 import org.adblockplus.libadblockplus.LogSystem; |
| 30 import org.adblockplus.libadblockplus.Subscription; | 30 import org.adblockplus.libadblockplus.Subscription; |
| 31 import org.adblockplus.libadblockplus.UpdateAvailableCallback; | 31 import org.adblockplus.libadblockplus.UpdateAvailableCallback; |
| 32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; | 32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; |
| 33 import org.adblockplus.libadblockplus.WebRequest; | |
| 34 | 33 |
| 35 import android.content.Context; | 34 import android.content.Context; |
| 36 import android.content.pm.PackageInfo; | 35 import android.content.pm.PackageInfo; |
| 37 import android.content.pm.PackageManager.NameNotFoundException; | 36 import android.content.pm.PackageManager.NameNotFoundException; |
| 38 import android.os.Build.VERSION; | 37 import android.os.Build.VERSION; |
| 39 import android.util.Log; | 38 import android.util.Log; |
| 40 | 39 |
| 41 public final class ABPEngine | 40 public final class ABPEngine |
| 42 { | 41 { |
| 43 private static final String TAG = Utils.getTag(ABPEngine.class); | 42 private static final String TAG = Utils.getTag(ABPEngine.class); |
| 44 | 43 |
| 45 private final Context context; | 44 private final Context context; |
| 46 | 45 |
| 47 /* | 46 /* |
| 48 * The fields below are volatile because: | 47 * The fields below are volatile because: |
| 49 * | 48 * |
| 50 * I encountered JNI related bugs/crashes caused by JNI backed Java objects. I
t seemed that under | 49 * I encountered JNI related bugs/crashes caused by JNI backed Java objects. I
t seemed that under |
| 51 * certain conditions the objects were optimized away which resulted in crashe
s when trying to | 50 * certain conditions the objects were optimized away which resulted in crashe
s when trying to |
| 52 * release the object, sometimes even on access. | 51 * release the object, sometimes even on access. |
| 53 * | 52 * |
| 54 * The only solution that really worked was to declare the variables holding t
he references | 53 * The only solution that really worked was to declare the variables holding t
he references |
| 55 * volatile, this seems to prevent the JNI from 'optimizing away' those object
s (as a volatile | 54 * volatile, this seems to prevent the JNI from 'optimizing away' those object
s (as a volatile |
| 56 * variable might be changed at any time from any thread). | 55 * variable might be changed at any time from any thread). |
| 57 */ | 56 */ |
| 58 private volatile JsEngine jsEngine; | 57 private volatile JsEngine jsEngine; |
| 59 private volatile FilterEngine filterEngine; | 58 private volatile FilterEngine filterEngine; |
| 60 private volatile LogSystem logSystem; | 59 private volatile LogSystem logSystem; |
| 61 private volatile WebRequest webRequest; | 60 private volatile AndroidWebRequest webRequest; |
| 62 private volatile UpdateAvailableCallback updateAvailableCallback; | 61 private volatile UpdateAvailableCallback updateAvailableCallback; |
| 63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; | 62 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; |
| 64 private volatile FilterChangeCallback filterChangeCallback; | 63 private volatile FilterChangeCallback filterChangeCallback; |
| 65 | 64 |
| 66 private ABPEngine(final Context context) | 65 private ABPEngine(final Context context) |
| 67 { | 66 { |
| 68 this.context = context; | 67 this.context = context; |
| 69 } | 68 } |
| 70 | 69 |
| 71 public static AppInfo generateAppInfo(final Context context) | 70 public static AppInfo generateAppInfo(final Context context) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 101 engine.jsEngine = new JsEngine(appInfo); | 100 engine.jsEngine = new JsEngine(appInfo); |
| 102 engine.jsEngine.setDefaultFileSystem(basePath); | 101 engine.jsEngine.setDefaultFileSystem(basePath); |
| 103 | 102 |
| 104 engine.logSystem = new AndroidLogSystem(); | 103 engine.logSystem = new AndroidLogSystem(); |
| 105 engine.jsEngine.setLogSystem(engine.logSystem); | 104 engine.jsEngine.setLogSystem(engine.logSystem); |
| 106 | 105 |
| 107 engine.webRequest = new AndroidWebRequest(); | 106 engine.webRequest = new AndroidWebRequest(); |
| 108 engine.jsEngine.setWebRequest(engine.webRequest); | 107 engine.jsEngine.setWebRequest(engine.webRequest); |
| 109 | 108 |
| 110 engine.filterEngine = new FilterEngine(engine.jsEngine); | 109 engine.filterEngine = new FilterEngine(engine.jsEngine); |
| 110 |
| 111 engine.webRequest.updateSubscriptionURLs(engine.filterEngine); |
| 112 |
| 111 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context)
; | 113 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context)
; |
| 112 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac
k); | 114 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac
k); |
| 113 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); | 115 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); |
| 114 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); | 116 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); |
| 115 | 117 |
| 116 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context)
; | 118 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context)
; |
| 117 | 119 |
| 118 return engine; | 120 return engine; |
| 119 } | 121 } |
| 120 | 122 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 274 |
| 273 public void updateSubscriptionStatus(final String url) | 275 public void updateSubscriptionStatus(final String url) |
| 274 { | 276 { |
| 275 final Subscription sub = this.filterEngine.getSubscription(url); | 277 final Subscription sub = this.filterEngine.getSubscription(url); |
| 276 if (sub != null) | 278 if (sub != null) |
| 277 { | 279 { |
| 278 Utils.updateSubscriptionStatus(this.context, sub); | 280 Utils.updateSubscriptionStatus(this.context, sub); |
| 279 } | 281 } |
| 280 } | 282 } |
| 281 } | 283 } |
| LEFT | RIGHT |