jberkel/sms-backup-plus — pull request #388 by beverloo (2013-11-04 17:40:40+00:00)
Title: [NOT A PULL REQUEST] Request SMS Backup+ to be the default SMS package before restoring

Request SMS Backup+ to be set as the default SMS package before restoring.

**THIS PATCH HAS A NUMBER OF TODOS AND SHOULD NOT LAND AS IS.**

Starting with Android KitKat, only the default SMS package is allowed to
write to the SMS provider. Because SMS Backup+ did not register for the
ComposeSmsActivity activity or the receivers at all, it could not be set
as such, rendering the restore functionality useless in KitKat.

This patch somewhat hacks the necessary functionality in the application to
make it possible to import SMS messages again. It adds the necessary
receivers and activity to the AndroidManifest.xml file (but does not become
the default SMS app by default) and adds some logic to the restore flow:

* When starting the restore, request to become the default SMS package
if the user is running KitKat or higher and it's not already.
* If the default SMS activity has changed, add this as an intent with
which we're launching the service.
* In the SmsRestoreService, abort restoring if we're not able to write
to the SMS provider. A better message should be added here.
* After the restore finished, check if the previous-sms-provider intent
extra has been set. If so, ask the user to restore to that activity.

It's important to reset the default SMS provider to something that's not
SMS Backup+, because otherwise incoming messages will disappear in a black
hole. There's a lot of user interaction involved here, but I'm not sure if
there's a good way around that.

This patch is not ready to land, but I hope it gives you a good idea about
what's needed to fix restore for Android KitKat and higher. It allowed me
to import my SMS messages just fine :-). Thanks for the great app!