summaryrefslogtreecommitdiffstats
path: root/src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java')
-rw-r--r--src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java110
1 files changed, 71 insertions, 39 deletions
diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java
index 44882ef..9572c39 100644
--- a/src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java
+++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManagerProxy.java
@@ -16,23 +16,58 @@
package com.android.internal.telephony;
-import java.util.Hashtable;
+import java.util.ArrayList;
import java.util.List;
import android.app.Activity;
import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
-import android.os.SystemProperties;
+import android.os.UserHandle;
import android.provider.Telephony.Sms.Intents;
import android.telephony.SmsMessage;
public class IccSmsInterfaceManagerProxy extends ISms.Stub {
private IccSmsInterfaceManager mIccSmsInterfaceManager;
- private Hashtable<String, ISmsMiddleware> mMiddleware = new Hashtable<String, ISmsMiddleware>();
+
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ public void onReceive(Context context, Intent intent) {
+ // check if the message was aborted
+ if (getResultCode() != Activity.RESULT_OK) {
+ return;
+ }
+ String destAddr = getResultData();
+ String scAddr = intent.getStringExtra("scAddr");
+ ArrayList<String> parts = intent.getStringArrayListExtra("parts");
+ ArrayList<PendingIntent> sentIntents = intent.getParcelableArrayListExtra("sentIntent");
+ ArrayList<PendingIntent> deliveryIntents = intent.getParcelableArrayListExtra("deliveryIntents");
+
+ if (intent.getBooleanExtra("multipart", false)) {
+ mIccSmsInterfaceManager.sendMultipartText(destAddr, scAddr,
+ parts, sentIntents, deliveryIntents);
+ return;
+ }
+
+ PendingIntent sentIntent = null;
+ if (sentIntents != null && sentIntents.size() > 0) {
+ sentIntent = sentIntents.get(0);
+ }
+ PendingIntent deliveryIntent = null;
+ if (deliveryIntents != null && deliveryIntents.size() > 0) {
+ deliveryIntent = deliveryIntents.get(0);
+ }
+ String text = null;
+ if (parts != null && parts.size() > 0) {
+ text = parts.get(0);
+ }
+ mIccSmsInterfaceManager.sendText(destAddr, scAddr, text,
+ sentIntent, deliveryIntent);
+ }
+ };
public IccSmsInterfaceManagerProxy(Context context,
IccSmsInterfaceManager iccSmsInterfaceManager) {
@@ -51,19 +86,10 @@ public class IccSmsInterfaceManagerProxy extends ISms.Stub {
private void createWakelock() {
PowerManager pm = (PowerManager)mContext.getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "SMSDispatcher");
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "IccSmsInterfaceManager");
mWakeLock.setReferenceCounted(true);
}
- @Override
- public void registerSmsMiddleware(String name, ISmsMiddleware middleware) throws android.os.RemoteException {
- if (!"1".equals(SystemProperties.get("persist.sys.sms_debug", "0"))) {
- mContext.enforceCallingPermission(
- "android.permission.INTERCEPT_SMS", "");
- }
- mMiddleware.put(name, middleware);
- }
-
private Context mContext;
private PowerManager.WakeLock mWakeLock;
private static final int WAKE_LOCK_TIMEOUT = 5000;
@@ -83,11 +109,8 @@ public class IccSmsInterfaceManagerProxy extends ISms.Stub {
@Override
public void synthesizeMessages(String originatingAddress, String scAddress, List<String> messages, long timestampMillis) throws RemoteException {
- // if not running in debug mode
- if (!"1".equals(SystemProperties.get("persist.sys.sms_debug", "0"))) {
- mContext.enforceCallingPermission(
- "android.permission.BROADCAST_SMS", "");
- }
+ mContext.enforceCallingPermission(
+ android.Manifest.permission.BROADCAST_SMS, "");
byte[][] pdus = new byte[messages.size()][];
for (int i = 0; i < messages.size(); i++) {
SyntheticSmsMessage message = new SyntheticSmsMessage(originatingAddress, scAddress, messages.get(i), timestampMillis);
@@ -116,34 +139,43 @@ public class IccSmsInterfaceManagerProxy extends ISms.Stub {
sentIntent, deliveryIntent);
}
+ private void broadcastOutgoingSms(String destAddr, String scAddr,
+ boolean multipart, ArrayList<String> parts,
+ ArrayList<PendingIntent> sentIntents, ArrayList<PendingIntent> deliveryIntents) {
+ Intent broadcast = new Intent(Intent.ACTION_NEW_OUTGOING_SMS);
+ broadcast.putExtra("destAddr", destAddr);
+ broadcast.putExtra("scAddr", scAddr);
+ broadcast.putExtra("multipart", multipart);
+ broadcast.putStringArrayListExtra("parts", parts);
+ broadcast.putParcelableArrayListExtra("sentIntents", sentIntents);
+ broadcast.putParcelableArrayListExtra("deliveryIntents", deliveryIntents);
+ mContext.sendOrderedBroadcastAsUser(broadcast, UserHandle.OWNER,
+ android.Manifest.permission.INTERCEPT_SMS,
+ mReceiver, null, Activity.RESULT_OK, destAddr, null);
+ }
+
public void sendText(String destAddr, String scAddr,
String text, PendingIntent sentIntent, PendingIntent deliveryIntent) {
- for (ISmsMiddleware middleware: mMiddleware.values()) {
- try {
- if (middleware.onSendText(destAddr, scAddr, text, sentIntent, deliveryIntent))
- return;
- }
- catch (Exception e) {
- // TOOD: remove the busted middleware?
- }
- }
- mIccSmsInterfaceManager.sendText(destAddr, scAddr, text, sentIntent, deliveryIntent);
+ mContext.enforceCallingPermission(
+ android.Manifest.permission.SEND_SMS,
+ "Sending SMS message");
+ ArrayList<String> parts = new ArrayList<String>();
+ parts.add(text);
+ ArrayList<PendingIntent> sentIntents = new ArrayList<PendingIntent>();
+ sentIntents.add(sentIntent);
+ ArrayList<PendingIntent> deliveryIntents = new ArrayList<PendingIntent>();
+ deliveryIntents.add(deliveryIntent);
+ broadcastOutgoingSms(destAddr, scAddr, false, parts, sentIntents, deliveryIntents);
}
public void sendMultipartText(String destAddr, String scAddr,
List<String> parts, List<PendingIntent> sentIntents,
List<PendingIntent> deliveryIntents) throws android.os.RemoteException {
- for (ISmsMiddleware middleware: mMiddleware.values()) {
- try {
- if (middleware.onSendMultipartText(destAddr, scAddr, parts, sentIntents, deliveryIntents))
- return;
- }
- catch (Exception e) {
- // TOOD: remove the busted middleware?
- }
- }
- mIccSmsInterfaceManager.sendMultipartText(destAddr, scAddr,
- parts, sentIntents, deliveryIntents);
+ mContext.enforceCallingPermission(
+ android.Manifest.permission.SEND_SMS,
+ "Sending SMS message");
+ broadcastOutgoingSms(destAddr, scAddr, true, new ArrayList<String>(parts),
+ new ArrayList<PendingIntent>(sentIntents), new ArrayList<PendingIntent>(deliveryIntents));
}
public boolean enableCellBroadcast(int messageIdentifier) throws android.os.RemoteException {