You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2014/07/10 17:37:38 UTC

[1/5] android commit: Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate

Repository: cordova-android
Updated Branches:
  refs/heads/4.0.x f0da63a8f -> b52fcb8aa
  refs/heads/master cc860804f -> a14c79425


Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/a14c7942
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/a14c7942
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/a14c7942

Branch: refs/heads/4.0.x
Commit: a14c7942557fbaea41438bd3fe104b47997d8371
Parents: aef96e9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:29:44 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:20 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaActivity.java | 78 ++++++++++----------
 1 file changed, 38 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a14c7942/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index d69dd59..1367f1c 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -207,37 +207,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         }
         
         loadConfig();
-
-        if(!preferences.getBoolean("ShowTitle", false))
-        {
-            getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-        }
-
-        if(preferences.getBoolean("SetFullscreen", false))
-        {
-            Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        } else if (preferences.getBoolean("Fullscreen", false)) {
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        } else {
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
-        }
-
-        appView = makeWebView();
-        appView.init(this, makeWebViewClient(appView), makeChromeClient(appView), pluginEntries, whitelist, preferences);
-
-        // TODO: Have the views set this themselves.
-        if (preferences.getBoolean("DisallowOverscroll", false)) {
-            appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
-        }
-        createViews();
-
-        // TODO: Make this a preference (CB-6153)
-        // Setup the hardware volume controls to handle volume control
-        setVolumeControlStream(AudioManager.STREAM_MUSIC);
     }
 
     @SuppressWarnings("deprecation")
@@ -323,32 +292,58 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         return webView.makeWebChromeClient(this);
     }
 
-    @Deprecated // No need to call init() anymore.
     public void init() {
         this.init(appView, null, null);
     }
 
     @SuppressLint("NewApi")
-    @Deprecated // No need to call init() anymore.
+    @Deprecated // Call init() instead and override makeWebView() to customize.
     public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
         LOG.d(TAG, "CordovaActivity.init()");
 
-        appView = webView;
+        if(!preferences.getBoolean("ShowTitle", false))
+        {
+            getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+        }
+
+        if(preferences.getBoolean("SetFullscreen", false))
+        {
+            Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        } else if (preferences.getBoolean("Fullscreen", false)) {
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        } else {
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+        }
 
-        if (webViewClient != null) {
-            this.appView.setWebViewClient(webViewClient);
-            webViewClient.setWebView(this.appView);
+        appView = webView != null ? webView : makeWebView();
+        if (appView.pluginManager == null) {
+            appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
+                    webChromeClient != null ? webChromeClient : makeChromeClient(appView),
+                    pluginEntries, whitelist, preferences);
         }
-        if (webChromeClient != null) {
-            this.appView.setWebChromeClient(webChromeClient);
-            webChromeClient.setWebView(this.appView);
+
+        // TODO: Have the views set this themselves.
+        if (preferences.getBoolean("DisallowOverscroll", false)) {
+            appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
         }
+        createViews();
+
+        // TODO: Make this a preference (CB-6153)
+        // Setup the hardware volume controls to handle volume control
+        setVolumeControlStream(AudioManager.STREAM_MUSIC);
     }
 
     /**
      * Load the url into the webview.
      */
     public void loadUrl(String url) {
+        if (appView == null) {
+            init();
+        }
         this.splashscreenTime = preferences.getInteger("SplashScreenDelay", this.splashscreenTime);
         String splash = preferences.getString("SplashScreen", null);
         if(this.splashscreenTime > 0 && splash != null)
@@ -436,6 +431,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     @Deprecated // Call method on appView directly.
     public void clearCache() {
+        if (appView == null) {
+            init();
+        }
         this.appView.clearCache(true);
     }
 


[4/5] android commit: Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate

Posted by ag...@apache.org.
Un-deprecate CordovaActivity.init() - it's needed to tweak prefs in onCreate


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/a14c7942
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/a14c7942
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/a14c7942

Branch: refs/heads/master
Commit: a14c7942557fbaea41438bd3fe104b47997d8371
Parents: aef96e9
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:29:44 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:20 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaActivity.java | 78 ++++++++++----------
 1 file changed, 38 insertions(+), 40 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a14c7942/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index d69dd59..1367f1c 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -207,37 +207,6 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         }
         
         loadConfig();
-
-        if(!preferences.getBoolean("ShowTitle", false))
-        {
-            getWindow().requestFeature(Window.FEATURE_NO_TITLE);
-        }
-
-        if(preferences.getBoolean("SetFullscreen", false))
-        {
-            Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        } else if (preferences.getBoolean("Fullscreen", false)) {
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        } else {
-            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
-                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
-        }
-
-        appView = makeWebView();
-        appView.init(this, makeWebViewClient(appView), makeChromeClient(appView), pluginEntries, whitelist, preferences);
-
-        // TODO: Have the views set this themselves.
-        if (preferences.getBoolean("DisallowOverscroll", false)) {
-            appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
-        }
-        createViews();
-
-        // TODO: Make this a preference (CB-6153)
-        // Setup the hardware volume controls to handle volume control
-        setVolumeControlStream(AudioManager.STREAM_MUSIC);
     }
 
     @SuppressWarnings("deprecation")
@@ -323,32 +292,58 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         return webView.makeWebChromeClient(this);
     }
 
-    @Deprecated // No need to call init() anymore.
     public void init() {
         this.init(appView, null, null);
     }
 
     @SuppressLint("NewApi")
-    @Deprecated // No need to call init() anymore.
+    @Deprecated // Call init() instead and override makeWebView() to customize.
     public void init(CordovaWebView webView, CordovaWebViewClient webViewClient, CordovaChromeClient webChromeClient) {
         LOG.d(TAG, "CordovaActivity.init()");
 
-        appView = webView;
+        if(!preferences.getBoolean("ShowTitle", false))
+        {
+            getWindow().requestFeature(Window.FEATURE_NO_TITLE);
+        }
+
+        if(preferences.getBoolean("SetFullscreen", false))
+        {
+            Log.d(TAG, "The SetFullscreen configuration is deprecated in favor of Fullscreen, and will be removed in a future version.");
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        } else if (preferences.getBoolean("Fullscreen", false)) {
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        } else {
+            getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN,
+                    WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
+        }
 
-        if (webViewClient != null) {
-            this.appView.setWebViewClient(webViewClient);
-            webViewClient.setWebView(this.appView);
+        appView = webView != null ? webView : makeWebView();
+        if (appView.pluginManager == null) {
+            appView.init(this, webViewClient != null ? webViewClient : makeWebViewClient(appView),
+                    webChromeClient != null ? webChromeClient : makeChromeClient(appView),
+                    pluginEntries, whitelist, preferences);
         }
-        if (webChromeClient != null) {
-            this.appView.setWebChromeClient(webChromeClient);
-            webChromeClient.setWebView(this.appView);
+
+        // TODO: Have the views set this themselves.
+        if (preferences.getBoolean("DisallowOverscroll", false)) {
+            appView.setOverScrollMode(View.OVER_SCROLL_NEVER);
         }
+        createViews();
+
+        // TODO: Make this a preference (CB-6153)
+        // Setup the hardware volume controls to handle volume control
+        setVolumeControlStream(AudioManager.STREAM_MUSIC);
     }
 
     /**
      * Load the url into the webview.
      */
     public void loadUrl(String url) {
+        if (appView == null) {
+            init();
+        }
         this.splashscreenTime = preferences.getInteger("SplashScreenDelay", this.splashscreenTime);
         String splash = preferences.getString("SplashScreen", null);
         if(this.splashscreenTime > 0 && splash != null)
@@ -436,6 +431,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
      */
     @Deprecated // Call method on appView directly.
     public void clearCache() {
+        if (appView == null) {
+            init();
+        }
         this.appView.clearCache(true);
     }
 


[5/5] android commit: Merge branch 'master' into 4.0.x (CordovaBridge tweaks)

Posted by ag...@apache.org.
Merge branch 'master' into 4.0.x (CordovaBridge tweaks)

Conflicts:
	framework/src/org/apache/cordova/CordovaActivity.java


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/b52fcb8a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/b52fcb8a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/b52fcb8a

Branch: refs/heads/4.0.x
Commit: b52fcb8aa966a7740dbd0768b57c4fb8e315200d
Parents: f0da63a a14c794
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:36:58 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:58 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaBridge.java   | 50 ++++++++++----------
 1 file changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------



[2/5] android commit: Tweak log messages in CordovaBridge with bridgeSecret is wrong

Posted by ag...@apache.org.
Tweak log messages in CordovaBridge with bridgeSecret is wrong


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/aef96e95
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/aef96e95
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/aef96e95

Branch: refs/heads/4.0.x
Commit: aef96e95e82545a2321d798b469ec7fe60f72803
Parents: cc86080
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:29:26 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:20 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaBridge.java   | 50 ++++++++++----------
 1 file changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/aef96e95/framework/src/org/apache/cordova/CordovaBridge.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaBridge.java b/framework/src/org/apache/cordova/CordovaBridge.java
index 2bfad11..081127d 100644
--- a/framework/src/org/apache/cordova/CordovaBridge.java
+++ b/framework/src/org/apache/cordova/CordovaBridge.java
@@ -33,7 +33,7 @@ public class CordovaBridge {
     private static final String LOG_TAG = "CordovaBridge";
     private PluginManager pluginManager;
     private NativeToJsMessageQueue jsMessageQueue;
-    private volatile int bridgeSecret = -1; // written by UI thread, read by JS thread.
+    private volatile int expectedBridgeSecret = -1; // written by UI thread, read by JS thread.
     private String loadedUrl;
 
     public CordovaBridge(PluginManager pluginManager, NativeToJsMessageQueue jsMessageQueue) {
@@ -41,23 +41,10 @@ public class CordovaBridge {
         this.jsMessageQueue = jsMessageQueue;
     }
     
-    private final boolean checkBridgeEnabled(String action) {
-        if (!jsMessageQueue.isBridgeEnabled()) {
-            if (bridgeSecret == -1) {
-                Log.d(LOG_TAG, action + " call made before bridge was enabled.");
-            } else {
-                Log.d(LOG_TAG, "Ignoring " + action + " from previous page load.");                
-            }
-            return false;
-        }
-        return true;
-    }
-
     public String jsExec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException {
-        if (!checkBridgeEnabled("exec()")) {
-            return "";
+        if (!verifySecret("exec()", bridgeSecret)) {
+            return null;
         }
-        verifySecret(bridgeSecret);
         // If the arguments weren't received, send a message back to JS.  It will switch bridge modes and try again.  See CB-2666.
         // We send a message meant specifically for this case.  It starts with "@" so no other message can be encoded into the same string.
         if (arguments == null) {
@@ -70,7 +57,7 @@ public class CordovaBridge {
             CordovaResourceApi.jsThread = Thread.currentThread();
 
             pluginManager.exec(service, action, callbackId, arguments);
-            String ret = "";
+            String ret = null;
             if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING) {
                 ret = jsMessageQueue.popAndEncode(false);
             }
@@ -84,33 +71,44 @@ public class CordovaBridge {
     }
 
     public void jsSetNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException {
-        verifySecret(bridgeSecret);
+        if (!verifySecret("setNativeToJsBridgeMode()", bridgeSecret)) {
+            return;
+        }
         jsMessageQueue.setBridgeMode(value);
     }
 
     public String jsRetrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException {
-        if (!checkBridgeEnabled("retrieveJsMessages()")) {
-            return "";
+        if (!verifySecret("retrieveJsMessages()", bridgeSecret)) {
+            return null;
         }
-        verifySecret(bridgeSecret);
         return jsMessageQueue.popAndEncode(fromOnlineEvent);
     }
 
-    private void verifySecret(int value) throws IllegalAccessException {
-        if (bridgeSecret < 0 || value != bridgeSecret) {
+    private boolean verifySecret(String action, int bridgeSecret) throws IllegalAccessException {
+        if (!jsMessageQueue.isBridgeEnabled()) {
+            if (bridgeSecret == -1) {
+                Log.d(LOG_TAG, action + " call made before bridge was enabled.");
+            } else {
+                Log.d(LOG_TAG, "Ignoring " + action + " from previous page load.");
+            }
+            return false;
+        }
+        // Bridge secret wrong and bridge not due to it being from the previous page.
+        if (expectedBridgeSecret < 0 || bridgeSecret != expectedBridgeSecret) {
             throw new IllegalAccessException();
         }
+        return true;
     }
 
     /** Called on page transitions */
     void clearBridgeSecret() {
-        bridgeSecret = -1;
+        expectedBridgeSecret = -1;
     }
 
     /** Called by cordova.js to initialize the bridge. */
     int generateBridgeSecret() {
-        bridgeSecret = (int)(Math.random() * Integer.MAX_VALUE);
-        return bridgeSecret;
+        expectedBridgeSecret = (int)(Math.random() * Integer.MAX_VALUE);
+        return expectedBridgeSecret;
     }
 
     public void reset(String loadedUrl) {


[3/5] android commit: Tweak log messages in CordovaBridge with bridgeSecret is wrong

Posted by ag...@apache.org.
Tweak log messages in CordovaBridge with bridgeSecret is wrong


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/aef96e95
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/aef96e95
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/aef96e95

Branch: refs/heads/master
Commit: aef96e95e82545a2321d798b469ec7fe60f72803
Parents: cc86080
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Jul 10 11:29:26 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Jul 10 11:36:20 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaBridge.java   | 50 ++++++++++----------
 1 file changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/aef96e95/framework/src/org/apache/cordova/CordovaBridge.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaBridge.java b/framework/src/org/apache/cordova/CordovaBridge.java
index 2bfad11..081127d 100644
--- a/framework/src/org/apache/cordova/CordovaBridge.java
+++ b/framework/src/org/apache/cordova/CordovaBridge.java
@@ -33,7 +33,7 @@ public class CordovaBridge {
     private static final String LOG_TAG = "CordovaBridge";
     private PluginManager pluginManager;
     private NativeToJsMessageQueue jsMessageQueue;
-    private volatile int bridgeSecret = -1; // written by UI thread, read by JS thread.
+    private volatile int expectedBridgeSecret = -1; // written by UI thread, read by JS thread.
     private String loadedUrl;
 
     public CordovaBridge(PluginManager pluginManager, NativeToJsMessageQueue jsMessageQueue) {
@@ -41,23 +41,10 @@ public class CordovaBridge {
         this.jsMessageQueue = jsMessageQueue;
     }
     
-    private final boolean checkBridgeEnabled(String action) {
-        if (!jsMessageQueue.isBridgeEnabled()) {
-            if (bridgeSecret == -1) {
-                Log.d(LOG_TAG, action + " call made before bridge was enabled.");
-            } else {
-                Log.d(LOG_TAG, "Ignoring " + action + " from previous page load.");                
-            }
-            return false;
-        }
-        return true;
-    }
-
     public String jsExec(int bridgeSecret, String service, String action, String callbackId, String arguments) throws JSONException, IllegalAccessException {
-        if (!checkBridgeEnabled("exec()")) {
-            return "";
+        if (!verifySecret("exec()", bridgeSecret)) {
+            return null;
         }
-        verifySecret(bridgeSecret);
         // If the arguments weren't received, send a message back to JS.  It will switch bridge modes and try again.  See CB-2666.
         // We send a message meant specifically for this case.  It starts with "@" so no other message can be encoded into the same string.
         if (arguments == null) {
@@ -70,7 +57,7 @@ public class CordovaBridge {
             CordovaResourceApi.jsThread = Thread.currentThread();
 
             pluginManager.exec(service, action, callbackId, arguments);
-            String ret = "";
+            String ret = null;
             if (!NativeToJsMessageQueue.DISABLE_EXEC_CHAINING) {
                 ret = jsMessageQueue.popAndEncode(false);
             }
@@ -84,33 +71,44 @@ public class CordovaBridge {
     }
 
     public void jsSetNativeToJsBridgeMode(int bridgeSecret, int value) throws IllegalAccessException {
-        verifySecret(bridgeSecret);
+        if (!verifySecret("setNativeToJsBridgeMode()", bridgeSecret)) {
+            return;
+        }
         jsMessageQueue.setBridgeMode(value);
     }
 
     public String jsRetrieveJsMessages(int bridgeSecret, boolean fromOnlineEvent) throws IllegalAccessException {
-        if (!checkBridgeEnabled("retrieveJsMessages()")) {
-            return "";
+        if (!verifySecret("retrieveJsMessages()", bridgeSecret)) {
+            return null;
         }
-        verifySecret(bridgeSecret);
         return jsMessageQueue.popAndEncode(fromOnlineEvent);
     }
 
-    private void verifySecret(int value) throws IllegalAccessException {
-        if (bridgeSecret < 0 || value != bridgeSecret) {
+    private boolean verifySecret(String action, int bridgeSecret) throws IllegalAccessException {
+        if (!jsMessageQueue.isBridgeEnabled()) {
+            if (bridgeSecret == -1) {
+                Log.d(LOG_TAG, action + " call made before bridge was enabled.");
+            } else {
+                Log.d(LOG_TAG, "Ignoring " + action + " from previous page load.");
+            }
+            return false;
+        }
+        // Bridge secret wrong and bridge not due to it being from the previous page.
+        if (expectedBridgeSecret < 0 || bridgeSecret != expectedBridgeSecret) {
             throw new IllegalAccessException();
         }
+        return true;
     }
 
     /** Called on page transitions */
     void clearBridgeSecret() {
-        bridgeSecret = -1;
+        expectedBridgeSecret = -1;
     }
 
     /** Called by cordova.js to initialize the bridge. */
     int generateBridgeSecret() {
-        bridgeSecret = (int)(Math.random() * Integer.MAX_VALUE);
-        return bridgeSecret;
+        expectedBridgeSecret = (int)(Math.random() * Integer.MAX_VALUE);
+        return expectedBridgeSecret;
     }
 
     public void reset(String loadedUrl) {