fix(android): permissions wizard

This commit is contained in:
devthejo 2025-09-26 14:49:54 +02:00
parent 4f132cebe2
commit a29501bb7c
No known key found for this signature in database
GPG key ID: 00CCA7A92B1D5351

View file

@ -111,24 +111,23 @@ const HeroMode = () => {
// Don't change step immediately to avoid race conditions // Don't change step immediately to avoid race conditions
console.log("Starting permission requests..."); console.log("Starting permission requests...");
// Request battery optimization FIRST (opens Android Settings) // Request background location last (after user returns from Settings if needed)
// This prevents the bubbling issue by handling Settings-based permissions before in-app dialogs const locationGranted = await requestPermissionLocationBackground();
const batteryOptDisabled = await handleBatteryOptimization(); permissionsActions.setLocationBackground(locationGranted);
console.log("Battery optimization disabled:", batteryOptDisabled); console.log("Location background permission:", locationGranted);
// Request motion permission second // Request motion permission second
const motionGranted = await requestPermissionMotion.requestPermission(); const motionGranted = await requestPermissionMotion.requestPermission();
permissionsActions.setMotion(motionGranted); permissionsActions.setMotion(motionGranted);
console.log("Motion permission:", motionGranted); console.log("Motion permission:", motionGranted);
// Request background location last (after user returns from Settings if needed)
const locationGranted = await requestPermissionLocationBackground();
permissionsActions.setLocationBackground(locationGranted);
console.log("Location background permission:", locationGranted);
// Only set step to tracking after all permission requests are complete
permissionWizardActions.setCurrentStep("tracking"); permissionWizardActions.setCurrentStep("tracking");
await new Promise((resolve) => setTimeout(resolve, 2000));
const batteryOptDisabled = await handleBatteryOptimization();
console.log("Battery optimization disabled:", batteryOptDisabled);
// Check if we should proceed to success immediately // Check if we should proceed to success immediately
if (locationGranted && motionGranted && batteryOptDisabled) { if (locationGranted && motionGranted && batteryOptDisabled) {
permissionWizardActions.setHeroPermissionsGranted(true); permissionWizardActions.setHeroPermissionsGranted(true);