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

Unified Diff: src/org/adblockplus/android/Starter.java

Issue 8837074: ABP/Android Post-update starter (Closed)
Patch Set: ABP/Android Post-update starter Created Nov. 15, 2012, 11:31 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « AndroidManifest.xml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
+ }
+
+}
« no previous file with comments | « AndroidManifest.xml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld