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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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.sbrowser.contentblocker; | 18 package org.adblockplus.sbrowser.contentblocker; |
19 | 19 |
20 import org.adblockplus.sbrowser.contentblocker.engine.Engine; | 20 import org.adblockplus.sbrowser.contentblocker.engine.Engine; |
21 import org.adblockplus.sbrowser.contentblocker.engine.EngineService; | 21 import org.adblockplus.sbrowser.contentblocker.engine.EngineManager; |
22 | 22 |
23 import android.content.BroadcastReceiver; | 23 import android.content.BroadcastReceiver; |
24 import android.content.Context; | 24 import android.content.Context; |
25 import android.content.Intent; | 25 import android.content.Intent; |
26 import android.util.Log; | 26 import android.util.Log; |
27 | 27 |
28 public class ConnectivityChanged extends BroadcastReceiver implements | 28 public class ConnectivityChanged extends BroadcastReceiver implements |
29 EngineService.OnEngineCreatedCallback | 29 EngineManager.OnEngineCreatedCallback |
30 { | 30 { |
31 private static final String TAG = ConnectivityChanged.class.getSimpleName(); | 31 private static final String TAG = ConnectivityChanged.class.getSimpleName(); |
32 | 32 |
33 private static final String ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; | 33 private static final String ACTION = "android.net.conn.CONNECTIVITY_CHANGE"; |
34 | 34 |
35 @Override | 35 @Override |
36 public void onReceive(final Context context, final Intent intent) | 36 public void onReceive(final Context context, final Intent intent) |
37 { | 37 { |
38 if (intent != null && ACTION.equals(intent.getAction())) | 38 if (intent != null && ACTION.equals(intent.getAction())) |
39 { | 39 { |
40 Log.d(TAG, "Triggering connectivity changed event"); | 40 Log.d(TAG, "Triggering connectivity changed event"); |
41 EngineService.startService(context, this); | 41 EngineManager.getInstance().retrieveEngine(context, this); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 @Override | 45 @Override |
46 public void onEngineCreated(Engine engine, boolean success) | 46 public void onEngineCreated(Engine engine) |
47 { | 47 { |
48 if (success) | 48 if (engine != null) |
49 { | 49 { |
50 engine.connectivityChanged(); | 50 engine.connectivityChanged(); |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
OLD | NEW |