ultimate_alarm_clock icon indicating copy to clipboard operation
ultimate_alarm_clock copied to clipboard

feat: WiFi BSSID based alarm cancellation (Addition to Smart Controls)

Open kushchoudhary98 opened this issue 9 months ago • 4 comments

Description

This PR adds a new condition, WiFi Based alarm cancellation, to the Smart Controls.

By using this feature, the user will be able to auto-cancel the alarm when their device is connected to the specified Wi-Fi network.

There may occur three different conditions when alarm is about to ring (when this feature is turned ON):

  • Device connected to the same Wi-Fi Network.
  • Device connected to a different Wi-Fi Network.
  • Device not connected to any Wi-Fi Network.

Screenshot 2025-04-17 at 6 54 50 PM

Proposed Changes

  • To the Alarm Model & Profile Model

isWifiEnabled INTEGER NOT NULL DEFAULT 0,
wifiName TEXT,
wifiBSSID TEXT
  • A new file wifi_based_tile.dart
  • A new Service WifiManagerService.kt

Fixes #802

Screenshots

Screenshot 2025-04-17 at 7 09 52 PM

Screenshot 2025-04-17 at 7 11 32 PM

Checklist

  • [ ] Tests have been added or updated to cover the changes
  • [ ] Documentation has been updated to reflect the changes
  • [x] Code follows the established coding style guidelines
  • [x] All tests are passing

kushchoudhary98 avatar Apr 17 '25 13:04 kushchoudhary98

Hey @MarkisDev, can you please review this. And lemme know if anything is out of its place :)

kushchoudhary98 avatar Apr 17 '25 13:04 kushchoudhary98

Hii @kushchoudhary98 i have tested the wifi SSID based in my device iam getting an issue

https://github.com/user-attachments/assets/dcab3eef-535b-408a-973f-4a0b821cd267

the issue is when clicking on the WiFi SSID smart control, it's calling the controller's checkAndRequestPermission() method which is designed for location permissions, not WiFi permissions. This is why the dialog isn't properly opening.

mahendra-918 avatar Apr 21 '25 06:04 mahendra-918

@mahendra-918 as a matter of fact, this is also an issue with Location-Based & Weather-Based conditions. I think it's an issue with the checkAndRequestPermission(), right? I used this function since the wifi state permissions are the same as those for location.

Screenshot 2025-04-21 at 1 25 54 PM

In the below video I denied Location access and it still allows me to select the Weather Types and opens the menu for Location Selection.

https://github.com/user-attachments/assets/374e1dd6-b4b5-4c2b-8197-b2ea2c1d78d5

And If I go ahead with it, the app crashes...

WhatsApp Image 2025-04-21 at 13 15 38

kushchoudhary98 avatar Apr 21 '25 07:04 kushchoudhary98

I will soon be raising a PR for this. Great find @mahendra-918.

kushchoudhary98 avatar Apr 21 '25 07:04 kushchoudhary98