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

Unified Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.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/Subscriptions.java
===================================================================
--- a/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java
+++ b/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/engine/Subscriptions.java
@@ -26,16 +26,17 @@ import java.nio.charset.StandardCharsets
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.adblockplus.sbrowser.contentblocker.engine.Subscription.Type;
+import org.adblockplus.sbrowser.contentblocker.util.SubscriptionUtils;
import android.util.Log;
/**
* This class holds all listed subscriptions and manages the subscription
* aggregation cache folder.
*/
final class Subscriptions
@@ -139,16 +140,21 @@ final class Subscriptions
else
{
filtersFile = new File(this.subscriptionFolder, "url_"
+ new File(sub.getURL().getPath()).getName() + ".sub");
}
return filtersFile;
}
+ private File getNotificationDataFile()
+ {
+ return new File (this.subscriptionFolder, Notification.NOTIFICATON_DATA_FILE_NAME);
+ }
+
File getMetaFile(final Subscription sub)
{
return new File(getFiltersFile(sub).getAbsolutePath() + ".meta");
}
void persistSubscription(final Subscription sub) throws IOException
{
sub.serializeSubscription(this.getMetaFile(sub), this.getFiltersFile(sub));
@@ -169,17 +175,17 @@ final class Subscriptions
* @param output
* @throws IOException
*/
private void writeFile(final File output) throws IOException
{
final HashSet<String> filters = new HashSet<>();
for (final Subscription s : this.subscriptions.values())
{
- if (s.isEnabled())
+ if (s.isEnabled() && !SubscriptionUtils.isNotificationSubscription(s.getId()))
{
Log.d(TAG, "Adding filters for '" + s.getId() + "'");
s.deserializeFilters(this.getFiltersFile(s));
s.copyFilters(filters);
s.clearFilters();
}
if ((!s.isMetaDataValid() || !s.isFiltersValid()) && s.getURL() != null)
{
@@ -283,16 +289,21 @@ final class Subscriptions
public void updateSubscription(final String id, final int responseCode, final String text,
final Map<String, String> httpHeaders)
throws IOException
{
final Subscription sub = this.subscriptions.get(id);
if (sub != null)
{
- if (sub.updateSubscription(responseCode, text, httpHeaders, this.getMetaFile(sub),
+ if (SubscriptionUtils.isNotificationSubscription(id))
+ {
+ sub.updateNotification(responseCode, text, getNotificationDataFile(), getMetaFile(sub));
+ return;
+ }
+ if (sub.updateSubscription(id, responseCode, text, httpHeaders, this.getMetaFile(sub),
this.getFiltersFile(sub)))
{
this.engine.requestUpdateBroadcast();
}
}
}
}

Powered by Google App Engine
This is Rietveld