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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/org/adblockplus/sbrowser/contentblocker/ListedSubscriptionsPreferenceCategory.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 private Engine engine = null; 42 private Engine engine = null;
43 43
44 @Override 44 @Override
45 public Bundle call(String method, String arg, Bundle extras) 45 public Bundle call(String method, String arg, Bundle extras)
46 { 46 {
47 // As of SBC interface v1.4 we return `null` here to signal that we do not 47 // As of SBC interface v1.4 we return `null` here to signal that we do not
48 // use encryption 48 // use encryption
49 return null; 49 return null;
50 } 50 }
51 51
52 private static boolean getBooleanPref(final SharedPreferences prefs, final Str ing key,
53 final boolean defValue)
54 {
55 try
56 {
57 return prefs.getBoolean(key, defValue);
58 }
59 catch (final Throwable t)
60 {
61 return defValue;
62 }
63 }
64
52 private void setApplicationActivated() 65 private void setApplicationActivated()
53 { 66 {
54 final SharedPreferences prefs = PreferenceManager 67 final SharedPreferences prefs = PreferenceManager
55 .getDefaultSharedPreferences(this.getContext()); 68 .getDefaultSharedPreferences(this.getContext().getApplicationContext());
56 final String key = this.getContext().getString(R.string.key_application_acti vated); 69 final String key = this.getContext().getString(R.string.key_application_acti vated);
57 final boolean applicationActived = prefs.getBoolean(key, false); 70 final boolean applicationActived = getBooleanPref(prefs, key, false);
58 if (!applicationActived) 71 if (!applicationActived)
59 { 72 {
60 prefs.edit() 73 prefs.edit()
61 .putBoolean(key, true) 74 .putBoolean(key, true)
62 .commit(); 75 .commit();
63 } 76 }
64 } 77 }
65 78
66 @Override 79 @Override
67 public ParcelFileDescriptor openFile(final Uri uri, final String mode) 80 public ParcelFileDescriptor openFile(final Uri uri, final String mode)
(...skipping 16 matching lines...) Expand all
84 catch (IOException e) 97 catch (IOException e)
85 { 98 {
86 Log.e(TAG, "File creation failed: " + e.getMessage(), e); 99 Log.e(TAG, "File creation failed: " + e.getMessage(), e);
87 return null; 100 return null;
88 } 101 }
89 } 102 }
90 103
91 @Override 104 @Override
92 public boolean onCreate() 105 public boolean onCreate()
93 { 106 {
94 EngineService.startService(this.getContext(), this); 107 EngineService.startService(this.getContext().getApplicationContext(), this);
95 return true; 108 return true;
96 } 109 }
97 110
98 @Override 111 @Override
99 public Cursor query(final Uri uri, final String[] projection, final String sel ection, 112 public Cursor query(final Uri uri, final String[] projection, final String sel ection,
100 final String[] selectionArgs, final String sortOrder) 113 final String[] selectionArgs, final String sortOrder)
101 { 114 {
102 return null; 115 return null;
103 } 116 }
104 117
(...skipping 24 matching lines...) Expand all
129 142
130 @Override 143 @Override
131 public void onEngineCreated(Engine engine, boolean success) 144 public void onEngineCreated(Engine engine, boolean success)
132 { 145 {
133 if (success) 146 if (success)
134 { 147 {
135 this.engine = engine; 148 this.engine = engine;
136 } 149 }
137 } 150 }
138 } 151 }
OLDNEW
« 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