You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by riknoll <gi...@git.apache.org> on 2016/03/28 23:00:33 UTC
[GitHub] cordova-plugin-file pull request: CB-10977 android: Removing globa...
GitHub user riknoll opened a pull request:
https://github.com/apache/cordova-plugin-file/pull/174
CB-10977 android: Removing global state used for permission requests
The associated JIRA is [CB-10977](https://issues.apache.org/jira/browse/CB-10977). Check out the description on the issue for an explanation of the problem. I also added some JS that reproduces it in the comments. This fix is contingent on https://github.com/apache/cordova-android/pull/285 to work properly (I plan to merge that PR soon).
This will also change the behavior when used with older versions of cordova-android (i.e. without https://github.com/apache/cordova-android/pull/285) and should prevent some of the weirder bugs. The behavior will still be broken, but less so.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/MSOpenTech/cordova-plugin-file CB-10977
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/cordova-plugin-file/pull/174.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #174
----
commit 91fe4a3111447af4878554b4a824abc52978e26a
Author: Richard Knoll <ri...@gmail.com>
Date: 2016-03-28T19:09:21Z
CB-10977 android: Removing global state used for permission requests
----
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-plugin-file pull request: CB-10977 android: Removing globa...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/cordova-plugin-file/pull/174
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-plugin-file pull request: CB-10977 android: Removing globa...
Posted by riknoll <gi...@git.apache.org>.
Github user riknoll commented on the pull request:
https://github.com/apache/cordova-plugin-file/pull/174#issuecomment-202582415
@infil00p @jasongin @rakatyal please review when you have a moment. Also, should I add manual tests for this? It requires interacting with permission dialogs, so we can't really do any auto tests.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-plugin-file pull request: CB-10977 android: Removing globa...
Posted by jasongin <gi...@git.apache.org>.
Github user jasongin commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-file/pull/174#discussion_r57761716
--- Diff: src/android/FileUtils.java ---
@@ -1151,51 +1140,55 @@ private long truncateFile(String srcURLstr, long size) throws FileNotFoundExcept
public void onRequestPermissionResult(int requestCode, String[] permissions,
int[] grantResults) throws JSONException {
- for(int r:grantResults)
- {
- if(r == PackageManager.PERMISSION_DENIED)
+
+ final PendingRequests.Request req = pendingRequests.getAndRemove(requestCode);
+ if (req != null) {
+ for(int r:grantResults)
{
- callback.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR));
+ if(r == PackageManager.PERMISSION_DENIED)
+ {
+ req.getCallbackContext().sendPluginResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR));
--- End diff --
Should there be a return after this line?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org
[GitHub] cordova-plugin-file pull request: CB-10977 android: Removing globa...
Posted by riknoll <gi...@git.apache.org>.
Github user riknoll commented on a diff in the pull request:
https://github.com/apache/cordova-plugin-file/pull/174#discussion_r57762270
--- Diff: src/android/FileUtils.java ---
@@ -1151,51 +1140,55 @@ private long truncateFile(String srcURLstr, long size) throws FileNotFoundExcept
public void onRequestPermissionResult(int requestCode, String[] permissions,
int[] grantResults) throws JSONException {
- for(int r:grantResults)
- {
- if(r == PackageManager.PERMISSION_DENIED)
+
+ final PendingRequests.Request req = pendingRequests.getAndRemove(requestCode);
+ if (req != null) {
+ for(int r:grantResults)
{
- callback.sendPluginResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR));
+ if(r == PackageManager.PERMISSION_DENIED)
+ {
+ req.getCallbackContext().sendPluginResult(new PluginResult(PluginResult.Status.ERROR, SECURITY_ERR));
--- End diff --
Ha, yep! Good catch! It doesn't look like there was a return there before either so I wonder how that worked.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org