FileDocCategorySizeDatePackage
SmsCbEtwsInfo.javaAPI DocAndroid 5.1 API7662Thu Mar 12 22:22:54 GMT 2015android.telephony

SmsCbEtwsInfo

public class SmsCbEtwsInfo extends Object implements android.os.Parcelable
Contains information elements for a GSM or UMTS ETWS warning notification. Supported values for each element are defined in 3GPP TS 23.041. {@hide}

Fields Summary
public static final int
ETWS_WARNING_TYPE_EARTHQUAKE
ETWS warning type for earthquake.
public static final int
ETWS_WARNING_TYPE_TSUNAMI
ETWS warning type for tsunami.
public static final int
ETWS_WARNING_TYPE_EARTHQUAKE_AND_TSUNAMI
ETWS warning type for earthquake and tsunami.
public static final int
ETWS_WARNING_TYPE_TEST_MESSAGE
ETWS warning type for test messages.
public static final int
ETWS_WARNING_TYPE_OTHER_EMERGENCY
ETWS warning type for other emergency types.
public static final int
ETWS_WARNING_TYPE_UNKNOWN
Unknown ETWS warning type.
private final int
mWarningType
One of the ETWS warning type constants defined in this class.
private final boolean
mEmergencyUserAlert
Whether or not to activate the emergency user alert tone and vibration.
private final boolean
mActivatePopup
Whether or not to activate a popup alert.
private final byte[]
mWarningSecurityInformation
50-byte security information (ETWS primary notification for GSM only). As of Release 10, 3GPP TS 23.041 states that the UE shall ignore the ETWS primary notification timestamp and digital signature if received. Therefore it is treated as a raw byte array and parceled with the broadcast intent if present, but the timestamp is only computed if an application asks for the individual components.
public static final Creator
CREATOR
Creator for unparcelling objects.
Constructors Summary
public SmsCbEtwsInfo(int warningType, boolean emergencyUserAlert, boolean activatePopup, byte[] warningSecurityInformation)
Create a new SmsCbEtwsInfo object with the specified values.


              
          
              
        mWarningType = warningType;
        mEmergencyUserAlert = emergencyUserAlert;
        mActivatePopup = activatePopup;
        mWarningSecurityInformation = warningSecurityInformation;
    
SmsCbEtwsInfo(android.os.Parcel in)
Create a new SmsCbEtwsInfo object from a Parcel.

        mWarningType = in.readInt();
        mEmergencyUserAlert = (in.readInt() != 0);
        mActivatePopup = (in.readInt() != 0);
        mWarningSecurityInformation = in.createByteArray();
    
Methods Summary
public intdescribeContents()
Describe the kinds of special objects contained in the marshalled representation.

return
a bitmask indicating this Parcelable contains no special objects

        return 0;
    
public byte[]getPrimaryNotificationSignature()
Returns the digital signature (GSM primary notifications only). As of Release 10, 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

        if (mWarningSecurityInformation == null || mWarningSecurityInformation.length < 50) {
            return null;
        }
        return Arrays.copyOfRange(mWarningSecurityInformation, 7, 50);
    
public longgetPrimaryNotificationTimestamp()
Returns the Warning-Security-Information timestamp (GSM primary notifications only). As of Release 10, 3GPP TS 23.041 states that the UE shall ignore this value if received.

return
a UTC timestamp in System.currentTimeMillis() format, or 0 if not present

        if (mWarningSecurityInformation == null || mWarningSecurityInformation.length < 7) {
            return 0;
        }

        int year = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[0]);
        int month = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[1]);
        int day = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[2]);
        int hour = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[3]);
        int minute = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[4]);
        int second = IccUtils.gsmBcdByteToInt(mWarningSecurityInformation[5]);

        // For the timezone, the most significant bit of the
        // least significant nibble is the sign byte
        // (meaning the max range of this field is 79 quarter-hours,
        // which is more than enough)

        byte tzByte = mWarningSecurityInformation[6];

        // Mask out sign bit.
        int timezoneOffset = IccUtils.gsmBcdByteToInt((byte) (tzByte & (~0x08)));

        timezoneOffset = ((tzByte & 0x08) == 0) ? timezoneOffset : -timezoneOffset;

        Time time = new Time(Time.TIMEZONE_UTC);

        // We only need to support years above 2000.
        time.year = year + 2000;
        time.month = month - 1;
        time.monthDay = day;
        time.hour = hour;
        time.minute = minute;
        time.second = second;

        // Timezone offset is in quarter hours.
        return time.toMillis(true) - timezoneOffset * 15 * 60 * 1000;
    
public intgetWarningType()
Returns the ETWS warning type.

return
a warning type such as {@link #ETWS_WARNING_TYPE_EARTHQUAKE}

        return mWarningType;
    
public booleanisEmergencyUserAlert()
Returns the ETWS emergency user alert flag.

return
true to notify terminal to activate emergency user alert; false otherwise

        return mEmergencyUserAlert;
    
public booleanisPopupAlert()
Returns the ETWS activate popup flag.

return
true to notify terminal to activate display popup; false otherwise

        return mActivatePopup;
    
public java.lang.StringtoString()

        return "SmsCbEtwsInfo{warningType=" + mWarningType + ", emergencyUserAlert="
                + mEmergencyUserAlert + ", activatePopup=" + mActivatePopup + '}";
    
public voidwriteToParcel(android.os.Parcel dest, int flags)
Flatten this object into a Parcel.

param
dest The Parcel in which the object should be written.
param
flags Additional flags about how the object should be written (ignored).

        dest.writeInt(mWarningType);
        dest.writeInt(mEmergencyUserAlert ? 1 : 0);
        dest.writeInt(mActivatePopup ? 1 : 0);
        dest.writeByteArray(mWarningSecurityInformation);