Removed SEND_SMS permission to comply with Google policy and use intent to send the SMS instead. BUT this just opens the SMS app - the user has to press 'Send', so this is not any good for us. I have applied to Google to keep SEND_SMS permission, so will hopefully undo this change in a week or two!
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
<!--<uses-permission android:name="android.permission.SEND_SMS" />-->
|
||||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||||
|
|||||||
@@ -658,6 +658,22 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void sendSMS(String phoneNo, String msgStr) {
|
||||||
|
Log.i(TAG, "sendSMS() - Sending to " + phoneNo);
|
||||||
|
// sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
|
||||||
|
Intent intent = new Intent(Intent.ACTION_SENDTO);
|
||||||
|
intent.setData(Uri.parse("smsto:")); //, HTTP.PLAIN_TEXT_TYPE);
|
||||||
|
intent.putExtra("sms_body", msgStr);
|
||||||
|
intent.putExtra("address", phoneNo);
|
||||||
|
if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
|
Log.i(TAG, "sendSMS() - Starting Activity to send SMS....");
|
||||||
|
startActivity(intent);
|
||||||
|
} else {
|
||||||
|
Log.e(TAG, "sendSMS() - Failed to send SMS - can not find activity do do it");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends SMS Alarms to the telephone numbers specified in mSMSNumbers[]
|
* Sends SMS Alarms to the telephone numbers specified in mSMSNumbers[]
|
||||||
* Attempts to find a better location, and sends a second SMS after location search
|
* Attempts to find a better location, and sends a second SMS after location search
|
||||||
@@ -682,16 +698,17 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
// SmsManager sm = SmsManager.getDefault();
|
// SmsManager sm = SmsManager.getDefault();
|
||||||
for (int i = 0; i < mSMSNumbers.length; i++) {
|
for (int i = 0; i < mSMSNumbers.length; i++) {
|
||||||
Log.i(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
Log.i(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
||||||
|
sendSMS(new String(mSMSNumbers[i]),mSMSMsgStr + " - " + dateStr);
|
||||||
// sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
|
// sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
|
||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
//Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setDataAndType(Uri.parse("smsto:"), "vnd.android-dir/mms-sms");
|
//intent.setDataAndType(Uri.parse("smsto:"), "text/plain");
|
||||||
intent.putExtra("sms_body", mSMSMsgStr + " - " + dateStr);
|
//intent.putExtra("sms_body", mSMSMsgStr + " - " + dateStr);
|
||||||
intent.putExtra("address", new String(mSMSNumbers[i]));
|
//intent.putExtra("address", new String(mSMSNumbers[i]));
|
||||||
if (intent.resolveActivity(getPackageManager()) != null) {
|
//if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
startActivity(intent);
|
// startActivity(intent);
|
||||||
} else {
|
//} else {
|
||||||
Log.e(TAG, "sendSMSAlarm() - Failed to send SMS.");
|
// Log.e(TAG, "sendSMSAlarm() - Failed to send SMS - can not find activity do do it");
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
|
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
|
||||||
@@ -735,12 +752,20 @@ public class SdServer extends Service implements SdDataReceiver, SdLocationRecei
|
|||||||
dateStr + " - " + googleUrl;
|
dateStr + " - " + googleUrl;
|
||||||
Log.i(TAG, "onSdLocationReceived() - Message is " + messageStr);
|
Log.i(TAG, "onSdLocationReceived() - Message is " + messageStr);
|
||||||
mUtil.showToast(messageStr);
|
mUtil.showToast(messageStr);
|
||||||
SmsManager sm = SmsManager.getDefault();
|
|
||||||
for (int i = 0; i < mSMSNumbers.length; i++) {
|
for (int i = 0; i < mSMSNumbers.length; i++) {
|
||||||
Log.i(TAG, "sendSMSAlarm() - Sending to " + mSMSNumbers[i]);
|
Log.i(TAG, "onSdLocationReceived() - Sending to " + mSMSNumbers[i]);
|
||||||
sm.sendTextMessage(mSMSNumbers[i], null,
|
sendSMS(new String(mSMSNumbers[i]), messageStr);
|
||||||
messageStr,
|
// sm.sendTextMessage(mSMSNumbers[i], null, mSMSMsgStr + " - " + dateStr, null, null);
|
||||||
null, null);
|
//Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
|
//intent.setDataAndType(Uri.parse("smsto:"), "vnd.android-dir/mms-sms");
|
||||||
|
//intent.putExtra("sms_body", messageStr);
|
||||||
|
//intent.putExtra("address", new String(mSMSNumbers[i]));
|
||||||
|
//if (intent.resolveActivity(getPackageManager()) != null) {
|
||||||
|
// Log.e(TAG, "onSdLocationReceived() - sending SMS.");
|
||||||
|
// startActivity(intent);
|
||||||
|
//} else {
|
||||||
|
// Log.e(TAG, "onSdLocationReceived() - Failed to send SMS - can not find activity to do it.");
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
|
Log.i(TAG, "sendSMSAlarm() - SMS Alarms Disabled - not doing anything!");
|
||||||
|
|||||||
Reference in New Issue
Block a user