Skip to content

Guard Android CallStyle notifications against empty caller names#116

Merged
WesUnwin merged 3 commits into
developfrom
copilot/ensure-native-logic-does-not-crash
Jun 2, 2026
Merged

Guard Android CallStyle notifications against empty caller names#116
WesUnwin merged 3 commits into
developfrom
copilot/ensure-native-logic-does-not-crash

Conversation

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown

Android foreground call notifications were crashing when the call peer name was null/blank. NotificationCompat.CallStyle.forOngoingCall(...) requires a Person with a non-empty name and throws IllegalArgumentException otherwise.

  • Crash containment

    • In OngoingCallNotification.build(), introduced a sanitized local safePeerName.
    • Fallback behavior: null or whitespace-only peerName now resolves to "unavailable".
  • CallStyle path hardening (API 28+)

    • Person.Builder().setName(...) now uses safePeerName so CallStyle.forOngoingCall(...) always receives a valid person name.
  • Consistency for non-CallStyle path

    • Legacy notification content text (setContentText) now also uses safePeerName to keep display behavior aligned across API levels.
String safePeerName = peerName;
if (safePeerName == null || safePeerName.trim().isEmpty()) {
    safePeerName = "unavailable";
}

Person callerPerson = new Person.Builder()
        .setName(safePeerName)
        .setImportant(true)
        .build();

@WesUnwin

WesUnwin commented Jun 2, 2026

Copy link
Copy Markdown
Member

@copilot remove all iOS related changes from this PR.

Copilot AI commented Jun 2, 2026

Copy link
Copy Markdown
Author

@copilot remove all iOS related changes from this PR.

Done in commit 4584668. All iOS-related changes were removed from this PR.

Copilot AI requested a review from WesUnwin June 2, 2026 17:46
@WesUnwin WesUnwin marked this pull request as ready for review June 2, 2026 17:49
Copilot AI review requested due to automatic review settings June 2, 2026 17:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Android ongoing-call foreground notifications against crashes when the peer/caller name is null or blank, ensuring NotificationCompat.CallStyle.forOngoingCall(...) always receives a Person with a valid non-empty name.

Changes:

  • Introduces safePeerName in OngoingCallNotification.build() with a fallback to "unavailable" when the provided peerName is null or whitespace-only.
  • Uses safePeerName when building the Person for CallStyle notifications (API 28+ path).
  • Uses safePeerName in the legacy (non-CallStyle) notification content text to keep behavior consistent across API levels.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@WesUnwin WesUnwin merged commit 48bb945 into develop Jun 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants