SimpleMobileTools / Simple-SMS-Messenger

An easy and quick way of managing SMS and MMS messages without ads.
https://www.simplemobiletools.com
GNU General Public License v3.0
600 stars 218 forks source link

Migrate to View binding, SDK 34 and Version catalogs #726

Closed naveensingh closed 1 year ago

naveensingh commented 1 year ago

Major changes:

Minor changes:

Testing:

I tested most of the features on an Android 14 emulator and no issues were found. Since I can not test MMS messages, please test the following cases:

tibbi commented 1 year ago

make activity binding consistent with Calculator please, like private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMainBinding.inflate(layoutInflater) }

tibbi commented 1 year ago

make activity binding consistent with Calculator please, like private val binding by lazy(LazyThreadSafetyMode.NONE) { ActivityMainBinding.inflate(layoutInflater) }

nevermind, forgot viewBinding is a helper extension, so its ok...

naveensingh commented 1 year ago

applied suggested changes, check again, please.

tibbi commented 1 year ago

looks good, thanks :)

naveensingh commented 1 year ago

Are you not getting any crashes when receiving MMS on Android 14 without including https://github.com/tibbi/android-smsmms/pull/15?

tibbi commented 1 year ago

Are you not getting any crashes when receiving MMS on Android 14 without including tibbi/android-smsmms#15?

right, havent tested that one, will do it now

tibbi commented 1 year ago

got a crash at trying to add another person into a conversation Process: com.simplemobiletools.smsmessenger.debug, PID: 17089 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. Make sure your adapter calls notifyDataSetChanged() when its content changes. [in ListView(-1, class android.widget.DropDownListView) with Adapter(class com.simplemobiletools.smsmessenger.adapters.AutoCompleteTextViewAdapter)] at android.widget.ListView.layoutChildren(ListView.java:1715) at android.widget.AbsListView.onLayout(AbsListView.java:2263) at android.view.View.layout(View.java:24421) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:24421) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) at android.widget.FrameLayout.onLayout(FrameLayout.java:270) at android.view.View.layout(View.java:24421) at android.view.ViewGroup.layout(ViewGroup.java:6440) at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4258) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3583) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2465) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:9305) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1339) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1348) at android.view.Choreographer.doCallbacks(Choreographer.java:952) at android.view.Choreographer.doFrame(Choreographer.java:882) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1322) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294)

tibbi commented 1 year ago

receiving mms on Android 14 doesnt work, not even onMessageReceived triggers in MmsReceiver.

tibbi commented 1 year ago

sending works. Both sending a file and group message. Checked device settings, I dont think it is an issue in the system itself, allowed everything I could.

tibbi commented 1 year ago

guess someone else should also check this app to be able to work with MMS directly. Maybe @fatihergin, can you send MMS and do you have 2 SIM cards?

naveensingh commented 1 year ago

got a crash at trying to add another person into a conversation

https://github.com/SimpleMobileTools/Simple-SMS-Messenger/pull/729 fixes this. Not sure why no one noticed it before, it should be there in the play console crash reports.

naveensingh commented 1 year ago

Since I can't test the MMS issue without messing around working up a dummy PDU, here are some pointers:

Before MmsReceiver.onMessageReceived() is called, PushReceiver.onReceive() is called which parses the MMS pdu and calls DownloadManager.downloadMultimediaMessage().

DownloadManager.downloadMultimediaMessage() then calls SmsManager.downloadMultimediaMessage() with a pending intent that will call MmsReceiver.onMessageReceived() once the MMS message is downloaded.

Adding a few breakpoints in PushReceiver and DownloadManager should help figure out the problem.

naveensingh commented 1 year ago

receiving mms on Android 14 doesnt work

@tibbi does receiving MMS still work on Android 13 and below? (with https://github.com/tibbi/android-smsmms/pull/15 applied)

tibbi commented 1 year ago

nope, it is actually quite broken on Android 13 too

tibbi commented 1 year ago

if I try attaching an image, I get "An unknown error occurred" and while it is seemingly sent well, the receiving side gets an error like File cannot be opened. Receiving on Android 13 doesnt work either

tibbi commented 1 year ago

maybe try reverting to targetSDK 33 if it worked well there, until rewritten properly.. There are already many changes in this app update, like viewbinding rewrite, recycle bin and archive.

fatihergin commented 1 year ago

guess someone else should also check this app to be able to work with MMS directly. Maybe @fatihergin, can you send MMS and do you have 2 SIM cards?

i can just send mms with an android 12 device. unfortunately don't have 2 sim card, but i was able to test receiving mms once, and it worked on my android 12 device. sending mms also worked on the same device. i did my tests with current master 166998f

tibbi commented 1 year ago

how about @esensar , do you have an Android 14, can you send MMS and maybe have 2 SIM cards?

naveensingh commented 1 year ago

if I try attaching an image, I get "An unknown error occurred" and while it is seemingly sent well, the receiving side gets an error like File cannot be opened

@tibbi that is conflicting. An unknown error occurred is shown only if contentResolver.getType(uri) returns null or if glide fails to load the image. In both these cases, the attachment is immediately removed and it's not possible to send it. I double-checked this with a defective image (on Android 13). Did you get 'An unknown error occurred' after you hit send?

tibbi commented 1 year ago

I got the error right after selecting the wanted image at the file picker, but it still showed the image and I could send it as MMS too. Everything is shown correctly on the senders side, like it succeeded.

esensar commented 1 year ago

how about @esensar , do you have an Android 14, can you send MMS and maybe have 2 SIM cards?

I don't have Android 14 on a physical device yet unfortunately. I will see if I can get a hold of one.

naveensingh commented 1 year ago

Ok guys, for future reference, here's a method to trigger a fake MMS push on any Android version (android 14 emulator too):

private fun triggerFakeMmsPush() {
        val pushData = byteArrayOf(-116, -126, -104, 84, 49, 56, 97, 50, 49, 55, 49, 100, 99, 54, 98, 0, -115, -110, -120, 5, -127, 3, 9, 58, -128, -118, -128, -114, 2, 4, 0, -125, 104, 116, 116, 112, 58, 47, 47, 54, 57, 46, 55, 56, 46, 55, 48, 46, 55, 48, 47, 115, 101, 114, 118, 108, 101, 116, 115, 47, 109, 109, 115, 63, 109, 101, 115, 115, 97, 103, 101, 45, 105, 100, 61, 84, 49, 56, 97, 50, 49, 55, 49, 100, 99, 54, 98, 0)
        val result = PduParser(pushData).parse()
        val transactionId = String((result as NotificationInd).transactionId)
        val selection = Telephony.Mms.TRANSACTION_ID + " = ?"
        val selectionArgs = arrayOf(transactionId)
        val deleted = contentResolver.delete(
            Telephony.Mms.CONTENT_URI, selection, selectionArgs
        )
        Log.d("MmsTest", "deleted previous notification: $deleted")
        Log.d("MmsTest", "Triggering fake MMS push...")
        PushReceiver().onReceive(this, Intent().apply {
            type = ContentType.MMS_MESSAGE
            action = Telephony.Sms.Intents.WAP_PUSH_RECEIVED_ACTION
            putExtras(bundleOf("data" to pushData))
        })
    }

If everything is working properly, android-smsmms will try to download the mms and fail with a FileNotFoundException which you can spot in the logcat.

If anyone is interested in providing a sample pdu.dat file (this may contain your personal info e.g. phone number), I'll be able to completely test receiving MMS messages:

  1. Connect your device and run the following:
    adb shell
    run-as com.simplemobiletools.smsmessenger.debug
    while true; do cp cache/download.*.dat /sdcard/ || true; done
  2. Send a sample MMS message to your MMS-supported device from some other device.
  3. A download.RANDOM_NUMBER.dat file should be there in the root sdcard folder after a few minutes.

@tibbi

receiving mms on Android 14 doesnt work, not even onMessageReceived triggers in MmsReceiver.

naveensingh commented 1 year ago

Side note: If you have a recent device with an unlocked bootloader, you might be able to boot an Android 14 GSI

esensar commented 1 year ago

I pulled the latest code from master and installed it on my Android 14 device with dual SIM (one of them MMS enabled). Sending MMS worked for me, but receiving seems to have some issues.

It seems that some receiver is missing the exported attribute, which is mandatory starting with Android 14. I will open a PR for android-smsmms

naveensingh commented 1 year ago

@esensar could you please try again with https://github.com/tibbi/android-smsmms/pull/16 included? I added the missing RECEIVER_EXPORTED flag there.

esensar commented 1 year ago

@esensar could you please try again with tibbi/android-smsmms#16 included? I added the missing RECEIVER_EXPORTED flag there.

Yeah, that was the spot where it crashed. It should work, I will let you know.

esensar commented 1 year ago

Yeah, it is working now :tada: