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

Commit f00a8768 authored by Sahin Caliskan's avatar Sahin Caliskan
Browse files

Implementation of RcsMessageStore APIs [base]

This change adds the implementation of RcsMessageStore. Please see the
bug for the design and one-pager

Test: Added unit tests

Bug: 109759350
Change-Id: I6049dcf74ef9e19a38ce58148a89497992bc1c98
parent e5f71e4e
Loading
Loading
Loading
Loading
+602 −0
Original line number Diff line number Diff line
@@ -2053,6 +2053,608 @@ public final class Telephony {
        }
    }

    /**
     * Columns for the "rcs_*" tables used by {@link android.telephony.ims.RcsMessageStore} classes.
     *
     * @hide - not meant for public use
     */
    public interface RcsColumns {
        /**
         * The authority for the content provider
         */
        String AUTHORITY = "rcs";

        /**
         * The URI to start building upon to use {@link com.android.providers.telephony.RcsProvider}
         */
        Uri CONTENT_AND_AUTHORITY = Uri.parse("content://" + AUTHORITY);

        /**
         * The value to be used whenever a transaction that expects an integer to be returned
         * failed.
         */
        int TRANSACTION_FAILED = Integer.MIN_VALUE;

        /**
         * The value that denotes a timestamp was not set before (e.g. a message that is not
         * delivered yet will not have a DELIVERED_TIMESTAMP)
         */
        long TIMESTAMP_NOT_SET = 0;

        /**
         * The table that {@link android.telephony.ims.RcsThread} gets persisted to
         */
        interface RcsThreadColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsThread}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String RCS_THREAD_URI_PART = "thread";

            /**
             * The URI to query or modify {@link android.telephony.ims.RcsThread} via the content
             * provider.
             */
            Uri RCS_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY, RCS_THREAD_URI_PART);

            /**
             * The unique identifier of an {@link android.telephony.ims.RcsThread}
             */
            String RCS_THREAD_ID_COLUMN = "rcs_thread_id";
        }

        /**
         * The table that {@link android.telephony.ims.Rcs1To1Thread} gets persisted to
         */
        interface Rcs1To1ThreadColumns extends RcsThreadColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.Rcs1To1Thread}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String RCS_1_TO_1_THREAD_URI_PART = "p2p_thread";

            /**
             * The URI to query or modify {@link android.telephony.ims.Rcs1To1Thread}s via the
             * content provider
             */
            Uri RCS_1_TO_1_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    RCS_1_TO_1_THREAD_URI_PART);

            /**
             * The SMS/MMS thread to fallback to in case of an RCS outage
             */
            String FALLBACK_THREAD_ID_COLUMN = "rcs_fallback_thread_id";
        }

        /**
         * The table that {@link android.telephony.ims.RcsGroupThread} gets persisted to
         */
        interface RcsGroupThreadColumns extends RcsThreadColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsGroupThread}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String RCS_GROUP_THREAD_URI_PART = "group_thread";

            /**
             * The URI to query or modify {@link android.telephony.ims.RcsGroupThread}s via the
             * content provider
             */
            Uri RCS_GROUP_THREAD_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    RCS_GROUP_THREAD_URI_PART);

            /**
             * The owner/admin of the {@link android.telephony.ims.RcsGroupThread}
             */
            String OWNER_PARTICIPANT_COLUMN = "owner_participant";

            /**
             * The user visible name of the group
             */
            String GROUP_NAME_COLUMN = "group_name";

            /**
             * The user visible icon of the group
             */
            String GROUP_ICON_COLUMN = "group_icon";

            /**
             * The RCS conference URI for this group
             */
            String CONFERENCE_URI_COLUMN = "conference_uri";
        }

        /**
         * The view that enables polling from all types of RCS threads at once
         */
        interface RcsUnifiedThreadColumns extends RcsThreadColumns, Rcs1To1ThreadColumns,
                RcsGroupThreadColumns {
            /**
             * The type of this {@link android.telephony.ims.RcsThread}
             */
            String THREAD_TYPE_COLUMN = "thread_type";

            /**
             * Integer returned as a result from a database query that denotes the thread is 1 to 1
             */
            int THREAD_TYPE_1_TO_1 = 0;

            /**
             * Integer returned as a result from a database query that denotes the thread is 1 to 1
             */
            int THREAD_TYPE_GROUP = 1;
        }

        /**
         * The table that {@link android.telephony.ims.RcsParticipant} gets persisted to
         */
        interface RcsParticipantColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsParticipant}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String RCS_PARTICIPANT_URI_PART = "participant";

            /**
             * The URI to query or modify {@link android.telephony.ims.RcsParticipant}s via the
             * content provider
             */
            Uri RCS_PARTICIPANT_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    RCS_PARTICIPANT_URI_PART);

            /**
             * The unique identifier of the entry in the database
             */
            String RCS_PARTICIPANT_ID_COLUMN = "rcs_participant_id";

            /**
             * A foreign key on canonical_address table, also used by SMS/MMS
             */
            String CANONICAL_ADDRESS_ID_COLUMN = "canonical_address_id";

            /**
             * The user visible RCS alias for this participant.
             */
            String RCS_ALIAS_COLUMN = "rcs_alias";
        }

        /**
         * Additional constants to enable access to {@link android.telephony.ims.RcsParticipant}
         * related data
         */
        interface RcsParticipantHelpers extends RcsParticipantColumns {
            /**
             * The view that unifies "rcs_participant" and "canonical_addresses" tables for easy
             * access to participant address.
             */
            String RCS_PARTICIPANT_WITH_ADDRESS_VIEW = "rcs_participant_with_address_view";

            /**
             * The view that unifies "rcs_participant", "canonical_addresses" and
             * "rcs_thread_participant" junction table to get full information on participants that
             * contribute to threads.
             */
            String RCS_PARTICIPANT_WITH_THREAD_VIEW = "rcs_participant_with_thread_view";
        }

        /**
         * The table that {@link android.telephony.ims.RcsMessage} gets persisted to
         */
        interface RcsMessageColumns {
            /**
             * Denotes the type of this message (i.e.
             * {@link android.telephony.ims.RcsIncomingMessage} or
             * {@link android.telephony.ims.RcsOutgoingMessage}
             */
            String MESSAGE_TYPE_COLUMN = "rcs_message_type";

            /**
             * The unique identifier for the message in the database - i.e. the primary key.
             */
            String MESSAGE_ID_COLUMN = "rcs_message_row_id";

            /**
             * The globally unique RCS identifier for the message. Please see 4.4.5.2 - GSMA
             * RCC.53 (RCS Device API 1.6 Specification)
             */
            String GLOBAL_ID_COLUMN = "rcs_message_global_id";

            /**
             * The subscription where this message was sent from/to.
             */
            String SUB_ID_COLUMN = "sub_id";

            /**
             * The sending status of the message.
             * @see android.telephony.ims.RcsMessage.RcsMessageStatus
             */
            String STATUS_COLUMN = "status";

            /**
             * The creation timestamp of the message.
             */
            String ORIGINATION_TIMESTAMP_COLUMN = "origination_timestamp";

            /**
             * The text content of the message.
             */
            String MESSAGE_TEXT_COLUMN = "rcs_text";

            /**
             * The latitude content of the message, if it contains a location.
             */
            String LATITUDE_COLUMN = "latitude";

            /**
             * The longitude content of the message, if it contains a location.
             */
            String LONGITUDE_COLUMN = "longitude";
        }

        /**
         * The table that additional information of {@link android.telephony.ims.RcsIncomingMessage}
         * gets persisted to.
         */
        interface RcsIncomingMessageColumns extends RcsMessageColumns {
            /**
             The path that should be used for referring to
             * {@link android.telephony.ims.RcsIncomingMessage}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String INCOMING_MESSAGE_URI_PART = "incoming_message";

            /**
             * The URI to query incoming messages through
             * {@link com.android.providers.telephony.RcsProvider}
             */
            Uri INCOMING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    INCOMING_MESSAGE_URI_PART);

            /**
             * The ID of the {@link android.telephony.ims.RcsParticipant} that sent this message
             */
            String SENDER_PARTICIPANT_ID_COLUMN = "sender_participant";

            /**
             * The timestamp of arrival for this message.
             */
            String ARRIVAL_TIMESTAMP_COLUMN = "arrival_timestamp";

            /**
             * The time when the recipient has read this message.
             */
            String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
        }

        /**
         * The table that additional information of {@link android.telephony.ims.RcsOutgoingMessage}
         * gets persisted to.
         */
        interface RcsOutgoingMessageColumns extends RcsMessageColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsOutgoingMessage}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String OUTGOING_MESSAGE_URI_PART = "outgoing_message";

            /**
             * The URI to query or modify {@link android.telephony.ims.RcsOutgoingMessage}s via the
             * content provider
             */
            Uri OUTGOING_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    OUTGOING_MESSAGE_URI_PART);
        }

        /**
         * The delivery information of an {@link android.telephony.ims.RcsOutgoingMessage}
         */
        interface RcsMessageDeliveryColumns extends RcsOutgoingMessageColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsOutgoingMessageDelivery}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String DELIVERY_URI_PART = "delivery";

            /**
             * The timestamp of delivery of this message.
             */
            String DELIVERED_TIMESTAMP_COLUMN = "delivered_timestamp";

            /**
             * The time when the recipient has read this message.
             */
            String SEEN_TIMESTAMP_COLUMN = "seen_timestamp";
        }

        /**
         * The views that allow querying {@link android.telephony.ims.RcsIncomingMessage} and
         * {@link android.telephony.ims.RcsOutgoingMessage} at the same time.
         */
        interface RcsUnifiedMessageColumns extends RcsIncomingMessageColumns,
                RcsOutgoingMessageColumns {
            /**
             * The path that is used to query all {@link android.telephony.ims.RcsMessage} in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String UNIFIED_MESSAGE_URI_PART = "message";

            /**
             * The URI to query all types of {@link android.telephony.ims.RcsMessage}s
             */
            Uri UNIFIED_MESSAGE_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    UNIFIED_MESSAGE_URI_PART);

            /**
             * The name of the view that unites rcs_message and rcs_incoming_message tables.
             */
            String UNIFIED_INCOMING_MESSAGE_VIEW = "unified_incoming_message_view";

            /**
             * The name of the view that unites rcs_message and rcs_outgoing_message tables.
             */
            String UNIFIED_OUTGOING_MESSAGE_VIEW = "unified_outgoing_message_view";

            /**
             * The column that shows from which table the message entry came from.
             */
            String MESSAGE_TYPE_COLUMN = "message_type";

            /**
             * Integer returned as a result from a database query that denotes that the message is
             * an incoming message
             */
            int MESSAGE_TYPE_INCOMING = 1;

            /**
             * Integer returned as a result from a database query that denotes that the message is
             * an outgoing message
             */
            int MESSAGE_TYPE_OUTGOING = 0;
        }

        /**
         * The table that {@link android.telephony.ims.RcsFileTransferPart} gets persisted to.
         */
        interface RcsFileTransferColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsFileTransferPart}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String FILE_TRANSFER_URI_PART = "file_transfer";

            /**
             * The URI to query or modify {@link android.telephony.ims.RcsFileTransferPart}s via the
             * content provider
             */
            Uri FILE_TRANSFER_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    FILE_TRANSFER_URI_PART);

            /**
             * The globally unique file transfer ID for this RCS file transfer.
             */
            String FILE_TRANSFER_ID_COLUMN = "rcs_file_transfer_id";

            /**
             * The RCS session ID for this file transfer. The ID is implementation dependent but
             * should be unique.
             */
            String SESSION_ID_COLUMN = "session_id";

            /**
             * The URI that points to the content of this file transfer
             */
            String CONTENT_URI_COLUMN = "content_uri";

            /**
             * The file type of this file transfer in bytes. The validity of types is not enforced
             * in {@link android.telephony.ims.RcsMessageStore} APIs.
             */
            String CONTENT_TYPE_COLUMN = "content_type";

            /**
             * The size of the file transfer in bytes.
             */
            String FILE_SIZE_COLUMN = "file_size";

            /**
             * Number of bytes that was successfully transmitted for this file transfer
             */
            String SUCCESSFULLY_TRANSFERRED_BYTES = "transfer_offset";

            /**
             * The status of this file transfer
             * @see android.telephony.ims.RcsFileTransferPart.RcsFileTransferStatus
             */
            String TRANSFER_STATUS_COLUMN = "transfer_status";

            /**
             * The on-screen width of the file transfer, if it contains multi-media
             */
            String WIDTH_COLUMN = "width";

            /**
             * The on-screen height of the file transfer, if it contains multi-media
             */
            String HEIGHT_COLUMN = "height";

            /**
             * The duration of the content in milliseconds if this file transfer contains
             * multi-media
             */
            String DURATION_MILLIS_COLUMN = "duration";

            /**
             * The URI to the preview of the content of this file transfer
             */
            String PREVIEW_URI_COLUMN = "preview_uri";

            /**
             * The type of the preview of the content of this file transfer. The validity of types
             * is not enforced in {@link android.telephony.ims.RcsMessageStore} APIs.
             */
            String PREVIEW_TYPE_COLUMN = "preview_type";
        }

        /**
         * The table that holds the information for
         * {@link android.telephony.ims.RcsGroupThreadEvent} and its subclasses.
         */
        interface RcsThreadEventColumns {
            /**
             * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
             * refer to participant joined events (example URI:
             * {@code content://rcs/group_thread/3/participant_joined_event})
             */
            String PARTICIPANT_JOINED_URI_PART = "participant_joined_event";

            /**
             * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
             * refer to participant left events. (example URI:
             * {@code content://rcs/group_thread/3/participant_left_event/4})
             */
            String PARTICIPANT_LEFT_URI_PART = "participant_left_event";

            /**
             * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
             * refer to name changed events. (example URI:
             * {@code content://rcs/group_thread/3/name_changed_event})
             */
            String NAME_CHANGED_URI_PART = "name_changed_event";

            /**
             * The string used in the {@link com.android.providers.telephony.RcsProvider} URI to
             * refer to icon changed events. (example URI:
             * {@code content://rcs/group_thread/3/icon_changed_event})
             */
            String ICON_CHANGED_URI_PART = "icon_changed_event";

            /**
             * The unique ID of this event in the database, i.e. the primary key
             */
            String EVENT_ID_COLUMN = "event_id";

            /**
             * The type of this event
             *
             * @see RcsEventTypes
             */
            String EVENT_TYPE_COLUMN = "event_type";

            /**
             * The timestamp in milliseconds of when this event happened
             */
            String TIMESTAMP_COLUMN = "origination_timestamp";

            /**
             * The participant that generated this event
             */
            String SOURCE_PARTICIPANT_ID_COLUMN = "source_participant";

            /**
             * The receiving participant of this event if this was an
             * {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent} or
             * {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
             */
            String DESTINATION_PARTICIPANT_ID_COLUMN = "destination_participant";

            /**
             * The URI for the new icon of the group thread if this was an
             * {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
             */
            String NEW_ICON_URI_COLUMN = "new_icon_uri";

            /**
             * The URI for the new name of the group thread if this was an
             * {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
             */
            String NEW_NAME_COLUMN = "new_name";
        }

        /**
         * The table that {@link android.telephony.ims.RcsParticipantAliasChangedEvent} gets
         * persisted to
         */
        interface RcsParticipantEventColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsParticipantAliasChangedEvent}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String ALIAS_CHANGE_EVENT_URI_PART = "alias_change_event";

            /**
             * The new alias of the participant
             */
            String NEW_ALIAS_COLUMN = "new_alias";
        }

        /**
         * These values are used in {@link com.android.providers.telephony.RcsProvider} to determine
         * what kind of event is present in the storage.
         */
        interface RcsEventTypes {
            /**
             * Integer constant that is stored in the
             * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
             * is of type {@link android.telephony.ims.RcsParticipantAliasChangedEvent}
             */
            int PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE = 1;

            /**
             * Integer constant that is stored in the
             * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
             * is of type {@link android.telephony.ims.RcsGroupThreadParticipantJoinedEvent}
             */
            int PARTICIPANT_JOINED_EVENT_TYPE = 2;

            /**
             * Integer constant that is stored in the
             * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
             * is of type {@link android.telephony.ims.RcsGroupThreadParticipantLeftEvent}
             */
            int PARTICIPANT_LEFT_EVENT_TYPE = 4;

            /**
             * Integer constant that is stored in the
             * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
             * is of type {@link android.telephony.ims.RcsGroupThreadIconChangedEvent}
             */
            int ICON_CHANGED_EVENT_TYPE = 8;

            /**
             * Integer constant that is stored in the
             * {@link com.android.providers.telephony.RcsProvider} database that denotes the event
             * is of type {@link android.telephony.ims.RcsGroupThreadNameChangedEvent}
             */
            int NAME_CHANGED_EVENT_TYPE = 16;
        }

        /**
         * The view that allows unified querying across all events
         */
        interface RcsUnifiedEventHelper extends RcsParticipantEventColumns, RcsThreadEventColumns {
            /**
             * The path that should be used for referring to
             * {@link android.telephony.ims.RcsEvent}s in
             * {@link com.android.providers.telephony.RcsProvider} URIs.
             */
            String RCS_EVENT_QUERY_URI_PATH = "event";

            /**
             * The URI to query {@link android.telephony.ims.RcsEvent}s via the content provider.
             */
            Uri RCS_EVENT_QUERY_URI = Uri.withAppendedPath(CONTENT_AND_AUTHORITY,
                    RCS_EVENT_QUERY_URI_PATH);
        }
    }

    /**
     * Contains all MMS messages.
     */
+53 −23

File changed.

Preview size limit exceeded, changes collapsed.

+64 −0

File added.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -17,4 +17,4 @@

package android.telephony.ims;

parcelable RcsPart;
parcelable RcsEvent;
Loading