| Index: mobile/android/base/java/org/adblockplus/browser/SubscriptionContainer.java | 
| =================================================================== | 
| --- a/mobile/android/base/java/org/adblockplus/browser/SubscriptionContainer.java | 
| +++ b/mobile/android/base/java/org/adblockplus/browser/SubscriptionContainer.java | 
| @@ -12,58 +12,59 @@ | 
| * GNU General Public License for more details. | 
| * | 
| * You should have received a copy of the GNU General Public License | 
| * along with Adblock Plus.  If not, see <http://www.gnu.org/licenses/>. | 
| */ | 
|  | 
| package org.adblockplus.browser; | 
|  | 
| +import java.io.BufferedReader; | 
| +import java.io.InputStreamReader; | 
| import java.io.IOException; | 
| -import java.io.StringReader; | 
| import java.lang.ref.WeakReference; | 
| import java.util.ArrayList; | 
| import java.util.HashMap; | 
| import java.util.Iterator; | 
| import java.util.List; | 
| import java.util.concurrent.ConcurrentHashMap; | 
| import java.util.concurrent.Semaphore; | 
|  | 
| import org.mozilla.gecko.util.GeckoBundle; | 
| import org.mozilla.gecko.util.ThreadUtils; | 
| import org.xmlpull.v1.XmlPullParser; | 
| import org.xmlpull.v1.XmlPullParserException; | 
|  | 
| +import android.content.Context; | 
| import android.util.Log; | 
| import android.util.Xml; | 
|  | 
| -final class SubscriptionContainer implements AdblockPlusApiCallback | 
| +final class SubscriptionContainer | 
| { | 
| private static final String TAG = SubscriptionContainer.class.getName(); | 
| private final ConcurrentHashMap<String, Boolean> enableState = new ConcurrentHashMap<>(); | 
| private final Semaphore entriesReady = new Semaphore(0); | 
| private final List<SubscriptionContainer.Subscription> entries = new ArrayList<>(); | 
| private final HashMap<String, SubscriptionContainer.Subscription> urlMap = new HashMap<>(); | 
| private final List<WeakReference<SubscriptionListener>> subscriptionListeners = new ArrayList<>(); | 
|  | 
| -  private SubscriptionContainer() | 
| +  // prevent external instantiation | 
| +  private SubscriptionContainer(final Context context) | 
| { | 
| -    // prevent external instantiation | 
| +      loadSubscriptions(context); | 
| } | 
|  | 
| -  public final static SubscriptionContainer create() | 
| +  public final static SubscriptionContainer create(Context context) | 
| { | 
| -    return create(true); | 
| +    return create(context, true); | 
| } | 
|  | 
| -  public final static SubscriptionContainer create(final boolean refresh) | 
| +  public final static SubscriptionContainer create(Context context, final boolean refresh) | 
| { | 
| -    final SubscriptionContainer sc = new SubscriptionContainer(); | 
| -    AddOnBridge.queryValue("subscriptionsXml", sc); | 
| -    sc.entriesReady.acquireUninterruptibly(); | 
| +    final SubscriptionContainer sc = new SubscriptionContainer(context); | 
|  | 
| for (final SubscriptionContainer.Subscription e : sc.entries) | 
| { | 
| sc.urlMap.put(e.url, e); | 
| sc.enableState.put(e.url, Boolean.FALSE); | 
| } | 
|  | 
| if (refresh) | 
| @@ -147,24 +148,27 @@ | 
| } | 
|  | 
| if (shouldAddListener) | 
| { | 
| this.subscriptionListeners.add(new WeakReference<>(listener)); | 
| } | 
| } | 
|  | 
| -  @Override | 
| -  public void onApiRequestSucceeded(GeckoBundle bundle) | 
| +  private void loadSubscriptions(Context context) | 
| { | 
| + | 
| final XmlPullParser parser = Xml.newPullParser(); | 
| try | 
| { | 
| +      final BufferedReader reader = new BufferedReader(new InputStreamReader( | 
| +              context.getAssets().open("extensions/subscriptions.xml"))); | 
| + | 
| parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); | 
| -      parser.setInput(new StringReader(bundle.getString("value", ""))); | 
| +      parser.setInput(reader); | 
| parser.nextTag(); | 
| parser.require(XmlPullParser.START_TAG, null, "subscriptions"); | 
| while (parser.next() != XmlPullParser.END_TAG) | 
| { | 
| if (parser.getEventType() != XmlPullParser.START_TAG) | 
| { | 
| continue; | 
| } | 
| @@ -181,27 +185,16 @@ | 
| catch (XmlPullParserException e) | 
| { | 
| Log.e(TAG, "Failed to parse subscriptions.xml: " + e.getMessage(), e); | 
| } | 
| catch (IOException e) | 
| { | 
| Log.e(TAG, "Failed to parse subscriptions.xml: " + e.getMessage(), e); | 
| } | 
| -    finally | 
| -    { | 
| -      this.entriesReady.release(); | 
| -    } | 
| -  } | 
| - | 
| -  @Override | 
| -  public void onApiRequestFailed(String errorMessage) | 
| -  { | 
| -    Log.e(TAG, "Error: " + errorMessage); | 
| -    this.entriesReady.release(); | 
| } | 
|  | 
| private static class SubscriptionChangeAction implements AdblockPlusApiCallback | 
| { | 
| private static final String TAG = SubscriptionContainer.SubscriptionChangeAction.class.getName(); | 
|  | 
| private final SubscriptionContainer.Subscription subscription; | 
| private final SubscriptionContainer parent; | 
| @@ -230,23 +223,23 @@ | 
| return new SubscriptionChangeAction(subscription, parent, mode).post(); | 
| } | 
|  | 
| public SubscriptionContainer.SubscriptionChangeAction post() | 
| { | 
| switch (this.mode) | 
| { | 
| case QUERY_SUBSCRIPTION_ENABLED: | 
| -          AddOnBridge.querySubscriptionListStatus(this.subscription.url, this); | 
| +          ExtensionBridge.querySubscriptionListStatus(this.subscription.url, this); | 
| break; | 
| case ENABLE_SUBSCRIPTION: | 
| -          AddOnBridge.addSubscription(this.subscription.url, this.subscription.title, this); | 
| +          ExtensionBridge.addSubscription(this.subscription.url, this.subscription.title, this); | 
| break; | 
| case DISABLE_SUBSCRIPTION: | 
| -          AddOnBridge.removeSubscription(this.subscription.url, this); | 
| +          ExtensionBridge.removeSubscription(this.subscription.url, this); | 
| break; | 
| default: | 
| break; | 
| } | 
| return this; | 
| } | 
|  | 
| @Override | 
| @@ -332,9 +325,9 @@ | 
| return this.specialization + " (" + this.title + ") @ " + this.url; | 
| } | 
| } | 
|  | 
| public interface SubscriptionListener | 
| { | 
| void onSubscriptionUpdated(); | 
| } | 
| -} | 
| +} | 
|  |