jberkel / sms-backup-plus

Backup Android SMS, MMS and call log to Gmail / Gcal / IMAP
https://play.google.com/store/apps/details?id=com.zegoggles.smssync
Apache License 2.0
1.79k stars 497 forks source link

Fix: SMS restore fails on newer versions of Android (missing permissions) #1049

Closed coderFrankenstain closed 2 years ago

coderFrankenstain commented 3 years ago

Modify uses-permission to solve duplication of SMS

kurahaupo commented 2 years ago

@coderFrankenstain thankyou, looks good.

I've approved this as it can't do any harm, even if it doesn't fix the problem; but can you explain how the lack of SEND_SMS & RECV_MMS permissions causes duplicates?

coderFrankenstain commented 2 years ago

If you plan to perform any SMS/MMS-related tasks, you also need related permissions. Although the system obviously does not check these when determining eligible default application candidates, the following permissions are necessary for their corresponding operations If you miss the SEND_SMS, READ_SMS or WRITE_SMS permission when trying to perform a given operation, a SecurityException will be thrown. However, if you lack the RECEIVE_MMS permission, your application will not be able to provide related broadcasts, and nothing seems to happen when testing these functions, but when inserting data into content://sms, it will not succeed. Return null

@coderFrankenstain thankyou, looks good.

I've approved this as it can't do any harm, even if it doesn't fix the problem; but can you explain how the lack of SEND_SMS & RECV_MMS permissions causes duplicates?

@coderFrankenstain thankyou, looks good.

I've approved this as it can't do any harm, even if it doesn't fix the problem; but can you explain how the lack of SEND_SMS & RECV_MMS permissions causes duplicates?

kurahaupo commented 2 years ago

I was hoping for a drill-down, not an overview.

Let's start with "duplication" where exactly? I assumed you were getting multiple copies of messages backed up into your mail folder; or do you mean multiple copies of restored messages? or something else instead?

Are these new finer-grained permissions whose allowed functions were previously enabled by some other permissions?

Otherwise what is your reasoning for adding those two permissions in particular?

Is there evidence that an exception is being thrown because of the lack of SEND_SMS, and that in turn somehow causes duplicates? If so, please walk me through the sequence of operations and highlight which one fails. (I would expect to need WRITE_SMS to be needed to restore SMSes, but not SEND_SMS. And neither to be required for backing up.)

What are "the related broadcasts" that are enabled by RECEIVE_MMS?

Have you tested the change in a live device? Or is this merely a hypothetical fix?

-Martin

coderFrankenstain commented 2 years ago

I have tried many times, if my sms-backup does not have full SMS permissions (SEND_SMS, RECEIVE_SMS, READ_SMS, WRITE_SMS, RECEIVE_MMS), I cannot restore my SMS to the SMS application

kurahaupo commented 2 years ago

Well that's worth fixing, so this is a useful PR.

But how is that causing "duplication of SMS"? Should I perhaps rename this PR, as it fixes a different problem (e.g. "restoration fails")?

This feels like a work-around for a buggy version of Android, so it would be helpful to get an idea of how many people are likely to be affected and/or will have their problem solved by this PR.

coderFrankenstain commented 2 years ago

I think I have a problem with the wrong expression, duplication of SMS means that the text message writing to content://sms failed my device is ZET9000N android version : 10 SMS app:System default SMS application

kurahaupo commented 2 years ago

Update title to state the purpose of this patch (in this case, describe the fault that's fixed by it)