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

Side by Side Diff: libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/AdblockHelper.java

Issue 29413555: Issue 5145 - Add test for IsAllowedConnectionCallbackImpl (Closed)
Patch Set: added "static final" Created April 28, 2017, 6:15 a.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 <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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.libadblockplus.android.settings; 18 package org.adblockplus.libadblockplus.android.settings;
19 19
20 import android.content.Context; 20 import android.content.Context;
21 import android.content.SharedPreferences; 21 import android.content.SharedPreferences;
22 import android.net.ConnectivityManager;
22 import android.util.Log; 23 import android.util.Log;
23 24
24 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback; 25 import org.adblockplus.libadblockplus.IsAllowedConnectionCallback;
25 import org.adblockplus.libadblockplus.android.AdblockEngine; 26 import org.adblockplus.libadblockplus.android.AdblockEngine;
26 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper; 27 import org.adblockplus.libadblockplus.android.AndroidWebRequestResourceWrapper;
27 import org.adblockplus.libadblockplus.android.Utils; 28 import org.adblockplus.libadblockplus.android.Utils;
28 29
29 import java.util.Map; 30 import java.util.Map;
30 import java.util.concurrent.CountDownLatch; 31 import java.util.concurrent.CountDownLatch;
31 import java.util.concurrent.atomic.AtomicInteger; 32 import java.util.concurrent.atomic.AtomicInteger;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 */ 135 */
135 public AdblockHelper preloadSubscriptions(String preferenceName, Map<String, I nteger> urlToResourceIdMap) 136 public AdblockHelper preloadSubscriptions(String preferenceName, Map<String, I nteger> urlToResourceIdMap)
136 { 137 {
137 this.preloadedPreferenceName = preferenceName; 138 this.preloadedPreferenceName = preferenceName;
138 this.urlToResourceIdMap = urlToResourceIdMap; 139 this.urlToResourceIdMap = urlToResourceIdMap;
139 return this; 140 return this;
140 } 141 }
141 142
142 private void createAdblock() 143 private void createAdblock()
143 { 144 {
144 this.isAllowedConnectionCallback = new IsAllowedConnectionCallbackImpl(conte xt); 145 ConnectivityManager connectivityManager =
146 (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVIC E);
147 this.isAllowedConnectionCallback = new IsAllowedConnectionCallbackImpl(conne ctivityManager);
145 148
146 Log.d(TAG, "Creating adblock engine ..."); 149 Log.d(TAG, "Creating adblock engine ...");
147 150
148 // read and apply current settings 151 // read and apply current settings
149 SharedPreferences settingsPrefs = context.getSharedPreferences( 152 SharedPreferences settingsPrefs = context.getSharedPreferences(
150 settingsPreferenceName, 153 settingsPreferenceName,
151 Context.MODE_PRIVATE); 154 Context.MODE_PRIVATE);
152 storage = new SharedPrefsStorage(settingsPrefs); 155 storage = new SharedPrefsStorage(settingsPrefs);
153 156
154 AdblockEngine.Builder builder = AdblockEngine 157 AdblockEngine.Builder builder = AdblockEngine
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 engineCreated.countDown(); 298 engineCreated.countDown();
296 engineCreated = null; 299 engineCreated = null;
297 } 300 }
298 else 301 else
299 { 302 {
300 disposeAdblock(); 303 disposeAdblock();
301 } 304 }
302 } 305 }
303 } 306 }
304 } 307 }
OLDNEW
« no previous file with comments | « no previous file | libadblockplus-android-settings/src/org/adblockplus/libadblockplus/android/settings/IsAllowedConnectionCallbackImpl.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld