Index: mobile/android/thirdparty/org/adblockplus/browser/AddOnBridge.java |
diff --git a/mobile/android/thirdparty/org/adblockplus/browser/AddOnBridge.java b/mobile/android/thirdparty/org/adblockplus/browser/AddOnBridge.java |
index 5bd4a06150082c674bb2b850c64267094357e8cf..d963f17d51c0769ecee4ffde0dedb95f9063ec83 100644 |
--- a/mobile/android/thirdparty/org/adblockplus/browser/AddOnBridge.java |
+++ b/mobile/android/thirdparty/org/adblockplus/browser/AddOnBridge.java |
@@ -42,15 +42,33 @@ public class AddOnBridge |
private static final int QUERY_GET_FILTERS_LOADED_DELAY = 500; |
// Handler+HandlerThread for posting delayed re-tries without interfering with |
// other threads (e.g. the UI or Gecko thread) |
- private static final HandlerThread HANDLER_THREAD; |
- private static final Handler HANDLER; |
+ private static final HandlerThread PRIVATE_HANDLER_THREAD; |
+ private static final Handler PRIVATE_HANDLER; |
+ // Global handler, for e.g. UI tasks |
+ private static final HandlerThread GLOBAL_HANDLER_THREAD; |
+ private static final Handler GLOBAL_HANDLER; |
static |
{ |
- HANDLER_THREAD = new HandlerThread("abp-bridge"); |
- HANDLER_THREAD.setDaemon(true); |
- HANDLER_THREAD.start(); |
- HANDLER = new Handler(HANDLER_THREAD.getLooper()); |
+ PRIVATE_HANDLER_THREAD = new HandlerThread("abp-private-handler"); |
+ PRIVATE_HANDLER_THREAD.setDaemon(true); |
+ PRIVATE_HANDLER_THREAD.start(); |
+ PRIVATE_HANDLER = new Handler(PRIVATE_HANDLER_THREAD.getLooper()); |
+ |
+ GLOBAL_HANDLER_THREAD = new HandlerThread("abp-global-handler"); |
+ GLOBAL_HANDLER_THREAD.setDaemon(true); |
+ GLOBAL_HANDLER_THREAD.start(); |
+ GLOBAL_HANDLER = new Handler(GLOBAL_HANDLER_THREAD.getLooper()); |
+ } |
+ |
+ public static void handlerPost(Runnable runnable) |
+ { |
+ GLOBAL_HANDLER.post(runnable); |
+ } |
+ |
+ public static void handlerPostDelayed(Runnable runnable, long delayMillis) |
+ { |
+ GLOBAL_HANDLER.postDelayed(runnable, delayMillis); |
} |
public static boolean getBooleanFromJsObject(final NativeJSObject obj, final String name, |
@@ -169,10 +187,20 @@ public class AddOnBridge |
Log.d(TAG, "addSubscription for " + url + " (" + title + ")"); |
final Map<String, Object> parameters = new HashMap<String, Object>(); |
parameters.put("url", url); |
- parameters.put("title", title); |
+ if (title != null) |
+ { |
+ parameters.put("title", title); |
+ } |
callFunction(callback, "addSubscription", parameters); |
} |
+ public static void queryActiveSubscriptions(final AdblockPlusApiCallback callback) |
+ { |
+ Log.d(TAG, "queryActiveSubscriptions"); |
+ final Map<String, Object> parameters = new HashMap<String, Object>(); |
+ callFunction(callback, "getActiveSubscriptions", parameters); |
+ } |
+ |
public static void removeSubscription(final AdblockPlusApiCallback callback, |
final String url) |
{ |
@@ -281,7 +309,7 @@ public class AddOnBridge |
{ |
Log.d(TAG, "Retrying: " + this.value); |
final ChainedRequest next = this.cloneForRetry(); |
- HANDLER.postDelayed(new Runnable() |
+ PRIVATE_HANDLER.postDelayed(new Runnable() |
{ |
@Override |
public void run() |