Merge "move CellBroadcastMessage from telephony-common to app" am: 17518fa149 am: e2d15a24c1
am: 3b5788f3fe
Change-Id: I1029effeff09fb27540badf91d5a4baa03a8695d
This commit is contained in:
@@ -8033,7 +8033,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);
|
||||
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);
|
||||
method @NonNull public static android.telephony.SmsCbMessage createFromCursor(@NonNull android.database.Cursor);
|
||||
method public int describeContents();
|
||||
method @Nullable public android.telephony.SmsCbCmasInfo getCmasWarningInfo();
|
||||
@@ -8048,6 +8048,7 @@ package android.telephony {
|
||||
method public long getReceivedTime();
|
||||
method public int getSerialNumber();
|
||||
method public int getServiceCategory();
|
||||
method public int getSlotIndex();
|
||||
method public boolean isCmasMessage();
|
||||
method public boolean isEmergencyMessage();
|
||||
method public boolean isEtwsMessage();
|
||||
|
||||
@@ -3963,12 +3963,20 @@ public final class Telephony {
|
||||
public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
|
||||
|
||||
/**
|
||||
* The id of the subscription which received this cell broadcast message.
|
||||
* 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";
|
||||
|
||||
/**
|
||||
* The slot which received this cell broadcast message.
|
||||
* <P>Type: INTEGER</P>
|
||||
* @hide
|
||||
*/
|
||||
public static final String SLOT_INDEX = "slot_index";
|
||||
|
||||
/**
|
||||
* Message geographical scope. Valid values are:
|
||||
* <ul>
|
||||
@@ -4203,7 +4211,7 @@ public final class Telephony {
|
||||
public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time";
|
||||
|
||||
/**
|
||||
* Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
|
||||
* Query columns for instantiating com.android.cellbroadcastreceiver.CellBroadcastMessage.
|
||||
* @hide
|
||||
*/
|
||||
@NonNull
|
||||
@@ -4236,6 +4244,7 @@ public final class Telephony {
|
||||
*/
|
||||
public static final String[] QUERY_COLUMNS_FWK = {
|
||||
_ID,
|
||||
SLOT_INDEX,
|
||||
GEOGRAPHICAL_SCOPE,
|
||||
PLMN,
|
||||
LAC,
|
||||
|
||||
@@ -207,17 +207,19 @@ public final class SmsCbMessage implements Parcelable {
|
||||
/** CMAS warning area coordinates. */
|
||||
private final List<Geometry> mGeometries;
|
||||
|
||||
private int mSlotIndex = 0;
|
||||
|
||||
/**
|
||||
* Create a new SmsCbMessage with the specified data.
|
||||
*/
|
||||
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) {
|
||||
@Nullable SmsCbCmasInfo cmasWarningInfo, int slotIndex) {
|
||||
|
||||
this(messageFormat, geographicalScope, serialNumber, location, serviceCategory, language,
|
||||
body, priority, etwsWarningInfo, cmasWarningInfo, 0 /* maximumWaitingTime */,
|
||||
null /* geometries */, System.currentTimeMillis());
|
||||
null /* geometries */, System.currentTimeMillis(), slotIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,7 +229,8 @@ public final class SmsCbMessage implements Parcelable {
|
||||
public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
|
||||
SmsCbLocation location, int serviceCategory, String language, String body,
|
||||
int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo,
|
||||
int maximumWaitTimeSec, List<Geometry> geometries, long receivedTimeMillis) {
|
||||
int maximumWaitTimeSec, List<Geometry> geometries, long receivedTimeMillis,
|
||||
int slotIndex) {
|
||||
mMessageFormat = messageFormat;
|
||||
mGeographicalScope = geographicalScope;
|
||||
mSerialNumber = serialNumber;
|
||||
@@ -241,6 +244,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
mReceivedTimeMillis = receivedTimeMillis;
|
||||
mGeometries = geometries;
|
||||
mMaximumWaitTimeSec = maximumWaitTimeSec;
|
||||
mSlotIndex = slotIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,6 +282,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
String geoStr = in.readString();
|
||||
mGeometries = geoStr != null ? CbGeoUtils.parseGeometriesFromString(geoStr) : null;
|
||||
mMaximumWaitTimeSec = in.readInt();
|
||||
mSlotIndex = in.readInt();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,6 +317,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
dest.writeString(
|
||||
mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : null);
|
||||
dest.writeInt(mMaximumWaitTimeSec);
|
||||
dest.writeInt(mSlotIndex);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -422,6 +428,14 @@ public final class SmsCbMessage implements Parcelable {
|
||||
return mReceivedTimeMillis;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the slotIndex associated with this message.
|
||||
* @return the slotIndex associated with this message
|
||||
*/
|
||||
public int getSlotIndex() {
|
||||
return mSlotIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message format ({@link #MESSAGE_FORMAT_3GPP} or {@link #MESSAGE_FORMAT_3GPP2}).
|
||||
* @return an integer representing 3GPP or 3GPP2 message format
|
||||
@@ -502,6 +516,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
+ (mEtwsWarningInfo != null ? (", " + mEtwsWarningInfo.toString()) : "")
|
||||
+ (mCmasWarningInfo != null ? (", " + mCmasWarningInfo.toString()) : "")
|
||||
+ ", maximumWaitingTime = " + mMaximumWaitTimeSec
|
||||
+ ", slotIndex = " + mSlotIndex
|
||||
+ ", geo=" + (mGeometries != null
|
||||
? CbGeoUtils.encodeGeometriesToString(mGeometries) : "null")
|
||||
+ '}';
|
||||
@@ -522,6 +537,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
@NonNull
|
||||
public ContentValues getContentValues() {
|
||||
ContentValues cv = new ContentValues(16);
|
||||
cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex);
|
||||
cv.put(CellBroadcasts.GEOGRAPHICAL_SCOPE, mGeographicalScope);
|
||||
if (mLocation.getPlmn() != null) {
|
||||
cv.put(CellBroadcasts.PLMN, mLocation.getPlmn());
|
||||
@@ -563,6 +579,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
}
|
||||
|
||||
cv.put(CellBroadcasts.MAXIMUM_WAIT_TIME, mMaximumWaitTimeSec);
|
||||
cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex);
|
||||
|
||||
return cv;
|
||||
}
|
||||
@@ -584,6 +601,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
String body = cursor.getString(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_BODY));
|
||||
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));
|
||||
|
||||
String plmn;
|
||||
int plmnColumn = cursor.getColumnIndex(CellBroadcasts.PLMN);
|
||||
@@ -681,7 +699,7 @@ public final class SmsCbMessage implements Parcelable {
|
||||
|
||||
return new SmsCbMessage(format, geoScope, serialNum, location, category,
|
||||
language, body, priority, etwsInfo, cmasInfo, maximumWaitTimeSec, geometries,
|
||||
receivedTimeMillis);
|
||||
receivedTimeMillis, slotIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -859,8 +859,9 @@ public class SmsMessage extends SmsMessageBase {
|
||||
* Parses a broadcast SMS, possibly containing a CMAS alert.
|
||||
*
|
||||
* @param plmn the PLMN for a broadcast SMS
|
||||
* @param subId
|
||||
*/
|
||||
public SmsCbMessage parseBroadcastSms(String plmn) {
|
||||
public SmsCbMessage parseBroadcastSms(String plmn, int subId) {
|
||||
BearerData bData = BearerData.decode(mEnvelope.bearerData, mEnvelope.serviceCategory);
|
||||
if (bData == null) {
|
||||
Rlog.w(LOG_TAG, "BearerData.decode() returned null");
|
||||
@@ -876,7 +877,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);
|
||||
bData.priority, null, bData.cmasWarningInfo, subId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,9 +90,10 @@ public class GsmSmsCbMessage {
|
||||
* Create a new SmsCbMessage object from a header object plus one or more received PDUs.
|
||||
*
|
||||
* @param pdus PDU bytes
|
||||
* @slotIndex slotIndex for which received sms cb message
|
||||
*/
|
||||
public static SmsCbMessage createSmsCbMessage(Context context, SmsCbHeader header,
|
||||
SmsCbLocation location, byte[][] pdus)
|
||||
SmsCbLocation location, byte[][] pdus, int slotIndex)
|
||||
throws IllegalArgumentException {
|
||||
long receivedTimeMillis = System.currentTimeMillis();
|
||||
if (header.isEtwsPrimaryNotification()) {
|
||||
@@ -104,7 +105,7 @@ 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);
|
||||
header.getCmasInfo(), 0, null /* geometries */, receivedTimeMillis, slotIndex);
|
||||
} else if (header.isUmtsFormat()) {
|
||||
// UMTS format has only 1 PDU
|
||||
byte[] pdu = pdus[0];
|
||||
@@ -138,7 +139,7 @@ public class GsmSmsCbMessage {
|
||||
header.getGeographicalScope(), header.getSerialNumber(), location,
|
||||
header.getServiceCategory(), language, body, priority,
|
||||
header.getEtwsInfo(), header.getCmasInfo(), maximumWaitingTimeSec, geometries,
|
||||
receivedTimeMillis);
|
||||
receivedTimeMillis, slotIndex);
|
||||
} else {
|
||||
String language = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -154,7 +155,7 @@ public class GsmSmsCbMessage {
|
||||
header.getGeographicalScope(), header.getSerialNumber(), location,
|
||||
header.getServiceCategory(), language, sb.toString(), priority,
|
||||
header.getEtwsInfo(), header.getCmasInfo(), 0, null /* geometries */,
|
||||
receivedTimeMillis);
|
||||
receivedTimeMillis, slotIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user