File tree Expand file tree Collapse file tree
android/app/src/main/java/com/httpsms Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -270,11 +270,27 @@ class MyFirebaseMessagingService : FirebaseMessagingService() {
270270 handleFailed(applicationContext, message.id, e.message ? : " Internal error while building or sending MMS." )
271271 return Result .failure()
272272 } finally {
273+ // Clean up any downloaded temporary files
273274 downloadedFiles.forEach { file ->
274275 if (file.exists()) {
275276 file.delete()
276277 }
277278 }
279+
280+ // Also clean up the MMS PDU file to avoid cache buildup in cases where
281+ // sendMultimediaMessage fails before the sent broadcast is delivered.
282+ try {
283+ val pduFile = java.io.File (applicationContext.cacheDir, " pdu_${message.id} .dat" )
284+ if (pduFile.exists()) {
285+ val deleted = pduFile.delete()
286+ if (! deleted) {
287+ Timber .w(" Failed to delete MMS PDU file for message ID [${message.id} ] at [${pduFile.absolutePath} ]" )
288+ }
289+ }
290+ } catch (cleanupException: Exception ) {
291+ // Best-effort cleanup; log but do not change the original result.
292+ Timber .w(cleanupException, " Error while cleaning up MMS PDU file for message ID [${message.id} ]" )
293+ }
278294 }
279295 }
280296
You can’t perform that action at this time.
0 commit comments