Loading src/java/com/android/internal/telephony/SmsController.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -197,6 +197,35 @@ public class SmsController extends ISmsImplBase { String callingAttributionTag, String destAddr, String scAddr, String text, String callingAttributionTag, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, long messageId) { boolean persistMessageForNonDefaultSmsApp, long messageId) { sendTextForSubscriber(subId, callingPackage, callingAttributionTag, destAddr, scAddr, text, sentIntent, deliveryIntent, persistMessageForNonDefaultSmsApp, messageId, false); } /** * @param subId Subscription Id * @param callingAttributionTag the attribution tag of the caller * @param destAddr the address to send the message to * @param scAddr is the service center address or null to use * the current default SMSC * @param text the body of the message to send * @param sentIntent if not NULL this <code>PendingIntent</code> is * broadcast when the message is successfully sent, or failed. * The result code will be <code>Activity.RESULT_OK</code> for success, or relevant errors * the sentIntent may include the extra "errorCode" containing a radio technology specific * value, generally only useful for troubleshooting. * @param deliveryIntent if not NULL this <code>PendingIntent</code> is * broadcast when the message is delivered to the recipient. The * raw pdu of the status report is in the extended data ("pdu"). * @param skipFdnCheck if set to true, FDN check must be skipped .This is set in case of STK sms * * @hide */ public void sendTextForSubscriber(int subId, String callingPackage, String callingAttributionTag, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, long messageId, boolean skipFdnCheck) { if (callingPackage == null) { if (callingPackage == null) { callingPackage = getCallingPackage(); callingPackage = getCallingPackage(); } } Loading @@ -209,7 +238,7 @@ public class SmsController extends ISmsImplBase { } } // Perform FDN check // Perform FDN check if (isNumberBlockedByFDN(subId, destAddr, callingPackage)) { if (!skipFdnCheck && isNumberBlockedByFDN(subId, destAddr, callingPackage)) { sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE); return; return; } } Loading src/java/com/android/internal/telephony/cat/CatCmdMessage.java +123 −91 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ public class CatCmdMessage implements Parcelable { private ToneSettings mToneSettings = null; private ToneSettings mToneSettings = null; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private CallSettings mCallSettings = null; private CallSettings mCallSettings = null; private SMSSettings mSMSSettings = null; private SetupEventListSettings mSetupEventListSettings = null; private SetupEventListSettings mSetupEventListSettings = null; private boolean mLoadIconFailed = false; private boolean mLoadIconFailed = false; Loading @@ -61,6 +62,14 @@ public class CatCmdMessage implements Parcelable { public TextMessage callMsg; public TextMessage callMsg; } } /** * Container for SEND SMS command settings. */ public class SMSSettings { public TextMessage smsText; public TextMessage destAddr; } public class SetupEventListSettings { public class SetupEventListSettings { @UnsupportedAppUsage @UnsupportedAppUsage public int[] eventList; public int[] eventList; Loading Loading @@ -88,10 +97,22 @@ public class CatCmdMessage implements Parcelable { case SELECT_ITEM: case SELECT_ITEM: mMenu = ((SelectItemParams) cmdParams).mMenu; mMenu = ((SelectItemParams) cmdParams).mMenu; break; break; case SEND_SMS: /* If cmdParams is an instanceof SendSMSParams , then it means config value * config_stk_sms_send_support is true and the SMS should be sent by framework */ if (cmdParams instanceof SendSMSParams) { mSMSSettings = new SMSSettings(); mSMSSettings.smsText = ((SendSMSParams) cmdParams).mTextSmsMsg; mSMSSettings.destAddr = ((SendSMSParams) cmdParams).mDestAddress; mTextMsg = ((SendSMSParams) cmdParams).mDisplayText.mTextMsg; } else { mTextMsg = ((DisplayTextParams) cmdParams).mTextMsg; } break; case DISPLAY_TEXT: case DISPLAY_TEXT: case SET_UP_IDLE_MODE_TEXT: case SET_UP_IDLE_MODE_TEXT: case SEND_DTMF: case SEND_DTMF: case SEND_SMS: case REFRESH: case REFRESH: case RUN_AT: case RUN_AT: case SEND_SS: case SEND_SS: Loading Loading @@ -166,6 +187,11 @@ public class CatCmdMessage implements Parcelable { mSetupEventListSettings.eventList[i] = in.readInt(); mSetupEventListSettings.eventList[i] = in.readInt(); } } break; break; case SEND_SMS: mSMSSettings = new SMSSettings(); mSMSSettings.smsText = in.readParcelable(SendSMSParams.class.getClassLoader()); mSMSSettings.destAddr = in.readParcelable(SendSMSParams.class.getClassLoader()); break; default: default: break; break; } } Loading Loading @@ -193,6 +219,12 @@ public class CatCmdMessage implements Parcelable { case SET_UP_EVENT_LIST: case SET_UP_EVENT_LIST: dest.writeIntArray(mSetupEventListSettings.eventList); dest.writeIntArray(mSetupEventListSettings.eventList); break; break; case SEND_SMS: if (mSMSSettings != null) { dest.writeParcelable(mSMSSettings.smsText, 0); dest.writeParcelable(mSMSSettings.destAddr, 0); } break; default: default: break; break; } } Loading src/java/com/android/internal/telephony/cat/CatService.java +127 −4 Original line number Original line Diff line number Diff line Loading @@ -20,24 +20,34 @@ import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListCon import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.PendingIntent; import android.app.backup.BackupManager; import android.app.backup.BackupManager; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo; import android.content.res.Resources.NotFoundException; import android.content.res.Resources.NotFoundException; import android.os.AsyncResult; import android.os.AsyncResult; import android.os.Build; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.HandlerThread; import android.os.LocaleList; import android.os.LocaleList; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.ProxyController; import com.android.internal.telephony.SmsController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.uicc.IccCardStatus.CardState; import com.android.internal.telephony.uicc.IccCardStatus.CardState; import com.android.internal.telephony.uicc.IccFileHandler; import com.android.internal.telephony.uicc.IccFileHandler; Loading Loading @@ -138,12 +148,21 @@ public class CatService extends Handler implements AppInterface { static final String STK_DEFAULT = "Default Message"; static final String STK_DEFAULT = "Default Message"; private static final String SMS_DELIVERY_ACTION = "com.android.internal.telephony.cat.SMS_DELIVERY_ACTION"; private static final String SMS_SENT_ACTION = "com.android.internal.telephony.cat.SMS_SENT_ACTION"; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private int mSlotId; private int mSlotId; private static HandlerThread sCatServiceThread; /* For multisim catservice should not be singleton */ /* For multisim catservice should not be singleton */ private CatService(CommandsInterface ci, UiccCardApplication ca, IccRecords ir, private CatService(CommandsInterface ci, UiccCardApplication ca, IccRecords ir, Context context, IccFileHandler fh, UiccProfile uiccProfile, int slotId) { Context context, IccFileHandler fh, UiccProfile uiccProfile, int slotId, Looper looper) { //creating new thread to avoid deadlock conditions with the framework thread. super(looper); if (ci == null || ca == null || ir == null || context == null || fh == null if (ci == null || ca == null || ir == null || context == null || fh == null || uiccProfile == null) { || uiccProfile == null) { throw new NullPointerException( throw new NullPointerException( Loading Loading @@ -187,6 +206,10 @@ public class CatService extends Handler implements AppInterface { CatLog.d(this, "Running CAT service on Slotid: " + mSlotId + CatLog.d(this, "Running CAT service on Slotid: " + mSlotId + ". STK app installed:" + mStkAppInstalled); ". STK app installed:" + mStkAppInstalled); SmsBroadcastReceiver smsBroadcastReceiver = new SmsBroadcastReceiver(); mContext.registerReceiver(smsBroadcastReceiver, new IntentFilter(SMS_DELIVERY_ACTION)); mContext.registerReceiver(smsBroadcastReceiver, new IntentFilter(SMS_SENT_ACTION)); } } /** /** Loading @@ -200,6 +223,10 @@ public class CatService extends Handler implements AppInterface { */ */ public static CatService getInstance(CommandsInterface ci, public static CatService getInstance(CommandsInterface ci, Context context, UiccProfile uiccProfile, int slotId) { Context context, UiccProfile uiccProfile, int slotId) { if (sCatServiceThread == null) { sCatServiceThread = new HandlerThread("CatServiceThread"); sCatServiceThread.start(); } UiccCardApplication ca = null; UiccCardApplication ca = null; IccFileHandler fh = null; IccFileHandler fh = null; IccRecords ir = null; IccRecords ir = null; Loading Loading @@ -227,8 +254,8 @@ public class CatService extends Handler implements AppInterface { || uiccProfile == null) { || uiccProfile == null) { return null; return null; } } sInstance[slotId] = new CatService(ci, ca, ir, context, fh, uiccProfile, slotId, sInstance[slotId] = new CatService(ci, ca, ir, context, fh, uiccProfile, slotId); sCatServiceThread.getLooper()); } else if ((ir != null) && (mIccRecords != ir)) { } else if ((ir != null) && (mIccRecords != ir)) { if (mIccRecords != null) { if (mIccRecords != null) { mIccRecords.unregisterForRecordsLoaded(sInstance[slotId]); mIccRecords.unregisterForRecordsLoaded(sInstance[slotId]); Loading Loading @@ -447,8 +474,49 @@ public class CatService extends Handler implements AppInterface { ((DisplayTextParams)cmdParams).mTextMsg.text = null; ((DisplayTextParams)cmdParams).mTextMsg.text = null; } } break; break; case SEND_DTMF: case SEND_SMS: case SEND_SMS: /* If cmdParams is an instanceof SendSMSParams , then it means config value * config_stk_sms_send_support is true and the SMS should be sent by framework */ if (cmdParams instanceof SendSMSParams) { String text = null, destAddr = null; if (((SendSMSParams) cmdParams).mTextSmsMsg != null) { text = ((SendSMSParams) cmdParams).mTextSmsMsg.text; } if (((SendSMSParams) cmdParams).mDestAddress != null) { destAddr = ((SendSMSParams) cmdParams).mDestAddress.text; } if (text != null && destAddr != null) { ProxyController proxyController = ProxyController.getInstance(mContext); SubscriptionManager subscriptionManager = (SubscriptionManager) mContext.getSystemService( Context.TELEPHONY_SUBSCRIPTION_SERVICE); SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex( mSlotId); if (subInfo != null) { sendStkSms(text, destAddr, subInfo.getSubscriptionId(), cmdParams, proxyController); } else { sendTerminalResponse(cmdParams.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD, false, 0x00, null); CatLog.d(this, "Subscription info is null"); } } else { sendTerminalResponse(cmdParams.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD, false, 0x00, null); CatLog.d(this, "Sms text or Destination Address is null"); } } else { if ((((DisplayTextParams) cmdParams).mTextMsg.text != null) && (((DisplayTextParams) cmdParams).mTextMsg.text.equals( STK_DEFAULT))) { message = mContext.getText(com.android.internal.R.string.sending); ((DisplayTextParams) cmdParams).mTextMsg.text = message.toString(); } } break; case SEND_DTMF: case SEND_SS: case SEND_SS: case SEND_USSD: case SEND_USSD: if ((((DisplayTextParams)cmdParams).mTextMsg.text != null) if ((((DisplayTextParams)cmdParams).mTextMsg.text != null) Loading Loading @@ -536,6 +604,61 @@ public class CatService extends Handler implements AppInterface { broadcastCatCmdIntent(cmdMsg); broadcastCatCmdIntent(cmdMsg); } } /** * Used to send STK based sms via CATService * @param text The message body * @param destAddr The destination Address * @param subId Subscription Id * @param cmdParams Send SMS Command Params * @param proxyController ProxyController * @hide */ public void sendStkSms(String text, String destAddr, int subId, CommandParams cmdParams, ProxyController proxyController) { PendingIntent sentPendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(SMS_SENT_ACTION).putExtra("cmdDetails", cmdParams.mCmdDet), PendingIntent.FLAG_MUTABLE); PendingIntent deliveryPendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(SMS_DELIVERY_ACTION).putExtra("cmdDetails", cmdParams.mCmdDet), PendingIntent.FLAG_MUTABLE); SmsController smsController = proxyController.getSmsController(); smsController.sendTextForSubscriber(subId, mContext.getOpPackageName(), mContext.getAttributionTag(), destAddr, null, text, sentPendingIntent, deliveryPendingIntent, false, 0L, true); } private class SmsBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CommandDetails commandDetails = (CommandDetails) intent.getExtra("cmdDetails"); if (intent.getAction().equals(SMS_SENT_ACTION)) { int resultCode = getResultCode(); switch (resultCode) { case Activity.RESULT_OK: break; default: //ToDO handle Error cases bug : b/243123292 CatLog.d(this, "Error sending STK SMS : " + resultCode); sendTerminalResponse(commandDetails, ResultCode.SMS_RP_ERROR, true, ResultCode.NETWORK_CRNTLY_UNABLE_TO_PROCESS.value(), null); } } if (intent.getAction().equals(SMS_DELIVERY_ACTION)) { int resultCode = getResultCode(); switch (resultCode) { case Activity.RESULT_OK: sendTerminalResponse(commandDetails, ResultCode.OK, false, 0, null); break; default: //ToDO handle Error cases bug: b/243123292 CatLog.d(this, "Error delivering STK SMS : " + resultCode); sendTerminalResponse(commandDetails, ResultCode.SMS_RP_ERROR, true, ResultCode.TERMINAL_CRNTLY_UNABLE_TO_PROCESS.value(), null); } } } } private void broadcastCatCmdIntent(CatCmdMessage cmdMsg) { private void broadcastCatCmdIntent(CatCmdMessage cmdMsg) { Intent intent = new Intent(AppInterface.CAT_CMD_ACTION); Intent intent = new Intent(AppInterface.CAT_CMD_ACTION); Loading src/java/com/android/internal/telephony/cat/CommandParams.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -22,16 +22,16 @@ import android.os.Build; /** /** * Container class for proactive command parameters. * Container class for proactive command parameters. * * @hide */ */ class CommandParams { public class CommandParams { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) CommandDetails mCmdDet; CommandDetails mCmdDet; // Variable to track if an optional icon load has failed. // Variable to track if an optional icon load has failed. boolean mLoadIconFailed = false; boolean mLoadIconFailed = false; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) CommandParams(CommandDetails cmdDet) { public CommandParams(CommandDetails cmdDet) { mCmdDet = cmdDet; mCmdDet = cmdDet; } } Loading src/java/com/android/internal/telephony/cat/CommandParamsFactory.java +82 −4 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.graphics.Bitmap; import android.os.Build; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.telephony.SmsMessage; import android.text.TextUtils; import android.text.TextUtils; import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.GsmAlphabet; Loading @@ -40,9 +41,9 @@ import java.util.Locale; /** /** * Factory class, used for decoding raw byte arrays, received from baseband, * Factory class, used for decoding raw byte arrays, received from baseband, * into a CommandParams object. * into a CommandParams object. * * @hide */ */ class CommandParamsFactory extends Handler { public class CommandParamsFactory extends Handler { private static CommandParamsFactory sInstance = null; private static CommandParamsFactory sInstance = null; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private IconLoader mIconLoader; private IconLoader mIconLoader; Loading @@ -53,6 +54,7 @@ class CommandParamsFactory extends Handler { private String mSavedLanguage; private String mSavedLanguage; private String mRequestedLanguage; private String mRequestedLanguage; private boolean mNoAlphaUsrCnf = false; private boolean mNoAlphaUsrCnf = false; private boolean mStkSmsSendViaTelephony = false; // constants // constants static final int MSG_ID_LOAD_ICON_DONE = 1; static final int MSG_ID_LOAD_ICON_DONE = 1; Loading Loading @@ -86,7 +88,15 @@ class CommandParamsFactory extends Handler { private static final int MAX_GSM7_DEFAULT_CHARS = 239; private static final int MAX_GSM7_DEFAULT_CHARS = 239; private static final int MAX_UCS2_CHARS = 118; private static final int MAX_UCS2_CHARS = 118; static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller, /** * Returns a singleton instance of CommandParamsFactory * @param caller Class used for queuing raw ril messages, decoding them into * CommandParams objects and sending the result back to the CAT Service. * @param fh IccFileHandler Object * @param context The Context * @return CommandParamsFactory instance */ public static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller, IccFileHandler fh, Context context) { IccFileHandler fh, Context context) { if (sInstance != null) { if (sInstance != null) { return sInstance; return sInstance; Loading @@ -106,6 +116,12 @@ class CommandParamsFactory extends Handler { } catch (NotFoundException e) { } catch (NotFoundException e) { mNoAlphaUsrCnf = false; mNoAlphaUsrCnf = false; } } try { mStkSmsSendViaTelephony = context.getResources().getBoolean( com.android.internal.R.bool.config_stk_sms_send_support); } catch (NotFoundException e) { mStkSmsSendViaTelephony = false; } } } private CommandDetails processCommandDetails(List<ComprehensionTlv> ctlvs) { private CommandDetails processCommandDetails(List<ComprehensionTlv> ctlvs) { Loading Loading @@ -187,8 +203,14 @@ class CommandParamsFactory extends Handler { case GET_INPUT: case GET_INPUT: cmdPending = processGetInput(cmdDet, ctlvs); cmdPending = processGetInput(cmdDet, ctlvs); break; break; case SEND_DTMF: case SEND_SMS: case SEND_SMS: if (mStkSmsSendViaTelephony) { cmdPending = processSMSEventNotify(cmdDet, ctlvs); } else { cmdPending = processEventNotify(cmdDet, ctlvs); } break; case SEND_DTMF: case REFRESH: case REFRESH: case RUN_AT: case RUN_AT: case SEND_SS: case SEND_SS: Loading Loading @@ -735,6 +757,62 @@ class CommandParamsFactory extends Handler { return false; return false; } } /** * Processes SMS_EVENT_NOTIFY message from baseband. * * Method extracts values such as Alpha Id,Icon Id,Sms Tpdu etc from the ComprehensionTlv, * in order to create the CommandParams i.e. SendSMSParams. * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command * @return true if the command is processing is pending and additional * asynchronous processing is required. * @hide */ public boolean processSMSEventNotify(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs) throws ResultException { CatLog.d(this, "processSMSEventNotify"); TextMessage textMsg = new TextMessage(); IconId iconId = null; ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs); /* Retrieves alpha identifier from an Alpha Identifier COMPREHENSION-TLV object. * * String corresponding to the alpha identifier is obtained and saved as part of * the DisplayTextParams. */ textMsg.text = ValueParser.retrieveAlphaId(ctlv, mNoAlphaUsrCnf); ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs); if (ctlv != null) { // Retrieves icon id from the Icon Identifier COMPREHENSION-TLV object iconId = ValueParser.retrieveIconId(ctlv); textMsg.iconSelfExplanatory = iconId.selfExplanatory; } textMsg.responseNeeded = false; DisplayTextParams displayTextParams = new DisplayTextParams(cmdDet, textMsg); ComprehensionTlv ctlvTpdu = searchForTag(ComprehensionTlvTag.SMS_TPDU, ctlvs); // Retrieves smsMessage from the SMS TPDU COMPREHENSION-TLV object SmsMessage smsMessage = ValueParser.retrieveTpduAsSmsMessage(ctlvTpdu); if (smsMessage != null) { TextMessage smsText = new TextMessage(); // Obtains the sms message content. smsText.text = smsMessage.getMessageBody(); TextMessage destAddr = new TextMessage(); // Obtains the destination Address. destAddr.text = smsMessage.getRecipientAddress(); mCmdParams = new SendSMSParams(cmdDet, smsText, destAddr, displayTextParams); return false; } return true; } /** /** * Processes SET_UP_EVENT_LIST proactive command from the SIM card. * Processes SET_UP_EVENT_LIST proactive command from the SIM card. * * Loading Loading
src/java/com/android/internal/telephony/SmsController.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -197,6 +197,35 @@ public class SmsController extends ISmsImplBase { String callingAttributionTag, String destAddr, String scAddr, String text, String callingAttributionTag, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, long messageId) { boolean persistMessageForNonDefaultSmsApp, long messageId) { sendTextForSubscriber(subId, callingPackage, callingAttributionTag, destAddr, scAddr, text, sentIntent, deliveryIntent, persistMessageForNonDefaultSmsApp, messageId, false); } /** * @param subId Subscription Id * @param callingAttributionTag the attribution tag of the caller * @param destAddr the address to send the message to * @param scAddr is the service center address or null to use * the current default SMSC * @param text the body of the message to send * @param sentIntent if not NULL this <code>PendingIntent</code> is * broadcast when the message is successfully sent, or failed. * The result code will be <code>Activity.RESULT_OK</code> for success, or relevant errors * the sentIntent may include the extra "errorCode" containing a radio technology specific * value, generally only useful for troubleshooting. * @param deliveryIntent if not NULL this <code>PendingIntent</code> is * broadcast when the message is delivered to the recipient. The * raw pdu of the status report is in the extended data ("pdu"). * @param skipFdnCheck if set to true, FDN check must be skipped .This is set in case of STK sms * * @hide */ public void sendTextForSubscriber(int subId, String callingPackage, String callingAttributionTag, String destAddr, String scAddr, String text, PendingIntent sentIntent, PendingIntent deliveryIntent, boolean persistMessageForNonDefaultSmsApp, long messageId, boolean skipFdnCheck) { if (callingPackage == null) { if (callingPackage == null) { callingPackage = getCallingPackage(); callingPackage = getCallingPackage(); } } Loading @@ -209,7 +238,7 @@ public class SmsController extends ISmsImplBase { } } // Perform FDN check // Perform FDN check if (isNumberBlockedByFDN(subId, destAddr, callingPackage)) { if (!skipFdnCheck && isNumberBlockedByFDN(subId, destAddr, callingPackage)) { sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_FDN_CHECK_FAILURE); return; return; } } Loading
src/java/com/android/internal/telephony/cat/CatCmdMessage.java +123 −91 Original line number Original line Diff line number Diff line Loading @@ -40,6 +40,7 @@ public class CatCmdMessage implements Parcelable { private ToneSettings mToneSettings = null; private ToneSettings mToneSettings = null; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private CallSettings mCallSettings = null; private CallSettings mCallSettings = null; private SMSSettings mSMSSettings = null; private SetupEventListSettings mSetupEventListSettings = null; private SetupEventListSettings mSetupEventListSettings = null; private boolean mLoadIconFailed = false; private boolean mLoadIconFailed = false; Loading @@ -61,6 +62,14 @@ public class CatCmdMessage implements Parcelable { public TextMessage callMsg; public TextMessage callMsg; } } /** * Container for SEND SMS command settings. */ public class SMSSettings { public TextMessage smsText; public TextMessage destAddr; } public class SetupEventListSettings { public class SetupEventListSettings { @UnsupportedAppUsage @UnsupportedAppUsage public int[] eventList; public int[] eventList; Loading Loading @@ -88,10 +97,22 @@ public class CatCmdMessage implements Parcelable { case SELECT_ITEM: case SELECT_ITEM: mMenu = ((SelectItemParams) cmdParams).mMenu; mMenu = ((SelectItemParams) cmdParams).mMenu; break; break; case SEND_SMS: /* If cmdParams is an instanceof SendSMSParams , then it means config value * config_stk_sms_send_support is true and the SMS should be sent by framework */ if (cmdParams instanceof SendSMSParams) { mSMSSettings = new SMSSettings(); mSMSSettings.smsText = ((SendSMSParams) cmdParams).mTextSmsMsg; mSMSSettings.destAddr = ((SendSMSParams) cmdParams).mDestAddress; mTextMsg = ((SendSMSParams) cmdParams).mDisplayText.mTextMsg; } else { mTextMsg = ((DisplayTextParams) cmdParams).mTextMsg; } break; case DISPLAY_TEXT: case DISPLAY_TEXT: case SET_UP_IDLE_MODE_TEXT: case SET_UP_IDLE_MODE_TEXT: case SEND_DTMF: case SEND_DTMF: case SEND_SMS: case REFRESH: case REFRESH: case RUN_AT: case RUN_AT: case SEND_SS: case SEND_SS: Loading Loading @@ -166,6 +187,11 @@ public class CatCmdMessage implements Parcelable { mSetupEventListSettings.eventList[i] = in.readInt(); mSetupEventListSettings.eventList[i] = in.readInt(); } } break; break; case SEND_SMS: mSMSSettings = new SMSSettings(); mSMSSettings.smsText = in.readParcelable(SendSMSParams.class.getClassLoader()); mSMSSettings.destAddr = in.readParcelable(SendSMSParams.class.getClassLoader()); break; default: default: break; break; } } Loading Loading @@ -193,6 +219,12 @@ public class CatCmdMessage implements Parcelable { case SET_UP_EVENT_LIST: case SET_UP_EVENT_LIST: dest.writeIntArray(mSetupEventListSettings.eventList); dest.writeIntArray(mSetupEventListSettings.eventList); break; break; case SEND_SMS: if (mSMSSettings != null) { dest.writeParcelable(mSMSSettings.smsText, 0); dest.writeParcelable(mSMSSettings.destAddr, 0); } break; default: default: break; break; } } Loading
src/java/com/android/internal/telephony/cat/CatService.java +127 −4 Original line number Original line Diff line number Diff line Loading @@ -20,24 +20,34 @@ import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListCon import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.LANGUAGE_SELECTION_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT; import static com.android.internal.telephony.cat.CatCmdMessage.SetupEventListConstants.USER_ACTIVITY_EVENT; import android.app.Activity; import android.app.ActivityManager; import android.app.ActivityManager; import android.app.PendingIntent; import android.app.backup.BackupManager; import android.app.backup.BackupManager; import android.compat.annotation.UnsupportedAppUsage; import android.compat.annotation.UnsupportedAppUsage; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Context; import android.content.Intent; import android.content.Intent; import android.content.IntentFilter; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo; import android.content.res.Resources.NotFoundException; import android.content.res.Resources.NotFoundException; import android.os.AsyncResult; import android.os.AsyncResult; import android.os.Build; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.HandlerThread; import android.os.LocaleList; import android.os.LocaleList; import android.os.Looper; import android.os.Message; import android.os.Message; import android.os.RemoteException; import android.os.RemoteException; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; import android.telephony.TelephonyManager; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.CommandsInterface; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.PhoneConstants; import com.android.internal.telephony.ProxyController; import com.android.internal.telephony.SmsController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.SubscriptionController; import com.android.internal.telephony.uicc.IccCardStatus.CardState; import com.android.internal.telephony.uicc.IccCardStatus.CardState; import com.android.internal.telephony.uicc.IccFileHandler; import com.android.internal.telephony.uicc.IccFileHandler; Loading Loading @@ -138,12 +148,21 @@ public class CatService extends Handler implements AppInterface { static final String STK_DEFAULT = "Default Message"; static final String STK_DEFAULT = "Default Message"; private static final String SMS_DELIVERY_ACTION = "com.android.internal.telephony.cat.SMS_DELIVERY_ACTION"; private static final String SMS_SENT_ACTION = "com.android.internal.telephony.cat.SMS_SENT_ACTION"; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private int mSlotId; private int mSlotId; private static HandlerThread sCatServiceThread; /* For multisim catservice should not be singleton */ /* For multisim catservice should not be singleton */ private CatService(CommandsInterface ci, UiccCardApplication ca, IccRecords ir, private CatService(CommandsInterface ci, UiccCardApplication ca, IccRecords ir, Context context, IccFileHandler fh, UiccProfile uiccProfile, int slotId) { Context context, IccFileHandler fh, UiccProfile uiccProfile, int slotId, Looper looper) { //creating new thread to avoid deadlock conditions with the framework thread. super(looper); if (ci == null || ca == null || ir == null || context == null || fh == null if (ci == null || ca == null || ir == null || context == null || fh == null || uiccProfile == null) { || uiccProfile == null) { throw new NullPointerException( throw new NullPointerException( Loading Loading @@ -187,6 +206,10 @@ public class CatService extends Handler implements AppInterface { CatLog.d(this, "Running CAT service on Slotid: " + mSlotId + CatLog.d(this, "Running CAT service on Slotid: " + mSlotId + ". STK app installed:" + mStkAppInstalled); ". STK app installed:" + mStkAppInstalled); SmsBroadcastReceiver smsBroadcastReceiver = new SmsBroadcastReceiver(); mContext.registerReceiver(smsBroadcastReceiver, new IntentFilter(SMS_DELIVERY_ACTION)); mContext.registerReceiver(smsBroadcastReceiver, new IntentFilter(SMS_SENT_ACTION)); } } /** /** Loading @@ -200,6 +223,10 @@ public class CatService extends Handler implements AppInterface { */ */ public static CatService getInstance(CommandsInterface ci, public static CatService getInstance(CommandsInterface ci, Context context, UiccProfile uiccProfile, int slotId) { Context context, UiccProfile uiccProfile, int slotId) { if (sCatServiceThread == null) { sCatServiceThread = new HandlerThread("CatServiceThread"); sCatServiceThread.start(); } UiccCardApplication ca = null; UiccCardApplication ca = null; IccFileHandler fh = null; IccFileHandler fh = null; IccRecords ir = null; IccRecords ir = null; Loading Loading @@ -227,8 +254,8 @@ public class CatService extends Handler implements AppInterface { || uiccProfile == null) { || uiccProfile == null) { return null; return null; } } sInstance[slotId] = new CatService(ci, ca, ir, context, fh, uiccProfile, slotId, sInstance[slotId] = new CatService(ci, ca, ir, context, fh, uiccProfile, slotId); sCatServiceThread.getLooper()); } else if ((ir != null) && (mIccRecords != ir)) { } else if ((ir != null) && (mIccRecords != ir)) { if (mIccRecords != null) { if (mIccRecords != null) { mIccRecords.unregisterForRecordsLoaded(sInstance[slotId]); mIccRecords.unregisterForRecordsLoaded(sInstance[slotId]); Loading Loading @@ -447,8 +474,49 @@ public class CatService extends Handler implements AppInterface { ((DisplayTextParams)cmdParams).mTextMsg.text = null; ((DisplayTextParams)cmdParams).mTextMsg.text = null; } } break; break; case SEND_DTMF: case SEND_SMS: case SEND_SMS: /* If cmdParams is an instanceof SendSMSParams , then it means config value * config_stk_sms_send_support is true and the SMS should be sent by framework */ if (cmdParams instanceof SendSMSParams) { String text = null, destAddr = null; if (((SendSMSParams) cmdParams).mTextSmsMsg != null) { text = ((SendSMSParams) cmdParams).mTextSmsMsg.text; } if (((SendSMSParams) cmdParams).mDestAddress != null) { destAddr = ((SendSMSParams) cmdParams).mDestAddress.text; } if (text != null && destAddr != null) { ProxyController proxyController = ProxyController.getInstance(mContext); SubscriptionManager subscriptionManager = (SubscriptionManager) mContext.getSystemService( Context.TELEPHONY_SUBSCRIPTION_SERVICE); SubscriptionInfo subInfo = subscriptionManager.getActiveSubscriptionInfoForSimSlotIndex( mSlotId); if (subInfo != null) { sendStkSms(text, destAddr, subInfo.getSubscriptionId(), cmdParams, proxyController); } else { sendTerminalResponse(cmdParams.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD, false, 0x00, null); CatLog.d(this, "Subscription info is null"); } } else { sendTerminalResponse(cmdParams.mCmdDet, ResultCode.CMD_DATA_NOT_UNDERSTOOD, false, 0x00, null); CatLog.d(this, "Sms text or Destination Address is null"); } } else { if ((((DisplayTextParams) cmdParams).mTextMsg.text != null) && (((DisplayTextParams) cmdParams).mTextMsg.text.equals( STK_DEFAULT))) { message = mContext.getText(com.android.internal.R.string.sending); ((DisplayTextParams) cmdParams).mTextMsg.text = message.toString(); } } break; case SEND_DTMF: case SEND_SS: case SEND_SS: case SEND_USSD: case SEND_USSD: if ((((DisplayTextParams)cmdParams).mTextMsg.text != null) if ((((DisplayTextParams)cmdParams).mTextMsg.text != null) Loading Loading @@ -536,6 +604,61 @@ public class CatService extends Handler implements AppInterface { broadcastCatCmdIntent(cmdMsg); broadcastCatCmdIntent(cmdMsg); } } /** * Used to send STK based sms via CATService * @param text The message body * @param destAddr The destination Address * @param subId Subscription Id * @param cmdParams Send SMS Command Params * @param proxyController ProxyController * @hide */ public void sendStkSms(String text, String destAddr, int subId, CommandParams cmdParams, ProxyController proxyController) { PendingIntent sentPendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(SMS_SENT_ACTION).putExtra("cmdDetails", cmdParams.mCmdDet), PendingIntent.FLAG_MUTABLE); PendingIntent deliveryPendingIntent = PendingIntent.getBroadcast(mContext, 0, new Intent(SMS_DELIVERY_ACTION).putExtra("cmdDetails", cmdParams.mCmdDet), PendingIntent.FLAG_MUTABLE); SmsController smsController = proxyController.getSmsController(); smsController.sendTextForSubscriber(subId, mContext.getOpPackageName(), mContext.getAttributionTag(), destAddr, null, text, sentPendingIntent, deliveryPendingIntent, false, 0L, true); } private class SmsBroadcastReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { CommandDetails commandDetails = (CommandDetails) intent.getExtra("cmdDetails"); if (intent.getAction().equals(SMS_SENT_ACTION)) { int resultCode = getResultCode(); switch (resultCode) { case Activity.RESULT_OK: break; default: //ToDO handle Error cases bug : b/243123292 CatLog.d(this, "Error sending STK SMS : " + resultCode); sendTerminalResponse(commandDetails, ResultCode.SMS_RP_ERROR, true, ResultCode.NETWORK_CRNTLY_UNABLE_TO_PROCESS.value(), null); } } if (intent.getAction().equals(SMS_DELIVERY_ACTION)) { int resultCode = getResultCode(); switch (resultCode) { case Activity.RESULT_OK: sendTerminalResponse(commandDetails, ResultCode.OK, false, 0, null); break; default: //ToDO handle Error cases bug: b/243123292 CatLog.d(this, "Error delivering STK SMS : " + resultCode); sendTerminalResponse(commandDetails, ResultCode.SMS_RP_ERROR, true, ResultCode.TERMINAL_CRNTLY_UNABLE_TO_PROCESS.value(), null); } } } } private void broadcastCatCmdIntent(CatCmdMessage cmdMsg) { private void broadcastCatCmdIntent(CatCmdMessage cmdMsg) { Intent intent = new Intent(AppInterface.CAT_CMD_ACTION); Intent intent = new Intent(AppInterface.CAT_CMD_ACTION); Loading
src/java/com/android/internal/telephony/cat/CommandParams.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -22,16 +22,16 @@ import android.os.Build; /** /** * Container class for proactive command parameters. * Container class for proactive command parameters. * * @hide */ */ class CommandParams { public class CommandParams { @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) CommandDetails mCmdDet; CommandDetails mCmdDet; // Variable to track if an optional icon load has failed. // Variable to track if an optional icon load has failed. boolean mLoadIconFailed = false; boolean mLoadIconFailed = false; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) CommandParams(CommandDetails cmdDet) { public CommandParams(CommandDetails cmdDet) { mCmdDet = cmdDet; mCmdDet = cmdDet; } } Loading
src/java/com/android/internal/telephony/cat/CommandParamsFactory.java +82 −4 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import android.graphics.Bitmap; import android.os.Build; import android.os.Build; import android.os.Handler; import android.os.Handler; import android.os.Message; import android.os.Message; import android.telephony.SmsMessage; import android.text.TextUtils; import android.text.TextUtils; import com.android.internal.telephony.GsmAlphabet; import com.android.internal.telephony.GsmAlphabet; Loading @@ -40,9 +41,9 @@ import java.util.Locale; /** /** * Factory class, used for decoding raw byte arrays, received from baseband, * Factory class, used for decoding raw byte arrays, received from baseband, * into a CommandParams object. * into a CommandParams object. * * @hide */ */ class CommandParamsFactory extends Handler { public class CommandParamsFactory extends Handler { private static CommandParamsFactory sInstance = null; private static CommandParamsFactory sInstance = null; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) private IconLoader mIconLoader; private IconLoader mIconLoader; Loading @@ -53,6 +54,7 @@ class CommandParamsFactory extends Handler { private String mSavedLanguage; private String mSavedLanguage; private String mRequestedLanguage; private String mRequestedLanguage; private boolean mNoAlphaUsrCnf = false; private boolean mNoAlphaUsrCnf = false; private boolean mStkSmsSendViaTelephony = false; // constants // constants static final int MSG_ID_LOAD_ICON_DONE = 1; static final int MSG_ID_LOAD_ICON_DONE = 1; Loading Loading @@ -86,7 +88,15 @@ class CommandParamsFactory extends Handler { private static final int MAX_GSM7_DEFAULT_CHARS = 239; private static final int MAX_GSM7_DEFAULT_CHARS = 239; private static final int MAX_UCS2_CHARS = 118; private static final int MAX_UCS2_CHARS = 118; static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller, /** * Returns a singleton instance of CommandParamsFactory * @param caller Class used for queuing raw ril messages, decoding them into * CommandParams objects and sending the result back to the CAT Service. * @param fh IccFileHandler Object * @param context The Context * @return CommandParamsFactory instance */ public static synchronized CommandParamsFactory getInstance(RilMessageDecoder caller, IccFileHandler fh, Context context) { IccFileHandler fh, Context context) { if (sInstance != null) { if (sInstance != null) { return sInstance; return sInstance; Loading @@ -106,6 +116,12 @@ class CommandParamsFactory extends Handler { } catch (NotFoundException e) { } catch (NotFoundException e) { mNoAlphaUsrCnf = false; mNoAlphaUsrCnf = false; } } try { mStkSmsSendViaTelephony = context.getResources().getBoolean( com.android.internal.R.bool.config_stk_sms_send_support); } catch (NotFoundException e) { mStkSmsSendViaTelephony = false; } } } private CommandDetails processCommandDetails(List<ComprehensionTlv> ctlvs) { private CommandDetails processCommandDetails(List<ComprehensionTlv> ctlvs) { Loading Loading @@ -187,8 +203,14 @@ class CommandParamsFactory extends Handler { case GET_INPUT: case GET_INPUT: cmdPending = processGetInput(cmdDet, ctlvs); cmdPending = processGetInput(cmdDet, ctlvs); break; break; case SEND_DTMF: case SEND_SMS: case SEND_SMS: if (mStkSmsSendViaTelephony) { cmdPending = processSMSEventNotify(cmdDet, ctlvs); } else { cmdPending = processEventNotify(cmdDet, ctlvs); } break; case SEND_DTMF: case REFRESH: case REFRESH: case RUN_AT: case RUN_AT: case SEND_SS: case SEND_SS: Loading Loading @@ -735,6 +757,62 @@ class CommandParamsFactory extends Handler { return false; return false; } } /** * Processes SMS_EVENT_NOTIFY message from baseband. * * Method extracts values such as Alpha Id,Icon Id,Sms Tpdu etc from the ComprehensionTlv, * in order to create the CommandParams i.e. SendSMSParams. * * @param cmdDet Command Details container object. * @param ctlvs List of ComprehensionTlv objects following Command Details * object and Device Identities object within the proactive command * @return true if the command is processing is pending and additional * asynchronous processing is required. * @hide */ public boolean processSMSEventNotify(CommandDetails cmdDet, List<ComprehensionTlv> ctlvs) throws ResultException { CatLog.d(this, "processSMSEventNotify"); TextMessage textMsg = new TextMessage(); IconId iconId = null; ComprehensionTlv ctlv = searchForTag(ComprehensionTlvTag.ALPHA_ID, ctlvs); /* Retrieves alpha identifier from an Alpha Identifier COMPREHENSION-TLV object. * * String corresponding to the alpha identifier is obtained and saved as part of * the DisplayTextParams. */ textMsg.text = ValueParser.retrieveAlphaId(ctlv, mNoAlphaUsrCnf); ctlv = searchForTag(ComprehensionTlvTag.ICON_ID, ctlvs); if (ctlv != null) { // Retrieves icon id from the Icon Identifier COMPREHENSION-TLV object iconId = ValueParser.retrieveIconId(ctlv); textMsg.iconSelfExplanatory = iconId.selfExplanatory; } textMsg.responseNeeded = false; DisplayTextParams displayTextParams = new DisplayTextParams(cmdDet, textMsg); ComprehensionTlv ctlvTpdu = searchForTag(ComprehensionTlvTag.SMS_TPDU, ctlvs); // Retrieves smsMessage from the SMS TPDU COMPREHENSION-TLV object SmsMessage smsMessage = ValueParser.retrieveTpduAsSmsMessage(ctlvTpdu); if (smsMessage != null) { TextMessage smsText = new TextMessage(); // Obtains the sms message content. smsText.text = smsMessage.getMessageBody(); TextMessage destAddr = new TextMessage(); // Obtains the destination Address. destAddr.text = smsMessage.getRecipientAddress(); mCmdParams = new SendSMSParams(cmdDet, smsText, destAddr, displayTextParams); return false; } return true; } /** /** * Processes SET_UP_EVENT_LIST proactive command from the SIM card. * Processes SET_UP_EVENT_LIST proactive command from the SIM card. * * Loading