Merge "Change CellBroadcast APIs to SystemApi"

This commit is contained in:
Jordan Liu
2019-09-03 20:41:03 +00:00
committed by Gerrit Code Review
12 changed files with 538 additions and 135 deletions

View File

@@ -4652,6 +4652,30 @@ package android.provider {
field public static final String WAIT_TIME_RETRY = "wait_time";
}
public static final class Telephony.CellBroadcasts implements android.provider.BaseColumns {
field public static final String CID = "cid";
field public static final String CMAS_CATEGORY = "cmas_category";
field public static final String CMAS_CERTAINTY = "cmas_certainty";
field public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
field public static final String CMAS_RESPONSE_TYPE = "cmas_response_type";
field public static final String CMAS_SEVERITY = "cmas_severity";
field public static final String CMAS_URGENCY = "cmas_urgency";
field @NonNull public static final android.net.Uri CONTENT_URI;
field public static final String DEFAULT_SORT_ORDER = "date DESC";
field public static final String DELIVERY_TIME = "date";
field public static final String ETWS_WARNING_TYPE = "etws_warning_type";
field public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
field public static final String LAC = "lac";
field public static final String LANGUAGE_CODE = "language";
field public static final String MESSAGE_BODY = "body";
field public static final String MESSAGE_FORMAT = "format";
field public static final String MESSAGE_PRIORITY = "priority";
field public static final String MESSAGE_READ = "read";
field public static final String PLMN = "plmn";
field public static final String SERIAL_NUMBER = "serial_number";
field public static final String SERVICE_CATEGORY = "service_category";
}
public final class TimeZoneRulesDataContract {
field public static final String AUTHORITY = "com.android.timezone";
}
@@ -6227,7 +6251,125 @@ package android.telephony {
field public static final int ROAMING_TYPE_UNKNOWN = 1; // 0x1
}
public final class SmsCbCmasInfo implements android.os.Parcelable {
ctor public SmsCbCmasInfo(int, int, int, int, int, int);
method public int describeContents();
method public int getCategory();
method public int getCertainty();
method public int getMessageClass();
method public int getResponseType();
method public int getSeverity();
method public int getUrgency();
method public void writeToParcel(android.os.Parcel, int);
field public static final int CMAS_CATEGORY_CBRNE = 10; // 0xa
field public static final int CMAS_CATEGORY_ENV = 7; // 0x7
field public static final int CMAS_CATEGORY_FIRE = 5; // 0x5
field public static final int CMAS_CATEGORY_GEO = 0; // 0x0
field public static final int CMAS_CATEGORY_HEALTH = 6; // 0x6
field public static final int CMAS_CATEGORY_INFRA = 9; // 0x9
field public static final int CMAS_CATEGORY_MET = 1; // 0x1
field public static final int CMAS_CATEGORY_OTHER = 11; // 0xb
field public static final int CMAS_CATEGORY_RESCUE = 4; // 0x4
field public static final int CMAS_CATEGORY_SAFETY = 2; // 0x2
field public static final int CMAS_CATEGORY_SECURITY = 3; // 0x3
field public static final int CMAS_CATEGORY_TRANSPORT = 8; // 0x8
field public static final int CMAS_CATEGORY_UNKNOWN = -1; // 0xffffffff
field public static final int CMAS_CERTAINTY_LIKELY = 1; // 0x1
field public static final int CMAS_CERTAINTY_OBSERVED = 0; // 0x0
field public static final int CMAS_CERTAINTY_UNKNOWN = -1; // 0xffffffff
field public static final int CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY = 3; // 0x3
field public static final int CMAS_CLASS_CMAS_EXERCISE = 5; // 0x5
field public static final int CMAS_CLASS_EXTREME_THREAT = 1; // 0x1
field public static final int CMAS_CLASS_OPERATOR_DEFINED_USE = 6; // 0x6
field public static final int CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT = 0; // 0x0
field public static final int CMAS_CLASS_REQUIRED_MONTHLY_TEST = 4; // 0x4
field public static final int CMAS_CLASS_SEVERE_THREAT = 2; // 0x2
field public static final int CMAS_CLASS_UNKNOWN = -1; // 0xffffffff
field public static final int CMAS_RESPONSE_TYPE_ASSESS = 6; // 0x6
field public static final int CMAS_RESPONSE_TYPE_AVOID = 5; // 0x5
field public static final int CMAS_RESPONSE_TYPE_EVACUATE = 1; // 0x1
field public static final int CMAS_RESPONSE_TYPE_EXECUTE = 3; // 0x3
field public static final int CMAS_RESPONSE_TYPE_MONITOR = 4; // 0x4
field public static final int CMAS_RESPONSE_TYPE_NONE = 7; // 0x7
field public static final int CMAS_RESPONSE_TYPE_PREPARE = 2; // 0x2
field public static final int CMAS_RESPONSE_TYPE_SHELTER = 0; // 0x0
field public static final int CMAS_RESPONSE_TYPE_UNKNOWN = -1; // 0xffffffff
field public static final int CMAS_SEVERITY_EXTREME = 0; // 0x0
field public static final int CMAS_SEVERITY_SEVERE = 1; // 0x1
field public static final int CMAS_SEVERITY_UNKNOWN = -1; // 0xffffffff
field public static final int CMAS_URGENCY_EXPECTED = 1; // 0x1
field public static final int CMAS_URGENCY_IMMEDIATE = 0; // 0x0
field public static final int CMAS_URGENCY_UNKNOWN = -1; // 0xffffffff
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SmsCbCmasInfo> CREATOR;
}
public final class SmsCbEtwsInfo implements android.os.Parcelable {
ctor public SmsCbEtwsInfo(int, boolean, boolean, boolean, @Nullable byte[]);
method public int describeContents();
method @Nullable public byte[] getPrimaryNotificationSignature();
method public long getPrimaryNotificationTimestamp();
method public int getWarningType();
method public boolean isEmergencyUserAlert();
method public boolean isPopupAlert();
method public boolean isPrimary();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SmsCbEtwsInfo> CREATOR;
field public static final int ETWS_WARNING_TYPE_EARTHQUAKE = 0; // 0x0
field public static final int ETWS_WARNING_TYPE_EARTHQUAKE_AND_TSUNAMI = 2; // 0x2
field public static final int ETWS_WARNING_TYPE_OTHER_EMERGENCY = 4; // 0x4
field public static final int ETWS_WARNING_TYPE_TEST_MESSAGE = 3; // 0x3
field public static final int ETWS_WARNING_TYPE_TSUNAMI = 1; // 0x1
field public static final int ETWS_WARNING_TYPE_UNKNOWN = -1; // 0xffffffff
}
public final class SmsCbLocation implements android.os.Parcelable {
method public int describeContents();
method public int getCid();
method public int getLac();
method @NonNull public String getPlmn();
method public boolean isInLocationArea(@NonNull android.telephony.SmsCbLocation);
method public boolean isInLocationArea(@Nullable String, int, int);
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SmsCbLocation> CREATOR;
}
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);
method @NonNull public static android.telephony.SmsCbMessage createFromCursor(@NonNull android.database.Cursor);
method public int describeContents();
method @Nullable public android.telephony.SmsCbCmasInfo getCmasWarningInfo();
method @NonNull public android.content.ContentValues getContentValues();
method @Nullable public android.telephony.SmsCbEtwsInfo getEtwsWarningInfo();
method public int getGeographicalScope();
method @Nullable public String getLanguageCode();
method @NonNull public android.telephony.SmsCbLocation getLocation();
method @Nullable public String getMessageBody();
method public int getMessageFormat();
method public int getMessagePriority();
method public long getReceivedTime();
method public int getSerialNumber();
method public int getServiceCategory();
method public boolean isCmasMessage();
method public boolean isEmergencyMessage();
method public boolean isEtwsMessage();
method public boolean needGeoFencingCheck();
method public void writeToParcel(android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.telephony.SmsCbMessage> CREATOR;
field public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE = 3; // 0x3
field public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE = 0; // 0x0
field public static final int GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE = 2; // 0x2
field public static final int GEOGRAPHICAL_SCOPE_PLMN_WIDE = 1; // 0x1
field public static final int MESSAGE_FORMAT_3GPP = 1; // 0x1
field public static final int MESSAGE_FORMAT_3GPP2 = 2; // 0x2
field public static final int MESSAGE_PRIORITY_EMERGENCY = 3; // 0x3
field public static final int MESSAGE_PRIORITY_INTERACTIVE = 1; // 0x1
field public static final int MESSAGE_PRIORITY_NORMAL = 0; // 0x0
field public static final int MESSAGE_PRIORITY_URGENT = 2; // 0x2
}
public final class SmsManager {
method public boolean disableCellBroadcastRange(int, int, int);
method public boolean enableCellBroadcastRange(int, int, int);
method @RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE) public void sendMultipartTextMessageWithoutPersisting(String, String, java.util.List<java.lang.String>, java.util.List<android.app.PendingIntent>, java.util.List<android.app.PendingIntent>);
field public static final int RESULT_CANCELLED = 23; // 0x17
field public static final int RESULT_ENCODING_ERROR = 18; // 0x12
@@ -6257,6 +6399,7 @@ package android.telephony {
public class SubscriptionManager {
method public java.util.List<android.telephony.SubscriptionInfo> getAvailableSubscriptionInfoList();
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public int getEnabledSubscriptionId(int);
method @NonNull public static android.content.res.Resources getResourcesForSubId(@NonNull android.content.Context, int);
method @RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE) public boolean isSubscriptionEnabled(int);
method public void requestEmbeddedSubscriptionInfoListRefresh();
method public void requestEmbeddedSubscriptionInfoListRefresh(int);

View File

@@ -699,30 +699,6 @@ Landroid/telephony/ims/compat/stub/ImsUtListenerImplBase;-><init>()V
Landroid/telephony/mbms/IMbmsStreamingSessionCallback$Stub;-><init>()V
Landroid/telephony/mbms/IStreamingServiceCallback$Stub;-><init>()V
Landroid/telephony/mbms/vendor/IMbmsStreamingService$Stub;->asInterface(Landroid/os/IBinder;)Landroid/telephony/mbms/vendor/IMbmsStreamingService;
Landroid/telephony/SmsCbCmasInfo;->getCategory()I
Landroid/telephony/SmsCbCmasInfo;->getCertainty()I
Landroid/telephony/SmsCbCmasInfo;->getMessageClass()I
Landroid/telephony/SmsCbCmasInfo;->getResponseType()I
Landroid/telephony/SmsCbCmasInfo;->getSeverity()I
Landroid/telephony/SmsCbCmasInfo;->getUrgency()I
Landroid/telephony/SmsCbEtwsInfo;->getWarningType()I
Landroid/telephony/SmsCbLocation;-><init>(Ljava/lang/String;)V
Landroid/telephony/SmsCbLocation;-><init>(Ljava/lang/String;II)V
Landroid/telephony/SmsCbLocation;->getCid()I
Landroid/telephony/SmsCbLocation;->getLac()I
Landroid/telephony/SmsCbLocation;->getPlmn()Ljava/lang/String;
Landroid/telephony/SmsCbMessage;-><init>(Landroid/os/Parcel;)V
Landroid/telephony/SmsCbMessage;->getCmasWarningInfo()Landroid/telephony/SmsCbCmasInfo;
Landroid/telephony/SmsCbMessage;->getEtwsWarningInfo()Landroid/telephony/SmsCbEtwsInfo;
Landroid/telephony/SmsCbMessage;->getGeographicalScope()I
Landroid/telephony/SmsCbMessage;->getLanguageCode()Ljava/lang/String;
Landroid/telephony/SmsCbMessage;->getLocation()Landroid/telephony/SmsCbLocation;
Landroid/telephony/SmsCbMessage;->getMessageBody()Ljava/lang/String;
Landroid/telephony/SmsCbMessage;->getMessageFormat()I
Landroid/telephony/SmsCbMessage;->getSerialNumber()I
Landroid/telephony/SmsCbMessage;->getServiceCategory()I
Landroid/telephony/SmsCbMessage;->isCmasMessage()Z
Landroid/telephony/SmsCbMessage;->isEmergencyMessage()Z
Landroid/telephony/TelephonyManager$MultiSimVariants;->values()[Landroid/telephony/TelephonyManager$MultiSimVariants;
Landroid/util/Singleton;-><init>()V
Landroid/view/accessibility/IAccessibilityManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V

View File

@@ -3872,9 +3872,10 @@ public final class Telephony {
}
/**
* Contains received SMS cell broadcast messages.
* Contains received SMS cell broadcast messages. More details are available in 3GPP TS 23.041.
* @hide
*/
@SystemApi
public static final class CellBroadcasts implements BaseColumns {
/**
@@ -3886,30 +3887,52 @@ public final class Telephony {
/**
* The {@code content://} URI for this table.
*/
@NonNull
public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
/**
* Message geographical scope.
* Message geographical scope. Valid values are:
* <ul>
* <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE}. meaning the
* message is for the radio service cell</li>
* <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE},
* meaning the message is for the radio service cell and immediately displayed</li>
* <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_PLMN_WIDE}, meaning the
* message is for the PLMN (i.e. MCC/MNC)</li>
* <li>{@link android.telephony.SmsCbMessage#GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE},
* meaning the message is for the location area (in GSM) or service area (in UMTS)</li>
* </ul>
*
* <p>A message meant for a particular scope is automatically dismissed when the device
* exits that scope.</p>
* <P>Type: INTEGER</P>
*/
public static final String GEOGRAPHICAL_SCOPE = "geo_scope";
/**
* Message serial number.
* <p>
* A 16-bit integer which identifies a particular CBS (cell
* broadcast short message service) message. The core network is responsible for
* allocating this value, and the value may be managed cyclically (3GPP TS 23.041 section
* 9.2.1) once the serial message has been incremented a sufficient number of times.
* </p>
* <P>Type: INTEGER</P>
*/
public static final String SERIAL_NUMBER = "serial_number";
/**
* PLMN of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID} uniquely identifies
* a broadcast for duplicate detection purposes.
* PLMN (i.e. MCC/MNC) of broadcast sender. {@code SERIAL_NUMBER + PLMN + LAC + CID}
* uniquely identifies a broadcast for duplicate detection purposes.
* <P>Type: TEXT</P>
*/
public static final String PLMN = "plmn";
/**
* Location Area (GSM) or Service Area (UMTS) of broadcast sender. Unused for CDMA.
* Only included if Geographical Scope of message is not PLMN wide (01).
* Location area code (LAC).
* <p>Code representing location area (GSM) or service area (UMTS) of broadcast sender.
* Unused for CDMA. Only included if Geographical Scope of message is not PLMN wide (01).
* This value is sent by the network based on the cell tower.
* <P>Type: INTEGER</P>
*/
public static final String LAC = "lac";
@@ -3924,23 +3947,29 @@ public final class Telephony {
/**
* Message code. <em>OBSOLETE: merged into SERIAL_NUMBER.</em>
* <P>Type: INTEGER</P>
* @hide
*/
public static final String V1_MESSAGE_CODE = "message_code";
/**
* Message identifier. <em>OBSOLETE: renamed to SERVICE_CATEGORY.</em>
* <P>Type: INTEGER</P>
* @hide
*/
public static final String V1_MESSAGE_IDENTIFIER = "message_id";
/**
* Service category (GSM/UMTS: message identifier; CDMA: service category).
* Service category which represents the general topic of the message.
* <p>
* For GSM/UMTS: message identifier (see 3GPP TS 23.041 section 9.4.1.2.2)
* For CDMA: a 16-bit CDMA service category (see 3GPP2 C.R1001-D section 9.3)
* </p>
* <P>Type: INTEGER</P>
*/
public static final String SERVICE_CATEGORY = "service_category";
/**
* Message language code.
* Message language code. (See 3GPP TS 23.041 section 9.4.1.2.3 for details).
* <P>Type: TEXT</P>
*/
public static final String LANGUAGE_CODE = "language";
@@ -3953,6 +3982,7 @@ public final class Telephony {
/**
* Message delivery time.
* <p>This value is a system timestamp using {@link System#currentTimeMillis}</p>
* <P>Type: INTEGER (long)</P>
*/
public static final String DELIVERY_TIME = "date";
@@ -3964,25 +3994,36 @@ public final class Telephony {
public static final String MESSAGE_READ = "read";
/**
* Message format (3GPP or 3GPP2).
* Message format ({@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP} or
* {@link android.telephony.SmsCbMessage#MESSAGE_FORMAT_3GPP2}).
* <P>Type: INTEGER</P>
*/
public static final String MESSAGE_FORMAT = "format";
/**
* Message priority (including emergency).
* Message priority.
* <p>This includes
* <ul>
* <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_NORMAL}</li>
* <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_INTERACTIVE}</li>
* <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_URGENT}</li>
* <li>{@link android.telephony.SmsCbMessage#MESSAGE_PRIORITY_EMERGENCY}</li>
* </p>
* </ul>
* <P>Type: INTEGER</P>
*/
public static final String MESSAGE_PRIORITY = "priority";
/**
* ETWS warning type (ETWS alerts only).
* ETWS (Earthquake and Tsunami Warning System) warning type (ETWS alerts only).
* <p>See {@link android.telephony.SmsCbEtwsInfo}</p>
* <P>Type: INTEGER</P>
*/
public static final String ETWS_WARNING_TYPE = "etws_warning_type";
/**
* CMAS message class (CMAS alerts only).
* CMAS (Commercial Mobile Alert System) message class (CMAS alerts only).
* <p>See {@link android.telephony.SmsCbCmasInfo}</p>
* <P>Type: INTEGER</P>
*/
public static final String CMAS_MESSAGE_CLASS = "cmas_message_class";
@@ -4023,12 +4064,14 @@ public final class Telephony {
/**
* The timestamp in millisecond of when the device received the message.
* <P>Type: BIGINT</P>
* @hide
*/
public static final String RECEIVED_TIME = "received_time";
/**
* Indicates that whether the message has been broadcasted to the application.
* <P>Type: BOOLEAN</P>
* @hide
*/
public static final String MESSAGE_BROADCASTED = "message_broadcasted";
@@ -4064,12 +4107,15 @@ public final class Telephony {
* "circle|0,0|100;polygon|0,0|0,1.5|1,1|1,0;circle|100.123,100|200.123"
*
* <P>Type: TEXT</P>
* @hide
*/
public static final String GEOMETRIES = "geometries";
/**
* Query columns for instantiating {@link android.telephony.CellBroadcastMessage} objects.
* @hide
*/
@NonNull
public static final String[] QUERY_COLUMNS = {
_ID,
GEOGRAPHICAL_SCOPE,
@@ -4095,6 +4141,7 @@ public final class Telephony {
/**
* Query columns for instantiating {@link android.telephony.SmsCbMessage} objects.
* @hide
*/
public static final String[] QUERY_COLUMNS_FWK = {
_ID,

View File

@@ -371,15 +371,16 @@ public class ServiceState implements Parcelable {
/**
* Create a new ServiceState from a intent notifier Bundle
*
* This method is used by PhoneStateIntentReceiver and maybe by
* This method is used by PhoneStateIntentReceiver, CellBroadcastReceiver, and maybe by
* external applications.
*
* @param m Bundle from intent notifier
* @return newly created ServiceState
* @hide
*/
@NonNull
@UnsupportedAppUsage
public static ServiceState newFromBundle(Bundle m) {
public static ServiceState newFromBundle(@NonNull Bundle m) {
ServiceState ret;
ret = new ServiceState();
ret.setFromNotifierBundle(m);

View File

@@ -16,17 +16,25 @@
package android.telephony;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Contains CMAS warning notification Type 1 elements for a {@link SmsCbMessage}.
* Contains CMAS (Commercial Mobile Alert System) warning notification Type 1 elements for a
* {@link SmsCbMessage}.
* Supported values for each element are defined in TIA-1149-0-1 (CMAS over CDMA) and
* 3GPP TS 23.041 (for GSM/UMTS).
*
* {@hide}
*/
public class SmsCbCmasInfo implements Parcelable {
@SystemApi
public final class SmsCbCmasInfo implements Parcelable {
// CMAS message class (in GSM/UMTS message identifier or CDMA service category).
@@ -54,6 +62,21 @@ public class SmsCbCmasInfo implements Parcelable {
/** CMAS category for warning types that are reserved for future extension. */
public static final int CMAS_CLASS_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_CLASS_"},
value = {
CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT,
CMAS_CLASS_EXTREME_THREAT,
CMAS_CLASS_SEVERE_THREAT,
CMAS_CLASS_CHILD_ABDUCTION_EMERGENCY,
CMAS_CLASS_REQUIRED_MONTHLY_TEST,
CMAS_CLASS_CMAS_EXERCISE,
CMAS_CLASS_OPERATOR_DEFINED_USE,
CMAS_CLASS_UNKNOWN,
})
public @interface Class {}
// CMAS alert category (in CDMA type 1 elements record).
/** CMAS alert category: Geophysical including landslide. */
@@ -98,6 +121,26 @@ public class SmsCbCmasInfo implements Parcelable {
*/
public static final int CMAS_CATEGORY_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_CATEORY_"},
value = {
CMAS_CATEGORY_GEO,
CMAS_CATEGORY_MET,
CMAS_CATEGORY_SAFETY,
CMAS_CATEGORY_SECURITY,
CMAS_CATEGORY_RESCUE,
CMAS_CATEGORY_FIRE,
CMAS_CATEGORY_HEALTH,
CMAS_CATEGORY_ENV,
CMAS_CATEGORY_TRANSPORT,
CMAS_CATEGORY_INFRA,
CMAS_CATEGORY_CBRNE,
CMAS_CATEGORY_OTHER,
CMAS_CATEGORY_UNKNOWN,
})
public @interface Category {}
// CMAS response type (in CDMA type 1 elements record).
/** CMAS response type: Take shelter in place. */
@@ -130,6 +173,22 @@ public class SmsCbCmasInfo implements Parcelable {
*/
public static final int CMAS_RESPONSE_TYPE_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_RESPONSE_TYPE_"},
value = {
CMAS_RESPONSE_TYPE_SHELTER,
CMAS_RESPONSE_TYPE_EVACUATE,
CMAS_RESPONSE_TYPE_PREPARE,
CMAS_RESPONSE_TYPE_EXECUTE,
CMAS_RESPONSE_TYPE_MONITOR,
CMAS_RESPONSE_TYPE_AVOID,
CMAS_RESPONSE_TYPE_ASSESS,
CMAS_RESPONSE_TYPE_NONE,
CMAS_RESPONSE_TYPE_UNKNOWN,
})
public @interface ResponseType {}
// 4-bit CMAS severity (in GSM/UMTS message identifier or CDMA type 1 elements record).
/** CMAS severity type: Extraordinary threat to life or property. */
@@ -145,6 +204,16 @@ public class SmsCbCmasInfo implements Parcelable {
*/
public static final int CMAS_SEVERITY_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_SEVERITY_"},
value = {
CMAS_SEVERITY_EXTREME,
CMAS_SEVERITY_SEVERE,
CMAS_SEVERITY_UNKNOWN,
})
public @interface Severity {}
// CMAS urgency (in GSM/UMTS message identifier or CDMA type 1 elements record).
/** CMAS urgency type: Responsive action should be taken immediately. */
@@ -160,6 +229,16 @@ public class SmsCbCmasInfo implements Parcelable {
*/
public static final int CMAS_URGENCY_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_URGENCY_"},
value = {
CMAS_URGENCY_IMMEDIATE,
CMAS_URGENCY_EXPECTED,
CMAS_URGENCY_UNKNOWN,
})
public @interface Urgency {}
// CMAS certainty (in GSM/UMTS message identifier or CDMA type 1 elements record).
/** CMAS certainty type: Determined to have occurred or to be ongoing. */
@@ -175,27 +254,38 @@ public class SmsCbCmasInfo implements Parcelable {
*/
public static final int CMAS_CERTAINTY_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"CMAS_CERTAINTY_"},
value = {
CMAS_CERTAINTY_OBSERVED,
CMAS_CERTAINTY_LIKELY,
CMAS_CERTAINTY_UNKNOWN,
})
public @interface Certainty {}
/** CMAS message class. */
private final int mMessageClass;
private final @Class int mMessageClass;
/** CMAS category. */
private final int mCategory;
private final @Category int mCategory;
/** CMAS response type. */
private final int mResponseType;
private final @ResponseType int mResponseType;
/** CMAS severity. */
private final int mSeverity;
private final @Severity int mSeverity;
/** CMAS urgency. */
private final int mUrgency;
private final @Urgency int mUrgency;
/** CMAS certainty. */
private final int mCertainty;
private final @Certainty int mCertainty;
/** Create a new SmsCbCmasInfo object with the specified values. */
public SmsCbCmasInfo(int messageClass, int category, int responseType, int severity,
int urgency, int certainty) {
public SmsCbCmasInfo(@Class int messageClass, @Category int category,
@ResponseType int responseType,
@Severity int severity, @Urgency int urgency, @Certainty int certainty) {
mMessageClass = messageClass;
mCategory = category;
mResponseType = responseType;
@@ -234,7 +324,7 @@ public class SmsCbCmasInfo implements Parcelable {
* Returns the CMAS message class, e.g. {@link #CMAS_CLASS_PRESIDENTIAL_LEVEL_ALERT}.
* @return one of the {@code CMAS_CLASS} values
*/
public int getMessageClass() {
public @Class int getMessageClass() {
return mMessageClass;
}
@@ -242,7 +332,7 @@ public class SmsCbCmasInfo implements Parcelable {
* Returns the CMAS category, e.g. {@link #CMAS_CATEGORY_GEO}.
* @return one of the {@code CMAS_CATEGORY} values
*/
public int getCategory() {
public @Category int getCategory() {
return mCategory;
}
@@ -250,7 +340,7 @@ public class SmsCbCmasInfo implements Parcelable {
* Returns the CMAS response type, e.g. {@link #CMAS_RESPONSE_TYPE_SHELTER}.
* @return one of the {@code CMAS_RESPONSE_TYPE} values
*/
public int getResponseType() {
public @ResponseType int getResponseType() {
return mResponseType;
}
@@ -258,7 +348,7 @@ public class SmsCbCmasInfo implements Parcelable {
* Returns the CMAS severity, e.g. {@link #CMAS_SEVERITY_EXTREME}.
* @return one of the {@code CMAS_SEVERITY} values
*/
public int getSeverity() {
public @Severity int getSeverity() {
return mSeverity;
}
@@ -266,15 +356,16 @@ public class SmsCbCmasInfo implements Parcelable {
* Returns the CMAS urgency, e.g. {@link #CMAS_URGENCY_IMMEDIATE}.
* @return one of the {@code CMAS_URGENCY} values
*/
public int getUrgency() {
public @Urgency int getUrgency() {
return mUrgency;
}
/**
* Returns the CMAS certainty, e.g. {@link #CMAS_CERTAINTY_OBSERVED}.
*
* @return one of the {@code CMAS_CERTAINTY} values
*/
public int getCertainty() {
public @Certainty int getCertainty() {
return mCertainty;
}
@@ -287,6 +378,7 @@ public class SmsCbCmasInfo implements Parcelable {
/**
* Describe the kinds of special objects contained in the marshalled representation.
*
* @return a bitmask indicating this Parcelable contains no special objects
*/
@Override
@@ -295,8 +387,9 @@ public class SmsCbCmasInfo implements Parcelable {
}
/** Creator for unparcelling objects. */
public static final Parcelable.Creator<SmsCbCmasInfo>
CREATOR = new Parcelable.Creator<SmsCbCmasInfo>() {
@NonNull
public static final Parcelable.Creator<SmsCbCmasInfo> CREATOR =
new Parcelable.Creator<SmsCbCmasInfo>() {
@Override
public SmsCbCmasInfo createFromParcel(Parcel in) {
return new SmsCbCmasInfo(in);

View File

@@ -16,22 +16,29 @@
package android.telephony;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.telephony.uicc.IccUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Arrays;
/**
* Contains information elements for a GSM or UMTS ETWS warning notification.
* Supported values for each element are defined in 3GPP TS 23.041.
* Contains information elements for a GSM or UMTS ETWS (Earthquake and Tsunami Warning
* System) warning notification. Supported values for each element are defined in 3GPP TS 23.041.
*
* {@hide}
*/
public class SmsCbEtwsInfo implements Parcelable {
@SystemApi
public final class SmsCbEtwsInfo implements Parcelable {
/** ETWS warning type for earthquake. */
public static final int ETWS_WARNING_TYPE_EARTHQUAKE = 0x00;
@@ -51,17 +58,30 @@ public class SmsCbEtwsInfo implements Parcelable {
/** Unknown ETWS warning type. */
public static final int ETWS_WARNING_TYPE_UNKNOWN = -1;
/** @hide */
@Retention(RetentionPolicy.SOURCE)
@IntDef(prefix = {"ETWS_WARNING_TYPE_"},
value = {
ETWS_WARNING_TYPE_EARTHQUAKE,
ETWS_WARNING_TYPE_TSUNAMI,
ETWS_WARNING_TYPE_EARTHQUAKE_AND_TSUNAMI,
ETWS_WARNING_TYPE_TEST_MESSAGE,
ETWS_WARNING_TYPE_OTHER_EMERGENCY,
ETWS_WARNING_TYPE_UNKNOWN,
})
public @interface WarningType {}
/** One of the ETWS warning type constants defined in this class. */
private final int mWarningType;
private final @WarningType int mWarningType;
/** Whether or not to activate the emergency user alert tone and vibration. */
private final boolean mEmergencyUserAlert;
private final boolean mIsEmergencyUserAlert;
/** Whether or not to activate a popup alert. */
private final boolean mActivatePopup;
private final boolean mIsPopupAlert;
/** Whether ETWS primary message or not/ */
private final boolean mPrimary;
private final boolean mIsPrimary;
/**
* 50-byte security information (ETWS primary notification for GSM only). As of Release 10,
@@ -70,24 +90,35 @@ public class SmsCbEtwsInfo implements Parcelable {
* parceled with the broadcast intent if present, but the timestamp is only computed if an
* application asks for the individual components.
*/
@Nullable
private final byte[] mWarningSecurityInformation;
/** Create a new SmsCbEtwsInfo object with the specified values. */
public SmsCbEtwsInfo(int warningType, boolean emergencyUserAlert, boolean activatePopup,
boolean primary, byte[] warningSecurityInformation) {
/**
* Create a new SmsCbEtwsInfo object with the specified values.
* @param warningType the type of ETWS warning
* @param isEmergencyUserAlert whether the warning is an emergency alert, which will activate
* the user alert tone and vibration
* @param isPopupAlert whether the warning will activate a popup alert
* @param isPrimary whether this is an ETWS primary message
* @param warningSecurityInformation 50-byte security information (for primary notifications
* on GSM only).
*/
public SmsCbEtwsInfo(@WarningType int warningType, boolean isEmergencyUserAlert,
boolean isPopupAlert,
boolean isPrimary, @Nullable byte[] warningSecurityInformation) {
mWarningType = warningType;
mEmergencyUserAlert = emergencyUserAlert;
mActivatePopup = activatePopup;
mPrimary = primary;
mIsEmergencyUserAlert = isEmergencyUserAlert;
mIsPopupAlert = isPopupAlert;
mIsPrimary = isPrimary;
mWarningSecurityInformation = warningSecurityInformation;
}
/** Create a new SmsCbEtwsInfo object from a Parcel. */
SmsCbEtwsInfo(Parcel in) {
mWarningType = in.readInt();
mEmergencyUserAlert = (in.readInt() != 0);
mActivatePopup = (in.readInt() != 0);
mPrimary = (in.readInt() != 0);
mIsEmergencyUserAlert = (in.readInt() != 0);
mIsPopupAlert = (in.readInt() != 0);
mIsPrimary = (in.readInt() != 0);
mWarningSecurityInformation = in.createByteArray();
}
@@ -100,9 +131,9 @@ public class SmsCbEtwsInfo implements Parcelable {
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mWarningType);
dest.writeInt(mEmergencyUserAlert ? 1 : 0);
dest.writeInt(mActivatePopup ? 1 : 0);
dest.writeInt(mPrimary ? 1 : 0);
dest.writeInt(mIsEmergencyUserAlert ? 1 : 0);
dest.writeInt(mIsPopupAlert ? 1 : 0);
dest.writeInt(mIsPrimary ? 1 : 0);
dest.writeByteArray(mWarningSecurityInformation);
}
@@ -110,16 +141,17 @@ public class SmsCbEtwsInfo implements Parcelable {
* Returns the ETWS warning type.
* @return a warning type such as {@link #ETWS_WARNING_TYPE_EARTHQUAKE}
*/
public int getWarningType() {
public @WarningType int getWarningType() {
return mWarningType;
}
/**
* Returns the ETWS emergency user alert flag.
* Returns the ETWS emergency user alert flag. If the ETWS message is an emergency alert, it
* will activate an alert tone and vibration.
* @return true to notify terminal to activate emergency user alert; false otherwise
*/
public boolean isEmergencyUserAlert() {
return mEmergencyUserAlert;
return mIsEmergencyUserAlert;
}
/**
@@ -127,7 +159,7 @@ public class SmsCbEtwsInfo implements Parcelable {
* @return true to notify terminal to activate display popup; false otherwise
*/
public boolean isPopupAlert() {
return mActivatePopup;
return mIsPopupAlert;
}
/**
@@ -135,7 +167,7 @@ public class SmsCbEtwsInfo implements Parcelable {
* @return true if the message is primary message, otherwise secondary message
*/
public boolean isPrimary() {
return mPrimary;
return mIsPrimary;
}
/**
@@ -188,6 +220,7 @@ public class SmsCbEtwsInfo implements Parcelable {
* 3GPP TS 23.041 states that the UE shall ignore this value if received.
* @return a byte array containing a copy of the primary notification digital signature
*/
@Nullable
public byte[] getPrimaryNotificationSignature() {
if (mWarningSecurityInformation == null || mWarningSecurityInformation.length < 50) {
return null;
@@ -198,7 +231,7 @@ public class SmsCbEtwsInfo implements Parcelable {
@Override
public String toString() {
return "SmsCbEtwsInfo{warningType=" + mWarningType + ", emergencyUserAlert="
+ mEmergencyUserAlert + ", activatePopup=" + mActivatePopup + '}';
+ mIsEmergencyUserAlert + ", activatePopup=" + mIsPopupAlert + '}';
}
/**
@@ -211,6 +244,7 @@ public class SmsCbEtwsInfo implements Parcelable {
}
/** Creator for unparcelling objects. */
@NonNull
public static final Creator<SmsCbEtwsInfo> CREATOR = new Creator<SmsCbEtwsInfo>() {
@Override
public SmsCbEtwsInfo createFromParcel(Parcel in) {

View File

@@ -16,6 +16,9 @@
package android.telephony;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
@@ -27,9 +30,11 @@ import android.os.Parcelable;
*
* @hide
*/
public class SmsCbLocation implements Parcelable {
@SystemApi
public final class SmsCbLocation implements Parcelable {
/** The PLMN. Note that this field may be an empty string, but isn't allowed to be null. */
/** The PLMN. Note that this field may be an empty string. */
@NonNull
private final String mPlmn;
private final int mLac;
@@ -38,6 +43,7 @@ public class SmsCbLocation implements Parcelable {
/**
* Construct an empty location object. This is used for some test cases, and for
* cell broadcasts saved in older versions of the database without location info.
* @hide
*/
public SmsCbLocation() {
mPlmn = "";
@@ -48,6 +54,7 @@ public class SmsCbLocation implements Parcelable {
/**
* Construct a location object for the PLMN. This class is immutable, so
* the same object can be reused for multiple broadcasts.
* @hide
*/
public SmsCbLocation(String plmn) {
mPlmn = plmn;
@@ -58,6 +65,7 @@ public class SmsCbLocation implements Parcelable {
/**
* Construct a location object for the PLMN, LAC, and Cell ID. This class is immutable, so
* the same object can be reused for multiple broadcasts.
* @hide
*/
public SmsCbLocation(String plmn, int lac, int cid) {
mPlmn = plmn;
@@ -67,6 +75,7 @@ public class SmsCbLocation implements Parcelable {
/**
* Initialize the object from a Parcel.
* @hide
*/
public SmsCbLocation(Parcel in) {
mPlmn = in.readString();
@@ -78,6 +87,7 @@ public class SmsCbLocation implements Parcelable {
* Returns the MCC/MNC of the network as a String.
* @return the PLMN identifier (MCC+MNC) as a String
*/
@NonNull
public String getPlmn() {
return mPlmn;
}
@@ -129,7 +139,7 @@ public class SmsCbLocation implements Parcelable {
* @param area the location area to compare with this location
* @return true if this location is contained within the specified location area
*/
public boolean isInLocationArea(SmsCbLocation area) {
public boolean isInLocationArea(@NonNull SmsCbLocation area) {
if (mCid != -1 && mCid != area.mCid) {
return false;
}
@@ -147,7 +157,7 @@ public class SmsCbLocation implements Parcelable {
* @param cid the Cell ID to compare with
* @return true if this location is contained within the specified PLMN, LAC, and Cell ID
*/
public boolean isInLocationArea(String plmn, int lac, int cid) {
public boolean isInLocationArea(@Nullable String plmn, int lac, int cid) {
if (!mPlmn.equals(plmn)) {
return false;
}
@@ -176,8 +186,9 @@ public class SmsCbLocation implements Parcelable {
dest.writeInt(mCid);
}
public static final Parcelable.Creator<SmsCbLocation> CREATOR
= new Parcelable.Creator<SmsCbLocation>() {
@NonNull
public static final Parcelable.Creator<SmsCbLocation> CREATOR =
new Parcelable.Creator<SmsCbLocation>() {
@Override
public SmsCbLocation createFromParcel(Parcel in) {
return new SmsCbLocation(in);

View File

@@ -16,7 +16,10 @@
package android.telephony;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.content.ContentValues;
import android.database.Cursor;
import android.os.Parcel;
@@ -26,6 +29,8 @@ import android.provider.Telephony.CellBroadcasts;
import com.android.internal.telephony.CbGeoUtils;
import com.android.internal.telephony.CbGeoUtils.Geometry;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
/**
@@ -70,9 +75,11 @@ import java.util.List;
*
* @hide
*/
public class SmsCbMessage implements Parcelable {
@SystemApi
public final class SmsCbMessage implements Parcelable {
protected static final String LOG_TAG = "SMSCB";
/** @hide */
public static final String LOG_TAG = "SMSCB";
/** Cell wide geographical scope with immediate display (GSM/UMTS only). */
public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE = 0;
@@ -81,17 +88,35 @@ public class SmsCbMessage implements Parcelable {
public static final int GEOGRAPHICAL_SCOPE_PLMN_WIDE = 1;
/** Location / service area wide geographical scope (GSM/UMTS only). */
public static final int GEOGRAPHICAL_SCOPE_LA_WIDE = 2;
public static final int GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE = 2;
/** Cell wide geographical scope (GSM/UMTS only). */
public static final int GEOGRAPHICAL_SCOPE_CELL_WIDE = 3;
/** @hide */
@IntDef(prefix = { "GEOGRAPHICAL_SCOPE_" }, value = {
GEOGRAPHICAL_SCOPE_CELL_WIDE_IMMEDIATE,
GEOGRAPHICAL_SCOPE_PLMN_WIDE,
GEOGRAPHICAL_SCOPE_LOCATION_AREA_WIDE,
GEOGRAPHICAL_SCOPE_CELL_WIDE,
})
@Retention(RetentionPolicy.SOURCE)
public @interface GeographicalScope {}
/** GSM or UMTS format cell broadcast. */
public static final int MESSAGE_FORMAT_3GPP = 1;
/** CDMA format cell broadcast. */
public static final int MESSAGE_FORMAT_3GPP2 = 2;
/** @hide */
@IntDef(prefix = { "MESSAGE_FORMAT_" }, value = {
MESSAGE_FORMAT_3GPP,
MESSAGE_FORMAT_3GPP2
})
@Retention(RetentionPolicy.SOURCE)
public @interface MessageFormat {}
/** Normal message priority. */
public static final int MESSAGE_PRIORITY_NORMAL = 0;
@@ -104,6 +129,16 @@ public class SmsCbMessage implements Parcelable {
/** Emergency message priority. */
public static final int MESSAGE_PRIORITY_EMERGENCY = 3;
/** @hide */
@IntDef(prefix = { "MESSAGE_PRIORITY_" }, value = {
MESSAGE_PRIORITY_NORMAL,
MESSAGE_PRIORITY_INTERACTIVE,
MESSAGE_PRIORITY_URGENT,
MESSAGE_PRIORITY_EMERGENCY,
})
@Retention(RetentionPolicy.SOURCE)
public @interface MessagePriority {}
/** Format of this message (for interpretation of service category values). */
private final int mMessageFormat;
@@ -123,6 +158,7 @@ public class SmsCbMessage implements Parcelable {
* message is not binary 01, the Location Area is included for comparison. If the GS is
* 00 or 11, the Cell ID is also included. LAC and Cell ID are -1 if not specified.
*/
@NonNull
private final SmsCbLocation mLocation;
/**
@@ -133,18 +169,22 @@ public class SmsCbMessage implements Parcelable {
private final int mServiceCategory;
/** Message language, as a two-character string, e.g. "en". */
@Nullable
private final String mLanguage;
/** Message body, as a String. */
@Nullable
private final String mBody;
/** Message priority (including emergency priority). */
private final int mPriority;
/** ETWS warning notification information (ETWS warnings only). */
@Nullable
private final SmsCbEtwsInfo mEtwsWarningInfo;
/** CMAS warning notification information (CMAS warnings only). */
@Nullable
private final SmsCbCmasInfo mCmasWarningInfo;
/** UNIX timestamp of when the message was received. */
@@ -157,8 +197,9 @@ public class SmsCbMessage implements Parcelable {
* Create a new SmsCbMessage with the specified data.
*/
public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
SmsCbLocation location, int serviceCategory, String language, String body,
int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo) {
@NonNull SmsCbLocation location, int serviceCategory, @Nullable String language,
@Nullable String body, int priority, @Nullable SmsCbEtwsInfo etwsWarningInfo,
@Nullable SmsCbCmasInfo cmasWarningInfo) {
this(messageFormat, geographicalScope, serialNumber, location, serviceCategory, language,
body, priority, etwsWarningInfo, cmasWarningInfo, null /* geometries */,
@@ -167,6 +208,7 @@ public class SmsCbMessage implements Parcelable {
/**
* Create a new {@link SmsCbMessage} with the warning area coordinates information.
* @hide
*/
public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
SmsCbLocation location, int serviceCategory, String language, String body,
@@ -186,8 +228,11 @@ public class SmsCbMessage implements Parcelable {
mGeometries = geometries;
}
/** Create a new SmsCbMessage object from a Parcel. */
public SmsCbMessage(Parcel in) {
/**
* Create a new SmsCbMessage object from a Parcel.
* @hide
*/
public SmsCbMessage(@NonNull Parcel in) {
mMessageFormat = in.readInt();
mGeographicalScope = in.readInt();
mSerialNumber = in.readInt();
@@ -252,8 +297,9 @@ public class SmsCbMessage implements Parcelable {
mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : null);
}
public static final Parcelable.Creator<SmsCbMessage> CREATOR
= new Parcelable.Creator<SmsCbMessage>() {
@NonNull
public static final Parcelable.Creator<SmsCbMessage> CREATOR =
new Parcelable.Creator<SmsCbMessage>() {
@Override
public SmsCbMessage createFromParcel(Parcel in) {
return new SmsCbMessage(in);
@@ -270,7 +316,7 @@ public class SmsCbMessage implements Parcelable {
*
* @return Geographical scope
*/
public int getGeographicalScope() {
public @GeographicalScope int getGeographicalScope() {
return mGeographicalScope;
}
@@ -294,7 +340,8 @@ public class SmsCbMessage implements Parcelable {
*
* @return the geographical location code for duplicate message detection
*/
public SmsCbLocation getLocation() {
@NonNull
public android.telephony.SmsCbLocation getLocation() {
return mLocation;
}
@@ -315,6 +362,7 @@ public class SmsCbMessage implements Parcelable {
*
* @return Language code
*/
@Nullable
public String getLanguageCode() {
return mLanguage;
}
@@ -324,6 +372,7 @@ public class SmsCbMessage implements Parcelable {
*
* @return Body, or null
*/
@Nullable
public String getMessageBody() {
return mBody;
}
@@ -332,6 +381,7 @@ public class SmsCbMessage implements Parcelable {
* Get the warning area coordinates information represent by polygons and circles.
* @return a list of geometries, {@link Nullable} means there is no coordinate information
* associated to this message.
* @hide
*/
@Nullable
public List<Geometry> getGeometries() {
@@ -350,7 +400,7 @@ public class SmsCbMessage implements Parcelable {
* Get the message format ({@link #MESSAGE_FORMAT_3GPP} or {@link #MESSAGE_FORMAT_3GPP2}).
* @return an integer representing 3GPP or 3GPP2 message format
*/
public int getMessageFormat() {
public @MessageFormat int getMessageFormat() {
return mMessageFormat;
}
@@ -360,7 +410,7 @@ public class SmsCbMessage implements Parcelable {
* {@link #MESSAGE_PRIORITY_INTERACTIVE} or {@link #MESSAGE_PRIORITY_URGENT}.
* @return an integer representing the message priority
*/
public int getMessagePriority() {
public @MessagePriority int getMessagePriority() {
return mPriority;
}
@@ -373,6 +423,7 @@ public class SmsCbMessage implements Parcelable {
*
* @return an SmsCbEtwsInfo object, or null if this is not an ETWS warning notification
*/
@Nullable
public SmsCbEtwsInfo getEtwsWarningInfo() {
return mEtwsWarningInfo;
}
@@ -387,13 +438,14 @@ public class SmsCbMessage implements Parcelable {
*
* @return an SmsCbCmasInfo object, or null if this is not a CMAS warning notification
*/
@Nullable
public SmsCbCmasInfo getCmasWarningInfo() {
return mCmasWarningInfo;
}
/**
* Return whether this message is an emergency (PWS) message type.
* @return true if the message is a public warning notification; false otherwise
* @return true if the message is an emergency notification; false otherwise
*/
public boolean isEmergencyMessage() {
return mPriority == MESSAGE_PRIORITY_EMERGENCY;
@@ -440,6 +492,7 @@ public class SmsCbMessage implements Parcelable {
/**
* @return the {@link ContentValues} instance that includes the cell broadcast data.
*/
@NonNull
public ContentValues getContentValues() {
ContentValues cv = new ContentValues(16);
cv.put(CellBroadcasts.GEOGRAPHICAL_SCOPE, mGeographicalScope);
@@ -491,7 +544,8 @@ public class SmsCbMessage implements Parcelable {
* @return a {@link SmsCbMessage} instance.
* @throws IllegalArgumentException if one of the required columns is missing
*/
public static SmsCbMessage createFromCursor(Cursor cursor) {
@NonNull
public static SmsCbMessage createFromCursor(@NonNull Cursor cursor) {
int geoScope = cursor.getInt(
cursor.getColumnIndexOrThrow(CellBroadcasts.GEOGRAPHICAL_SCOPE));
int serialNum = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.SERIAL_NUMBER));

View File

@@ -1670,15 +1670,14 @@ public final class SmsManager {
*
* @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param ranType as defined in class SmsManager, the value can be one of these:
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA
* @param ranType the message format as defined in {@link SmsCbMessage]
* @return true if successful, false otherwise
* @see #disableCellBroadcast(int, int)
*
* {@hide}
*/
public boolean enableCellBroadcast(int messageIdentifier, int ranType) {
public boolean enableCellBroadcast(int messageIdentifier,
@android.telephony.SmsCbMessage.MessageFormat int ranType) {
boolean success = false;
try {
@@ -1717,16 +1716,15 @@ public final class SmsManager {
*
* @param messageIdentifier Message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param ranType as defined in class SmsManager, the value can be one of these:
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA
* @param ranType the message format as defined in {@link SmsCbMessage}
* @return true if successful, false otherwise
*
* @see #enableCellBroadcast(int, int)
*
* {@hide}
*/
public boolean disableCellBroadcast(int messageIdentifier, int ranType) {
public boolean disableCellBroadcast(int messageIdentifier,
@android.telephony.SmsCbMessage.MessageFormat int ranType) {
boolean success = false;
try {
@@ -1746,8 +1744,8 @@ public final class SmsManager {
/**
* Enable reception of cell broadcast (SMS-CB) messages with the given
* message identifier range and RAN type. The RAN type specify this message ID
* belong to 3GPP (GSM) or 3GPP2(CDMA). Note that if two different clients enable
* message identifier range and RAN type. The RAN type specifies if this message ID
* belongs to 3GPP (GSM) or 3GPP2(CDMA). Note that if two different clients enable
* the same message identifier, they must both disable it for the device to stop
* receiving those messages. All received messages will be broadcast in an
* intent with the action "android.provider.Telephony.SMS_CB_RECEIVED".
@@ -1759,26 +1757,29 @@ public final class SmsManager {
* dialog. If this method is called on a device that has multiple active subscriptions, this
* {@link SmsManager} instance has been created with {@link #getDefault()}, and no user-defined
* default subscription is defined, the subscription ID associated with this message will be
* INVALID, which will result in the operation being completed on the subscription associated
* with logical slot 0. Use {@link #getSmsManagerForSubscriptionId(int)} to ensure the
* operation is performed on the correct subscription.
* {@link SubscriptionManager#INVALID_SUBSCRIPTION_ID}, which will result in the operation
* being completed on the subscription associated with logical slot 0. Use
* {@link #getSmsManagerForSubscriptionId(int)} to ensure the operation is performed on the
* correct subscription.
* </p>
*
* <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST}</p>
*
* @param startMessageId first message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param endMessageId last message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param ranType as defined in class SmsManager, the value can be one of these:
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA
* @return true if successful, false otherwise
* @param ranType the message format as defined in {@link SmsCbMessage}
* @return true if successful, false if the modem reports a failure (e.g. the given range or
* RAN type is invalid).
* @see #disableCellBroadcastRange(int, int, int)
*
* @throws IllegalArgumentException if endMessageId < startMessageId
* {@hide}
*/
@UnsupportedAppUsage
public boolean enableCellBroadcastRange(int startMessageId, int endMessageId, int ranType) {
@SystemApi
public boolean enableCellBroadcastRange(int startMessageId, int endMessageId,
@android.telephony.SmsCbMessage.MessageFormat int ranType) {
boolean success = false;
if (endMessageId < startMessageId) {
@@ -1818,22 +1819,24 @@ public final class SmsManager {
* operation is performed on the correct subscription.
* </p>
*
* <p>Requires {@link android.Manifest.permission#RECEIVE_EMERGENCY_BROADCAST}</p>
*
* @param startMessageId first message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param endMessageId last message identifier as specified in TS 23.041 (3GPP)
* or C.R1001-G (3GPP2)
* @param ranType as defined in class SmsManager, the value can be one of these:
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_GSM
* android.telephony.SmsMessage.CELL_BROADCAST_RAN_TYPE_CDMA
* @return true if successful, false otherwise
* @param ranType the message format as defined in {@link SmsCbMessage}
* @return true if successful, false if the modem reports a failure (e.g. the given range or
* RAN type is invalid).
*
* @see #enableCellBroadcastRange(int, int, int)
*
* @throws IllegalArgumentException if endMessageId < startMessageId
* {@hide}
*/
@UnsupportedAppUsage
public boolean disableCellBroadcastRange(int startMessageId, int endMessageId, int ranType) {
@SystemApi
public boolean disableCellBroadcastRange(int startMessageId, int endMessageId,
@android.telephony.SmsCbMessage.MessageFormat int ranType) {
boolean success = false;
if (endMessageId < startMessageId) {

View File

@@ -2273,14 +2273,19 @@ public class SubscriptionManager {
}
/**
* Returns the resources associated with Subscription.
* Returns the {@link Resources} from the given {@link Context} for the MCC/MNC associated with
* the subscription. If the subscription ID is invalid, the base resources are returned instead.
*
* Requires Permission: {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE}
*
* @param context Context object
* @param subId Subscription Id of Subscription who's resources are required
* @param subId Subscription Id of Subscription whose resources are required
* @return Resources associated with Subscription.
* @hide
*/
@UnsupportedAppUsage
public static Resources getResourcesForSubId(Context context, int subId) {
@NonNull
@SystemApi
public static Resources getResourcesForSubId(@NonNull Context context, int subId) {
return getResourcesForSubId(context, subId, false);
}

View File

@@ -16,6 +16,7 @@
package android.telephony.cdma;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
@@ -28,7 +29,7 @@ import android.os.Parcelable;
*
* {@hide}
*/
public class CdmaSmsCbProgramData implements Parcelable {
public final class CdmaSmsCbProgramData implements Parcelable {
/** Delete the specified service category from the list of enabled categories. */
public static final int OPERATION_DELETE_CATEGORY = 0;
@@ -95,7 +96,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
/** Create a new CdmaSmsCbProgramData object with the specified values. */
public CdmaSmsCbProgramData(int operation, int category, int language, int maxMessages,
int alertOption, String categoryName) {
int alertOption, @NonNull String categoryName) {
mOperation = operation;
mCategory = category;
mLanguage = language;
@@ -174,6 +175,7 @@ public class CdmaSmsCbProgramData implements Parcelable {
* Returns the service category name, in the language specified by {@link #getLanguage()}.
* @return an optional service category name
*/
@NonNull
public String getCategoryName() {
return mCategoryName;
}

View File

@@ -16,12 +16,12 @@
package com.android.framework.permission.tests;
import java.util.ArrayList;
import android.telephony.SmsManager;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
import java.util.ArrayList;
/**
* Verify that SmsManager apis cannot be called without required permissions.
*/
@@ -32,6 +32,10 @@ public class SmsManagerPermissionTest extends AndroidTestCase {
private static final String DEST_NUMBER = "4567";
private static final String SRC_NUMBER = "1234";
private static final int CELL_BROADCAST_MESSAGE_ID_START = 10;
private static final int CELL_BROADCAST_MESSAGE_ID_END = 20;
private static final int CELL_BROADCAST_GSM_RAN_TYPE = 0;
/**
* Verify that SmsManager.sendTextMessage requires permissions.
* <p>Tests Permission:
@@ -82,4 +86,34 @@ public class SmsManagerPermissionTest extends AndroidTestCase {
// expected
}
}
/**
* Verify that SmsManager.enableCellBroadcastRange requires permissions.
* <p>Tests system permission: android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
*/
@SmallTest
public void testEnableCellBroadcastRange() {
try {
SmsManager.getDefault().enableCellBroadcastRange(CELL_BROADCAST_MESSAGE_ID_START,
CELL_BROADCAST_MESSAGE_ID_END, CELL_BROADCAST_GSM_RAN_TYPE);
fail("SmsManager.sendDataMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
/**
* Verify that SmsManager.disableCellBroadcastRange requires permissions.
* <p>Tests system permission: android.Manifest.permission.RECEIVE_EMERGENCY_BROADCAST
*/
@SmallTest
public void testDisableCellBroadcastRange() {
try {
SmsManager.getDefault().disableCellBroadcastRange(CELL_BROADCAST_MESSAGE_ID_START,
CELL_BROADCAST_MESSAGE_ID_END, CELL_BROADCAST_GSM_RAN_TYPE);
fail("SmsManager.sendDataMessage did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected
}
}
}