Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of the Adblock Plus, | 2 * This file is part of the Adblock Plus, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 @Override | 29 @Override |
30 public void onReceive(Context context, Intent intent) | 30 public void onReceive(Context context, Intent intent) |
31 { | 31 { |
32 String action = intent.getAction(); | 32 String action = intent.getAction(); |
33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext); | 33 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(cont ext); |
34 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); | 34 boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); |
35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), false); | 35 boolean proxyenabled = prefs.getBoolean(context.getString(R.string.pref_prox yenabled), false); |
36 if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) | 36 if (Intent.ACTION_PACKAGE_REPLACED.equals(action)) |
37 { | 37 { |
38 boolean us = "org.adblockplus.android".equals(intent.getData().getSchemeSp ecificPart()); | 38 String pkg = context.getApplicationInfo().packageName; |
Felix Dahlke
2013/03/11 06:57:38
Any idea how we could not hard code the package he
Andrey Novikov
2013/03/11 07:32:55
Done.
Andrey Novikov
2013/03/11 07:32:55
Done.
| |
39 boolean us = pkg.equals(intent.getData().getSchemeSpecificPart()); | |
39 enabled &= us; | 40 enabled &= us; |
40 proxyenabled &= us; | 41 proxyenabled &= us; |
41 } | 42 } |
42 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) | 43 if (Intent.ACTION_BOOT_COMPLETED.equals(action)) |
43 { | 44 { |
44 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot)); | 45 boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_sta rtatboot), context.getResources().getBoolean(R.bool.def_startatboot)); |
45 enabled &= startAtBoot; | 46 enabled &= startAtBoot; |
46 proxyenabled &= startAtBoot; | 47 proxyenabled &= startAtBoot; |
47 } | 48 } |
48 if (enabled) | 49 if (enabled) |
49 { | 50 { |
50 AdblockPlus application = AdblockPlus.getApplication(); | 51 AdblockPlus application = AdblockPlus.getApplication(); |
51 application.setFilteringEnabled(true); | 52 application.setFilteringEnabled(true); |
52 application.startEngine(); | 53 application.startEngine(); |
53 } | 54 } |
54 if (proxyenabled) | 55 if (proxyenabled) |
55 context.startService(new Intent(context, ProxyService.class)); | 56 context.startService(new Intent(context, ProxyService.class)); |
56 } | 57 } |
57 | 58 |
58 } | 59 } |
LEFT | RIGHT |