diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java index 43e013bc..868b2430 100755 --- a/framework/src/org/apache/cordova/CordovaActivity.java +++ b/framework/src/org/apache/cordova/CordovaActivity.java @@ -493,7 +493,16 @@ public class CordovaActivity extends Activity { @Override public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) { - cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + try + { + cordovaInterface.onRequestPermissionResult(requestCode, permissions, grantResults); + } + catch (JSONException e) + { + LOG.d(TAG, "JSONException: Parameters fed into the method are not valid"); + e.printStackTrace(); + } + } } diff --git a/framework/src/org/apache/cordova/CordovaInterface.java b/framework/src/org/apache/cordova/CordovaInterface.java index 2aa04526..4b43580c 100755 --- a/framework/src/org/apache/cordova/CordovaInterface.java +++ b/framework/src/org/apache/cordova/CordovaInterface.java @@ -70,6 +70,6 @@ public interface CordovaInterface { */ public ExecutorService getThreadPool(); - public void requestPermission(CordovaPlugin plugin, String permission); - public void requestPermissions(CordovaPlugin plugin); + public void requestPermission(CordovaPlugin plugin, int requestCode, String permission); + public void requestPermissions(CordovaPlugin plugin, int requestCode); } diff --git a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java index 7b436af9..ac311894 100644 --- a/framework/src/org/apache/cordova/CordovaInterfaceImpl.java +++ b/framework/src/org/apache/cordova/CordovaInterfaceImpl.java @@ -24,6 +24,8 @@ import android.content.Intent; import android.os.Bundle; import android.util.Log; +import org.json.JSONException; + import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -171,7 +173,7 @@ public class CordovaInterfaceImpl implements CordovaInterface { * @param grantResults */ public void onRequestPermissionResult(int requestCode, String[] permissions, - int[] grantResults) { + int[] grantResults) throws JSONException { if(permissionResultCallback != null) { permissionResultCallback.onRequestPermissionResult(requestCode, permissions, grantResults); @@ -179,19 +181,17 @@ public class CordovaInterfaceImpl implements CordovaInterface { } } - public void requestPermission(CordovaPlugin plugin, String permission) { + public void requestPermission(CordovaPlugin plugin, int requestCode, String permission) { permissionResultCallback = plugin; String[] permissions = new String [1]; permissions[0] = permission; - int requestCode = 1; getActivity().requestPermissions(permissions, requestCode); } - public void requestPermissions(CordovaPlugin plugin) + public void requestPermissions(CordovaPlugin plugin, int requestCode) { permissionResultCallback = plugin; String[] permissions = plugin.getPermissionRequest(); - int requestCode = 1; getActivity().requestPermissions(permissions, requestCode); } diff --git a/framework/src/org/apache/cordova/CordovaPlugin.java b/framework/src/org/apache/cordova/CordovaPlugin.java index 6e82027c..7dc18e3b 100644 --- a/framework/src/org/apache/cordova/CordovaPlugin.java +++ b/framework/src/org/apache/cordova/CordovaPlugin.java @@ -391,15 +391,8 @@ public class CordovaPlugin { * @param permissions * @param grantResults */ - public boolean onRequestPermissionResult(int requestCode, String[] permissions, - int[] grantResults) { + public void onRequestPermissionResult(int requestCode, String[] permissions, + int[] grantResults) throws JSONException { - for(int r:grantResults) - { - if(r == PackageManager.PERMISSION_DENIED) - return false; - } - - return true; } } diff --git a/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java b/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java index bca847bf..d4114217 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java +++ b/framework/src/org/apache/cordova/engine/SystemWebChromeClient.java @@ -21,6 +21,7 @@ package org.apache.cordova.engine; import java.util.Arrays; import android.annotation.TargetApi; import android.app.Activity; +import android.content.Context; import android.content.ActivityNotFoundException; import android.content.Intent; import android.net.Uri; @@ -63,13 +64,15 @@ public class SystemWebChromeClient extends WebChromeClient { private View mVideoProgressView; private CordovaDialogsHelper dialogsHelper; + private Context appContext; private WebChromeClient.CustomViewCallback mCustomViewCallback; private View mCustomView; public SystemWebChromeClient(SystemWebViewEngine parentEngine) { this.parentEngine = parentEngine; - dialogsHelper = new CordovaDialogsHelper(parentEngine.webView.getContext()); + appContext = parentEngine.webView.getContext(); + dialogsHelper = new CordovaDialogsHelper(appContext); } /** @@ -186,7 +189,7 @@ public class SystemWebChromeClient extends WebChromeClient { CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation"); if(geolocation != null && !geolocation.hasPermisssion()) { - parentEngine.pluginManager.requestPermission(geolocation); + //cordova.requestPermissions(geolocation); } }