-
Notifications
You must be signed in to change notification settings - Fork 751
Manage unnecessary permission data for android #1263
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
base: master
Are you sure you want to change the base?
Conversation
(cherry picked from commit 0cefe4c)
Raw workouts distance android
Hi @klnfreedom, I’m fairly new to the I noticed this PR introduces permission checks using Could you explain the motivation for using the Android-level checks instead of (or in addition to) the Health Connect API approach? |
@klnfreedom Thanks for the PR! |
We do not request Android-level Health permissions (e.g., android.permission.health.READ_STEPS, ACCESS_FINE_LOCATION) unless the Dart layer explicitly requests the corresponding types. Previously, native code would probe steps/distance unconditionally, throwing an error on Android when the app hadn’t declared extra manifest permissions. That error bubbled to Dart and looked like a failure, effectively forcing developers to add Android permissions they don’t need — which in turn triggers extra Play Console checks. Now we gate native checks by the Dart request and gracefully no-op for non-requested types (no crash, no manifest requirements, no extra Play Console declarations). Result: if an app only asks for, say, heart rate or workouts, it won’t see native probes for steps/distance/location, won’t need extra manifest permissions, and won’t fail at runtime. |
…proved readability
|
This pull request introduces improved permission handling for health data retrieval on Android and adds support for capturing the raw workout activity type in the Dart data model. The main changes are grouped into Android permission checks and Dart model enhancements.
Android permission checks:
HealthPermissionChecker
class to encapsulate permission checks for location, distance, calories burned, and steps inHealthPermissionChecker.kt
.HealthDataReader.kt
to useHealthPermissionChecker
before attempting to read workout distance, calories burned, and steps; if permissions are missing, the retrieval is skipped and a log message is recorded. [1] [2] [3] [4] [5]HealthDataReader.kt
to return a proper error result when data is unavailable, instead of returningnull
.Dart model enhancements:
rawWorkoutActivityType
field to theWorkoutHealthValue
class inhealth_value_types.dart
, storing the raw activity type from native data. Updated the constructor, factory,toString
, equality, and hashCode methods to support this new field. [1] [2] [3] [4]