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

Unified Diff: src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java

Issue 29341124: Issue 4029 - SharedPreference related crash on filter list fetch (Closed)
Patch Set: Created May 10, 2016, 12:15 p.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 | « no previous file | src/org/adblockplus/sbrowser/contentblocker/ListedSubscriptionsPreferenceCategory.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java
diff --git a/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java b/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java
index 15bf7b49d9a924a7d5c03890bbc509473ae0cf9c..7a6008e6e99c4e1bbf8224038ef75b5c1e3e8100 100644
--- a/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java
+++ b/src/org/adblockplus/sbrowser/contentblocker/ContentBlockerContentProvider.java
@@ -49,12 +49,25 @@ public class ContentBlockerContentProvider extends ContentProvider implements
return null;
}
+ private static boolean getBooleanPref(final SharedPreferences prefs, final String key,
+ final boolean defValue)
+ {
+ try
+ {
+ return prefs.getBoolean(key, defValue);
+ }
+ catch (final Throwable t)
+ {
+ return defValue;
+ }
+ }
+
private void setApplicationActivated()
{
final SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(this.getContext());
+ .getDefaultSharedPreferences(this.getContext().getApplicationContext());
final String key = this.getContext().getString(R.string.key_application_activated);
- final boolean applicationActived = prefs.getBoolean(key, false);
+ final boolean applicationActived = getBooleanPref(prefs, key, false);
if (!applicationActived)
{
prefs.edit()
@@ -91,7 +104,7 @@ public class ContentBlockerContentProvider extends ContentProvider implements
@Override
public boolean onCreate()
{
- EngineService.startService(this.getContext(), this);
+ EngineService.startService(this.getContext().getApplicationContext(), this);
return true;
}
« no previous file with comments | « no previous file | src/org/adblockplus/sbrowser/contentblocker/ListedSubscriptionsPreferenceCategory.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld