Index: src/org/adblockplus/android/Starter.java |
=================================================================== |
old mode 100755 |
new mode 100644 |
rename from src/org/adblockplus/android/BootBroadcastReceiver.java |
rename to src/org/adblockplus/android/Starter.java |
--- a/src/org/adblockplus/android/BootBroadcastReceiver.java |
+++ b/src/org/adblockplus/android/Starter.java |
@@ -1,20 +1,30 @@ |
-package org.adblockplus.android; |
- |
-import android.content.BroadcastReceiver; |
-import android.content.Context; |
-import android.content.Intent; |
-import android.content.SharedPreferences; |
-import android.preference.PreferenceManager; |
- |
-public class BootBroadcastReceiver extends BroadcastReceiver |
-{ |
- @Override |
- public void onReceive(Context context, Intent intent) |
- { |
- SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
- boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); |
- boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_startatboot), context.getResources().getBoolean(R.bool.def_startatboot)); |
- if (enabled && startAtBoot) |
- context.startService(new Intent(context, ProxyService.class)); |
- } |
-} |
+package org.adblockplus.android; |
+ |
+import android.content.BroadcastReceiver; |
+import android.content.Context; |
+import android.content.Intent; |
+import android.content.SharedPreferences; |
+import android.preference.PreferenceManager; |
+ |
+public class Starter extends BroadcastReceiver |
+{ |
+ |
+ @Override |
+ public void onReceive(Context context, Intent intent) |
+ { |
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
+ boolean enabled = prefs.getBoolean(context.getString(R.string.pref_enabled), false); |
+ if (Intent.ACTION_PACKAGE_REPLACED.equals(intent.getAction())) |
Felix Dahlke
2012/11/16 13:54:18
intent.getAction() is used twice, I'd assign it to
Andrey Novikov
2012/11/16 13:56:08
Yes, I wanted to, but forgot. :) Fixed.
|
+ { |
+ enabled &= "org.adblockplus.android".equals(intent.getData().getSchemeSpecificPart()); |
+ } |
+ if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) |
+ { |
+ boolean startAtBoot = prefs.getBoolean(context.getString(R.string.pref_startatboot), context.getResources().getBoolean(R.bool.def_startatboot)); |
+ enabled &= startAtBoot; |
+ } |
+ if (enabled) |
+ context.startService(new Intent(context, ProxyService.class)); |
+ } |
+ |
+} |