Skip to content

Commit ce3e59b

Browse files
author
try2codesecure
committed
v1.1 - bugfixing, improvement
1 parent 9ec8927 commit ce3e59b

File tree

8 files changed

+76
-19
lines changed

8 files changed

+76
-19
lines changed

.classpath

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
<classpathentry kind="src" path="gen"/>
55
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
66
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
7+
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
78
<classpathentry kind="output" path="bin/classes"/>
89
</classpath>

AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.android.shellms"
44
android:versionCode="1"
5-
android:versionName="1.0"
5+
android:versionName="1.1"
66
android:installLocation="auto" >
77

88
<uses-permission android:name="android.permission.SEND_SMS" />
@@ -28,6 +28,7 @@
2828
<category android:name="android.intent.category.LAUNCHER" />
2929
</intent-filter>
3030
</activity>
31+
3132
<service
3233
android:enabled="true"
3334
android:name=".sendSMS"

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,21 @@ ShellMS
44
ShellMS - Android Debug Bridge Shell SMS Application
55

66
ShellMS is the simplest and easiest ADB Shell Messaging Application.
7-
If you don't know what ADB or SDK is you defintely don't need this app.
7+
If you don't know what ADB or SDK is you definitely don't need this app.
88
For the others it's useful tool to speed up messaging when you're working on your computer.
99

10+
Changelog:
11+
12+
IMPORTANT NOTE: If you're using a new cyanogenmod version =>
13+
!! Please disable Privacy Guard for ShellMS !!
14+
(otherwise the app can't search in your phonebook for the contact-names)
15+
16+
v1.1 (20130704)
17+
* fixed crash when sending long SMS
18+
* improved shell template
19+
v1.0
20+
* First Release
21+
1022
License:
1123

1224
Copyleft 2013, by Rainer [email protected]
@@ -56,9 +68,10 @@ Project's HomeSweetHome:
5668

5769
Templates:
5870
* simple shell "template_sendsms.sh"
71+
* for multiple contacts "template_sendsms_multiple-contacts.sh"
5972

60-
Roadmap (planned improvements in next version):
61-
* improve the sendsms function => with reply value if it's sent correct
73+
Roadmap / TODO (planned improvements in the future):
74+
* improve the sendsms function => with reply value if it's sent correct (BroadcastReceivers)
6275
* improve the serach for telephone numbers in address book
6376

6477
Bug found? PLEASE report it =>

bin/AndroidManifest.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.android.shellms"
44
android:versionCode="1"
5-
android:versionName="1.0"
5+
android:versionName="1.1"
66
android:installLocation="auto" >
77

88
<uses-permission android:name="android.permission.SEND_SMS" />
@@ -28,6 +28,7 @@
2828
<category android:name="android.intent.category.LAUNCHER" />
2929
</intent-filter>
3030
</activity>
31+
3132
<service
3233
android:enabled="true"
3334
android:name=".sendSMS"
1.15 KB
Binary file not shown.

res/layout/activity_main.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
android:layout_height="wrap_content"
1717
android:layout_alignParentBottom="true"
1818
android:layout_centerHorizontal="true"
19-
android:text="Thanks for using. visit https://github.com/try2codesecure/ShellMS" />
19+
android:text="Thanks for using. visit https://github.com/try2codesecure/ShellMS for Shell templates" />
2020

2121
<TextView
2222
android:id="@+id/textView3"

src/com/android/shellms/sendSMS.java

+34-13
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
package com.android.shellms;
1010

11+
import java.util.ArrayList;
12+
1113
import android.net.Uri;
1214
import android.os.Bundle;
15+
import android.app.PendingIntent;
1316
import android.app.Service;
1417
import android.telephony.PhoneNumberUtils;
1518
import android.telephony.SmsManager;
@@ -106,9 +109,9 @@ public int onStartCommand(Intent intent, int flags, int startId) {
106109
sendsms(contact, msg, !SECRET);
107110
Log.i(TAG, "Sent SMS to contact: " + contact );
108111
} else {
109-
Log.e(TAG, "NO MESSAGE WILL BE SENT IN DEBUG MODE" );
110-
Log.e(TAG, "Contact: " + contact );
111-
Log.e(TAG, "Message: " + msg);
112+
Log.d(TAG, "NO MESSAGE WILL BE SENT IN DEBUG MODE" );
113+
Log.d(TAG, "Contact: " + contact );
114+
Log.d(TAG, "Message: " + msg);
112115
}
113116
} else {
114117
Log.e(TAG, "Unknown Error occoured with contact: " + contact);
@@ -202,16 +205,34 @@ private String getNumberfromContact(String contact, Boolean debugging) {
202205
}
203206
}
204207

205-
206208
// This function sends the sms with the SMSManager
207209
private void sendsms(String phoneNumber, String message, Boolean AddtoSent) {
208-
SmsManager sms = SmsManager.getDefault();
209-
sms.sendTextMessage(phoneNumber, null, message, null, null);
210-
if (AddtoSent) {
211-
addMessageToSent(phoneNumber, message);
212-
}
213-
}
214-
210+
String SENT = "SMS_SENT";
211+
String DELIVERED = "SMS_DELIVERED";
212+
213+
ArrayList<PendingIntent> sentPendingIntents = new ArrayList<PendingIntent>();
214+
ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<PendingIntent>();
215+
216+
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0, new Intent(SENT), 0);
217+
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0, new Intent(DELIVERED), 0);
218+
219+
try {
220+
SmsManager sms = SmsManager.getDefault();
221+
ArrayList<String> msgparts = sms.divideMessage(message);
222+
for (int i = 0; i < msgparts.size(); i++) {
223+
sentPendingIntents.add(i, sentPI);
224+
deliveredPendingIntents.add(i, deliveredPI);
225+
}
226+
sms.sendMultipartTextMessage(phoneNumber, null, msgparts, sentPendingIntents, deliveredPendingIntents);
227+
if (AddtoSent) {
228+
addMessageToSent(phoneNumber, message);
229+
}
230+
} catch (Exception e) {
231+
e.printStackTrace();
232+
Log.e(TAG, "undefined Error: SMS sending failed ... please REPORT to ISSUE Tracker");
233+
}
234+
}
235+
215236
// This function add's the sent sms to the SMS sent folder
216237
private void addMessageToSent(String phoneNumber, String message) {
217238
ContentValues sentSms = new ContentValues();
@@ -220,8 +241,8 @@ private void addMessageToSent(String phoneNumber, String message) {
220241

221242
ContentResolver contentResolver = getContentResolver();
222243
contentResolver.insert(SENT_MSGS_CONTET_PROVIDER, sentSms);
223-
}
224-
244+
}
245+
225246
@Override
226247
public IBinder onBind(Intent intent) {
227248
// TODO Auto-generated method stub

template_sendsms_multiple-contacts.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# ShellMS Script
3+
ADB=adb
4+
MYIFS=','
5+
#or your path to adb
6+
if [ $# != 2 ];then
7+
echo "Usage: $0 \"Contact's DISPLAY NAME or Phone Number,nextContact,anotherContact,...\" \"Your message\""
8+
exit
9+
else
10+
IFS=$MYIFS read -ra CONTACTS <<< "$1"
11+
for i in "${CONTACTS[@]}"; do
12+
echo "... try sending to contact $i"
13+
$ADB shell am startservice --user 0 -n com.android.shellms/.sendSMS -e contact "$i" -e msg "$2" 1>/dev/null
14+
done
15+
16+
sleep 1;
17+
$ADB logcat -d -s -C ShellMS_Service_sendSMS:*
18+
fi
19+
20+

0 commit comments

Comments
 (0)