Skip to content

feat: a sent contact is a real vCard, not its text - #508

Merged
an1ndra merged 1 commit into
Developfrom
fix/contact-vcard
Nov 19, 2026
Merged

an1ndra merged 1 commit into
Developfrom
fix/contact-vcard

Conversation

@an1ndra

@an1ndra an1ndra commented Nov 19, 2026

Copy link
Copy Markdown
Owner

What changed

The Contact tile now sends a real vCard: an MMS part typed text/x-vcard, named contact.vcf, instead of pasting the card's properties into the body of a text message.

  • The tile writes the card to the cache and sends it as the contact kind; the send path declares the part type and the MMS builder names it contact.vcf.
  • The chat draws a contact row as a card — the name and number, with the person badge — read back from the attachment, so it survives the cache file being cleaned up. The raw BEGIN:VCARD properties never reach the screen.
  • The conversation preview says "Contact" instead of "Voice message", and saving a card writes a .vcf rather than a .bin.
  • A contact that cannot be read (denied READ_CONTACTS, or a contact with no number) now says so; it used to do nothing at all.

Why

Attaching a contact stored the vCard as the message body. The receiving phone — Google Messages included — shows that as a wall of BEGIN:VCARD properties: a text message, not a contact. Only the attachment form is a card.

Also removed: ContactCard.kt, a second vCard builder left unused by an earlier merge, which held the name folding the live one was missing. A contact saved with a line break or a semicolon in the name produced a malformed card; ContactShare now folds both.

Testing

  • ./gradlew testDebugUnitTest passes (and :mms:test)
  • JUnit test added under app/src/test/java/ (ContactShareTest, ContactCardWiringTest, MmsSupportTest, SendReqBuilderTest)
  • scripts/test-*.sh added, and it fails before the fix / passes after

scripts/test-contact-card.sh on emulator-5556: 5 passed, 0 failed. On the previous build the same run fails the three that matter:

[FAIL] the message is stored as 'text', not a contact card
[FAIL] no .vcf attachment behind the card (uri: none)
[FAIL] the chat did not draw a card (raw vCard text, or no number)

The stored row after the fix (emulator-5556, MMS itself cannot leave an emulator without a carrier):

id=37  media_type=contact  body=''  media_uri=content://com.anindra.messages.fileprovider/mms/vcard/contact_1795086525627.vcf

and the PDU level, from SendReqBuilderTest:

part.contentType = text/x-vcard
part.name        = contact.vcf

Related issue

None — reported while checking that a contact arrives as a card.

Note: this changes the transport. A contact now costs an MMS (data / carrier MMS profile) instead of an SMS, and fails where MMS is unavailable — the same as sending a photo.

Attaching a contact pasted the vCard into the body of a text message, so
the receiving phone showed a wall of BEGIN:VCARD properties — a message,
not a contact. It now leaves as an MMS part: `text/x-vcard`, named
`contact.vcf`, which is what a contacts app on the other end turns into a
card it can save.

- The tile writes the card to the cache and sends it as the `contact`
  kind; the send path declares the part's type and the MMS builder names
  it `contact.vcf`.
- The chat draws a `contact` row as a card: the name and number read back
  from the attachment (so it survives the cache file being cleaned up),
  with the person badge; the raw properties never reach the screen.
- The conversation preview says "Contact" instead of "Voice message".
- Saving a card writes a .vcf rather than a .bin.
- A contact that cannot be read — a denied READ_CONTACTS, a contact with
  no number — now says so. It used to do nothing at all.

ContactCard.kt was a second, unused vCard builder left behind by an
earlier merge, with the name folding the live one was missing: a name
with a line break or a semicolon produced a malformed card. ContactShare
now folds both, and the duplicate object and its test are gone.

JUnit: ContactShareTest (the card's shape, folding, read-back),
ContactCardWiringTest (the tile writes and sends a card, the chat draws
one), MmsSupportTest (the wire type, the preview, the saved name) and a
SendReqBuilderTest case pinning the part as text/x-vcard named
contact.vcf.

scripts/test-contact-card.sh: 5 checks on emulator-5556, 0 failed; on the
previous build the same run fails the three that matter — the message is
stored as `text`, has no .vcf, and the chat shows the raw properties.
@an1ndra
an1ndra merged commit 01cea7b into Develop Nov 19, 2026
1 check failed
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.

1 participant