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

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

Issue 5153282527854592: Issue 98 - Use the libadblockplus update mechanism (Closed)
Patch Set: Created Sept. 25, 2014, 3:57 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
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; 18 package org.adblockplus.android;
19 19
20 import java.util.List; 20 import java.util.List;
21 import java.util.Locale; 21 import java.util.Locale;
22 22
23 import org.adblockplus.libadblockplus.AppInfo; 23 import org.adblockplus.libadblockplus.AppInfo;
24 import org.adblockplus.libadblockplus.EventCallback;
25 import org.adblockplus.libadblockplus.Filter; 24 import org.adblockplus.libadblockplus.Filter;
26 import org.adblockplus.libadblockplus.FilterChangeCallback; 25 import org.adblockplus.libadblockplus.FilterChangeCallback;
27 import org.adblockplus.libadblockplus.FilterEngine; 26 import org.adblockplus.libadblockplus.FilterEngine;
28 import org.adblockplus.libadblockplus.FilterEngine.ContentType; 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType;
29 import org.adblockplus.libadblockplus.JsEngine; 28 import org.adblockplus.libadblockplus.JsEngine;
30 import org.adblockplus.libadblockplus.LogSystem; 29 import org.adblockplus.libadblockplus.LogSystem;
31 import org.adblockplus.libadblockplus.Subscription; 30 import org.adblockplus.libadblockplus.Subscription;
31 import org.adblockplus.libadblockplus.UpdateAvailableCallback;
32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; 32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback;
33 import org.adblockplus.libadblockplus.WebRequest; 33 import org.adblockplus.libadblockplus.WebRequest;
34 34
35 import android.content.Context; 35 import android.content.Context;
36 import android.content.pm.PackageInfo; 36 import android.content.pm.PackageInfo;
37 import android.content.pm.PackageManager.NameNotFoundException; 37 import android.content.pm.PackageManager.NameNotFoundException;
38 import android.os.Build.VERSION; 38 import android.os.Build.VERSION;
39 import android.util.Log; 39 import android.util.Log;
40 40
41 public final class ABPEngine 41 public final class ABPEngine
(...skipping 10 matching lines...) Expand all
52 * release the object, sometimes even on access. 52 * release the object, sometimes even on access.
53 * 53 *
54 * The only solution that really worked was to declare the variables holding t he references 54 * 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 55 * 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). 56 * variable might be changed at any time from any thread).
57 */ 57 */
58 private volatile JsEngine jsEngine; 58 private volatile JsEngine jsEngine;
59 private volatile FilterEngine filterEngine; 59 private volatile FilterEngine filterEngine;
60 private volatile LogSystem logSystem; 60 private volatile LogSystem logSystem;
61 private volatile WebRequest webRequest; 61 private volatile WebRequest webRequest;
62 private volatile EventCallback updateCallback; 62 private volatile UpdateAvailableCallback updateAvailableCallback;
63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; 63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback;
64 private volatile FilterChangeCallback filterChangeCallback; 64 private volatile FilterChangeCallback filterChangeCallback;
65 65
66 private ABPEngine(final Context context) 66 private ABPEngine(final Context context)
67 { 67 {
68 this.context = context; 68 this.context = context;
69 } 69 }
70 70
71 public static AppInfo generateAppInfo(final Context context) 71 public static AppInfo generateAppInfo(final Context context)
72 { 72 {
(...skipping 25 matching lines...) Expand all
98 98
99 engine.jsEngine = new JsEngine(appInfo); 99 engine.jsEngine = new JsEngine(appInfo);
100 engine.jsEngine.setDefaultFileSystem(basePath); 100 engine.jsEngine.setDefaultFileSystem(basePath);
101 101
102 engine.logSystem = new AndroidLogSystem(); 102 engine.logSystem = new AndroidLogSystem();
103 engine.jsEngine.setLogSystem(engine.logSystem); 103 engine.jsEngine.setLogSystem(engine.logSystem);
104 104
105 engine.webRequest = new AndroidWebRequest(); 105 engine.webRequest = new AndroidWebRequest();
106 engine.jsEngine.setWebRequest(engine.webRequest); 106 engine.jsEngine.setWebRequest(engine.webRequest);
107 107
108 engine.updateCallback = new AndroidUpdateAvailableCallback(context);
109 engine.jsEngine.setEventCallback("updateAvailable", engine.updateCallback);
110
111 engine.filterEngine = new FilterEngine(engine.jsEngine); 108 engine.filterEngine = new FilterEngine(engine.jsEngine);
109 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context) ;
110 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac k);
112 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); 111 engine.filterChangeCallback = new AndroidFilterChangeCallback(context);
113 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); 112 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback);
114 113
115 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context) ; 114 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context) ;
116 115
117 return engine; 116 return engine;
118 } 117 }
119 118
120 public void dispose() 119 public void dispose()
121 { 120 {
(...skipping 15 matching lines...) Expand all
137 this.logSystem.dispose(); 136 this.logSystem.dispose();
138 this.logSystem = null; 137 this.logSystem = null;
139 } 138 }
140 139
141 if (this.webRequest != null) 140 if (this.webRequest != null)
142 { 141 {
143 this.webRequest.dispose(); 142 this.webRequest.dispose();
144 this.webRequest = null; 143 this.webRequest = null;
145 } 144 }
146 145
147 if (this.updateCallback != null) 146 if (this.updateAvailableCallback != null)
148 { 147 {
149 this.updateCallback.dispose(); 148 this.updateAvailableCallback.dispose();
150 this.updateCallback = null; 149 this.updateAvailableCallback = null;
151 } 150 }
152 151
153 if (this.updateCheckDoneCallback != null) 152 if (this.updateCheckDoneCallback != null)
154 { 153 {
155 this.updateCheckDoneCallback.dispose(); 154 this.updateCheckDoneCallback.dispose();
156 this.updateCheckDoneCallback = null; 155 this.updateCheckDoneCallback = null;
157 } 156 }
158 157
159 if (this.filterChangeCallback != null) 158 if (this.filterChangeCallback != null)
160 { 159 {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 270
272 public void updateSubscriptionStatus(final String url) 271 public void updateSubscriptionStatus(final String url)
273 { 272 {
274 final Subscription sub = this.filterEngine.getSubscription(url); 273 final Subscription sub = this.filterEngine.getSubscription(url);
275 if (sub != null) 274 if (sub != null)
276 { 275 {
277 Utils.updateSubscriptionStatus(this.context, sub); 276 Utils.updateSubscriptionStatus(this.context, sub);
278 } 277 }
279 } 278 }
280 } 279 }
OLDNEW

Powered by Google App Engine
This is Rietveld