Bug 1306497 - Check that the GeckoInterface and instance EventDispatcher are non-null before dispatching events. r=jchen
authorDylan Roeh <droeh@mozilla.com>
Fri, 30 Sep 2016 12:01:56 -0500
changeset 419816 a08af19f3b3c08a431da4951537ac76ed58c7da2
parent 419815 56f95c86c04c893ecf87a0dad7b2d1ff91b5b1c7
child 419817 069d41a294b8179a226e359de8c9936e003f5309
push id31023
push usercykesiopka.bmo@gmail.com
push dateSat, 01 Oct 2016 01:30:33 +0000
reviewersjchen
bugs1306497
milestone52.0a1
Bug 1306497 - Check that the GeckoInterface and instance EventDispatcher are non-null before dispatching events. r=jchen
mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java
@@ -1945,18 +1945,21 @@ public class GeckoAppShell
      */
     @WrapForJNI(calledFrom = "gecko")
     private static void enableBatteryNotifications() {
         GeckoBatteryManager.enableNotifications();
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private static void handleGeckoMessage(final NativeJSContainer message) {
-        final boolean success = EventDispatcher.getInstance().dispatchEvent(message) |
-                                getGeckoInterface().getAppEventDispatcher().dispatchEvent(message);
+        boolean success = EventDispatcher.getInstance().dispatchEvent(message);
+        if (getGeckoInterface() != null && getGeckoInterface().getAppEventDispatcher() != null) {
+            success |= getGeckoInterface().getAppEventDispatcher().dispatchEvent(message);
+        }
+
         if (!success) {
             final String type = message.optString("type", null);
             final String guid = message.optString(EventDispatcher.GUID, null);
             if (type != null && guid != null) {
                 (new EventDispatcher.GeckoEventCallback(guid, type)).sendError("No listeners for request");
             }
         }
         message.disposeNative();