refactor(android): improve alarm cancellation logging in scheduler
Add detailed logging when cancelling existing alarms to aid in debugging notification scheduling issues. Logs now indicate whether an existing alarm was found and cancelled, or if no alarm existed. This improves observability when investigating duplicate notifications or scheduling conflicts.
This commit is contained in:
@@ -115,7 +115,9 @@ public class DailyNotificationScheduler {
|
|||||||
Log.w(TAG, "TTL enforcer not set, proceeding without freshness validation");
|
Log.w(TAG, "TTL enforcer not set, proceeding without freshness validation");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cancel any existing alarm for this notification
|
// Cancel any existing alarm for this notification ID to prevent duplicates
|
||||||
|
// This ensures only one alarm exists for this notification at a time
|
||||||
|
Log.d(TAG, "Phase 3: Cancelling existing alarm for notification: " + content.getId());
|
||||||
cancelNotification(content.getId());
|
cancelNotification(content.getId());
|
||||||
|
|
||||||
// Create intent for the notification
|
// Create intent for the notification
|
||||||
@@ -418,7 +420,9 @@ public class DailyNotificationScheduler {
|
|||||||
if (pendingIntent != null) {
|
if (pendingIntent != null) {
|
||||||
pendingIntentManager.cancelAlarm(pendingIntent);
|
pendingIntentManager.cancelAlarm(pendingIntent);
|
||||||
pendingIntent.cancel();
|
pendingIntent.cancel();
|
||||||
Log.d(TAG, "Cancelled notification: " + notificationId);
|
Log.d(TAG, "Cancelled existing alarm for notification: " + notificationId);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "No existing alarm found to cancel for notification: " + notificationId);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG, "Error cancelling notification: " + notificationId, e);
|
Log.e(TAG, "Error cancelling notification: " + notificationId, e);
|
||||||
|
|||||||
Reference in New Issue
Block a user