Loading src/java/android/telephony/SmsMessage.java +12 −9 Original line number Diff line number Diff line Loading @@ -149,17 +149,18 @@ public class SmsMessage { } /** * Create an SmsMessage from a raw PDU. * * <p><b>This method will soon be deprecated</b> and all applications which handle * Create an SmsMessage from a raw PDU. Guess format based on Voice * technology first, if it fails use other format. * All applications which handle * incoming SMS messages by processing the {@code SMS_RECEIVED_ACTION} broadcast * intent <b>must</b> now pass the new {@code format} String extra from the intent * into the new method {@code createFromPdu(byte[], String)} which takes an * extra format parameter. This is required in order to correctly decode the PDU on * devices that require support for both 3GPP and 3GPP2 formats at the same time, * such as dual-mode GSM/CDMA and CDMA/LTE phones. Guess format based on Voice * technology first, if it fails use other format. * such as dual-mode GSM/CDMA and CDMA/LTE phones. * @deprecated Use {@link #createFromPdu(byte[], String)} instead. */ @Deprecated public static SmsMessage createFromPdu(byte[] pdu) { SmsMessage message = null; Loading @@ -181,13 +182,15 @@ public class SmsMessage { /** * Create an SmsMessage from a raw PDU with the specified message format. The * message format is passed in the {@code SMS_RECEIVED_ACTION} as the {@code format} * message format is passed in the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} as the {@code format} * String extra, and will be either "3gpp" for GSM/UMTS/LTE messages in 3GPP format * or "3gpp2" for CDMA/LTE messages in 3GPP2 format. * * @param pdu the message PDU from the SMS_RECEIVED_ACTION intent * @param format the format extra from the SMS_RECEIVED_ACTION intent * @hide pending API council approval * @param pdu the message PDU from the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent * @param format the format extra from the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent */ public static SmsMessage createFromPdu(byte[] pdu, String format) { SmsMessageBase wrappedMessage; Loading src/java/com/android/internal/telephony/SMSDispatcher.java +14 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; Loading Loading @@ -354,6 +355,13 @@ public abstract class SMSDispatcher extends Handler { } } private static int getSendSmsFlag(@Nullable PendingIntent deliveryIntent) { if (deliveryIntent == null) { return 0; } return CarrierMessagingService.SEND_FLAG_REQUEST_DELIVERY_STATUS; } /** * Use the carrier messaging service to send a text SMS. */ Loading @@ -370,7 +378,8 @@ public abstract class SMSDispatcher extends Handler { if (text != null) { try { carrierMessagingService.sendTextSms(text, getSubId(), mTracker.mDestAddress, mSenderCallback); mTracker.mDestAddress, getSendSmsFlag(mTracker.mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendSmsComplete( Loading Loading @@ -402,7 +411,8 @@ public abstract class SMSDispatcher extends Handler { if (data != null) { try { carrierMessagingService.sendDataSms(data, getSubId(), mTracker.mDestAddress, destPort, mSenderCallback); mTracker.mDestAddress, destPort, getSendSmsFlag(mTracker.mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendSmsComplete( Loading Loading @@ -528,7 +538,8 @@ public abstract class SMSDispatcher extends Handler { protected void onServiceReady(ICarrierMessagingService carrierMessagingService) { try { carrierMessagingService.sendMultipartTextSms( mParts, getSubId(), mTrackers[0].mDestAddress, mSenderCallback); mParts, getSubId(), mTrackers[0].mDestAddress, getSendSmsFlag(mTrackers[0].mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendMultipartSmsComplete( Loading src/java/com/android/internal/telephony/SubscriptionController.java +50 −57 Original line number Diff line number Diff line Loading @@ -47,12 +47,13 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** * SubscriptionController to provide an inter-process communication to Loading Loading @@ -128,7 +129,8 @@ public class SubscriptionController extends ISub.Stub { private final AppOpsManager mAppOps; // FIXME: Does not allow for multiple subs in a slot and change to SparseArray private static HashMap<Integer, Integer> mSlotIdxToSubId = new HashMap<Integer, Integer>(); private static Map<Integer, Integer> sSlotIdxToSubId = new ConcurrentHashMap<Integer, Integer>(); private static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; Loading Loading @@ -179,7 +181,7 @@ public class SubscriptionController extends ISub.Stub { } private boolean isSubInfoReady() { return mSlotIdxToSubId.size() > 0; return sSlotIdxToSubId.size() > 0; } private SubscriptionController(Phone phone) { Loading Loading @@ -755,9 +757,9 @@ public class SubscriptionController extends ISub.Stub { do { int subId = cursor.getInt(cursor.getColumnIndexOrThrow( SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID)); // If mSlotIdToSubIdMap already has a valid subId for a slotId/phoneId, // If sSlotIdxToSubId already has a valid subId for a slotId/phoneId, // do not add another subId for same slotId/phoneId. Integer currentSubId = mSlotIdxToSubId.get(slotId); Integer currentSubId = sSlotIdxToSubId.get(slotId); if (currentSubId == null || !SubscriptionManager.isValidSubscriptionId(currentSubId)) { // TODO While two subs active, if user deactivats first Loading @@ -766,12 +768,12 @@ public class SubscriptionController extends ISub.Stub { // FIXME: Currently we assume phoneId == slotId which in the future // may not be true, for instance with multiple subs per slot. // But is true at the moment. mSlotIdxToSubId.put(slotId, subId); sSlotIdxToSubId.put(slotId, subId); int subIdCountMax = getActiveSubInfoCountMax(); int defaultSubId = getDefaultSubId(); if (DBG) { logdl("[addSubInfoRecord]" + " mSlotIdxToSubId.size=" + mSlotIdxToSubId.size() + " sSlotIdxToSubId.size=" + sSlotIdxToSubId.size() + " slotId=" + slotId + " subId=" + subId + " defaultSubId=" + defaultSubId + " simCount=" + subIdCountMax); } Loading Loading @@ -808,7 +810,7 @@ public class SubscriptionController extends ISub.Stub { // Once the records are loaded, notify DcTracker updateAllDataConnectionTrackers(); if (DBG) logdl("[addSubInfoRecord]- info size=" + mSlotIdxToSubId.size()); if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size()); return 0; } finally { Binder.restoreCallingIdentity(identity); Loading Loading @@ -1105,7 +1107,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.INVALID_SIM_SLOT_INDEX; } int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { Loading @@ -1113,7 +1115,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.SIM_NOT_INSERTED; } for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int sim = entry.getKey(); int sub = entry.getValue(); Loading Loading @@ -1154,10 +1156,10 @@ public class SubscriptionController extends ISub.Stub { } // Check if we've got any SubscriptionInfo records using slotIdToSubId as a surrogate. int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { if (DBG) { logd("[getSubId]- mSlotIdToSubIdMap.size == 0, return DummySubIds slotIdx=" logd("[getSubId]- sSlotIdxToSubId.size == 0, return DummySubIds slotIdx=" + slotIdx); } return getDummySubIds(slotIdx); Loading @@ -1165,7 +1167,7 @@ public class SubscriptionController extends ISub.Stub { // Create an array of subIds that are in this slot? ArrayList<Integer> subIds = new ArrayList<Integer>(); for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int slot = entry.getKey(); int sub = entry.getValue(); if (slotIdx == slot) { Loading Loading @@ -1206,7 +1208,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.INVALID_PHONE_INDEX; } int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { phoneId = mDefaultPhoneId; if (DBG) logdl("[getPhoneId]- no sims, returning default phoneId=" + phoneId); Loading @@ -1214,7 +1216,7 @@ public class SubscriptionController extends ISub.Stub { } // FIXME: Assumes phoneId == slotId for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int sim = entry.getKey(); int sub = entry.getValue(); Loading Loading @@ -1633,7 +1635,7 @@ public class SubscriptionController extends ISub.Stub { */ @Override public int[] getActiveSubIdList() { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); Set<Entry<Integer, Integer>> simInfoSet = sSlotIdxToSubId.entrySet(); if (DBG) logdl("[getActiveSubIdList] simInfoSet=" + simInfoSet); int[] subIdArr = new int[simInfoSet.size()]; Loading @@ -1648,20 +1650,11 @@ public class SubscriptionController extends ISub.Stub { return subIdArr; } private boolean isActiveSubId(int subId) { boolean retVal = false; if (SubscriptionManager.isValidSubscriptionId(subId)) { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); if (VDBG) logdl("[isActiveSubId] simInfoSet=" + simInfoSet); public boolean isActiveSubId(int subId) { enforceSubscriptionPermission(); for (Entry<Integer, Integer> entry: simInfoSet) { if (subId == entry.getValue()) { retVal = true; break; } } } boolean retVal = SubscriptionManager.isValidSubscriptionId(subId) && sSlotIdxToSubId.containsValue(subId); if (VDBG) logdl("[isActiveSubId]- " + retVal); return retVal; Loading Loading @@ -1733,8 +1726,8 @@ public class SubscriptionController extends ISub.Stub { .from(mContext).getDefaultSmsPhoneId()); pw.flush(); for (Entry<Integer, Integer> entry : mSlotIdxToSubId.entrySet()) { pw.println(" mSlotIdToSubIdMap[" + entry.getKey() + "]: subId=" + entry.getValue()); for (Entry<Integer, Integer> entry : sSlotIdxToSubId.entrySet()) { pw.println(" sSlotIdxToSubId[" + entry.getKey() + "]: subId=" + entry.getValue()); } pw.flush(); pw.println("++++++++++++++++++++++++++++++++"); Loading src/java/com/android/internal/telephony/UiccSmsController.java +47 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.PendingIntent; import android.content.Context; Loading @@ -25,7 +26,9 @@ import android.net.Uri; import android.os.Binder; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Telephony.Sms.Intents; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -118,8 +121,10 @@ public class UiccSmsController extends ISms.Stub { iccSmsIntMgr.sendData(callingPackage, destAddr, scAddr, destPort, data, sentIntent, deliveryIntent); } else { Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" + Rlog.e(LOG_TAG,"sendData iccSmsIntMgr is null for" + " Subscription: " + subId); // TODO: Use a more specific error code to replace RESULT_ERROR_GENERIC_FAILURE. sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -151,6 +156,7 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" + " Subscription: " + subId); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -185,6 +191,7 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendMultipartText iccSmsIntMgr is null for" + " Subscription: " + subId); sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -348,13 +355,24 @@ public class UiccSmsController extends ISms.Stub { // FIXME: Add injectSmsPdu to ISms.aidl public void injectSmsPdu(int subId, byte[] pdu, String format, PendingIntent receivedIntent) { getIccSmsInterfaceManager(subId).injectSmsPdu(pdu, format, receivedIntent); IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId); if (iccSmsIntMgr != null) { iccSmsIntMgr.injectSmsPdu(pdu, format, receivedIntent); } else { // RESULT_SMS_GENERIC_ERROR is documented for injectSmsPdu sendErrorInPendingIntent(receivedIntent, Intents.RESULT_SMS_GENERIC_ERROR); } } /** * get sms interface manager object based on subscription. **/ private IccSmsInterfaceManager getIccSmsInterfaceManager(int subId) { private @Nullable IccSmsInterfaceManager getIccSmsInterfaceManager(int subId) { if (!isActiveSubId(subId)) { Rlog.e(LOG_TAG, "Subscription " + subId + " is inactive."); return null; } int phoneId = SubscriptionController.getInstance().getPhoneId(subId) ; //Fixme: for multi-subscription case if (!SubscriptionManager.isValidPhoneId(phoneId) Loading @@ -367,11 +385,11 @@ public class UiccSmsController extends ISms.Stub { ((PhoneProxy)mPhone[(int)phoneId]).getIccSmsInterfaceManager(); } catch (NullPointerException e) { Rlog.e(LOG_TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); e.printStackTrace(); //This will print stact trace e.printStackTrace(); return null; } catch (ArrayIndexOutOfBoundsException e) { Rlog.e(LOG_TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); e.printStackTrace(); //This will print stack trace e.printStackTrace(); return null; } } Loading @@ -398,6 +416,7 @@ public class UiccSmsController extends ISms.Stub { deliveryIntent); } else { Rlog.e(LOG_TAG,"sendStoredText iccSmsIntMgr is null for subscription: " + subId); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading @@ -412,7 +431,29 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendStoredMultipartText iccSmsIntMgr is null for subscription: " + subId); sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } /* * @return true if the subId is active. */ private boolean isActiveSubId(int subId) { return SubscriptionController.getInstance().isActiveSubId(subId); } private void sendErrorInPendingIntent(@Nullable PendingIntent intent, int errorCode) { if (intent != null) { try { intent.send(errorCode); } catch (PendingIntent.CanceledException ex) { } } } private void sendErrorInPendingIntents(List<PendingIntent> intents, int errorCode) { for (PendingIntent intent : intents) { sendErrorInPendingIntent(intent, errorCode); } } } Loading
src/java/android/telephony/SmsMessage.java +12 −9 Original line number Diff line number Diff line Loading @@ -149,17 +149,18 @@ public class SmsMessage { } /** * Create an SmsMessage from a raw PDU. * * <p><b>This method will soon be deprecated</b> and all applications which handle * Create an SmsMessage from a raw PDU. Guess format based on Voice * technology first, if it fails use other format. * All applications which handle * incoming SMS messages by processing the {@code SMS_RECEIVED_ACTION} broadcast * intent <b>must</b> now pass the new {@code format} String extra from the intent * into the new method {@code createFromPdu(byte[], String)} which takes an * extra format parameter. This is required in order to correctly decode the PDU on * devices that require support for both 3GPP and 3GPP2 formats at the same time, * such as dual-mode GSM/CDMA and CDMA/LTE phones. Guess format based on Voice * technology first, if it fails use other format. * such as dual-mode GSM/CDMA and CDMA/LTE phones. * @deprecated Use {@link #createFromPdu(byte[], String)} instead. */ @Deprecated public static SmsMessage createFromPdu(byte[] pdu) { SmsMessage message = null; Loading @@ -181,13 +182,15 @@ public class SmsMessage { /** * Create an SmsMessage from a raw PDU with the specified message format. The * message format is passed in the {@code SMS_RECEIVED_ACTION} as the {@code format} * message format is passed in the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} as the {@code format} * String extra, and will be either "3gpp" for GSM/UMTS/LTE messages in 3GPP format * or "3gpp2" for CDMA/LTE messages in 3GPP2 format. * * @param pdu the message PDU from the SMS_RECEIVED_ACTION intent * @param format the format extra from the SMS_RECEIVED_ACTION intent * @hide pending API council approval * @param pdu the message PDU from the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent * @param format the format extra from the * {@link android.provider.Telephony.Sms.Intents#SMS_RECEIVED_ACTION} intent */ public static SmsMessage createFromPdu(byte[] pdu, String format) { SmsMessageBase wrappedMessage; Loading
src/java/com/android/internal/telephony/SMSDispatcher.java +14 −3 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ */ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.Activity; import android.app.AlertDialog; import android.app.PendingIntent; Loading Loading @@ -354,6 +355,13 @@ public abstract class SMSDispatcher extends Handler { } } private static int getSendSmsFlag(@Nullable PendingIntent deliveryIntent) { if (deliveryIntent == null) { return 0; } return CarrierMessagingService.SEND_FLAG_REQUEST_DELIVERY_STATUS; } /** * Use the carrier messaging service to send a text SMS. */ Loading @@ -370,7 +378,8 @@ public abstract class SMSDispatcher extends Handler { if (text != null) { try { carrierMessagingService.sendTextSms(text, getSubId(), mTracker.mDestAddress, mSenderCallback); mTracker.mDestAddress, getSendSmsFlag(mTracker.mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendSmsComplete( Loading Loading @@ -402,7 +411,8 @@ public abstract class SMSDispatcher extends Handler { if (data != null) { try { carrierMessagingService.sendDataSms(data, getSubId(), mTracker.mDestAddress, destPort, mSenderCallback); mTracker.mDestAddress, destPort, getSendSmsFlag(mTracker.mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendSmsComplete( Loading Loading @@ -528,7 +538,8 @@ public abstract class SMSDispatcher extends Handler { protected void onServiceReady(ICarrierMessagingService carrierMessagingService) { try { carrierMessagingService.sendMultipartTextSms( mParts, getSubId(), mTrackers[0].mDestAddress, mSenderCallback); mParts, getSubId(), mTrackers[0].mDestAddress, getSendSmsFlag(mTrackers[0].mDeliveryIntent), mSenderCallback); } catch (RemoteException e) { Rlog.e(TAG, "Exception sending the SMS: " + e); mSenderCallback.onSendMultipartSmsComplete( Loading
src/java/com/android/internal/telephony/SubscriptionController.java +50 −57 Original line number Diff line number Diff line Loading @@ -47,12 +47,13 @@ import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; /** * SubscriptionController to provide an inter-process communication to Loading Loading @@ -128,7 +129,8 @@ public class SubscriptionController extends ISub.Stub { private final AppOpsManager mAppOps; // FIXME: Does not allow for multiple subs in a slot and change to SparseArray private static HashMap<Integer, Integer> mSlotIdxToSubId = new HashMap<Integer, Integer>(); private static Map<Integer, Integer> sSlotIdxToSubId = new ConcurrentHashMap<Integer, Integer>(); private static int mDefaultFallbackSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID; private static int mDefaultPhoneId = SubscriptionManager.DEFAULT_PHONE_INDEX; Loading Loading @@ -179,7 +181,7 @@ public class SubscriptionController extends ISub.Stub { } private boolean isSubInfoReady() { return mSlotIdxToSubId.size() > 0; return sSlotIdxToSubId.size() > 0; } private SubscriptionController(Phone phone) { Loading Loading @@ -755,9 +757,9 @@ public class SubscriptionController extends ISub.Stub { do { int subId = cursor.getInt(cursor.getColumnIndexOrThrow( SubscriptionManager.UNIQUE_KEY_SUBSCRIPTION_ID)); // If mSlotIdToSubIdMap already has a valid subId for a slotId/phoneId, // If sSlotIdxToSubId already has a valid subId for a slotId/phoneId, // do not add another subId for same slotId/phoneId. Integer currentSubId = mSlotIdxToSubId.get(slotId); Integer currentSubId = sSlotIdxToSubId.get(slotId); if (currentSubId == null || !SubscriptionManager.isValidSubscriptionId(currentSubId)) { // TODO While two subs active, if user deactivats first Loading @@ -766,12 +768,12 @@ public class SubscriptionController extends ISub.Stub { // FIXME: Currently we assume phoneId == slotId which in the future // may not be true, for instance with multiple subs per slot. // But is true at the moment. mSlotIdxToSubId.put(slotId, subId); sSlotIdxToSubId.put(slotId, subId); int subIdCountMax = getActiveSubInfoCountMax(); int defaultSubId = getDefaultSubId(); if (DBG) { logdl("[addSubInfoRecord]" + " mSlotIdxToSubId.size=" + mSlotIdxToSubId.size() + " sSlotIdxToSubId.size=" + sSlotIdxToSubId.size() + " slotId=" + slotId + " subId=" + subId + " defaultSubId=" + defaultSubId + " simCount=" + subIdCountMax); } Loading Loading @@ -808,7 +810,7 @@ public class SubscriptionController extends ISub.Stub { // Once the records are loaded, notify DcTracker updateAllDataConnectionTrackers(); if (DBG) logdl("[addSubInfoRecord]- info size=" + mSlotIdxToSubId.size()); if (DBG) logdl("[addSubInfoRecord]- info size=" + sSlotIdxToSubId.size()); return 0; } finally { Binder.restoreCallingIdentity(identity); Loading Loading @@ -1105,7 +1107,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.INVALID_SIM_SLOT_INDEX; } int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { Loading @@ -1113,7 +1115,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.SIM_NOT_INSERTED; } for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int sim = entry.getKey(); int sub = entry.getValue(); Loading Loading @@ -1154,10 +1156,10 @@ public class SubscriptionController extends ISub.Stub { } // Check if we've got any SubscriptionInfo records using slotIdToSubId as a surrogate. int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { if (DBG) { logd("[getSubId]- mSlotIdToSubIdMap.size == 0, return DummySubIds slotIdx=" logd("[getSubId]- sSlotIdxToSubId.size == 0, return DummySubIds slotIdx=" + slotIdx); } return getDummySubIds(slotIdx); Loading @@ -1165,7 +1167,7 @@ public class SubscriptionController extends ISub.Stub { // Create an array of subIds that are in this slot? ArrayList<Integer> subIds = new ArrayList<Integer>(); for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int slot = entry.getKey(); int sub = entry.getValue(); if (slotIdx == slot) { Loading Loading @@ -1206,7 +1208,7 @@ public class SubscriptionController extends ISub.Stub { return SubscriptionManager.INVALID_PHONE_INDEX; } int size = mSlotIdxToSubId.size(); int size = sSlotIdxToSubId.size(); if (size == 0) { phoneId = mDefaultPhoneId; if (DBG) logdl("[getPhoneId]- no sims, returning default phoneId=" + phoneId); Loading @@ -1214,7 +1216,7 @@ public class SubscriptionController extends ISub.Stub { } // FIXME: Assumes phoneId == slotId for (Entry<Integer, Integer> entry: mSlotIdxToSubId.entrySet()) { for (Entry<Integer, Integer> entry: sSlotIdxToSubId.entrySet()) { int sim = entry.getKey(); int sub = entry.getValue(); Loading Loading @@ -1633,7 +1635,7 @@ public class SubscriptionController extends ISub.Stub { */ @Override public int[] getActiveSubIdList() { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); Set<Entry<Integer, Integer>> simInfoSet = sSlotIdxToSubId.entrySet(); if (DBG) logdl("[getActiveSubIdList] simInfoSet=" + simInfoSet); int[] subIdArr = new int[simInfoSet.size()]; Loading @@ -1648,20 +1650,11 @@ public class SubscriptionController extends ISub.Stub { return subIdArr; } private boolean isActiveSubId(int subId) { boolean retVal = false; if (SubscriptionManager.isValidSubscriptionId(subId)) { Set<Entry<Integer, Integer>> simInfoSet = mSlotIdxToSubId.entrySet(); if (VDBG) logdl("[isActiveSubId] simInfoSet=" + simInfoSet); public boolean isActiveSubId(int subId) { enforceSubscriptionPermission(); for (Entry<Integer, Integer> entry: simInfoSet) { if (subId == entry.getValue()) { retVal = true; break; } } } boolean retVal = SubscriptionManager.isValidSubscriptionId(subId) && sSlotIdxToSubId.containsValue(subId); if (VDBG) logdl("[isActiveSubId]- " + retVal); return retVal; Loading Loading @@ -1733,8 +1726,8 @@ public class SubscriptionController extends ISub.Stub { .from(mContext).getDefaultSmsPhoneId()); pw.flush(); for (Entry<Integer, Integer> entry : mSlotIdxToSubId.entrySet()) { pw.println(" mSlotIdToSubIdMap[" + entry.getKey() + "]: subId=" + entry.getValue()); for (Entry<Integer, Integer> entry : sSlotIdxToSubId.entrySet()) { pw.println(" sSlotIdxToSubId[" + entry.getKey() + "]: subId=" + entry.getValue()); } pw.flush(); pw.println("++++++++++++++++++++++++++++++++"); Loading
src/java/com/android/internal/telephony/UiccSmsController.java +47 −6 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.internal.telephony; import android.annotation.Nullable; import android.app.ActivityThread; import android.app.PendingIntent; import android.content.Context; Loading @@ -25,7 +26,9 @@ import android.net.Uri; import android.os.Binder; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Telephony.Sms.Intents; import android.telephony.Rlog; import android.telephony.SmsManager; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; Loading Loading @@ -118,8 +121,10 @@ public class UiccSmsController extends ISms.Stub { iccSmsIntMgr.sendData(callingPackage, destAddr, scAddr, destPort, data, sentIntent, deliveryIntent); } else { Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" + Rlog.e(LOG_TAG,"sendData iccSmsIntMgr is null for" + " Subscription: " + subId); // TODO: Use a more specific error code to replace RESULT_ERROR_GENERIC_FAILURE. sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -151,6 +156,7 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendText iccSmsIntMgr is null for" + " Subscription: " + subId); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -185,6 +191,7 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendMultipartText iccSmsIntMgr is null for" + " Subscription: " + subId); sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading Loading @@ -348,13 +355,24 @@ public class UiccSmsController extends ISms.Stub { // FIXME: Add injectSmsPdu to ISms.aidl public void injectSmsPdu(int subId, byte[] pdu, String format, PendingIntent receivedIntent) { getIccSmsInterfaceManager(subId).injectSmsPdu(pdu, format, receivedIntent); IccSmsInterfaceManager iccSmsIntMgr = getIccSmsInterfaceManager(subId); if (iccSmsIntMgr != null) { iccSmsIntMgr.injectSmsPdu(pdu, format, receivedIntent); } else { // RESULT_SMS_GENERIC_ERROR is documented for injectSmsPdu sendErrorInPendingIntent(receivedIntent, Intents.RESULT_SMS_GENERIC_ERROR); } } /** * get sms interface manager object based on subscription. **/ private IccSmsInterfaceManager getIccSmsInterfaceManager(int subId) { private @Nullable IccSmsInterfaceManager getIccSmsInterfaceManager(int subId) { if (!isActiveSubId(subId)) { Rlog.e(LOG_TAG, "Subscription " + subId + " is inactive."); return null; } int phoneId = SubscriptionController.getInstance().getPhoneId(subId) ; //Fixme: for multi-subscription case if (!SubscriptionManager.isValidPhoneId(phoneId) Loading @@ -367,11 +385,11 @@ public class UiccSmsController extends ISms.Stub { ((PhoneProxy)mPhone[(int)phoneId]).getIccSmsInterfaceManager(); } catch (NullPointerException e) { Rlog.e(LOG_TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); e.printStackTrace(); //This will print stact trace e.printStackTrace(); return null; } catch (ArrayIndexOutOfBoundsException e) { Rlog.e(LOG_TAG, "Exception is :"+e.toString()+" For subscription :"+subId ); e.printStackTrace(); //This will print stack trace e.printStackTrace(); return null; } } Loading @@ -398,6 +416,7 @@ public class UiccSmsController extends ISms.Stub { deliveryIntent); } else { Rlog.e(LOG_TAG,"sendStoredText iccSmsIntMgr is null for subscription: " + subId); sendErrorInPendingIntent(sentIntent, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } Loading @@ -412,7 +431,29 @@ public class UiccSmsController extends ISms.Stub { } else { Rlog.e(LOG_TAG,"sendStoredMultipartText iccSmsIntMgr is null for subscription: " + subId); sendErrorInPendingIntents(sentIntents, SmsManager.RESULT_ERROR_GENERIC_FAILURE); } } /* * @return true if the subId is active. */ private boolean isActiveSubId(int subId) { return SubscriptionController.getInstance().isActiveSubId(subId); } private void sendErrorInPendingIntent(@Nullable PendingIntent intent, int errorCode) { if (intent != null) { try { intent.send(errorCode); } catch (PendingIntent.CanceledException ex) { } } } private void sendErrorInPendingIntents(List<PendingIntent> intents, int errorCode) { for (PendingIntent intent : intents) { sendErrorInPendingIntent(intent, errorCode); } } }