diff options
Diffstat (limited to 'src/java/com/android/internal')
4 files changed, 82 insertions, 63 deletions
diff --git a/src/java/com/android/internal/telephony/ISms.aidl b/src/java/com/android/internal/telephony/ISms.aidl index 0f50ff0..88a92df 100644 --- a/src/java/com/android/internal/telephony/ISms.aidl +++ b/src/java/com/android/internal/telephony/ISms.aidl @@ -18,7 +18,6 @@ package com.android.internal.telephony; import android.app.PendingIntent; import com.android.internal.telephony.SmsRawData; -import com.android.internal.telephony.ISmsMiddleware; import java.util.List; @@ -37,7 +36,6 @@ import java.util.List; */ interface ISms { - void registerSmsMiddleware(String name, ISmsMiddleware middleware); void synthesizeMessages(String originatingAddress, String scAddress, in List<String> messages, long timestampMillis); /** diff --git a/src/java/com/android/internal/telephony/ISmsMiddleware.aidl b/src/java/com/android/internal/telephony/ISmsMiddleware.aidl deleted file mode 100644 index 1268f2e..0000000 --- a/src/java/com/android/internal/telephony/ISmsMiddleware.aidl +++ /dev/null @@ -1,12 +0,0 @@ -package com.android.internal.telephony; - -import android.app.PendingIntent; - -interface ISmsMiddleware { - boolean onSendText(in String destAddr, in String scAddr, in String text, - in PendingIntent sentIntent, in PendingIntent deliveryIntent); - - boolean onSendMultipartText(in String destinationAddress, in String scAddress, - in List<String> parts, in List<PendingIntent> sentIntents, - in List<PendingIntent> deliveryIntents); -}
\ No newline at end of file diff --git a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java index b4d13fd..dec58e6 100644 --- a/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java +++ b/src/java/com/android/internal/telephony/IccSmsInterfaceManager.java @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.app.PendingIntent; import android.content.Context; +import android.os.Binder; import android.os.RemoteException; import android.util.Log; @@ -50,10 +51,6 @@ public abstract class IccSmsInterfaceManager extends ISms.Stub { } @Override - public void registerSmsMiddleware(String name, ISmsMiddleware middleware) throws android.os.RemoteException { - } - - @Override public void synthesizeMessages(String originatingAddress, String scAddress, List<String> messages, long timestampMillis) throws RemoteException { } @@ -121,9 +118,11 @@ public abstract class IccSmsInterfaceManager extends ISms.Stub { */ public void sendText(String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent) { - mPhone.getContext().enforceCallingPermission( - "android.permission.SEND_SMS", - "Sending SMS message"); + if (Binder.getCallingPid() != android.os.Process.myPid()) { + mPhone.getContext().enforceCallingPermission( + "android.permission.SEND_SMS", + "Sending SMS message"); + } if (Log.isLoggable("SMS", Log.VERBOSE)) { log("sendText: destAddr=" + destAddr + " scAddr=" + scAddr + " text='"+ text + "' sentIntent=" + @@ -159,9 +158,11 @@ public abstract class IccSmsInterfaceManager extends ISms.Stub { */ public void sendMultipartText(String destAddr, String scAddr, List<String> parts, List<PendingIntent> sentIntents, List<PendingIntent> deliveryIntents) { - mPhone.getContext().enforceCallingPermission( - "android.permission.SEND_SMS", - "Sending SMS message"); + if (Binder.getCallingPid() != android.os.Process.myPid()) { + mPhone.getContext().enforceCallingPermission( + "android.permission.SEND_SMS", + "Sending SMS message"); + } if (Log.isLoggable("SMS", Log.VERBOSE)) { int i = 0; for (String part : parts) { 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 { |