add data SMS receiving
This commit is contained in:
parent
a932d440eb
commit
76bd47869d
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -32,6 +32,8 @@
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
|
||||
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/>
|
||||
<data android:host="localhost" android:port="5499" android:scheme="sms"/>
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
</application>
|
||||
|
@ -15,7 +15,8 @@ class SmsReceiver : BroadcastReceiver() {
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
if (intent.action == Telephony.Sms.Intents.SMS_RECEIVED_ACTION) {
|
||||
if (intent.action == Telephony.Sms.Intents.SMS_RECEIVED_ACTION ||
|
||||
intent.action == Telephony.Sms.Intents.DATA_SMS_RECEIVED_ACTION) {
|
||||
val bundle: Bundle? = intent.extras
|
||||
bundle?.let {
|
||||
val pdus = bundle.get("pdus") as Array<ByteArray>
|
||||
@ -23,6 +24,9 @@ class SmsReceiver : BroadcastReceiver() {
|
||||
val smsMessage =
|
||||
SmsMessage.createFromPdu(pdu, bundle.getString("format"))
|
||||
smsMessage?.let {
|
||||
if (intent.action == Telephony.Sms.Intents.DATA_SMS_RECEIVED_ACTION) {
|
||||
Log.d(TAG, "Data SMS received on port 5499")
|
||||
}
|
||||
val messageBody = smsMessage.messageBody
|
||||
Log.d(TAG, "Message body: $messageBody")
|
||||
val pduHexString = pdu.toHexString()
|
||||
|
Loading…
Reference in New Issue
Block a user