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
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.