You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/03/27 20:50:28 UTC

[GitHub] infil00p closed pull request #435: CB-13975: (android) Fix to fire pause event when cdvStartInBackground=true

infil00p closed pull request #435: CB-13975: (android) Fix to fire pause event when cdvStartInBackground=true
URL: https://github.com/apache/cordova-android/pull/435
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/framework/src/org/apache/cordova/CoreAndroid.java b/framework/src/org/apache/cordova/CoreAndroid.java
index e384f8d74..46a23edf2 100755
--- a/framework/src/org/apache/cordova/CoreAndroid.java
+++ b/framework/src/org/apache/cordova/CoreAndroid.java
@@ -43,6 +43,7 @@ Licensed to the Apache Software Foundation (ASF) under one
     private BroadcastReceiver telephonyReceiver;
     private CallbackContext messageChannel;
     private PluginResult pendingResume;
+    private PluginResult pendingPause;
     private final Object messageChannelLock = new Object();
 
     /**
@@ -113,6 +114,10 @@ else if (action.equals("exitApp")) {
 			else if (action.equals("messageChannel")) {
                 synchronized(messageChannelLock) {
                     messageChannel = callbackContext;
+                    if (pendingPause != null) {
+                        sendEventMessage(pendingPause);
+                        pendingPause = null;
+                    }
                     if (pendingResume != null) {
                         sendEventMessage(pendingResume);
                         pendingResume = null;
@@ -321,7 +326,19 @@ private void sendEventMessage(String action) {
         } catch (JSONException e) {
             LOG.e(TAG, "Failed to create event message", e);
         }
-        sendEventMessage(new PluginResult(PluginResult.Status.OK, obj));
+        PluginResult result = new PluginResult(PluginResult.Status.OK, obj);
+
+        if (messageChannel == null) {
+            LOG.i(TAG, "Request to send event before messageChannel initialised: " + action);
+            if ("pause".equals(action)) {
+                pendingPause = result;
+            } else if ("resume".equals(action)) {
+                // When starting normally onPause then onResume is called
+                pendingPause = null;
+            }
+        } else {
+            sendEventMessage(result);
+        }
     }
 
     private void sendEventMessage(PluginResult payload) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org