Skip to content

Bug: Guardian Angel feature fails silently and maintains incorrect UI state when permissions are denied #888

@vibhutomer

Description

@vibhutomer

Description

Description

There is a critical UX flaw in the Guardian Angel feature's permission handling. If a user toggles the feature "On" but subsequently denies the required system permissions (Phone and SMS), the application fails silently without providing any feedback. Furthermore, the UI switch remains in the "Active" (True) state, creating a false impression that the safety feature is armed when it actually lacks the necessary permissions to function.

Steps to Reproduce

  1. Navigate to the Add/Update Alarm screen.
  2. Scroll to the "Guardian Angel" toggle.
  3. Tap the switch to enable the feature.
  4. When the OS prompts for SMS and Phone permissions, select "Deny".
  5. Observe that the app provides no error message, and the switch remains in the active/green state.

Root Cause

In lib/app/modules/addOrUpdateAlarm/views/guardian_angel.dart, the showGuardianDialog() method requests permissions and uses an if (phonePerm && smsPerm) block to handle the success state. However, it lacks an else block to handle the denial state. Because the state update (toggling the switch) happens before the permission is fully granted, denying the permission leaves the controller's observable boolean in a mismatched state.

Proposed Solution

Implement an else block that programmatically reverts controller.isGuardian.value to false and triggers a Get.snackbar to inform the user why the action was aborted.

Proposed Implementation:

      } else {
        // Revert the toggle state to accurately reflect the disabled feature
        controller.isGuardian.value = false;
        
        Get.snackbar(
          'Permission Required',
          'Please enable Phone and SMS permissions in app settings to use the Guardian Angel feature.',
          snackPosition: SnackPosition.BOTTOM,
          backgroundColor: themeController.secondaryBackgroundColor.value,
          colorText: themeController.primaryTextColor.value,
          duration: const Duration(seconds: 4),
        );
      }

### Screenshots

_No response_

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions