youngj / EnvayaSMS

Simple SMS and MMS gateway running on Android
http://sms.envaya.org
Other
161 stars 177 forks source link

force quitting after phone receives MMS #22

Closed regaladys closed 12 years ago

regaladys commented 12 years ago

EnvayaSMS force quits after phone receives an MMS message. Envaya restarts and logs do not indicate receiving an MMS.

youngj commented 12 years ago

What version of Android does your phone have? (Settings -> About phone -> Firmware version)

If someone experiencing this bug has the Android SDK installed on their computer, they could connect the phone and use "adb logcat" to get the stack trace for the exception ... that would help me figure out how to fix it.

Android does not have an official API for apps to interact with MMS, so it is possible that MMS would break in different versions of Android from what I tested with.

regaladys commented 12 years ago

Android version 2.3.6 Kernel version 2.6.35.7

mfb commented 12 years ago

I have also seen a couple of crashes while receiving MMS messages, on Android 2.3.4. Both times upon receiving a large high-res picture that I sent to myself.. sent it to myself again and was able to process it without a crash.

youngj commented 12 years ago

Interesting. The only Android phone I have at the moment is running Android 2.1. And the largest images I've tested with are around 35 KB (haven't seen any crashes yet). How large are the files you're sending?

Unless I can find some way to reproduce the crash myself, I would need someone to send me a stack trace of the exception that causes the crash. Basically the steps are:

mfb commented 12 years ago

The message size that is causing a crash pretty consistently is 1208 KB for the sent message and 406 KB for the received message (according to "View message details" in the messaging app) - I sent it to myself so there are two entries (and I guess the photo was automatically reduced to a smaller file size)

mfb commented 12 years ago

Here is a sample crash. Note it does not always crash. In fact, after being unable to reproduce the crash, I rebooted my phone, and then was able to make it crash again...

03-09 23:45:33.055 2020 2705 D EnvayaSMS: New MMS id=215 in inbox 03-09 23:45:33.055 2020 2705 W dalvikvm: threadid=17: thread exiting with uncaught exception (group=0x40018560) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: FATAL EXCEPTION: IntentService[CheckMmsInboxService] 03-09 23:45:33.063 2020 2705 E AndroidRuntime: java.lang.NullPointerException 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at org.envaya.sms.App.isForwardablePhoneNumber(App.java:689) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at org.envaya.sms.IncomingMessage.isForwardable(IncomingMessage.java:46) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at org.envaya.sms.CheckMmsInboxService.onHandleIntent(CheckMmsInboxService.java:46) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at android.os.Looper.loop(Looper.java:130) 03-09 23:45:33.063 2020 2705 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:60) 03-09 23:45:33.079 1310 1457 W ActivityManager: Force finishing activity org.envaya.sms/.ui.Main 03-09 23:45:33.220 1310 1340 I ActivityManager: Resumed Activity: org.envaya.sms/.ui.Main totalTime: 5606 ms 03-09 23:45:33.352 2126 2632 I Transaction: MMS-STATUS-DURATION, result=1, uri=content://mms/inbox/215, trans id=11E1122338E000008540000101, bytes sent=0, bytes rec=406602, type=0, created=23:45:10, finished=23:45:33, duration=22876ms, rate=17774 bytes/seg, state=1

youngj commented 12 years ago

Perfect, that's exactly what I needed.

The app crashes there because the 'from' address of the IncomingMms is null. It seems that depending on timing, EnvayaSMS may attempt to read the sender address from the Android MMS database before it's written to the database.

It seems a likely fix would be for MmsUtils.getMessagesInInbox() to skip the MMS if getSenderNumber(id) returns null.

Although depending on whether Android notifies MmsUtils.OBSERVER_URI again, it may need to retry after a timeout.

youngj commented 12 years ago

Fixed in version 2.0.5.