public class SmsCbMessage extends Object implements Parcelable
There are also four different CB message formats: GSM, ETWS Primary Notification (GSM only), UMTS, and CDMA. Some fields are only applicable for some message formats. Other fields were unified under a common name, avoiding some names, such as "Message Identifier", that refer to two completely different concepts in 3GPP and CDMA.
The GSM/UMTS Message Identifier field is available via getServiceCategory()
, the name
of the equivalent field in CDMA. In both cases the service category is a 16-bit value, but 3GPP
and 3GPP2 have completely different meanings for the respective values. For ETWS and CMAS, the
application should
The CDMA Message Identifier field is available via getSerialNumber()
, which is used
to detect the receipt of a duplicate message to be discarded. In CDMA, the message ID is
unique to the current PLMN. In GSM/UMTS, there is a 16-bit serial number containing a 2-bit
Geographical Scope field which indicates whether the 10-bit message code and 4-bit update number
are considered unique to the PLMN, to the current cell, or to the current Location Area (or
Service Area in UMTS). The relevant values are concatenated into a single String which will be
unique if the messages are not duplicates.
The SMS dispatcher does not detect duplicate messages. However, it does concatenate the pages of a GSM multi-page cell broadcast into a single SmsCbMessage object.
Interested applications with RECEIVE_SMS_PERMISSION
can register to receive
SMS_CB_RECEIVED_ACTION
broadcast intents for incoming non-emergency broadcasts.
Only system applications such as the CellBroadcastReceiver may receive notifications for
emergency broadcasts (ETWS and CMAS). This is intended to prevent any potential for delays or
interference with the immediate display of the alert message and playing of the alert sound and
vibration pattern, which could be caused by poorly written or malicious non-system code.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<SmsCbMessage> |
CREATOR |
static int |
GEOGRAPHICAL_SCOPE_CELL_WIDE
Cell wide geographical scope (GSM/UMTS only).
|
static int |
GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE
Cell wide geographical scope with immediate display (GSM/UMTS only).
|
static int |
GEOGRAPHICAL_SCOPE_LA_WIDE
Location / service area wide geographical scope (GSM/UMTS only).
|
static int |
GEOGRAPHICAL_SCOPE_PLMN_WIDE
PLMN wide geographical scope (GSM/UMTS and all CDMA broadcasts).
|
protected static String |
LOG_TAG |
static int |
MESSAGE_FORMAT_3GPP
GSM or UMTS format cell broadcast.
|
static int |
MESSAGE_FORMAT_3GPP2
CDMA format cell broadcast.
|
static int |
MESSAGE_PRIORITY_EMERGENCY
Emergency message priority.
|
static int |
MESSAGE_PRIORITY_INTERACTIVE
Interactive message priority.
|
static int |
MESSAGE_PRIORITY_NORMAL
Normal message priority.
|
static int |
MESSAGE_PRIORITY_URGENT
Urgent message priority.
|
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
SmsCbMessage(int messageFormat,
int geographicalScope,
int serialNumber,
SmsCbLocation location,
int serviceCategory,
String language,
String body,
int priority,
SmsCbEtwsInfo etwsWarningInfo,
SmsCbCmasInfo cmasWarningInfo)
Create a new SmsCbMessage with the specified data.
|
SmsCbMessage(Parcel in)
Create a new SmsCbMessage object from a Parcel.
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in the marshalled representation.
|
SmsCbCmasInfo |
getCmasWarningInfo()
If this is a CMAS warning notification then this method will return an object containing
the CMAS message class, category, response type, severity, urgency and certainty.
|
SmsCbEtwsInfo |
getEtwsWarningInfo()
If this is an ETWS warning notification then this method will return an object containing
the ETWS warning type, the emergency user alert flag, and the popup flag.
|
int |
getGeographicalScope()
Return the geographical scope of this message (GSM/UMTS only).
|
String |
getLanguageCode()
Get the ISO-639-1 language code for this message, or null if unspecified
|
SmsCbLocation |
getLocation()
Return the location identifier for this message, consisting of the MCC/MNC as a
5 or 6-digit decimal string.
|
String |
getMessageBody()
Get the body of this message, or null if no body available
|
int |
getMessageFormat()
Get the message format (
MESSAGE_FORMAT_3GPP or MESSAGE_FORMAT_3GPP2 ). |
int |
getMessagePriority()
Get the message priority.
|
int |
getSerialNumber()
Return the broadcast serial number of broadcast (message identifier for CDMA, or
geographical scope + message code + update number for GSM/UMTS).
|
int |
getServiceCategory()
Return the 16-bit CDMA service category or GSM/UMTS message identifier.
|
boolean |
isCmasMessage()
Return whether this message is a CMAS warning alert.
|
boolean |
isEmergencyMessage()
Return whether this message is an emergency (PWS) message type.
|
boolean |
isEtwsMessage()
Return whether this message is an ETWS warning alert.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
object.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object into a Parcel.
|
protected static final String LOG_TAG
public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE
public static final int GEOGRAPHICAL_SCOPE_PLMN_WIDE
public static final int GEOGRAPHICAL_SCOPE_LA_WIDE
public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE
public static final int MESSAGE_FORMAT_3GPP
public static final int MESSAGE_FORMAT_3GPP2
public static final int MESSAGE_PRIORITY_NORMAL
public static final int MESSAGE_PRIORITY_INTERACTIVE
public static final int MESSAGE_PRIORITY_URGENT
public static final int MESSAGE_PRIORITY_EMERGENCY
public static final Parcelable.Creator<SmsCbMessage> CREATOR
public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber, SmsCbLocation location, int serviceCategory, String language, String body, int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo)
public SmsCbMessage(Parcel in)
public void writeToParcel(Parcel dest, int flags)
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written (ignored).public int getGeographicalScope()
public int getSerialNumber()
public SmsCbLocation getLocation()
SmsCbLocation
object includes a method to test
if the location is included within another location area or within a PLMN and CellLocation.public int getServiceCategory()
getEtwsWarningInfo()
or
getCmasWarningInfo()
in a radio technology independent format.public String getLanguageCode()
public String getMessageBody()
public int getMessageFormat()
MESSAGE_FORMAT_3GPP
or MESSAGE_FORMAT_3GPP2
).public int getMessagePriority()
MESSAGE_PRIORITY_NORMAL
and emergency broadcasts return MESSAGE_PRIORITY_EMERGENCY
. CDMA also may return
MESSAGE_PRIORITY_INTERACTIVE
or MESSAGE_PRIORITY_URGENT
.public SmsCbEtwsInfo getEtwsWarningInfo()
public SmsCbCmasInfo getCmasWarningInfo()
public boolean isEmergencyMessage()
public boolean isEtwsMessage()
public boolean isCmasMessage()
public String toString()
Object
getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toString
method
if you intend implementing your own toString
method.
public int describeContents()
describeContents
in interface Parcelable