Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit de393c76 authored by Jorge Ruesga's avatar Jorge Ruesga Committed by Michael Bestas
Browse files

Telephony: Mock SMS (2/4)

This change brings the possibility of simulate the reception of SMS on real devices.
This change adds a MockSmsReceiver inside SMSDispatcher that have a BroadcastReceiver listening
for Intents.MOCK_SMS_RECEIVED_ACTION actions. This class accept the SMS simulation if and only if
Settings.Secure.ALLOW_MOCK_SMS is enabled and the sender application has the
"android.permission.SEND_MOCK_SMS" permission.

This receiver should be used in the next way:

Devs should declare <uses-permission android:name="android.permission.SEND_MOCK_SMS" />
and call it with:

Intent in = new Intent(Intents.MOCK_SMS_RECEIVED_ACTION);
in.putExtra("scAddr", "+01123456789");
in.putExtra("senderAddr", "+01123456789");
in.putExtra("msg", "This is a mock SMS message.");
sendBroadcast(in);

or

String pdu = "07914151551512f2040B916105551511f100006060605130308A04D4F29C0E";
byte[][] pdus = new byte[1][];
pdus[0] = HexDump.hexStringToByteArray(pdu);
Intent in = new Intent(Intents.MOCK_SMS_RECEIVED_ACTION);
intent.putExtra("pdus", pdus);
sendBroadcast(in);

Ported from http://review.cyanogenmod.org/#/c/23017

 + Some changes:

* Move receiver to ImsSMSDispatcher class
* Send message as SMS_DELIVER_ACTION action, so it send to the registered SMS app

Change-Id: I14cab3d8ceb484df71a676dcfa44ca1634be908d
Signed-off-by: default avatarJorge Ruesga <jorge@ruesga.com>
parent 961d3a08
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment