I'm using a Samsung phone with Android 10
I found this adb command online
adb shell service call isms 7 i32 0 s16 "com.android.mms.service" s16 "${phone}" s16 "null" s16 "'${text}'" s16 "null" s16 "null"
This works, it sends the SMS if i respect the character limit. However, the SMS does not show up in the phone's messages app
I can't find documentation about all those flags and what they mean. Please help me and tell me how I can make it show in the messages app. If this is not possible with adb, is there any other way?
I was able to achieve this by providing another argument at the end
i32 1
this article helped me
Based on this documentation it seems i needed to provide the persistMessageForNonDefaultSmsApp boolean
Not sure if this was the way to go, I'm not an android dev, but it works :/
Related
adb shell service call isms 7 i32 1 s16 "com.android.mms" s16 "+1234567890" s16 "null" s16 "'text is here'" s16 "null" s16 "null"
This code , send sms without problem, but i want to turn "delivery report request on".
But how to do it ?
because when you send sms from command line, it's ignores your phone settings and do not request delivery report on outgoing messages.
I'm making a shell script to control txt msg from my s5 phone and I've tried 2 different ways:
1)
am start -a android.intent.action.SENDTO -d sms:$1 --es sms_body "$2" --ez exit_on_sent true
sleep 1
input keyevent 22
sleep 1
input keyevent 66
2)
using DDMS to get the coordinates of the send button, x, y
service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText".
input tap x y
My goal is to generalize this for different phones that I want to test, and 1) doesn't send the message at all. It just loads sms app with the send to number and message body while not actually pressing the send buttong.
2) Works, but is specific to my phone. Some phones have the keyboard showing to coordinates are different, and additionally, most of my phones have different resolutions.
Is there a better way to automate the sending process? Like a keyevent code, or even an action to perform the last and most important step (for what I need this script for) of actually sending the message?
So the SENDTO syntax is for the default Android API's packages. It turns out my verizon messaging app behaves differently. All I had to do was reset my default text messenger to the android messenger and not the verizon one.
Example: Samsung S5 Verizon default: Messages and NOT Message+(verizon)
Currently I send SMS by this command:
adb shell service call isms 6 s16 "phoneNumber" i32 0 i32 0 s16 "smsText"
in Android 2.3.6 and works perfectly.
Now I want to use the same command in Android 4.1.2 but when I send the command I received this output in Logcat
> 12-11 14:17:37.97 1626-2182/? D/PhoneRestrictionPolicy﹕ SmsRestrictionPolicy.canOutgoingSms >>>>
Anyone Can help me to remove this "SmsRestrictionPolicy" please?
Thanks
Quoting this post:
adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22
adb shell input keyevent 66
Where CCXXXXXXXXXX is country-code followed by phone number. This may not work correctly on non-standard android installations, you will need to find the correct keyevent values to pass.
From comments on this post it appears that sending via service call isms, as mentioned in the question, is not possible (though I would bet it is possible if your app is set as the default SMS app for the device).
One work-around to sending an SMS without user interaction would be to send the number and message to a server that sends SMS messages. There is likely already a third party tool for this. At quick glance, this may be useful.
Try with telnet and sms send commands.
Read more here.
My Environment:
Android 4.1.2
MIUI ROM
you can try this.
Switch to the message application user before service call isms .. command.
su u0_a34 \
service call isms 5 s16 "10086" i32 0 i32 0 s16 "11"
u0_a34 is the user name of the message application.
It didn't work because in android 4.1.2 the isms number is 5 and not 6.
So it's :
adb shell service call isms 5 s16 "com.android.mms" s16 "+01234567890" s16 "+01000000000" s16 "Hello world !" i32 0 i32 0
You could check how to do it for any android version here : link
Do you know the command "service call isms" with adb shell on Android?
Here is the complete command I use : service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText".
There are some parameter but I don't know what it means (5, s16, i32, 0). Is there somewhere a manual ?
The most important for me is to get an error when the sms doesn't send successfully (about 10% of the sms aren't send) => this question asked already but there isn't answer (https://stackoverflow.com/questions/17395546/get-status-sms-from-isms-service-using-shell-adb-android-sdk).
I don't wanna use the commands
(adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22
adb shell input keyevent 66)
because it uses the graphical interface.
Could you help me? (I'm sorry, I can't speak English. So, I hope you understand my request)
Thanks a lot
In every "service call" command, you need to enter:
the service you want to call, in this case it is "isms";
the "function" you want to call, in this case it is "5" (more about that later);
the function parameters.
There's two types of possible parameters: Strings and Integers. Before entering an Integer parameter you need to specify its type using i32.
Same thing for a String parameter, but instead you need to write s16.
Most of the "service call" commands have no documentation, or very little.
For the ISms you can look here: http://www.androidjavadoc.com/1.0_r1_src/constant-values.html
to get a list of the possible functions and their number code. Hit ctrl-f and enter ISms for quick access.
The "5" function for the ISms service is the sendMultipartText function from the ISms interface of the Android API. Here is the doc about this function. And here is the implementation class from the API.
So, service call isms 5 s16 "PhoneNumber" i32 0 i32 0 s16 "BodyText", equals:
Call the sendMultipartText function from the ISms service with the
String parameter "PhoneNumber", the Integer parameter 0, the Integer
parameter 0 and the String parameter "BodyText".
To answer your question, I am pretty sure there's no way to know if the sms are being sent or not from the command line... But maybe if you dig a little deeper than I did in the API you'll find a way.
I would like to be able to send an actual SMS message from a shell using just the command line and not relying on any apk to do so. I am interested in sending this message between phones, not from the emulator to the phone. For example, by running the command:
service call phone 2 s16 "1234567890"
I can place a call from phone to phone using the command line. The 'service list' command shows an isms service, which I can't seem to provide the correct arguments for. I would assume that one of the args should be a PDU string but haven't had any luck so far.
In fact, this can be done but requires adb to be installed (Part of the android SDK)
adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
adb shell input keyevent 22
adb shell input keyevent 66
Where CCXXXXXXXXXX is country-code followed by phone number. This may not work correctly on non-standard android installations, you will need to find the correct keyevent values to pass.
How about this?
service call isms 5 s16 "+??????????" i32 0 i32 0 s16 "SMS TEXT HERE"
You can telnet to the emulator doing something similar to "telnet localhost 5554", where 5554 is the port the emulator is listening on. After that, you can send an sms message by doing the following:
sms send 1234 "Hello"
The 1234 can be any string of digits. Enclose the message in quotes if you are including spaces.
edit:
an sms command doesn't exist in Android on real devices, it's an emulator-only feature to fake an SMS receiving not sending.
It's just a convenience for emulated devices that don't have access to any actual cellular network.
cf. http://developer.android.com/guide/developing/devices/emulator.html#sms
I don't have enough reputation points up upvote the answer given by Dmitry, but that IS the answer that works with one minor modification: At least for a US number, instead of putting a plus-sign (+) it worked for me with a "1" e.g. 17079876543 ...
service call isms 5 s16 "17079876543" i32 0 i32 0 s16 "SMS TEXT HERE"
Oh boy oh boy oh boy ... now if I can figure out how to receive SMS over the command line and combine that with emacs (in an emacs shell say - he begins to rub his hands together and crack a slanted grin ... and think about all the other command line levers we can pull!)
You can send any intent you want from the command line, so it's merely a matter of figuring out what intent can be used to send an sms, or if one doesn't exist, then writing an apk which provides such intent-to-sms capability and sending the intent to trigger that from the command line.
If you end up writing an apk to do that, think a little bit about permissions. Which user will the command line be running as - the adb shell user? any old ordinary app user? Your apk will presumably have sms permissions, but do you want to extent that to everything on the phone, or implement some security mechanism in your intent?