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

Unified Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscription.java

Issue 29722618: Issue 6238 - Download/store notifications.json (Closed)
Patch Set: Created March 14, 2018, 1:34 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
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);
+ }
+ }
}

Powered by Google App Engine
This is Rietveld