Problem
Notification IDs are currently scattered across multiple classes with no shared contract:
| Location |
ID |
Type |
ActiveCallNotificationBuilder.NOTIFICATION_ID |
1 |
fixed |
IncomingCallService.PLACEHOLDER_NOTIFICATION_ID |
3 |
fixed |
StandaloneCallService.NOTIFICATION_ID |
97 |
fixed |
IncomingCallNotificationBuilder.notificationId(callId) |
≥ 1000 |
dynamic (callId.hashCode) |
There is no single place to understand the full ID space, verify there are no collisions, or safely add a new notification type. The MIN_CALL_NOTIFICATION_ID = 1000 threshold that separates fixed IDs from dynamic per-call IDs is defined inside IncomingCallNotificationBuilder — invisible to anyone working in another class.
Proposed solution
Introduce a single NotificationIds object that owns all notification ID constants and the per-call ID derivation:
object NotificationIds {
const val ACTIVE_CALL = 1
const val INCOMING_CALL_PLACEHOLDER = 3
const val STANDALONE_CALL = 97
// Per-call IDs are dynamically derived and kept above this threshold
// to guarantee no collision with the fixed IDs above.
private const val CALL_ID_MIN = 1000
fun forCall(callId: String): Int =
(callId.hashCode() and Int.MAX_VALUE).coerceAtLeast(CALL_ID_MIN)
}
All existing constants and notificationId(callId) usages are migrated to reference NotificationIds.
Benefits
- The full notification ID space is visible in one place
- Collisions between fixed and dynamic IDs are impossible to introduce accidentally
- Adding a new notification type requires updating one file, making conflicts obvious
- The
CALL_ID_MIN = 1000 boundary is self-documenting in context
Related
Problem
Notification IDs are currently scattered across multiple classes with no shared contract:
ActiveCallNotificationBuilder.NOTIFICATION_IDIncomingCallService.PLACEHOLDER_NOTIFICATION_IDStandaloneCallService.NOTIFICATION_IDIncomingCallNotificationBuilder.notificationId(callId)There is no single place to understand the full ID space, verify there are no collisions, or safely add a new notification type. The
MIN_CALL_NOTIFICATION_ID = 1000threshold that separates fixed IDs from dynamic per-call IDs is defined insideIncomingCallNotificationBuilder— invisible to anyone working in another class.Proposed solution
Introduce a single
NotificationIdsobject that owns all notification ID constants and the per-call ID derivation:All existing constants and
notificationId(callId)usages are migrated to referenceNotificationIds.Benefits
CALL_ID_MIN = 1000boundary is self-documenting in contextRelated
MIN_CALL_NOTIFICATION_IDandnotificationId(callId)inIncomingCallNotificationBuilderas part of the WT-1306 fix — this refactor is the logical follow-up