Methods Summary |
---|
public static android.telephony.CellBroadcastMessage | createFromCursor(android.database.Cursor cursor)Create a CellBroadcastMessage from a row in the database.
int geoScope = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.GEOGRAPHICAL_SCOPE));
int serialNum = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.SERIAL_NUMBER));
int category = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.SERVICE_CATEGORY));
String language = cursor.getString(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.LANGUAGE_CODE));
String body = cursor.getString(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_BODY));
int format = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_FORMAT));
int priority = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.CellBroadcasts.MESSAGE_PRIORITY));
String plmn;
int plmnColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.PLMN);
if (plmnColumn != -1 && !cursor.isNull(plmnColumn)) {
plmn = cursor.getString(plmnColumn);
} else {
plmn = null;
}
int lac;
int lacColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.LAC);
if (lacColumn != -1 && !cursor.isNull(lacColumn)) {
lac = cursor.getInt(lacColumn);
} else {
lac = -1;
}
int cid;
int cidColumn = cursor.getColumnIndex(Telephony.CellBroadcasts.CID);
if (cidColumn != -1 && !cursor.isNull(cidColumn)) {
cid = cursor.getInt(cidColumn);
} else {
cid = -1;
}
SmsCbLocation location = new SmsCbLocation(plmn, lac, cid);
SmsCbEtwsInfo etwsInfo;
int etwsWarningTypeColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.ETWS_WARNING_TYPE);
if (etwsWarningTypeColumn != -1 && !cursor.isNull(etwsWarningTypeColumn)) {
int warningType = cursor.getInt(etwsWarningTypeColumn);
etwsInfo = new SmsCbEtwsInfo(warningType, false, false, null);
} else {
etwsInfo = null;
}
SmsCbCmasInfo cmasInfo;
int cmasMessageClassColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_MESSAGE_CLASS);
if (cmasMessageClassColumn != -1 && !cursor.isNull(cmasMessageClassColumn)) {
int messageClass = cursor.getInt(cmasMessageClassColumn);
int cmasCategory;
int cmasCategoryColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_CATEGORY);
if (cmasCategoryColumn != -1 && !cursor.isNull(cmasCategoryColumn)) {
cmasCategory = cursor.getInt(cmasCategoryColumn);
} else {
cmasCategory = SmsCbCmasInfo.CMAS_CATEGORY_UNKNOWN;
}
int responseType;
int cmasResponseTypeColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_RESPONSE_TYPE);
if (cmasResponseTypeColumn != -1 && !cursor.isNull(cmasResponseTypeColumn)) {
responseType = cursor.getInt(cmasResponseTypeColumn);
} else {
responseType = SmsCbCmasInfo.CMAS_RESPONSE_TYPE_UNKNOWN;
}
int severity;
int cmasSeverityColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_SEVERITY);
if (cmasSeverityColumn != -1 && !cursor.isNull(cmasSeverityColumn)) {
severity = cursor.getInt(cmasSeverityColumn);
} else {
severity = SmsCbCmasInfo.CMAS_SEVERITY_UNKNOWN;
}
int urgency;
int cmasUrgencyColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_URGENCY);
if (cmasUrgencyColumn != -1 && !cursor.isNull(cmasUrgencyColumn)) {
urgency = cursor.getInt(cmasUrgencyColumn);
} else {
urgency = SmsCbCmasInfo.CMAS_URGENCY_UNKNOWN;
}
int certainty;
int cmasCertaintyColumn = cursor.getColumnIndex(
Telephony.CellBroadcasts.CMAS_CERTAINTY);
if (cmasCertaintyColumn != -1 && !cursor.isNull(cmasCertaintyColumn)) {
certainty = cursor.getInt(cmasCertaintyColumn);
} else {
certainty = SmsCbCmasInfo.CMAS_CERTAINTY_UNKNOWN;
}
cmasInfo = new SmsCbCmasInfo(messageClass, cmasCategory, responseType, severity,
urgency, certainty);
} else {
cmasInfo = null;
}
SmsCbMessage msg = new SmsCbMessage(format, geoScope, serialNum, location, category,
language, body, priority, etwsInfo, cmasInfo);
long deliveryTime = cursor.getLong(cursor.getColumnIndexOrThrow(
Telephony.CellBroadcasts.DELIVERY_TIME));
boolean isRead = (cursor.getInt(cursor.getColumnIndexOrThrow(
Telephony.CellBroadcasts.MESSAGE_READ)) != 0);
return new CellBroadcastMessage(msg, deliveryTime, isRead);
|
public int | describeContents()Parcelable: no special flags.
return 0;
|
public int | getCmasMessageClass()Return the CMAS message class.
if (mSmsCbMessage.isCmasMessage()) {
return mSmsCbMessage.getCmasWarningInfo().getMessageClass();
} else {
return SmsCbCmasInfo.CMAS_CLASS_UNKNOWN;
}
|
public SmsCbCmasInfo | getCmasWarningInfo()
return mSmsCbMessage.getCmasWarningInfo();
|
public android.content.ContentValues | getContentValues()Return a ContentValues object for insertion into the database.
ContentValues cv = new ContentValues(16);
SmsCbMessage msg = mSmsCbMessage;
cv.put(Telephony.CellBroadcasts.GEOGRAPHICAL_SCOPE, msg.getGeographicalScope());
SmsCbLocation location = msg.getLocation();
if (location.getPlmn() != null) {
cv.put(Telephony.CellBroadcasts.PLMN, location.getPlmn());
}
if (location.getLac() != -1) {
cv.put(Telephony.CellBroadcasts.LAC, location.getLac());
}
if (location.getCid() != -1) {
cv.put(Telephony.CellBroadcasts.CID, location.getCid());
}
cv.put(Telephony.CellBroadcasts.SERIAL_NUMBER, msg.getSerialNumber());
cv.put(Telephony.CellBroadcasts.SERVICE_CATEGORY, msg.getServiceCategory());
cv.put(Telephony.CellBroadcasts.LANGUAGE_CODE, msg.getLanguageCode());
cv.put(Telephony.CellBroadcasts.MESSAGE_BODY, msg.getMessageBody());
cv.put(Telephony.CellBroadcasts.DELIVERY_TIME, mDeliveryTime);
cv.put(Telephony.CellBroadcasts.MESSAGE_READ, mIsRead);
cv.put(Telephony.CellBroadcasts.MESSAGE_FORMAT, msg.getMessageFormat());
cv.put(Telephony.CellBroadcasts.MESSAGE_PRIORITY, msg.getMessagePriority());
SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
if (etwsInfo != null) {
cv.put(Telephony.CellBroadcasts.ETWS_WARNING_TYPE, etwsInfo.getWarningType());
}
SmsCbCmasInfo cmasInfo = mSmsCbMessage.getCmasWarningInfo();
if (cmasInfo != null) {
cv.put(Telephony.CellBroadcasts.CMAS_MESSAGE_CLASS, cmasInfo.getMessageClass());
cv.put(Telephony.CellBroadcasts.CMAS_CATEGORY, cmasInfo.getCategory());
cv.put(Telephony.CellBroadcasts.CMAS_RESPONSE_TYPE, cmasInfo.getResponseType());
cv.put(Telephony.CellBroadcasts.CMAS_SEVERITY, cmasInfo.getSeverity());
cv.put(Telephony.CellBroadcasts.CMAS_URGENCY, cmasInfo.getUrgency());
cv.put(Telephony.CellBroadcasts.CMAS_CERTAINTY, cmasInfo.getCertainty());
}
return cv;
|
public java.lang.String | getDateString(android.content.Context context)Return the abbreviated date string for the message delivery time.
int flags = DateUtils.FORMAT_NO_NOON_MIDNIGHT | DateUtils.FORMAT_SHOW_TIME |
DateUtils.FORMAT_ABBREV_ALL | DateUtils.FORMAT_SHOW_DATE |
DateUtils.FORMAT_CAP_AMPM;
return DateUtils.formatDateTime(context, mDeliveryTime, flags);
|
public long | getDeliveryTime()
return mDeliveryTime;
|
public SmsCbEtwsInfo | getEtwsWarningInfo()
return mSmsCbMessage.getEtwsWarningInfo();
|
public java.lang.String | getLanguageCode()
return mSmsCbMessage.getLanguageCode();
|
public java.lang.String | getMessageBody()
return mSmsCbMessage.getMessageBody();
|
public int | getSerialNumber()
return mSmsCbMessage.getSerialNumber();
|
public int | getServiceCategory()
return mSmsCbMessage.getServiceCategory();
|
public java.lang.String | getSpokenDateString(android.content.Context context)Return the date string for the message delivery time, suitable for text-to-speech.
int flags = DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE;
return DateUtils.formatDateTime(context, mDeliveryTime, flags);
|
public int | getSubId()get Subscription information
return mSubId;
|
public boolean | isCmasMessage()Return whether the broadcast is a CMAS emergency message type.
return mSmsCbMessage.isCmasMessage();
|
public boolean | isEmergencyAlertMessage()Returns whether the broadcast is an emergency (PWS) message type,
including test messages and AMBER alerts.
return mSmsCbMessage.isEmergencyMessage();
|
public boolean | isEtwsEmergencyUserAlert()Return whether the broadcast is an ETWS emergency user alert.
This method checks the message ID and the message code.
SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
return etwsInfo != null && etwsInfo.isEmergencyUserAlert();
|
public boolean | isEtwsMessage()Return whether the broadcast is an ETWS emergency message type.
return mSmsCbMessage.isEtwsMessage();
|
public boolean | isEtwsPopupAlert()Return whether the broadcast is an ETWS popup alert.
This method checks the message ID and the message code.
SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
return etwsInfo != null && etwsInfo.isPopupAlert();
|
public boolean | isEtwsTestMessage()Return whether the broadcast is an ETWS test message.
SmsCbEtwsInfo etwsInfo = mSmsCbMessage.getEtwsWarningInfo();
return etwsInfo != null &&
etwsInfo.getWarningType() == SmsCbEtwsInfo.ETWS_WARNING_TYPE_TEST_MESSAGE;
|
public boolean | isPublicAlertMessage()Return whether the broadcast is an emergency (PWS) message type.
This includes lower priority test messages and Amber alerts.
All public alerts show the flashing warning icon in the dialog,
but only emergency alerts play the alert sound and speak the message.
return mSmsCbMessage.isEmergencyMessage();
|
public boolean | isRead()
return mIsRead;
|
public void | setIsRead(boolean isRead)Set or clear the "read message" flag.
mIsRead = isRead;
|
public void | setSubId(int subId)set Subscription information
mSubId = subId;
|
public void | writeToParcel(android.os.Parcel out, int flags)
mSmsCbMessage.writeToParcel(out, flags);
out.writeLong(mDeliveryTime);
out.writeInt(mIsRead ? 1 : 0);
|