Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b5788f3 authored by Chen Xu's avatar Chen Xu Committed by android-build-merger
Browse files

Merge "move CellBroadcastMessage from telephony-common to app" am: 17518fa1

am: e2d15a24

Change-Id: I5cafd42d4b9b5251f51da34488b94c0ca40be76b
parents 610244cd e2d15a24
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -8033,7 +8033,7 @@ package android.telephony {
  }
  }
  public final class SmsCbMessage implements android.os.Parcelable {
  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 @NonNull public static android.telephony.SmsCbMessage createFromCursor(@NonNull android.database.Cursor);
    method public int describeContents();
    method public int describeContents();
    method @Nullable public android.telephony.SmsCbCmasInfo getCmasWarningInfo();
    method @Nullable public android.telephony.SmsCbCmasInfo getCmasWarningInfo();
@@ -8048,6 +8048,7 @@ package android.telephony {
    method public long getReceivedTime();
    method public long getReceivedTime();
    method public int getSerialNumber();
    method public int getSerialNumber();
    method public int getServiceCategory();
    method public int getServiceCategory();
    method public int getSlotIndex();
    method public boolean isCmasMessage();
    method public boolean isCmasMessage();
    method public boolean isEmergencyMessage();
    method public boolean isEmergencyMessage();
    method public boolean isEtwsMessage();
    method public boolean isEtwsMessage();
+11 −2
Original line number Original line Diff line number Diff line
@@ -3963,12 +3963,20 @@ public final class Telephony {
        public static final Uri CONTENT_URI = Uri.parse("content://cellbroadcasts");
        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>
         * <P>Type: INTEGER</P>
         * @hide
         * @hide
         */
         */
        public static final String SUB_ID = "sub_id";
        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:
         * Message geographical scope. Valid values are:
         * <ul>
         * <ul>
@@ -4203,7 +4211,7 @@ public final class Telephony {
        public static final String MAXIMUM_WAIT_TIME = "maximum_wait_time";
        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
         * @hide
         */
         */
        @NonNull
        @NonNull
@@ -4236,6 +4244,7 @@ public final class Telephony {
         */
         */
        public static final String[] QUERY_COLUMNS_FWK = {
        public static final String[] QUERY_COLUMNS_FWK = {
                _ID,
                _ID,
                SLOT_INDEX,
                GEOGRAPHICAL_SCOPE,
                GEOGRAPHICAL_SCOPE,
                PLMN,
                PLMN,
                LAC,
                LAC,
+22 −4
Original line number Original line Diff line number Diff line
@@ -207,17 +207,19 @@ public final class SmsCbMessage implements Parcelable {
    /** CMAS warning area coordinates. */
    /** CMAS warning area coordinates. */
    private final List<Geometry> mGeometries;
    private final List<Geometry> mGeometries;


    private int mSlotIndex = 0;

    /**
    /**
     * Create a new SmsCbMessage with the specified data.
     * Create a new SmsCbMessage with the specified data.
     */
     */
    public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
    public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
            @NonNull SmsCbLocation location, int serviceCategory, @Nullable String language,
            @NonNull SmsCbLocation location, int serviceCategory, @Nullable String language,
            @Nullable String body, int priority, @Nullable SmsCbEtwsInfo etwsWarningInfo,
            @Nullable String body, int priority, @Nullable SmsCbEtwsInfo etwsWarningInfo,
            @Nullable SmsCbCmasInfo cmasWarningInfo) {
            @Nullable SmsCbCmasInfo cmasWarningInfo, int slotIndex) {


        this(messageFormat, geographicalScope, serialNumber, location, serviceCategory, language,
        this(messageFormat, geographicalScope, serialNumber, location, serviceCategory, language,
                body, priority, etwsWarningInfo, cmasWarningInfo, 0 /* maximumWaitingTime */,
                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,
    public SmsCbMessage(int messageFormat, int geographicalScope, int serialNumber,
            SmsCbLocation location, int serviceCategory, String language, String body,
            SmsCbLocation location, int serviceCategory, String language, String body,
            int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo,
            int priority, SmsCbEtwsInfo etwsWarningInfo, SmsCbCmasInfo cmasWarningInfo,
            int maximumWaitTimeSec, List<Geometry> geometries, long receivedTimeMillis) {
            int maximumWaitTimeSec, List<Geometry> geometries, long receivedTimeMillis,
            int slotIndex) {
        mMessageFormat = messageFormat;
        mMessageFormat = messageFormat;
        mGeographicalScope = geographicalScope;
        mGeographicalScope = geographicalScope;
        mSerialNumber = serialNumber;
        mSerialNumber = serialNumber;
@@ -241,6 +244,7 @@ public final class SmsCbMessage implements Parcelable {
        mReceivedTimeMillis = receivedTimeMillis;
        mReceivedTimeMillis = receivedTimeMillis;
        mGeometries = geometries;
        mGeometries = geometries;
        mMaximumWaitTimeSec = maximumWaitTimeSec;
        mMaximumWaitTimeSec = maximumWaitTimeSec;
        mSlotIndex = slotIndex;
    }
    }


    /**
    /**
@@ -278,6 +282,7 @@ public final class SmsCbMessage implements Parcelable {
        String geoStr = in.readString();
        String geoStr = in.readString();
        mGeometries = geoStr != null ? CbGeoUtils.parseGeometriesFromString(geoStr) : null;
        mGeometries = geoStr != null ? CbGeoUtils.parseGeometriesFromString(geoStr) : null;
        mMaximumWaitTimeSec = in.readInt();
        mMaximumWaitTimeSec = in.readInt();
        mSlotIndex = in.readInt();
    }
    }


    /**
    /**
@@ -312,6 +317,7 @@ public final class SmsCbMessage implements Parcelable {
        dest.writeString(
        dest.writeString(
                mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : null);
                mGeometries != null ? CbGeoUtils.encodeGeometriesToString(mGeometries) : null);
        dest.writeInt(mMaximumWaitTimeSec);
        dest.writeInt(mMaximumWaitTimeSec);
        dest.writeInt(mSlotIndex);
    }
    }


    @NonNull
    @NonNull
@@ -422,6 +428,14 @@ public final class SmsCbMessage implements Parcelable {
        return mReceivedTimeMillis;
        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}).
     * Get the message format ({@link #MESSAGE_FORMAT_3GPP} or {@link #MESSAGE_FORMAT_3GPP2}).
     * @return an integer representing 3GPP or 3GPP2 message format
     * @return an integer representing 3GPP or 3GPP2 message format
@@ -502,6 +516,7 @@ public final class SmsCbMessage implements Parcelable {
                + (mEtwsWarningInfo != null ? (", " + mEtwsWarningInfo.toString()) : "")
                + (mEtwsWarningInfo != null ? (", " + mEtwsWarningInfo.toString()) : "")
                + (mCmasWarningInfo != null ? (", " + mCmasWarningInfo.toString()) : "")
                + (mCmasWarningInfo != null ? (", " + mCmasWarningInfo.toString()) : "")
                + ", maximumWaitingTime = " + mMaximumWaitTimeSec
                + ", maximumWaitingTime = " + mMaximumWaitTimeSec
                + ", slotIndex = " + mSlotIndex
                + ", geo=" + (mGeometries != null
                + ", geo=" + (mGeometries != null
                ? CbGeoUtils.encodeGeometriesToString(mGeometries) : "null")
                ? CbGeoUtils.encodeGeometriesToString(mGeometries) : "null")
                + '}';
                + '}';
@@ -522,6 +537,7 @@ public final class SmsCbMessage implements Parcelable {
    @NonNull
    @NonNull
    public ContentValues getContentValues() {
    public ContentValues getContentValues() {
        ContentValues cv = new ContentValues(16);
        ContentValues cv = new ContentValues(16);
        cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex);
        cv.put(CellBroadcasts.GEOGRAPHICAL_SCOPE, mGeographicalScope);
        cv.put(CellBroadcasts.GEOGRAPHICAL_SCOPE, mGeographicalScope);
        if (mLocation.getPlmn() != null) {
        if (mLocation.getPlmn() != null) {
            cv.put(CellBroadcasts.PLMN, mLocation.getPlmn());
            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.MAXIMUM_WAIT_TIME, mMaximumWaitTimeSec);
        cv.put(CellBroadcasts.SLOT_INDEX, mSlotIndex);


        return cv;
        return cv;
    }
    }
@@ -584,6 +601,7 @@ public final class SmsCbMessage implements Parcelable {
        String body = cursor.getString(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_BODY));
        String body = cursor.getString(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_BODY));
        int format = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_FORMAT));
        int format = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_FORMAT));
        int priority = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_PRIORITY));
        int priority = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.MESSAGE_PRIORITY));
        int slotIndex = cursor.getInt(cursor.getColumnIndexOrThrow(CellBroadcasts.SLOT_INDEX));


        String plmn;
        String plmn;
        int plmnColumn = cursor.getColumnIndex(CellBroadcasts.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,
        return new SmsCbMessage(format, geoScope, serialNum, location, category,
                language, body, priority, etwsInfo, cmasInfo, maximumWaitTimeSec, geometries,
                language, body, priority, etwsInfo, cmasInfo, maximumWaitTimeSec, geometries,
                receivedTimeMillis);
                receivedTimeMillis, slotIndex);
    }
    }


    /**
    /**
+3 −2
Original line number Original line Diff line number Diff line
@@ -859,8 +859,9 @@ public class SmsMessage extends SmsMessageBase {
     * Parses a broadcast SMS, possibly containing a CMAS alert.
     * Parses a broadcast SMS, possibly containing a CMAS alert.
     *
     *
     * @param plmn the PLMN for a broadcast SMS
     * @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);
        BearerData bData = BearerData.decode(mEnvelope.bearerData, mEnvelope.serviceCategory);
        if (bData == null) {
        if (bData == null) {
            Rlog.w(LOG_TAG, "BearerData.decode() returned 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,
        return new SmsCbMessage(SmsCbMessage.MESSAGE_FORMAT_3GPP2,
                SmsCbMessage.GEOGRAPHICAL_SCOPE_PLMN_WIDE, bData.messageId, location,
                SmsCbMessage.GEOGRAPHICAL_SCOPE_PLMN_WIDE, bData.messageId, location,
                mEnvelope.serviceCategory, bData.getLanguage(), bData.userData.payloadStr,
                mEnvelope.serviceCategory, bData.getLanguage(), bData.userData.payloadStr,
                bData.priority, null, bData.cmasWarningInfo);
                bData.priority, null, bData.cmasWarningInfo, subId);
    }
    }


    /**
    /**
+5 −4
Original line number Original line Diff line number Diff line
@@ -90,9 +90,10 @@ public class GsmSmsCbMessage {
     * Create a new SmsCbMessage object from a header object plus one or more received PDUs.
     * Create a new SmsCbMessage object from a header object plus one or more received PDUs.
     *
     *
     * @param pdus PDU bytes
     * @param pdus PDU bytes
     * @slotIndex slotIndex for which received sms cb message
     */
     */
    public static SmsCbMessage createSmsCbMessage(Context context, SmsCbHeader header,
    public static SmsCbMessage createSmsCbMessage(Context context, SmsCbHeader header,
            SmsCbLocation location, byte[][] pdus)
            SmsCbLocation location, byte[][] pdus, int slotIndex)
            throws IllegalArgumentException {
            throws IllegalArgumentException {
        long receivedTimeMillis = System.currentTimeMillis();
        long receivedTimeMillis = System.currentTimeMillis();
        if (header.isEtwsPrimaryNotification()) {
        if (header.isEtwsPrimaryNotification()) {
@@ -104,7 +105,7 @@ public class GsmSmsCbMessage {
                    header.getSerialNumber(), location, header.getServiceCategory(), null,
                    header.getSerialNumber(), location, header.getServiceCategory(), null,
                    getEtwsPrimaryMessage(context, header.getEtwsInfo().getWarningType()),
                    getEtwsPrimaryMessage(context, header.getEtwsInfo().getWarningType()),
                    SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, header.getEtwsInfo(),
                    SmsCbMessage.MESSAGE_PRIORITY_EMERGENCY, header.getEtwsInfo(),
                    header.getCmasInfo(), 0, null /* geometries */, receivedTimeMillis);
                    header.getCmasInfo(), 0, null /* geometries */, receivedTimeMillis, slotIndex);
        } else if (header.isUmtsFormat()) {
        } else if (header.isUmtsFormat()) {
            // UMTS format has only 1 PDU
            // UMTS format has only 1 PDU
            byte[] pdu = pdus[0];
            byte[] pdu = pdus[0];
@@ -138,7 +139,7 @@ public class GsmSmsCbMessage {
                    header.getGeographicalScope(), header.getSerialNumber(), location,
                    header.getGeographicalScope(), header.getSerialNumber(), location,
                    header.getServiceCategory(), language, body, priority,
                    header.getServiceCategory(), language, body, priority,
                    header.getEtwsInfo(), header.getCmasInfo(), maximumWaitingTimeSec, geometries,
                    header.getEtwsInfo(), header.getCmasInfo(), maximumWaitingTimeSec, geometries,
                    receivedTimeMillis);
                    receivedTimeMillis, slotIndex);
        } else {
        } else {
            String language = null;
            String language = null;
            StringBuilder sb = new StringBuilder();
            StringBuilder sb = new StringBuilder();
@@ -154,7 +155,7 @@ public class GsmSmsCbMessage {
                    header.getGeographicalScope(), header.getSerialNumber(), location,
                    header.getGeographicalScope(), header.getSerialNumber(), location,
                    header.getServiceCategory(), language, sb.toString(), priority,
                    header.getServiceCategory(), language, sb.toString(), priority,
                    header.getEtwsInfo(), header.getCmasInfo(), 0, null /* geometries */,
                    header.getEtwsInfo(), header.getCmasInfo(), 0, null /* geometries */,
                    receivedTimeMillis);
                    receivedTimeMillis, slotIndex);
        }
        }
    }
    }