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: Created Nov. 15, 2012, 11:20 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
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/org/adblockplus/android/Starter.java
@@ -0,0 +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 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()))
+ {
+ 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