Framework Base: Allow Mock SMS (1/2)
This change brings the possibility of simulate the reception of SMS on real devices. Fow now,
the only way of simulate the reception of SMS is using the android emulator, but this hasn't have
a CM10 image.
This change adds a MockSmsReceiver inside SMSDispatcher that have a BroadcastReceiver listening
for Intents.MOCK_SMS_RECEIVED_ACTION action. This class accept the SMS simulation if and only if
Settings.Secure.ALLOW_MOCK_SMS is enabled. The application that sends the mock SMS
requires the "android.permission.SEND_MOCK_SMS" permission.
This receiver should be used in the next way:
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);
Patch 2: * Protect the mock SMS BroadcastReceiver with the permission "android.permission.SEND_MOCK_SMS".
This permission is required for send mock SMSs, in addition to ALLOW_MOCK_SMS system setting.
* Add result to ordered broadcast requests.
Activity.RESULT_OK -> Ok. At least one message was sent
Activity.RESULT_CANCELED -> Error. No messages were sent
Patch 3: English typos
Patch 4: Add Marco Brohet's suggestion
Change-Id: I5322cf748449a863ea8e8deda977108b9b58a413
Loading
Please register or sign in to comment