Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not crash if mms part data is not exist #42

Closed
keydon3 opened this issue Jul 30, 2022 · 6 comments
Closed

Do not crash if mms part data is not exist #42

keydon3 opened this issue Jul 30, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@keydon3
Copy link

keydon3 commented Jul 30, 2022

When i export messages with "Include (encoded) binary MMS data", i get fatal error:

07-30 22:41:37.675  7582  7582 D MediaScannerReceiver: action: android.intent.action.MEDIA_SCANNER_SCAN_FILE path: /storage/emulated/0/backup/messages.json
07-30 22:41:37.715  5454  5454 E AndroidRuntime: FATAL EXCEPTION: main
07-30 22:41:37.715  5454  5454 E AndroidRuntime: Process: com.github.tmo1.sms_ie, PID: 5454
07-30 22:41:37.715  5454  5454 E AndroidRuntime: java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1410)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1247)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at android.content.ContentResolver.openInputStream(ContentResolver.java:967)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at com.github.tmo1.sms_ie.ImportExportKt.mmsToJSON(ImportExport.kt:374)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at com.github.tmo1.sms_ie.ImportExportKt.access$mmsToJSON(ImportExport.kt:1)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at com.github.tmo1.sms_ie.ImportExportKt$mmsToJSON$1.invokeSuspend(Unknown Source:17)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
07-30 22:41:37.715  5454  5454 E AndroidRuntime:        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
07-30 22:41:37.719  1243  2063 W ActivityManager:   Force finishing activity com.github.tmo1.sms_ie/.MainActivity
07-30 22:41:37.723  1243  2063 E LightsService: Light requested not available on this device. 2
07-30 22:41:37.726  1243  2063 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:966 com.android.server.am.AppErrors.crashApplicationInner:393 com.android.server.am.AppErrors.crashApplication:321 com.android.server.am.ActivityManagerService.handleApplicationCrashInner:14489 com.android.server.am.ActivityManagerService.handleApplicationCrash:14471 
07-30 22:41:37.728  1243  1262 I ActivityManager: Showing crash dialog for package com.github.tmo1.sms_ie u0

Tail in messages.json:

    "parts": [
      {
        "_id": "6",
        "mid": "5",
        "seq": "-1",
        "ct": "application/smil",
        "cid": "<smil>",
        "cl": "smil.xml",
        "text": "<smil>...</smil>"
      },
      {
        "_id": "7",
        "mid": "5",
        "seq": "0",
        "ct": "image/jpeg",
        "cid": "<image000000>",
        "cl": "image000000.jpg",
        "_data": "/data/user_de/0/com.android.providers.telephony/app_parts/PART_1617028091818_image000000.jpg"

Probably it's because the file doesn't exist:

/data/user_de/0/com.android.providers.telephony/app_parts # ls PART_1617028091818_image000000.jpg
ls: PART_1617028091818_image000000.jpg: No such file or directory

Without "Include (encoded) binary MMS data" all works fine.

@tmo1
Copy link
Owner

tmo1 commented Aug 5, 2022

Thank you for reporting this. I'm not sure why Android is providing us with the name of a non-existent file, but perhaps we need to add some sort of null check to work around this. Is this a normal Android system, or have you done low-level manipulation of the filesystem, perhaps deleting the JPG file in question?

@tmo1 tmo1 added the bug Something isn't working label Aug 5, 2022
@tmo1 tmo1 self-assigned this Aug 5, 2022
@keydon3
Copy link
Author

keydon3 commented Aug 27, 2022

Is this a normal Android system, or have you done low-level manipulation of the filesystem, perhaps deleting the JPG file in question?

I didn't do any low-level manipulations and didn't delete the JPG file. But I can't guarantee that some software didn't. I'm using a custom build of android (crDroid 4.7 on android 8.1.0), but I will assume that it works like a "normal" android.

@tmo1
Copy link
Owner

tmo1 commented Aug 28, 2022

Thank you. I should probably add a check for problems, even if I don't understand why they would occur :)

@tmo1
Copy link
Owner

tmo1 commented Aug 30, 2022

I've attached a patched version of the app that should catch and log any exceptions thrown when trying to access MMS binary message parts and then continue with the export. Please test it and report back here, if you can.
catch-mms-part-access-exceptions.zip

@keydon3
Copy link
Author

keydon3 commented Sep 18, 2022

catch-mms-part-access-exceptions.zip perfectly works without any errors

@tmo1
Copy link
Owner

tmo1 commented Sep 19, 2022

catch-mms-part-access-exceptions.zip perfectly works without any errors

Thank you! Closing.

[Edit:] It's this commit (below in the thread) that fixes the problem.

@tmo1 tmo1 closed this as completed Sep 19, 2022
tmo1 added a commit that referenced this issue Sep 20, 2022
Catch (and log) exceptions (e.g., FileNotFoundException) thrown when
trying to access binary data of MMS parts during export.

Closes: #42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants