diff options
| -rw-r--r-- | api/system-current.txt | 4 | ||||
| -rw-r--r-- | api/test-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/provider/Telephony.java | 3 | ||||
| -rw-r--r-- | telephony/java/android/telephony/SmsCbMessage.java | 38 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/cdma/SmsMessage.java | 7 | ||||
| -rw-r--r-- | telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java | 16 |
6 files changed, 49 insertions, 20 deletions
diff --git a/api/system-current.txt b/api/system-current.txt index a0f543b641e2..6340cfecdbb1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -6520,6 +6520,7 @@ package android.provider { field public static final String SERIAL_NUMBER = "serial_number"; field public static final String SERVICE_CATEGORY = "service_category"; field public static final String SLOT_INDEX = "slot_index"; + field public static final String SUB_ID = "sub_id"; } public static final class Telephony.Sms.Intents { @@ -8530,7 +8531,7 @@ package android.telephony { } public final class SmsCbMessage implements android.os.Parcelable { - ctor public SmsCbMessage(int, int, int, @NonNull android.telephony.SmsCbLocation, int, @Nullable String, @Nullable String, int, @Nullable android.telephony.SmsCbEtwsInfo, @Nullable android.telephony.SmsCbCmasInfo, int, @Nullable java.util.List<android.telephony.CbGeoUtils.Geometry>, long, int); + ctor public SmsCbMessage(int, int, int, @NonNull android.telephony.SmsCbLocation, int, @Nullable String, @Nullable String, int, @Nullable android.telephony.SmsCbEtwsInfo, @Nullable android.telephony.SmsCbCmasInfo, int, @Nullable java.util.List<android.telephony.CbGeoUtils.Geometry>, long, int, int); method @NonNull public static android.telephony.SmsCbMessage createFromCursor(@NonNull android.database.Cursor); method public int describeContents(); method @Nullable public android.telephony.SmsCbCmasInfo getCmasWarningInfo(); @@ -8547,6 +8548,7 @@ package android.telephony { method public int getSerialNumber(); method public int getServiceCategory(); method public int getSlotIndex(); + method public int getSubscriptionId(); method public boolean isCmasMessage(); method public boolean isEmergencyMessage(); method public boolean isEtwsMessage(); diff --git a/api/test-current.txt b/api/test-current.txt index 5d6f9418dee9..c29ef996ee43 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2426,6 +2426,7 @@ package android.provider { field public static final String SERIAL_NUMBER = "serial_number"; field public static final String SERVICE_CATEGORY = "service_category"; field public static final String SLOT_INDEX = "slot_index"; + field public static final String SUB_ID = "sub_id"; } public static final class Telephony.Sms.Intents { diff --git a/core/java/android/provider/Telephony.java b/core/java/android/provider/Telephony.java index 5063b2c698a3..e80df2ddd010 100644 --- a/core/java/android/provider/Telephony.java +++ b/core/java/android/provider/Telephony.java @@ -4055,9 +4055,7 @@ public final class Telephony { /** * The subscription which received this cell broadcast message. - * @deprecated use {@link #SLOT_INDEX} instead. * <P>Type: INTEGER</P> - * @hide */ public static final String SUB_ID = "sub_id"; @@ -4331,6 +4329,7 @@ public final class Telephony { public static final String[] QUERY_COLUMNS_FWK = { _ID, SLOT_INDEX, + SUB_ID, GEOGRAPHICAL_SCOPE, PLMN, LAC, diff --git a/telephony/java/android/telephony/SmsCbMessage.java b/telephony/java/android/telephony/SmsCbMessage.java index 737ead1f8131..fad70d2da8be 100644 --- a/telephony/java/android/telephony/SmsCbMessage.java +++ b/telephony/java/android/telephony/SmsCbMessage.java @@ -205,7 +205,9 @@ public final class SmsCbMessage implements Parcelable { /** CMAS warning area coordinates. */ private final List<Geometry> mGeometries; - private int mSlotIndex = 0; + private final int mSlotIndex; + + private final int mSubId; /** * Create a new SmsCbMessage with the specified data. @@ -214,11 +216,11 @@ public final class SmsCbMessage implements Parcelable { public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber, @NonNull SmsCbLocation location, int serviceCategory, @Nullable String language, @Nullable String body, int priority, @Nullable SmsCbEtwsInfo etwsWarningInfo, - @Nullable SmsCbCmasInfo cmasWarningInfo, int slotIndex) { + @Nullable SmsCbCmasInfo cmasWarningInfo, int slotIndex, int subId) { this(messageFormat, geographicalScope, serialNumber, location, serviceCategory, language, body, priority, etwsWarningInfo, cmasWarningInfo, 0 /* maximumWaitingTime */, - null /* geometries */, System.currentTimeMillis(), slotIndex); + null /* geometries */, System.currentTimeMillis(), slotIndex, subId); } /** @@ -226,10 +228,12 @@ public final class SmsCbMessage implements Parcelable { * coordinates information. */ public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber, - @NonNull SmsCbLocation location, int serviceCategory, @Nullable String language, - @Nullable String body, int priority, @Nullable SmsCbEtwsInfo etwsWarningInfo, - @Nullable SmsCbCmasInfo cmasWarningInfo, int maximumWaitTimeSec, - @Nullable List<Geometry> geometries, long receivedTimeMillis, int slotIndex) { + @NonNull SmsCbLocation location, int serviceCategory, + @Nullable String language, @Nullable String body, int priority, + @Nullable SmsCbEtwsInfo etwsWarningInfo, + @Nullable SmsCbCmasInfo cmasWarningInfo, int maximumWaitTimeSec, + @Nullable List<Geometry> geometries, long receivedTimeMillis, int slotIndex, + int subId) { mMessageFormat = messageFormat; mGeographicalScope = geographicalScope; mSerialNumber = serialNumber; @@ -244,6 +248,7 @@ public final class SmsCbMessage implements Parcelable { mGeometries = geometries; mMaximumWaitTimeSec = maximumWaitTimeSec; mSlotIndex = slotIndex; + mSubId = subId; } /** @@ -282,6 +287,7 @@ public final class SmsCbMessage implements Parcelable { mGeometries = geoStr != null ? CbGeoUtils.parseGeometriesFromString(geoStr) : null; mMaximumWaitTimeSec = in.readInt(); mSlotIndex = in.readInt(); + mSubId = in.readInt(); } /** @@ -317,6 +323,7 @@ public final class SmsCbMessage implements Parcelable { mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : null); dest.writeInt(mMaximumWaitTimeSec); dest.writeInt(mSlotIndex); + dest.writeInt(mSubId); } @NonNull @@ -427,14 +434,22 @@ public final class SmsCbMessage implements Parcelable { } /** - * Get the slotIndex associated with this message. - * @return the slotIndex associated with this message + * Get the slot index associated with this message. + * @return the slot index associated with this message */ public int getSlotIndex() { return mSlotIndex; } /** + * Get the subscription id associated with this message. + * @return the subscription id associated with this message + */ + public int getSubscriptionId() { + return mSubId; + } + + /** * Get the message format ({@link #MESSAGE_FORMAT_3GPP} or {@link #MESSAGE_FORMAT_3GPP2}). * @return an integer representing 3GPP or 3GPP2 message format */ @@ -536,6 +551,7 @@ public final class SmsCbMessage implements Parcelable { public ContentValues getContentValues() { ContentValues cv = new ContentValues(16); cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex); + cv.put(CellBroadcasts.SUB_ID, mSubId); cv.put(CellBroadcasts.GEOGRAPHICAL_SCOPE, mGeographicalScope); if (mLocation.getPlmn() != null) { cv.put(CellBroadcasts.PLMN, mLocation.getPlmn()); @@ -577,7 +593,6 @@ public final class SmsCbMessage implements Parcelable { } cv.put(CellBroadcasts.MAXIMUM_WAIT_TIME, mMaximumWaitTimeSec); - cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex); return cv; } @@ -600,6 +615,7 @@ public final class SmsCbMessage implements Parcelable { int format = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_FORMAT)); int priority = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_PRIORITY)); int slotIndex = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.SLOT_INDEX)); + int subId = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.SUB_ID)); String plmn; int plmnColumn = cursor.getColumnIndex(CellBroadcasts.PLMN); @@ -697,7 +713,7 @@ public final class SmsCbMessage implements Parcelable { return new SmsCbMessage(format, geoScope, serialNum, location, category, language, body, priority, etwsInfo, cmasInfo, maximumWaitTimeSec, geometries, - receivedTimeMillis, slotIndex); + receivedTimeMillis, slotIndex, subId); } /** diff --git a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java index b357fa43008f..8b95617e82c8 100644 --- a/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java +++ b/telephony/java/com/android/internal/telephony/cdma/SmsMessage.java @@ -878,9 +878,10 @@ public class SmsMessage extends SmsMessageBase { * Parses a broadcast SMS, possibly containing a CMAS alert. * * @param plmn the PLMN for a broadcast SMS - * @param subId + * @param slotIndex SIM slot index + * @param subId Subscription id */ - public SmsCbMessage parseBroadcastSms(String plmn, int subId) { + public SmsCbMessage parseBroadcastSms(String plmn, int slotIndex, int subId) { BearerData bData = BearerData.decode(mEnvelope.bearerData, mEnvelope.serviceCategory); if (bData == null) { Rlog.w(LOG_TAG, "BearerData.decode() returned null"); @@ -896,7 +897,7 @@ public class SmsMessage extends SmsMessageBase { return new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP2, SmsCbMessage.GEOGRAPHICAL_SCOPE_PLMN_WIDE, bData.messageId, location, mEnvelope.serviceCategory, bData.getLanguage(), bData.userData.payloadStr, - bData.priority, null, bData.cmasWarningInfo, subId); + bData.priority, null, bData.cmasWarningInfo, slotIndex, subId); } /** diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java b/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java index 5766287d6691..bdd1fab34a3c 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmSmsCbMessage.java @@ -32,6 +32,7 @@ import android.telephony.CbGeoUtils.LatLng; import android.telephony.CbGeoUtils.Polygon; import android.telephony.SmsCbLocation; import android.telephony.SmsCbMessage; +import android.telephony.SubscriptionManager; import android.util.Pair; import android.util.Slog; @@ -95,6 +96,14 @@ public class GsmSmsCbMessage { public static SmsCbMessage createSmsCbMessage(Context context, SmsCbHeader header, SmsCbLocation location, byte[][] pdus, int slotIndex) throws IllegalArgumentException { + SubscriptionManager sm = (SubscriptionManager) context.getSystemService( + Context.TELEPHONY_SUBSCRIPTION_SERVICE); + int subId = SubscriptionManager.DEFAULT_SUBSCRIPTION_ID; + int[] subIds = sm.getSubscriptionIds(slotIndex); + if (subIds != null && subIds.length > 0) { + subId = subIds[0]; + } + long receivedTimeMillis = System.currentTimeMillis(); if (header.isEtwsPrimaryNotification()) { // ETSI TS 23.041 ETWS Primary Notification message @@ -105,7 +114,8 @@ public class GsmSmsCbMessage { header.getSerialNumber(), location, header.getServiceCategory(), null, getEtwsPrimaryMessage(context, header.getEtwsInfo().getWarningType()), SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, header.getEtwsInfo(), - header.getCmasInfo(), 0, null /* geometries */, receivedTimeMillis, slotIndex); + header.getCmasInfo(), 0, null /* geometries */, receivedTimeMillis, slotIndex, + subId); } else if (header.isUmtsFormat()) { // UMTS format has only 1 PDU byte[] pdu = pdus[0]; @@ -139,7 +149,7 @@ public class GsmSmsCbMessage { header.getGeographicalScope(), header.getSerialNumber(), location, header.getServiceCategory(), language, body, priority, header.getEtwsInfo(), header.getCmasInfo(), maximumWaitingTimeSec, geometries, - receivedTimeMillis, slotIndex); + receivedTimeMillis, slotIndex, subId); } else { String language = null; StringBuilder sb = new StringBuilder(); @@ -155,7 +165,7 @@ public class GsmSmsCbMessage { header.getGeographicalScope(), header.getSerialNumber(), location, header.getServiceCategory(), language, sb.toString(), priority, header.getEtwsInfo(), header.getCmasInfo(), 0, null /* geometries */, - receivedTimeMillis, slotIndex); + receivedTimeMillis, slotIndex, subId); } } |