You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2012/04/20 01:24:58 UTC

[3/13] android commit: [CB-164] Changed network plugin to sync from async and removed setKeepCallback(true) on plugin result in there. Fixes location.reload() not firing deviceready due to network plugin being unresponsive

[CB-164] Changed network plugin to sync from async and removed setKeepCallback(true) on plugin result in there. Fixes location.reload() not firing deviceready due to network plugin being unresponsive


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

Branch: refs/heads/CordovaWebView
Commit: 31d5a94ea917fc0147a18435a458630d0ff2181b
Parents: 1e5457a
Author: Fil Maj <ma...@gmail.com>
Authored: Thu Apr 19 12:33:45 2012 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Thu Apr 19 12:33:45 2012 -0700

----------------------------------------------------------------------
 .../src/org/apache/cordova/NetworkManager.java     |   15 ++++++---------
 1 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/31d5a94e/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 808dac1..0fac00f 100755
--- a/framework/src/org/apache/cordova/NetworkManager.java
+++ b/framework/src/org/apache/cordova/NetworkManager.java
@@ -89,7 +89,7 @@ public class NetworkManager extends Plugin {
      */
     public void setContext(CordovaInterface ctx) {
         super.setContext(ctx);
-        this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);        
+        this.sockMan = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
         this.connectionCallbackId = null;
         
         // We need to listen to connectivity events to update navigator.connection
@@ -98,7 +98,7 @@ public class NetworkManager extends Plugin {
         if (this.receiver == null) {
             this.receiver = new BroadcastReceiver() {
                 @Override
-                public void onReceive(Context context, Intent intent) {                
+                public void onReceive(Context context, Intent intent) {
                     updateConnectionInfo((NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO));                
                 }
             };
@@ -117,13 +117,12 @@ public class NetworkManager extends Plugin {
      */
     public PluginResult execute(String action, JSONArray args, String callbackId) {
         PluginResult.Status status = PluginResult.Status.INVALID_ACTION;
-        String result = "Unsupported Operation: " + action;    
+        String result = "Unsupported Operation: " + action;
         
         if (action.equals("getConnectionInfo")) {
             this.connectionCallbackId = callbackId;
             NetworkInfo info = sockMan.getActiveNetworkInfo();
             PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, this.getConnectionInfo(info));
-            pluginResult.setKeepCallback(true);
             return pluginResult;
         }
         
@@ -137,8 +136,7 @@ public class NetworkManager extends Plugin {
      * @return            T=returns value
      */
     public boolean isSynch(String action) {
-        // All methods take a while, so always use async
-        return false;
+        return true;
     }
     
     /**
@@ -182,7 +180,7 @@ public class NetworkManager extends Plugin {
             // If we are not connected to any network set type to none
             if (!info.isConnected()) {
                 type = TYPE_NONE;
-            }            
+            }
             else {
                 type = getType(info);
             }
@@ -197,7 +195,6 @@ public class NetworkManager extends Plugin {
      */
     private void sendUpdate(String type) {
         PluginResult result = new PluginResult(PluginResult.Status.OK, type);
-        result.setKeepCallback(true);
         this.success(result, this.connectionCallbackId);
         
         // Send to all plugins
@@ -212,7 +209,7 @@ public class NetworkManager extends Plugin {
      */
     private String getType(NetworkInfo info) {
         if (info != null) {
-            String type = info.getTypeName(); 
+            String type = info.getTypeName();
 
             if (type.toLowerCase().equals(WIFI)) {
                 return TYPE_WIFI;