| Index: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java |
| =================================================================== |
| --- a/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java |
| +++ b/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java |
| @@ -601,9 +601,37 @@ final class Subscription |
| if (filtersChanged) |
| { |
| this.serializeFilters(filtersFile); |
| this.clearFilters(); |
| } |
| return filtersChanged; |
| } |
| + |
| + void updateNotification(final int responseCode, final String text, final File notificationDataFile, |
| + final File metaFile) throws IOException |
| + { |
| + if (responseCode != 200 || text == null) |
| + { |
| + this.meta.put(KEY_TRIED_UPDATE_TIMESTAMP, Long.toString(System.currentTimeMillis())); |
| + } |
| + else |
| + { |
| + this.meta.put(KEY_UPDATE_TIMESTAMP, Long.toString(System.currentTimeMillis())); |
| + saveNotificationData(notificationDataFile, text); |
| + } |
| + serializeMetaData(metaFile); |
| + } |
| + |
| + private void saveNotificationData(final File filtersFile, final String text) |
| + { |
| + try (final DataOutputStream outputStream = new DataOutputStream(new BufferedOutputStream( |
| + new GZIPOutputStream(new FileOutputStream(filtersFile))))) |
| + { |
| + outputStream.write(text.getBytes()); |
| + } |
| + catch (IOException e) |
| + { |
| + Log.d(TAG, "Failed to write notification data to internal storage.", e); |
| + } |
| + } |
| } |