mutualmobile / ComposeSensors

Access sensor data for any Android device easily using Jetpack Compose 🌡️ 🧲 🧭
Apache License 2.0
209 stars 13 forks source link

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

Open shubhamsinghmutualmobile opened 1 year ago

shubhamsinghmutualmobile commented 1 year ago

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

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"/>
Chandra-Mauli-Sharma commented 1 year ago

I would like to work on it.

shubhamsinghmutualmobile commented 1 year ago

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 commented 1 year ago

Ok, will start working on it.