Merge "Added sub id to SmsCbMessage"

am: 258e925cd6

Change-Id: I5b6a4c5c39861465337cce124d47ecc7ed3c2eb9
This commit is contained in:
Jack Yu
2019-12-04 09:42:08 -08:00
committed by android-build-merger
6 changed files with 49 additions and 20 deletions

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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,13 +434,21 @@ 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);
}
/**

View File

@@ -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);
}
/**

View File

@@ -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);
}
}