Skip to content

Instantly share code, notes, and snippets.

@lucianogiuseppe
Created March 29, 2022 13:48
Show Gist options
  • Save lucianogiuseppe/758bb8471fe0119e7b55232343af9ecc to your computer and use it in GitHub Desktop.
Save lucianogiuseppe/758bb8471fe0119e7b55232343af9ecc to your computer and use it in GitHub Desktop.
Android 11 send SMS by ADB

Android 11

Before run the adb command you must enable the Developer Options on your Android phone, then enable USB Debug (to use ADB) and disable Permission Monitoring

Run:

adb shell service call isms 5 i32 1 s16 "com.android.mms.service" s16 "null" s16 "+39phonenumber" s16 "null" s16 "hello\ world\ " s16 "null" s16 "null" i32 1 i32 0

The method is :

// link : https://github.com/aosp-mirror/platform_frameworks_base/blob/android11-release/telephony/java/com/android/internal/telephony/ISms.aidl
    void sendTextForSubscriber(in int subId, String callingPkg, String callingAttributionTag,
            in String destAddr, in String scAddr, in String text, in PendingIntent sentIntent,
            in PendingIntent deliveryIntent, in boolean persistMessageForNonDefaultSmsApp,
            in long messageId);
            
  • subId : SIM index ( 0 or 1 ) Not 1 and 2 !!

  • callingPkg : SMS Package name -> "com.android.mms.service"

  • destAddr : Receiver Number

  • scAddr : Number of SMS service center --> we don't care so we put "null" to set it to default value.

  • text : Message Body

  • sentIntent : we don't care so we put "null" to set it to default value.

  • deliveryIntent : we don't care so we put "null" to set it to default value.

For other Android versions see this tutorial and this adb tutorial

@BorisAdams
Copy link

Thanks! Worked for me FIRST TIME targetting Android 11 Go.

Two notes:

"+39phonenumber" is the international number for Italy. In Australia, for example, use " +61412345678". It also works without the country code, so in Australia "0412345678".

The message must be escaped for special characters, so, eg. "Hello, world!" becomes "Hello,\ world!". (hint: in linux use printf '%q\n' "Hello, world!" to automatically escape a string.

@jflaflamme
Copy link

jflaflamme commented Nov 10, 2024

cat generate_sms.sh

#!/bin/bash
SENDER=$1
MESSAGE=`printf '%q\ ' $2`
echo 'adb shell service call isms 5 i32 1 s16 "com.android.mms.service" s16 "null" s16 "'$SENDER'" s16 "null" s16 "'$MESSAGE'" s16 "null" s16 "null" i32 1 i32 0'

Usage
./generate_sms.sh <sender> <message>

./generate_sms.sh +12125551212 "Here is your secret code to activate the app 98121928912"

adb shell service call isms 5 i32 1 s16 "com.android.mms.service" s16 "null" s16 "+12125551212" s16 "null" s16 "Here\ is\ your\ secret\ code\ to\ activate\ the\ app\ 98121928912" s16 "null" s16 "null" i32 1 i32 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment