Silleellie / dnd-bedtime-sync

Sync DND state and BedTime mode between Android phone and watch
31 stars 3 forks source link

DNDSync

This App was developed to enable synchronization between the smartphone and the Galaxy Watch 4 of the Do Not Disturb (DND) and Bedtime mode from Digital Wellbeing. DND synchronization is only supported officially if using a Samsung phone with this smartwatch, Bedtime mode synchronization is only newly available for the newest Pixel Watch 2:

Functionalities:

Majority of the credits goes to @rhaeus for the initial developing of this app and to @DreadedLama for the initial developing of a better bedtime mode implementation!

Tested on Nothing Phone (1) (Android 13) paired with a Galaxy Watch 4 (40mm, Wear OS 4.0)

Setup

Manual installation is required. The use of ADB is required. (Don't worry, it's very easy!)

Phone

  1. Install the app dndsync-mobile.apk on the phone via adb
    • Enable USB Debugging in the Developer Options of your phone and the connect it to the PC
    • Run adb install dndsync-mobile.apk
  2. Disconnect the phone from the PC
    • Disable USB Debugging from the Developer Options of your phone
  3. Open the app and grant the permission for DND Access and Bedtime Access by clicking on the menu entry DND-Bedtime Permission. This will open the permission screen.
    • This Permission is required so that the app can read/write DND state and read Bedtime mode. Without this permission, the sync will not work.
  4. Go back on the app and check that DND-Bedtime Permission now says DND-Bedtime access granted (you may need to tap on the menu entry for it to update)

Watch

Setting up the watch is a bit more tricky since the watch OS lacks the permission screen for DND access, but the permission needed can be easily set via ADB!

Note: This is only tested on my Galaxy Watch 4 and it might not work on other devices!

  1. Connect the watch to your computer via adb (watch and computer have to be in the same network!)
    • Enable Developer Options: Go to Settings -> About watch -> Software -> tap the Software version 5 times -> developer mode is on (you can disable it in the same way)
    • Enable ADB debugging and Debug over WIFI (in Settings -> Developer Options)
    • Click on Pair new device
    • Note the watch IP address and port, something like 192.168.0.100:5555
    • Note also the pair key, something like 123456
    • Pair the watch with adb pair 192.168.0.100:5555 123456 (insert your value!)
    • Check that now your PC is listed under Paired devices and there's a text under it saying Currently connected
      • If not, perform adb connect 192.168.0.100:6666 with the IP address and port listed in the Debug over WIFI screen
  2. Install the app dndsync-wear.apk on the watch
    • Run adb install dndsync-wear.apk
  3. Grant permission for DND access (This allows the app to listen to DND changes and to change the DND setting)
    • Run adb shell cmd notification allow_listener it.silleellie.dndsync/it.silleellie.dndsync.DNDNotificationService
  4. Grant permission for Secure Setting access (This allows the app to change BedTime mode setting on the watch)
    • Run adb shell pm grant it.silleellie.dndsync android.permission.WRITE_SECURE_SETTINGS
  5. Open the app on the watch, scroll to the permission section and check if both DND Permission and Secure Settings Permission say Granted (you may need to tap on the menu entries for them to update)
  6. IMPORTANT: Disable ADB debugging and Debug over WIFI, because these options drain the battery!

Preferences options

Phone preferences

Watch preferences

To do (developers)

There are only two flags which the Power saver mode of this app does not enable but which are enabled by the Power saver mode of the watch itself:

Pull requests are welcome!

Note

If you are unable to "Allow Notification Access" to the mobile app and it is faded, go the apps section in Settings, open DNDSync app, click 3 dots on top right and grant "Allow Restricted Settings" access. Now you'll be able to grant the Notification access to mobile app.