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 2016/03/01 20:20:39 UTC

cordova-plugin-geolocation git commit: CB-10691: Check the context to avoid null errors

Repository: cordova-plugin-geolocation
Updated Branches:
  refs/heads/master d56ab5b08 -> 7c57ae9c0


CB-10691: Check the context to avoid null errors


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/commit/7c57ae9c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/tree/7c57ae9c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/diff/7c57ae9c

Branch: refs/heads/master
Commit: 7c57ae9c0470905124c0d5a1430bf09f3a46f1cc
Parents: d56ab5b
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Mar 1 11:20:24 2016 -0800
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Mar 1 11:20:34 2016 -0800

----------------------------------------------------------------------
 src/android/Geolocation.java | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation/blob/7c57ae9c/src/android/Geolocation.java
----------------------------------------------------------------------
diff --git a/src/android/Geolocation.java b/src/android/Geolocation.java
index 79f0684..f5a1cae 100644
--- a/src/android/Geolocation.java
+++ b/src/android/Geolocation.java
@@ -21,6 +21,7 @@ package org.apache.cordova.geolocation;
 import android.content.pm.PackageManager;
 import android.Manifest;
 import android.os.Build;
+import android.util.Log;
 
 import org.apache.cordova.CallbackContext;
 import org.apache.cordova.CordovaArgs;
@@ -41,6 +42,7 @@ public class Geolocation extends CordovaPlugin {
 
 
     public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
+        Log.d(TAG, "We are entering execute");
         context = callbackContext;
         if(action.equals("getPermission"))
         {
@@ -63,18 +65,20 @@ public class Geolocation extends CordovaPlugin {
                                           int[] grantResults) throws JSONException
     {
         PluginResult result;
-        for(int r:grantResults)
-        {
-            if(r == PackageManager.PERMISSION_DENIED)
-            {
-                LOG.d(TAG, "Permission Denied!");
-                result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION);
-                context.sendPluginResult(result);
-                return;
+        //This is important if we're using Cordova without using Cordova, but we have the geolocation plugin installed
+        if(context != null) {
+            for (int r : grantResults) {
+                if (r == PackageManager.PERMISSION_DENIED) {
+                    LOG.d(TAG, "Permission Denied!");
+                    result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION);
+                    context.sendPluginResult(result);
+                    return;
+                }
+
             }
+            result = new PluginResult(PluginResult.Status.OK);
+            context.sendPluginResult(result);
         }
-        result = new PluginResult(PluginResult.Status.OK);
-        context.sendPluginResult(result);
     }
 
     public boolean hasPermisssion() {


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