cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: Partial Fix/Workaround for CB-1856. Also removed old deprecated code
Date Wed, 28 Nov 2012 22:47:37 GMT
Updated Branches:
  refs/heads/master a42dc0875 -> 2c202b82d


Partial Fix/Workaround for CB-1856.  Also removed old deprecated code


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

Branch: refs/heads/master
Commit: 2c202b82d737c00b3b03b9c6988e1780d3f2df68
Parents: a42dc08
Author: Joe Bowser <bowserj@apache.org>
Authored: Wed Nov 28 14:42:55 2012 -0800
Committer: Joe Bowser <bowserj@apache.org>
Committed: Wed Nov 28 14:42:55 2012 -0800

----------------------------------------------------------------------
 .../src/org/apache/cordova/NetworkManager.java     |   17 ++++++++++----
 1 files changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/2c202b82/framework/src/org/apache/cordova/NetworkManager.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NetworkManager.java b/framework/src/org/apache/cordova/NetworkManager.java
index af2fc7d..bb4743f 100755
--- a/framework/src/org/apache/cordova/NetworkManager.java
+++ b/framework/src/org/apache/cordova/NetworkManager.java
@@ -74,6 +74,7 @@ public class NetworkManager extends CordovaPlugin {
 
     ConnectivityManager sockMan;
     BroadcastReceiver receiver;
+    private String lastStatus = "";
 
     /**
      * Constructor.
@@ -99,12 +100,11 @@ public class NetworkManager extends CordovaPlugin {
         intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
         if (this.receiver == null) {
             this.receiver = new BroadcastReceiver() {
-                @SuppressWarnings("deprecation")
                 @Override
                 public void onReceive(Context context, Intent intent) {
                     // (The null check is for the ARM Emulator, please use Intel Emulator
for better results)
-                    if(NetworkManager.this.webView != null)
-                        updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));
+                    if(NetworkManager.this.webView != null)                        
+                        updateConnectionInfo(sockMan.getActiveNetworkInfo());
                 }
             };
             cordova.getActivity().registerReceiver(this.receiver, intentFilter);
@@ -159,7 +159,14 @@ public class NetworkManager extends CordovaPlugin {
      */
     private void updateConnectionInfo(NetworkInfo info) {
         // send update to javascript "navigator.network.connection"
-        sendUpdate(this.getConnectionInfo(info));
+        // Jellybean sends its own info
+        String thisStatus = this.getConnectionInfo(info);
+        if(!thisStatus.equals(lastStatus))
+        {
+            sendUpdate(thisStatus);
+            lastStatus = thisStatus;
+        }
+            
     }
 
     /**
@@ -179,6 +186,7 @@ public class NetworkManager extends CordovaPlugin {
                 type = getType(info);
             }
         }
+        Log.d("CordovaNetworkManager", "Connection Type: " + type);
         return type;
     }
 
@@ -193,7 +201,6 @@ public class NetworkManager extends CordovaPlugin {
             result.setKeepCallback(true);
             connectionCallbackContext.sendPluginResult(result);
         }
-
         webView.postMessage("networkconnection", type);
     }
 


Mime
View raw message