Skip to content

fix(#613): give up on an MMS the carrier cannot serve - #619

Open
an1ndra wants to merge 5 commits into
Developfrom
fix/613-mms-download-giveup
Open

an1ndra wants to merge 5 commits into
Developfrom
fix/613-mms-download-giveup

Conversation

@an1ndra

@an1ndra an1ndra commented Dec 6, 2026

Copy link
Copy Markdown
Owner

v1.0.34 showed a "Downloading message" notice that kept coming back. The notice was new (#477); the loop was older. The attempt count lived in a map in MmsDownloader and requestPending cleared every row that had reached MAX_AUTO_ATTEMPTS, so every launch, WAP push and background re-check handed the same message three more attempts, with a notice each time, while MmsRetry.shouldRetryNow kept retrying past the budget on the 15-minute cooldown for as long as the process lived. No outcome was terminal: the row stayed m_type=130 and nothing ever said the message would not arrive.

  • MmsDownloadBudget persists the attempt count and a failed flag per announced row (JSON in SharedPreferences), pruned to the rows the provider still announces and capped, so it outlives the process: a budget that forgets itself is a cooldown.
  • MmsRetry.shouldRetryNow stops at the budget. WAIT_FOR_DATA stays outside it, because nothing was attempted.
  • MmsDownloader skips a given-up row in the sweep, ends the loop on a terminal outcome or a spent budget, logs the give-up, and posts the failure notice. retryFailed clears the budget and is the only thing that does.
  • MmsDownloadNotice.fail is one quiet, non-ongoing notice on its own mms_download_failed channel whose tap broadcasts MMS_DOWNLOAD_RETRY; strings in all 13 locales.
  • MmsDownloadProbe, armed only by a debug intent, reports the result a failing carrier would for one seeded row: an emulator has no MMSC to produce a 504.

Tests: MmsDownloadBudgetTest (13), MmsDownloadGiveUpTest (4, wiring), MmsRetryTest updated; testDebugUnitTest green. scripts/test-mms-download-giveup.sh (11 checks) is red on the pre-#613 sweep — the relaunch re-requested the row and the failure notice never appeared — and green after.


name: Messages
about: Kotlin + Compose SMS app. Every change needs a JUnit test and a scripts/test-*.sh run.
title: ""
labels: []

What changed

Why

Testing

  • ./gradlew testDebugUnitTest passes
  • JUnit test added under app/src/test/java/ for the changed logic
  • scripts/test-*.sh added, and it fails before the fix / passes after

Related issue

Closes #

v1.0.34 showed a "Downloading message" notice that kept coming back. The
notice was new (#477); the loop was older. The attempt count lived in a map in
MmsDownloader and requestPending cleared every row that had reached
MAX_AUTO_ATTEMPTS, so every launch, WAP push and background re-check handed the
same message three more attempts, with a notice each time, while
MmsRetry.shouldRetryNow kept retrying past the budget on the 15-minute cooldown
for as long as the process lived. No outcome was terminal: the row stayed
m_type=130 and nothing ever said the message would not arrive.

- MmsDownloadBudget persists the attempt count and a failed flag per announced
  row (JSON in SharedPreferences), pruned to the rows the provider still
  announces and capped, so it outlives the process: a budget that forgets
  itself is a cooldown.
- MmsRetry.shouldRetryNow stops at the budget. WAIT_FOR_DATA stays outside it,
  because nothing was attempted.
- MmsDownloader skips a given-up row in the sweep, ends the loop on a terminal
  outcome or a spent budget, logs the give-up, and posts the failure notice.
  retryFailed clears the budget and is the only thing that does.
- MmsDownloadNotice.fail is one quiet, non-ongoing notice on its own
  mms_download_failed channel whose tap broadcasts MMS_DOWNLOAD_RETRY; strings
  in all 13 locales.
- MmsDownloadProbe, armed only by a debug intent, reports the result a failing
  carrier would for one seeded row: an emulator has no MMSC to produce a 504.

Tests: MmsDownloadBudgetTest (13), MmsDownloadGiveUpTest (4, wiring),
MmsRetryTest updated; testDebugUnitTest green. scripts/test-mms-download-giveup.sh
(11 checks) is red on the pre-#613 sweep — the relaunch re-requested the row and
the failure notice never appeared — and green after.
Reported from a report dump: `Bubble icons: conversation_117
+94723889854|AVATAR|471ef3e7`. The shortcut signature was the display name,
the picture marker and the icon hash joined with '|', and a chat with no saved
contact is named by the sender's number — so Diagnostics, the sheet users paste
into public issues, printed that number.

- shortcutSignature is now `AVATAR:<16 hex>`: the marker stays readable, the
  name is a SHA-256 digest. Equality is all the republish check compares, so
  nothing reads the name back out.
- publishedShortcutIcons fingerprints the stored value as well, through one
  shortcutLine, so an install upgraded from a build that wrote the name in the
  clear does not print it before each chat is next posted.
- The MmsStageProbe debug line logged the recipient number; it now says
  `to=set`.

Tests: BubbleContactRefreshTest (5) pins the format, digest stability and that
neither the name nor the number survives. scripts/test-bubble-shortcut-privacy.sh
(6 checks) reads the shortcut the platform actually holds: red on the old
signature, green after. test-441-bubble-photo-back.sh anchors updated.
Two more lines in the Diagnostics text named data a public issue should not
carry:

  [send]pdu size=1185 from=insert-address-token to=+15557778597/TYPE=PLMN ...
  [download]requested row=36 attempt=1 location=http://mmsc.local/privacy...

`to` is the recipients' own numbers; the Content-Location path names the
message on the carrier's server.

MmsReportText (spi, new) masks both once, for every reader — the logcat mirror,
the recorder behind Diagnostics and the app's own download line. A number keeps
its '+', its /TYPE= suffix and its last four digits (two for a short code), so a
wrongly addressed submission is still visible. A fetch URL keeps scheme, host
and port and loses path and query, so a wrong MMSC is still visible. `cid:` and
relative part identifiers are left alone: they are PDU-internal, and the
submission trace is unreadable without them. insert-address-token is a marker,
not a person, and stays.

Tests: MmsReportTextTest (10) pins both masks and their edges; SendPduFactsTest,
MmsDebugRecorderTest and MmsFacadeTest moved to the masked expectations.
scripts/test-mms-report-privacy.sh (11 checks) sends a real MMS to a known
number and drives a real download request: red on the unmasked build (5 FAIL),
green after.
#613's author read "result code 4, http status 504" and had to guess. The codes
stay where a maintainer greps them, but each line now also says what they mean,
how far the attempt budget has gone, and what the reader can do:

  MMS content://mms/63 failed (code 4), retrying in 30 second(s):
    the carrier's server timed out (HTTP 504). Attempt 1 of 3.
  MMS content://mms/63 will not be fetched again after 3 attempt(s):
    the carrier's server timed out (HTTP 504), result code 4.
    Tap the "Couldn't download message" notification to try again.

- MmsRetry.describeFailure / describeOutcome / describeDelay hold the words.
- MmsDownloadBudget remembers the last result code and HTTP status per row, so
  the report can name the failure rather than only count attempts.
- MmsDownloadStatus.describe turns that state into one sentence per announced
  message, and MmsDownloader.describePending feeds it to Diagnostics, which
  gains a "--- MMS downloads ---" block before the raw activity trace: either
  "Nothing is waiting to be downloaded." or what each message is waiting for,
  with the last attempt dated and the one action that restarts it. No address
  appears: the report is public.

Tests: MmsDownloadStatusTest (7), plus MmsRetryTest, MmsDownloadBudgetTest and
DiagnosticsReportTest for the words, the remembered failure and the block.
scripts/test-mms-download-giveup.sh asserts the lines explain themselves and
test-mms-diagnostics.sh asserts the block reaches the real sheet.
Second half of #613: the spinner had no switch of its own. Android's per-app
notification settings now lists two categories beside Direct messages / Group
messages / Unknown senders:

  Message downloads  (low)      the "still fetching" spinner
  Download failures  (default)  the one that replaces it when the app gives up

- The ids are the ones earlier builds already created (mms_download,
  mms_download_failed), so an install that quieted one keeps that choice.
- NotificationHelper.ensureDownloadChannels creates both with the message
  categories at launch, not on the first notice: a download that has not
  happened yet is exactly when the switch could not be found.
- Names and descriptions come from resources in all 13 locales instead of the
  hardcoded English they carried.
- MmsDownloadNotice takes its channel ids from NotificationChannels, one owner
  for the poster, the settings list and Diagnostics.

Tests: NotificationChannelWiringTest pins the ids, the launch creation and the
shared mapping (17); TranslationParityTest covers the new keys.
scripts/test-mms-download-channel.sh (9 checks) asserts both channels exist
after a cold start, are named for the user, and that the spinner and the failure
notice post on different categories. Fresh install of the old build: 0 download
channels at launch; new build: both.
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