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

Add auto-permission approval mechanism for every sensor state function #68

Open
6 tasks
shubhamsinghmutualmobile opened this issue Jun 9, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@shubhamsinghmutualmobile
Copy link
Collaborator

shubhamsinghmutualmobile commented Jun 9, 2023

The idea is to explore if it is possible to ask for permissions whenever the user starts consuming any sensor state.

If implemented successfully, the developers won't need to write code for asking permissions for the sensors they are using, the library will do it for them 🎉 They will only need to add the <uses-permission> tag inside AndroidManifest.xml for the required permission (check if even that can be avoided with the library's own Manifest file 🤷).

For example: Whenever a user starts consuming values from rememberHeartRateSensorState, the required permission i.e. android.permission.BODY_SENSORS should automatically be requested first and only when the user grants it, the state function should start emitting sensor values.

TODO

  • Research which sensor requires what permission (in progress)
  • Search which permission is required for High Speed / Real-Time sensor data emission
  • Make sure to emit default value (0 for Float and false for Boolean) while the permission is being requested
  • Expose the permission state (granted / denied) from the sensor state classes
  • Update documentation for all sensor state classes to inform the dev which permission is required to access that sensor's information
  • Use Accompanist Permissions to implement this feature

Resources

  1. https://developer.android.com/training/wearables/versions/4/background-body-sensors
  2. https://developer.android.com/guide/topics/sensors/sensors_overview#sensors-rate-limiting

Permissions required

  1. For HEART_RATE sensor: android.permission.BODY_SENSORS
  2. For STEP_COUNTER and STEP_DETECTOR sensors: android.permission.ACTIVITY_RECOGNITION
  3. For High Sampling Rate: <uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"/>
@shubhamsinghmutualmobile shubhamsinghmutualmobile added the enhancement New feature or request label Jun 9, 2023
@Chandra-Mauli-Sharma
Copy link
Contributor

I would like to work on it.

@shubhamsinghmutualmobile
Copy link
Collaborator Author

Sure, please feel free to raise a PR @Chandra-Mauli-Sharma 🌟 You don't need to be assigned to the ticket in order to work on it 👍

If the PR is in a working state, we'll assign this issue to you and merge it ✅

@Chandra-Mauli-Sharma
Copy link
Contributor

Ok, will start working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants