| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |