Split Health Connect import permissions by category - #1509
Conversation
|
Nice piece of work — the decomposition is clean, all seven locales are covered, and every one of the 16 The migration misses a real cohort
preferences.contains(PERMISSION_SIGNATURE_KEY)That key arrived on 2026-07-30 with #949. For them this PR silently stops importing steps, calories, VO₂max, exercise sessions, distance, weight, The signal that doesn't have this problemWhat Android has already granted. Someone holding a granted I built and tested the change rather than sketching it, because two details only show up if you compile it. 1. The derivation, and a guarded one-time writeinternal fun categoriesFromGrantedPermissions(granted: Set<String>): Set<ImportCategory> =
ImportCategory.entries.filterTo(linkedSetOf()) { category ->
permissionsFor(setOf(category)).any { it in granted }
}
fun migrateSelectionFromGrants(context: Context, granted: Set<String>) {
if (prefs(context).getStringSet(CATEGORY_SELECTION_KEY, null) != null) return
val inferred = categoriesFromGrantedPermissions(granted)
if (inferred.isNotEmpty()) setSelectedCategories(context, inferred)
}It only writes when nothing is stored, so someone who deliberately narrows to Recovery is never 2.
|
Closes #645
Summary
Tests