diff --git a/app/src/main/java/org/thoughtcrime/securesms/notifications/profiles/NotificationProfiles.kt b/app/src/main/java/org/thoughtcrime/securesms/notifications/profiles/NotificationProfiles.kt index 01404ce6d9..498dc6122e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/notifications/profiles/NotificationProfiles.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/notifications/profiles/NotificationProfiles.kt @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.notifications.profiles import android.content.Context import org.signal.core.util.concurrent.SignalExecutors +import org.signal.core.util.logging.Log import org.thoughtcrime.securesms.R import org.thoughtcrime.securesms.database.SignalDatabase import org.thoughtcrime.securesms.keyvalue.NotificationProfileValues @@ -22,6 +23,8 @@ import java.time.ZoneId */ object NotificationProfiles { + val TAG = Log.tag(NotificationProfiles::class.java) + @JvmStatic @JvmOverloads fun getActiveProfile(profiles: List, now: Long = System.currentTimeMillis(), zoneId: ZoneId = ZoneId.systemDefault()): NotificationProfile? { @@ -39,6 +42,7 @@ object NotificationProfiles { } if (shouldClearManualOverride(manualProfile, scheduledProfile)) { + Log.i(TAG, "Clearing manual override") SignalExecutors.UNBOUNDED.execute { SignalDatabase.recipients.markNeedsSync(Recipient.self().id) StorageSyncHelper.scheduleSyncForDataChange() diff --git a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.kt b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.kt index 8fbd03dd8c..44cdc842d0 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/storage/StorageSyncHelper.kt @@ -210,6 +210,7 @@ object StorageSyncHelper { private fun getNotificationProfileManualOverride(): AccountRecord.NotificationProfileManualOverride { val profile = SignalDatabase.notificationProfiles.getProfile(SignalStore.notificationProfile.manuallyEnabledProfile) return if (profile != null && profile.deletedTimestampMs == 0L) { + Log.i(TAG, "Setting a manually enabled profile ${profile.id}") // From [StorageService.proto], end timestamp should be unset if no timespan was chosen in the UI val endTimestamp = if (SignalStore.notificationProfile.manuallyEnabledUntil == Long.MAX_VALUE) 0 else SignalStore.notificationProfile.manuallyEnabledUntil AccountRecord.NotificationProfileManualOverride( @@ -219,6 +220,7 @@ object StorageSyncHelper { ) ) } else if (SignalStore.notificationProfile.manuallyDisabledAt != 0L) { + Log.i(TAG, "Setting a manually disabled profile ${SignalStore.notificationProfile.manuallyDisabledAt}") AccountRecord.NotificationProfileManualOverride( disabledAtTimestampMs = SignalStore.notificationProfile.manuallyDisabledAt ) @@ -296,6 +298,7 @@ object StorageSyncHelper { if (update.new.proto.notificationProfileManualOverride != null) { if (update.new.proto.notificationProfileManualOverride!!.enabled != null) { + Log.i(TAG, "Found a remote enabled notification override") val remoteProfile = update.new.proto.notificationProfileManualOverride!!.enabled!! val remoteId = UuidUtil.parseOrNull(remoteProfile.id) val remoteEndTime = if (remoteProfile.endAtTimestampMs == 0L) Long.MAX_VALUE else remoteProfile.endAtTimestampMs @@ -309,12 +312,14 @@ object StorageSyncHelper { if (localProfile == null) { Log.w(TAG, "Unable to find local notification profile with given remote id") } else { + Log.i(TAG, "Setting manually enabled profile to ${localProfile.id}") SignalStore.notificationProfile.manuallyEnabledProfile = localProfile.id SignalStore.notificationProfile.manuallyEnabledUntil = remoteEndTime SignalStore.notificationProfile.manuallyDisabledAt = System.currentTimeMillis() } } } else if (update.new.proto.notificationProfileManualOverride!!.disabledAtTimestampMs != null) { + Log.i(TAG, "Found a remote disabled notification override for ${update.new.proto.notificationProfileManualOverride!!.disabledAtTimestampMs!!}") SignalStore.notificationProfile.manuallyEnabledProfile = 0 SignalStore.notificationProfile.manuallyEnabledUntil = 0 SignalStore.notificationProfile.manuallyDisabledAt = update.new.proto.notificationProfileManualOverride!!.disabledAtTimestampMs!!