Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ACTIVITY_RECOGNITION runtime permission #430

Merged
merged 2 commits into from
Aug 27, 2021

Conversation

JackMcKew
Copy link

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Documentation changes
  • Other... Please describe:

PR Checklist

For bug fixes / features, please check if your PR fulfills the following requirements:

  • Testing has been carried out for the changes have been added
  • Regression testing has been carried out for existing functionality
  • Docs have been added / updated

What is the purpose of this PR?

Add ability to request ACTIVITY_RECOGNITION run time permission: https://developer.android.com/about/versions/10/privacy/changes#physical-activity-recognition

Does this PR introduce a breaking change?

  • Yes
  • No

What testing has been done on the changes in the PR?

I have installed this branch of PR in my app and works as expected with the cordova.plugins.diagnostic.requestRuntimePermission function.

What testing has been done on existing functionality?

Other information

@fgarcia5
Copy link

I have tested this PR and it works correctly in all Android version, except Android 11 (API 30).
For this platform, when running:

cordova.plugins.diagnostic.requestRuntimePermissions(function(statuses){
      console.log(statuses);
}, function(error){
        console.error("The following error occurred: " + error);
},[
      cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
      cordova.plugins.diagnostic.permission.ACCESS_COARSE_LOCATION,
      cordova.plugins.diagnostic.permission.ACCESS_BACKGROUND_LOCATION,
      cordova.plugins.diagnostic.permission.ACTIVITY_RECOGNITION
]);

Returns the following statuses without requesting the permissions:

{
      ACCESS_BACKGROUND_LOCATION: "DENIED_ONCE"
      ACCESS_COARSE_LOCATION: "DENIED_ONCE"
      ACCESS_FINE_LOCATION: "DENIED_ONCE"
      ACTIVITY_RECOGNITION: "DENIED_ONCE"
}

In all other versions of OS it works correctly. Could you tell me if I'm making a mistake?

@JackMcKew
Copy link
Author

Could this potentially be due to the Physical Activity permission only having the possible state of 'Allow' or 'Deny', as opposed to the Location permission having 4 states: 'Allow all the time', 'Allow only while using the app', 'Ask every time' and 'Deny'?

@fgarcia5
Copy link

fgarcia5 commented Feb 9, 2021

Could be. What test should I take to find out if it is?

@fgarcia5
Copy link

fgarcia5 commented Apr 9, 2021

If I request all the permissions together in an array (ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION, ACCESS_BACKGROUND_LOCATION and ACTIVITY_RECOGNITION) the error occurs. I mean, the permissions are not required and the status "DENIED_ONCE" is returned for each of them..
If I do it one at a time it works correctly.
For my use case I need request all the permissions at the same time.
Any ideas to fix this error that appears only in API 30?

@JackMcKew
Copy link
Author

Seems like it might be an error more underlying to how this plugin makes requests for multiple permissions at this point

Unfortunately don't have the time to spend on this at the moment as it works for the use case when calling individually, maybe we put a caveat on it and say it only works when being called on it's own?

A workaround for your use case would be to request all the others together and the physical activity permission on it's own?

@stale
Copy link

stale bot commented Jun 11, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 11, 2021
@dpa99c dpa99c changed the base branch from master to dev August 27, 2021 13:11
@dpa99c dpa99c merged commit b50f5c9 into dpa99c:dev Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants