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)
Related
i am working on a project to read the sms of my android mobile,but on internet didn't find much about it. in my search i found following points
You can access android mobile phone through ADB shell commands ,but
only certain limited features.
ADB is a best method to communicate, as it do not require user to add any extension on android device
I use the shell command (found on internet) to send
message ,but it also didn't work
adb shell service call isms 5 s16 "com.android.mms" s16 "+01234567890" s16 "+01000000000" s16 "Hello world !" i32 0 i32 0
Moreover i found that if i want to
use AT commands to do so i have to root the mobile phone
even i tried accessing
com.android.internal.telephony
it shows result permission denied
above are my search results related to reading sms from my android device,
so i just want know,how can i read the sms from my android device
using adb shell commands?
if there is any other way to do so please suggest.
You can Read sms from android mobile using sqlite3, i m also working on the same project. but for this you have to do few things:
1) You must root your mobile (using any root app e.g Kingoroot app)
2) You should know the exact path for sms database of your mobile and you must install sqlite3 (simply google it and you will find it)
3) Only Super User can access that database
4) You must put sqlite.exe file into device/system/xbin (root directory)
5) how to accomplish step 4 ,you need (Titanium backup, root browser )
if done every thing written above all u need is
C:\Users\Ray>cd appdata/local/android/sdk/platform-tools
adb
adb shell
shell#htc_v02_dug:/ $ su
root#htc_v02_dug:/ # cd /data/data/com.android.providers.telephony/databases
root#htc_v02_dug:/data/data/com.android.providers.telephony/databases # sqlite3 mmssms.db
SQLite version 3.7.6.3-Titanium
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> select body from sms where read=0;
hi
i m using htc mobile. And the sms i just read hi.
Is there a way to do the following instructions using Android on phone and Windows on computer?
Computer: Reads numbers and meeting-dates out of a database.
Computer: Connects to the smartphone (via USB?) and uses its "send SMS"-function
Smartphone: Sends SMS with given Text.
Or do i have to use Third Party Email to SMS tools? I'd like to avoid that.
You can use USB debugging and some faked user input.
First, enable USB debugging. Depending on your Android version and device model, this may be either an option somewhere in the normal settings app or in the hidden developer mode which you can access by tapping the build number under "Status" 7 times. Also, you may be asked to allow access from your computer the first time you try to do anything with this feature.
Then, download ADB and any driver needed for your device, if any. ADB is a command-line tool to send debugging commands to your device.
You can use adb devices in the console to see if things work - you should see your device listed.
The idea is now to start the SMS app with recipient and text already filled in (which is a supported action) and then fake the user clicking "Send". This is where the tricky part lies. Depending on your device, there can be different key input required than for mine, for example. Usually you will need to send one or more D-Pad presses plus "Enter" (yes this works even if the device doesn't have a D-Pad).
The commands you'll need:
adb shell am start -a android.intent.action.SENDTO -d sms:<full phone number here> --es sms_body "<SMS text here>" --ez exit_on_sent true
This will open the SMS app with the values already filled in. Replace <full phone number here> with the phone number, and <SMS text here> with your text. If you need to use quotes inside the text, you have to escape them like \".
adb shell input keyevent <id>
This will send a fake keypress. The possible IDs are listed here. Particularly interesting are:
19: D-Pad up
20: D-Pad down
21: D-Pad left
22: D-Pad right
23: D-Pad center
66: Enter
You will need to play with these. You probably need to send 22 or 20 to simulate a "right" or "down" press to focus the "Send" button followed by 23 or 66 to simulate a press on the D-Pad center or enter key to "click" the button.
So, for example, it could look like this:
adb shell am start -a android.intent.action.SENDTO -d sms:+436501234567 --es sms_body "This is a test" --ez exit_on_sent true
adb shell input keyevent 20
adb shell input keyevent 66
This would open the SMS app with the number +436501234567 and the text This is a test already filled in and then simulate the "down" key and the "enter" key.
Please give the whole thing some time. Add some delays (at least 1s) between each command.
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?