Merge "Delete unused RcsMessage code for now."

This commit is contained in:
TreeHugger Robot
2020-01-25 01:46:00 +00:00
committed by Android (Google) Code Review
74 changed files with 0 additions and 7051 deletions

View File

@@ -1,92 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
/**
* Rcs1To1Thread represents a single RCS conversation thread with a total of two
* {@link RcsParticipant}s. Please see Section 5 (1-to-1 Messaging) - GSMA RCC.71 (RCS Universal
* Profile Service Definition Document)
*
* @hide
*/
public class Rcs1To1Thread extends RcsThread {
private int mThreadId;
/**
* Public constructor only for RcsMessageStoreController to initialize new threads.
*
* @hide
*/
public Rcs1To1Thread(RcsControllerCall rcsControllerCall, int threadId) {
super(rcsControllerCall, threadId);
mThreadId = threadId;
}
/**
* @return Returns {@code false} as this is always a 1 to 1 thread.
*/
@Override
public boolean isGroup() {
return false;
}
/**
* {@link Rcs1To1Thread}s can fall back to SMS as a back-up protocol. This function returns the
* thread id to be used to query {@code content://mms-sms/conversation/#} to get the fallback
* thread.
*
* @return The thread id to be used to query the mms-sms authority
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getFallbackThreadId() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.get1To1ThreadFallbackThreadId(mThreadId,
callingPackage));
}
/**
* If the RCS client allows falling back to SMS, it needs to create an MMS-SMS thread in the
* SMS/MMS Provider( see {@link android.provider.Telephony.MmsSms#CONTENT_CONVERSATIONS_URI}.
* Use this function to link the {@link Rcs1To1Thread} to the MMS-SMS thread. This function
* also updates the storage.
*
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.set1To1ThreadFallbackThreadId(mThreadId,
fallbackThreadId, callingPackage));
}
/**
* @return Returns the {@link RcsParticipant} that receives the messages sent in this thread.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@NonNull
@WorkerThread
public RcsParticipant getRecipient() throws RcsMessageStoreException {
return new RcsParticipant(
mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.get1To1ThreadOtherParticipantId(mThreadId,
callingPackage)));
}
}

View File

@@ -1,69 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.content.Context;
import android.os.RemoteException;
import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IRcsMessage;
/**
* A wrapper class around RPC calls that {@link RcsMessageManager} APIs to minimize boilerplate
* code.
*
* @hide - not meant for public use
*/
class RcsControllerCall {
private final Context mContext;
RcsControllerCall(Context context) {
mContext = context;
}
<R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException {
IRcsMessage iRcsMessage = IRcsMessage.Stub.asInterface(
TelephonyFrameworkInitializer
.getTelephonyServiceManager()
.getTelephonyRcsMessageServiceRegisterer()
.get());
if (iRcsMessage == null) {
throw new RcsMessageStoreException("Could not connect to RCS storage service");
}
try {
return serviceCall.methodOnIRcs(iRcsMessage, mContext.getOpPackageName());
} catch (RemoteException exception) {
throw new RcsMessageStoreException(exception.getMessage());
}
}
void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
throws RcsMessageStoreException {
call((iRcsMessage, callingPackage) -> {
serviceCall.methodOnIRcs(iRcsMessage, callingPackage);
return null;
});
}
interface RcsServiceCall<R> {
R methodOnIRcs(IRcsMessage iRcs, String callingPackage) throws RemoteException;
}
interface RcsServiceCallWithNoReturn {
void methodOnIRcs(IRcsMessage iRcs, String callingPackage) throws RemoteException;
}
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
/**
* The base class for events that can happen on {@link RcsParticipant}s and {@link RcsThread}s.
*
* @hide
*/
public abstract class RcsEvent {
private final long mTimestamp;
protected RcsEvent(long timestamp) {
mTimestamp = timestamp;
}
/**
* @return Returns the time of when this event happened. The timestamp is defined as
* milliseconds passed after midnight, January 1, 1970 UTC
*/
public long getTimestamp() {
return mTimestamp;
}
/**
* Persists the event to the data store
*
* @hide
*/
abstract void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException;
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsEventDescriptor;

View File

@@ -1,56 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public abstract class RcsEventDescriptor implements Parcelable {
protected final long mTimestamp;
RcsEventDescriptor(long timestamp) {
mTimestamp = timestamp;
}
/**
* Creates an RcsEvent based on this RcsEventDescriptor. Overriding this method practically
* allows an injection point for RcsEvent dependencies outside of the values contained in the
* descriptor.
*/
@VisibleForTesting(visibility = PROTECTED)
public abstract RcsEvent createRcsEvent(RcsControllerCall rcsControllerCall);
RcsEventDescriptor(Parcel in) {
mTimestamp = in.readLong();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(mTimestamp);
}
@Override
public int describeContents() {
return 0;
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsEventQueryParams;

View File

@@ -1,321 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static android.provider.Telephony.RcsColumns.RcsEventTypes.ICON_CHANGED_EVENT_TYPE;
import static android.provider.Telephony.RcsColumns.RcsEventTypes.NAME_CHANGED_EVENT_TYPE;
import static android.provider.Telephony.RcsColumns.RcsEventTypes.PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE;
import static android.provider.Telephony.RcsColumns.RcsEventTypes.PARTICIPANT_JOINED_EVENT_TYPE;
import static android.provider.Telephony.RcsColumns.RcsEventTypes.PARTICIPANT_LEFT_EVENT_TYPE;
import android.annotation.CheckResult;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.InvalidParameterException;
/**
* The parameters to pass into
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} in order to select a
* subset of {@link RcsEvent}s present in the message store.
*
* @hide
*/
public final class RcsEventQueryParams implements Parcelable {
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return all types of
* {@link RcsEvent}s
*/
public static final int ALL_EVENTS = -1;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return sub-types of
* {@link RcsGroupThreadEvent}s
*/
public static final int ALL_GROUP_THREAD_EVENTS = 0;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return only
* {@link RcsParticipantAliasChangedEvent}s
*/
public static final int PARTICIPANT_ALIAS_CHANGED_EVENT =
PARTICIPANT_ALIAS_CHANGED_EVENT_TYPE;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return only
* {@link RcsGroupThreadParticipantJoinedEvent}s
*/
public static final int GROUP_THREAD_PARTICIPANT_JOINED_EVENT =
PARTICIPANT_JOINED_EVENT_TYPE;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return only
* {@link RcsGroupThreadParticipantLeftEvent}s
*/
public static final int GROUP_THREAD_PARTICIPANT_LEFT_EVENT =
PARTICIPANT_LEFT_EVENT_TYPE;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return only
* {@link RcsGroupThreadNameChangedEvent}s
*/
public static final int GROUP_THREAD_NAME_CHANGED_EVENT = NAME_CHANGED_EVENT_TYPE;
/**
* Flag to be used with {@link Builder#setEventType(int)} to make
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)} return only
* {@link RcsGroupThreadIconChangedEvent}s
*/
public static final int GROUP_THREAD_ICON_CHANGED_EVENT = ICON_CHANGED_EVENT_TYPE;
@Retention(RetentionPolicy.SOURCE)
@IntDef({ALL_EVENTS, ALL_GROUP_THREAD_EVENTS, PARTICIPANT_ALIAS_CHANGED_EVENT,
GROUP_THREAD_PARTICIPANT_JOINED_EVENT, GROUP_THREAD_PARTICIPANT_LEFT_EVENT,
GROUP_THREAD_NAME_CHANGED_EVENT, GROUP_THREAD_ICON_CHANGED_EVENT})
public @interface EventType {
}
/**
* Flag to be used with {@link Builder#setSortProperty(int)} that makes the result set sorted
* in the order of creation for faster query results.
*/
public static final int SORT_BY_CREATION_ORDER = 0;
/**
* Flag to be used with {@link Builder#setSortProperty(int)} that makes the result set sorted
* with respect to {@link RcsEvent#getTimestamp()}
*/
public static final int SORT_BY_TIMESTAMP = 1;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SORT_BY_CREATION_ORDER, SORT_BY_TIMESTAMP})
public @interface SortingProperty {
}
/**
* The key to pass into a Bundle, for usage in RcsProvider.query(Bundle)
* @hide - not meant for public use
*/
public static final String EVENT_QUERY_PARAMETERS_KEY = "event_query_parameters";
// Which types of events the results should be limited to
private @EventType int mEventType;
// The property which the results should be sorted against
private int mSortingProperty;
// Whether the results should be sorted in ascending order
private boolean mIsAscending;
// The number of results that should be returned with this query
private int mLimit;
// The thread that the results are limited to
private int mThreadId;
RcsEventQueryParams(@EventType int eventType, int threadId,
@SortingProperty int sortingProperty, boolean isAscending, int limit) {
mEventType = eventType;
mSortingProperty = sortingProperty;
mIsAscending = isAscending;
mLimit = limit;
mThreadId = threadId;
}
/**
* @return Returns the type of {@link RcsEvent}s that this {@link RcsEventQueryParams} is
* set to query for.
*/
public @EventType int getEventType() {
return mEventType;
}
/**
* @return Returns the number of {@link RcsEvent}s to be returned from the query. A value of
* 0 means there is no set limit.
*/
public int getLimit() {
return mLimit;
}
/**
* @return Returns the property where the results should be sorted against.
* @see SortingProperty
*/
public int getSortingProperty() {
return mSortingProperty;
}
/**
* @return Returns {@code true} if the result set will be sorted in ascending order,
* {@code false} if it will be sorted in descending order.
*/
public boolean getSortDirection() {
return mIsAscending;
}
/**
* @return Returns the ID of the {@link RcsGroupThread} that the results are limited to. As this
* API exposes an ID, it should stay hidden.
*
* @hide
*/
public int getThreadId() {
return mThreadId;
}
/**
* A helper class to build the {@link RcsEventQueryParams}.
*/
public static class Builder {
private @EventType int mEventType;
private @SortingProperty int mSortingProperty;
private boolean mIsAscending;
private int mLimit = 100;
private int mThreadId;
/**
* Creates a new builder for {@link RcsEventQueryParams} to be used in
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)}
*/
public Builder() {
// empty implementation
}
/**
* Desired number of events to be returned from the query. Passing in 0 will return all
* existing events at once. The limit defaults to 100.
*
* @param limit The number to limit the query result to.
* @return The same instance of the builder to chain parameters.
* @throws InvalidParameterException If the given limit is negative.
*/
@CheckResult
public Builder setResultLimit(@IntRange(from = 0) int limit)
throws InvalidParameterException {
if (limit < 0) {
throw new InvalidParameterException("The query limit must be non-negative");
}
mLimit = limit;
return this;
}
/**
* Sets the type of events to be returned from the query.
*
* @param eventType The type of event to be returned.
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setEventType(@EventType int eventType) {
mEventType = eventType;
return this;
}
/**
* Sets the property where the results should be sorted against. Defaults to
* {@link RcsEventQueryParams.SortingProperty#SORT_BY_CREATION_ORDER}
*
* @param sortingProperty against which property the results should be sorted
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortProperty(@SortingProperty int sortingProperty) {
mSortingProperty = sortingProperty;
return this;
}
/**
* Sets whether the results should be sorted ascending or descending
*
* @param isAscending whether the results should be sorted ascending
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortDirection(boolean isAscending) {
mIsAscending = isAscending;
return this;
}
/**
* Limits the results to the given {@link RcsGroupThread}. Setting this value prevents
* returning any instances of {@link RcsParticipantAliasChangedEvent}.
*
* @param groupThread The thread to limit the results to.
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setGroupThread(@NonNull RcsGroupThread groupThread) {
mThreadId = groupThread.getThreadId();
return this;
}
/**
* Builds the {@link RcsEventQueryParams} to use in
* {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)}
*
* @return An instance of {@link RcsEventQueryParams} to use with the event query.
*/
public RcsEventQueryParams build() {
return new RcsEventQueryParams(mEventType, mThreadId, mSortingProperty,
mIsAscending, mLimit);
}
}
private RcsEventQueryParams(Parcel in) {
mEventType = in.readInt();
mThreadId = in.readInt();
mSortingProperty = in.readInt();
mIsAscending = in.readBoolean();
mLimit = in.readInt();
}
public static final @android.annotation.NonNull Creator<RcsEventQueryParams> CREATOR =
new Creator<RcsEventQueryParams>() {
@Override
public RcsEventQueryParams createFromParcel(Parcel in) {
return new RcsEventQueryParams(in);
}
@Override
public RcsEventQueryParams[] newArray(int size) {
return new RcsEventQueryParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mEventType);
dest.writeInt(mThreadId);
dest.writeInt(mSortingProperty);
dest.writeBoolean(mIsAscending);
dest.writeInt(mLimit);
}
}

View File

@@ -1,62 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import java.util.List;
/**
* The result of a {@link RcsMessageStore#getRcsEvents(RcsEventQueryParams)}
* call. This class allows getting the token for querying the next batch of events in order to
* prevent handling large amounts of data at once.
*
* @hide
*/
public class RcsEventQueryResult {
private RcsQueryContinuationToken mContinuationToken;
private List<RcsEvent> mEvents;
/**
* Internal constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController}
* to create query results
*
* @hide
*/
public RcsEventQueryResult(
RcsQueryContinuationToken continuationToken,
List<RcsEvent> events) {
mContinuationToken = continuationToken;
mEvents = events;
}
/**
* Returns a token to call
* {@link RcsMessageStore#getRcsEvents(RcsQueryContinuationToken)}
* to get the next batch of {@link RcsEvent}s.
*/
public RcsQueryContinuationToken getContinuationToken() {
return mContinuationToken;
}
/**
* Returns all the {@link RcsEvent}s in the current query result. Call {@link
* RcsMessageStore#getRcsEvents(RcsQueryContinuationToken)} to get the next batch
* of {@link RcsEvent}s.
*/
public List<RcsEvent> getEvents() {
return mEvents;
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsEventQueryResultDescriptor;

View File

@@ -1,79 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Contains the raw data backing a {@link RcsEventQueryResult}.
*
* @hide - used only for internal communication with the ircs service
*/
public class RcsEventQueryResultDescriptor implements Parcelable {
private final RcsQueryContinuationToken mContinuationToken;
private final List<RcsEventDescriptor> mEvents;
public RcsEventQueryResultDescriptor(
RcsQueryContinuationToken continuationToken,
List<RcsEventDescriptor> events) {
mContinuationToken = continuationToken;
mEvents = events;
}
protected RcsEventQueryResult getRcsEventQueryResult(RcsControllerCall rcsControllerCall) {
List<RcsEvent> rcsEvents = mEvents.stream()
.map(rcsEvent -> rcsEvent.createRcsEvent(rcsControllerCall))
.collect(Collectors.toList());
return new RcsEventQueryResult(mContinuationToken, rcsEvents);
}
protected RcsEventQueryResultDescriptor(Parcel in) {
mContinuationToken = in.readParcelable(RcsQueryContinuationToken.class.getClassLoader());
mEvents = new LinkedList<>();
in.readList(mEvents, null);
}
public static final @android.annotation.NonNull Creator<RcsEventQueryResultDescriptor> CREATOR =
new Creator<RcsEventQueryResultDescriptor>() {
@Override
public RcsEventQueryResultDescriptor createFromParcel(Parcel in) {
return new RcsEventQueryResultDescriptor(in);
}
@Override
public RcsEventQueryResultDescriptor[] newArray(int size) {
return new RcsEventQueryResultDescriptor[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mContinuationToken, flags);
dest.writeList(mEvents);
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsFileTransferCreationParams;

View File

@@ -1,360 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.CheckResult;
import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Pass an instance of this class to
* {@link RcsMessage#insertFileTransfer(RcsFileTransferCreationParams)} create an
* {@link RcsFileTransferPart} and save it into storage.
*
* @hide
*/
public final class RcsFileTransferCreationParams implements Parcelable {
private String mRcsFileTransferSessionId;
private Uri mContentUri;
private String mContentMimeType;
private long mFileSize;
private long mTransferOffset;
private int mWidth;
private int mHeight;
private long mMediaDuration;
private Uri mPreviewUri;
private String mPreviewMimeType;
private @RcsFileTransferPart.RcsFileTransferStatus int mFileTransferStatus;
/**
* @return Returns the globally unique RCS file transfer session ID for the
* {@link RcsFileTransferPart} to be created
*/
public String getRcsFileTransferSessionId() {
return mRcsFileTransferSessionId;
}
/**
* @return Returns the URI for the content of the {@link RcsFileTransferPart} to be created
*/
public Uri getContentUri() {
return mContentUri;
}
/**
* @return Returns the MIME type for the content of the {@link RcsFileTransferPart} to be
* created
*/
public String getContentMimeType() {
return mContentMimeType;
}
/**
* @return Returns the file size in bytes for the {@link RcsFileTransferPart} to be created
*/
public long getFileSize() {
return mFileSize;
}
/**
* @return Returns the transfer offset for the {@link RcsFileTransferPart} to be created. The
* file transfer offset is defined as how many bytes have been successfully transferred to the
* receiver of this file transfer.
*/
public long getTransferOffset() {
return mTransferOffset;
}
/**
* @return Returns the width of the {@link RcsFileTransferPart} to be created. The value is in
* pixels.
*/
public int getWidth() {
return mWidth;
}
/**
* @return Returns the height of the {@link RcsFileTransferPart} to be created. The value is in
* pixels.
*/
public int getHeight() {
return mHeight;
}
/**
* @return Returns the duration of the {@link RcsFileTransferPart} to be created.
*/
public long getMediaDuration() {
return mMediaDuration;
}
/**
* @return Returns the URI of the preview of the content of the {@link RcsFileTransferPart} to
* be created. This should only be used for multi-media files.
*/
public Uri getPreviewUri() {
return mPreviewUri;
}
/**
* @return Returns the MIME type of the preview of the content of the
* {@link RcsFileTransferPart} to be created. This should only be used for multi-media files.
*/
public String getPreviewMimeType() {
return mPreviewMimeType;
}
/**
* @return Returns the status of the {@link RcsFileTransferPart} to be created.
*/
public @RcsFileTransferPart.RcsFileTransferStatus int getFileTransferStatus() {
return mFileTransferStatus;
}
/**
* @hide
*/
RcsFileTransferCreationParams(Builder builder) {
mRcsFileTransferSessionId = builder.mRcsFileTransferSessionId;
mContentUri = builder.mContentUri;
mContentMimeType = builder.mContentMimeType;
mFileSize = builder.mFileSize;
mTransferOffset = builder.mTransferOffset;
mWidth = builder.mWidth;
mHeight = builder.mHeight;
mMediaDuration = builder.mLength;
mPreviewUri = builder.mPreviewUri;
mPreviewMimeType = builder.mPreviewMimeType;
mFileTransferStatus = builder.mFileTransferStatus;
}
/**
* A builder to create instances of {@link RcsFileTransferCreationParams}
*/
public class Builder {
private String mRcsFileTransferSessionId;
private Uri mContentUri;
private String mContentMimeType;
private long mFileSize;
private long mTransferOffset;
private int mWidth;
private int mHeight;
private long mLength;
private Uri mPreviewUri;
private String mPreviewMimeType;
private @RcsFileTransferPart.RcsFileTransferStatus int mFileTransferStatus;
/**
* Sets the globally unique RCS file transfer session ID for the {@link RcsFileTransferPart}
* to be created
*
* @param sessionId The RCS file transfer session ID
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setFileTransferSessionId(String sessionId) {
mRcsFileTransferSessionId = sessionId;
return this;
}
/**
* Sets the URI for the content of the {@link RcsFileTransferPart} to be created
*
* @param contentUri The URI for the file
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setContentUri(Uri contentUri) {
mContentUri = contentUri;
return this;
}
/**
* Sets the MIME type for the content of the {@link RcsFileTransferPart} to be created
*
* @param contentType The MIME type of the file
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setContentMimeType(String contentType) {
mContentMimeType = contentType;
return this;
}
/**
* Sets the file size for the {@link RcsFileTransferPart} to be created
*
* @param size The size of the file in bytes
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setFileSize(long size) {
mFileSize = size;
return this;
}
/**
* Sets the transfer offset for the {@link RcsFileTransferPart} to be created. The file
* transfer offset is defined as how many bytes have been successfully transferred to the
* receiver of this file transfer.
*
* @param offset The transfer offset in bytes
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setTransferOffset(long offset) {
mTransferOffset = offset;
return this;
}
/**
* Sets the width of the {@link RcsFileTransferPart} to be created. This should only be used
* for multi-media files.
*
* @param width The width of the multi-media file in pixels.
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setWidth(int width) {
mWidth = width;
return this;
}
/**
* Sets the height of the {@link RcsFileTransferPart} to be created. This should only be
* used for multi-media files.
*
* @param height The height of the multi-media file in pixels.
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setHeight(int height) {
mHeight = height;
return this;
}
/**
* Sets the length of the {@link RcsFileTransferPart} to be created. This should only be
* used for multi-media files such as audio or video.
*
* @param length The length of the multi-media file in milliseconds
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setMediaDuration(long length) {
mLength = length;
return this;
}
/**
* Sets the URI of the preview of the content of the {@link RcsFileTransferPart} to be
* created. This should only be used for multi-media files.
*
* @param previewUri The URI of the preview of the file transfer
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setPreviewUri(Uri previewUri) {
mPreviewUri = previewUri;
return this;
}
/**
* Sets the MIME type of the preview of the content of the {@link RcsFileTransferPart} to
* be created. This should only be used for multi-media files.
*
* @param previewType The MIME type of the preview of the file transfer
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setPreviewMimeType(String previewType) {
mPreviewMimeType = previewType;
return this;
}
/**
* Sets the status of the {@link RcsFileTransferPart} to be created.
*
* @param status The status of the file transfer
* @return The same instance of {@link Builder} to chain methods
*/
@CheckResult
public Builder setFileTransferStatus(
@RcsFileTransferPart.RcsFileTransferStatus int status) {
mFileTransferStatus = status;
return this;
}
/**
* Creates an instance of {@link RcsFileTransferCreationParams} with the given
* parameters.
*
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#insertFileTransfer(RcsFileTransferCreationParams)
*/
public RcsFileTransferCreationParams build() {
return new RcsFileTransferCreationParams(this);
}
}
private RcsFileTransferCreationParams(Parcel in) {
mRcsFileTransferSessionId = in.readString();
mContentUri = in.readParcelable(Uri.class.getClassLoader());
mContentMimeType = in.readString();
mFileSize = in.readLong();
mTransferOffset = in.readLong();
mWidth = in.readInt();
mHeight = in.readInt();
mMediaDuration = in.readLong();
mPreviewUri = in.readParcelable(Uri.class.getClassLoader());
mPreviewMimeType = in.readString();
mFileTransferStatus = in.readInt();
}
public static final @android.annotation.NonNull Creator<RcsFileTransferCreationParams> CREATOR =
new Creator<RcsFileTransferCreationParams>() {
@Override
public RcsFileTransferCreationParams createFromParcel(Parcel in) {
return new RcsFileTransferCreationParams(in);
}
@Override
public RcsFileTransferCreationParams[] newArray(int size) {
return new RcsFileTransferCreationParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mRcsFileTransferSessionId);
dest.writeParcelable(mContentUri, flags);
dest.writeString(mContentMimeType);
dest.writeLong(mFileSize);
dest.writeLong(mTransferOffset);
dest.writeInt(mWidth);
dest.writeInt(mHeight);
dest.writeLong(mMediaDuration);
dest.writeParcelable(mPreviewUri, flags);
dest.writeString(mPreviewMimeType);
dest.writeInt(mFileTransferStatus);
}
}

View File

@@ -1,388 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
import android.net.Uri;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* A part of a composite {@link RcsMessage} that holds a file transfer. Please see Section 7
* (File Transfer) - GSMA RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public class RcsFileTransferPart {
/**
* The status to indicate that this {@link RcsFileTransferPart} is not set yet.
*/
public static final int NOT_SET = 0;
/**
* The status to indicate that this {@link RcsFileTransferPart} is a draft and is not in the
* process of sending yet.
*/
public static final int DRAFT = 1;
/**
* The status to indicate that this {@link RcsFileTransferPart} is actively being sent right
* now.
*/
public static final int SENDING = 2;
/**
* The status to indicate that this {@link RcsFileTransferPart} was being sent, but the user has
* paused the sending process.
*/
public static final int SENDING_PAUSED = 3;
/**
* The status to indicate that this {@link RcsFileTransferPart} was attempted, but failed to
* send.
*/
public static final int SENDING_FAILED = 4;
/**
* The status to indicate that this {@link RcsFileTransferPart} is permanently cancelled to
* send.
*/
public static final int SENDING_CANCELLED = 5;
/**
* The status to indicate that this {@link RcsFileTransferPart} is actively being downloaded
* right now.
*/
public static final int DOWNLOADING = 6;
/**
* The status to indicate that this {@link RcsFileTransferPart} was being downloaded, but the
* user paused the downloading process.
*/
public static final int DOWNLOADING_PAUSED = 7;
/**
* The status to indicate that this {@link RcsFileTransferPart} was attempted, but failed to
* download.
*/
public static final int DOWNLOADING_FAILED = 8;
/**
* The status to indicate that this {@link RcsFileTransferPart} is permanently cancelled to
* download.
*/
public static final int DOWNLOADING_CANCELLED = 9;
/**
* The status to indicate that this {@link RcsFileTransferPart} was successfully sent or
* received.
*/
public static final int SUCCEEDED = 10;
@IntDef({
DRAFT, SENDING, SENDING_PAUSED, SENDING_FAILED, SENDING_CANCELLED, DOWNLOADING,
DOWNLOADING_PAUSED, DOWNLOADING_FAILED, DOWNLOADING_CANCELLED, SUCCEEDED
})
@Retention(RetentionPolicy.SOURCE)
public @interface RcsFileTransferStatus {
}
private final RcsControllerCall mRcsControllerCall;
private int mId;
/**
* @hide
*/
RcsFileTransferPart(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id;
}
/**
* @hide
*/
public void setId(int id) {
mId = id;
}
/**
* @hide
*/
public int getId() {
return mId;
}
/**
* Sets the RCS file transfer session ID for this file transfer and persists into storage.
*
* @param sessionId The session ID to be used for this file transfer.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setFileTransferSessionId(String sessionId) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferSessionId(mId, sessionId,
callingPackage));
}
/**
* @return Returns the file transfer session ID.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public String getFileTransferSessionId() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferSessionId(mId, callingPackage));
}
/**
* Sets the content URI for this file transfer and persists into storage. The file transfer
* should be reachable using this URI.
*
* @param contentUri The URI for this file transfer.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setContentUri(Uri contentUri) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferContentUri(mId, contentUri,
callingPackage));
}
/**
* @return Returns the URI for this file transfer
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public Uri getContentUri() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferContentUri(mId, callingPackage));
}
/**
* Sets the MIME type of this file transfer and persists into storage. Whether this type
* actually matches any known or supported types is not checked.
*
* @param contentMimeType The type of this file transfer.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setContentMimeType(String contentMimeType) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferContentType(mId, contentMimeType,
callingPackage));
}
/**
* @return Returns the content type of this file transfer
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
@Nullable
public String getContentMimeType() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferContentType(mId, callingPackage));
}
/**
* Sets the content length (i.e. file size) for this file transfer and persists into storage.
*
* @param contentLength The content length of this file transfer
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setFileSize(long contentLength) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferFileSize(mId, contentLength,
callingPackage));
}
/**
* @return Returns the content length (i.e. file size) for this file transfer.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getFileSize() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferFileSize(mId, callingPackage));
}
/**
* Sets the transfer offset for this file transfer and persists into storage. The file transfer
* offset is defined as how many bytes have been successfully transferred to the receiver of
* this file transfer.
*
* @param transferOffset The transfer offset for this file transfer.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setTransferOffset(long transferOffset) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferTransferOffset(mId, transferOffset,
callingPackage));
}
/**
* @return Returns the number of bytes that have successfully transferred.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getTransferOffset() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferTransferOffset(mId, callingPackage));
}
/**
* Sets the status for this file transfer and persists into storage.
*
* @param status The status of this file transfer.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setFileTransferStatus(@RcsFileTransferStatus int status)
throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferStatus(mId, status, callingPackage));
}
/**
* @return Returns the status of this file transfer.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public @RcsFileTransferStatus int getFileTransferStatus() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferStatus(mId, callingPackage));
}
/**
* @return Returns the width of this multi-media message part in pixels.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public int getWidth() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferWidth(mId, callingPackage));
}
/**
* Sets the width of this RCS multi-media message part and persists into storage.
*
* @param width The width value in pixels
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setWidth(int width) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferWidth(mId, width, callingPackage));
}
/**
* @return Returns the height of this multi-media message part in pixels.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public int getHeight() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferHeight(mId, callingPackage));
}
/**
* Sets the height of this RCS multi-media message part and persists into storage.
*
* @param height The height value in pixels
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setHeight(int height) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferHeight(mId, height, callingPackage));
}
/**
* @return Returns the length of this multi-media file (e.g. video or audio) in milliseconds.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getLength() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferLength(mId, callingPackage));
}
/**
* Sets the length of this multi-media file (e.g. video or audio) and persists into storage.
*
* @param length The length of the file in milliseconds.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setLength(long length) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferLength(mId, length, callingPackage));
}
/**
* @return Returns the URI for the preview of this multi-media file (e.g. an image thumbnail for
* a video)
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public Uri getPreviewUri() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferPreviewUri(mId, callingPackage));
}
/**
* Sets the URI for the preview of this multi-media file and persists into storage.
*
* @param previewUri The URI to access to the preview file.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setPreviewUri(Uri previewUri) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferPreviewUri(mId, previewUri,
callingPackage));
}
/**
* @return Returns the MIME type of this multi-media file's preview.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public String getPreviewMimeType() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransferPreviewType(mId, callingPackage));
}
/**
* Sets the MIME type for this multi-media file's preview and persists into storage.
*
* @param previewMimeType The MIME type for the preview
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setPreviewMimeType(String previewMimeType) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setFileTransferPreviewType(mId, previewMimeType,
callingPackage));
}
}

View File

@@ -1,223 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
import android.net.Uri;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
/**
* RcsGroupThread represents a single RCS conversation thread where {@link RcsParticipant}s can join
* or leave. Please see Section 6 (Group Chat) - GSMA RCC.71 (RCS Universal Profile Service
* Definition Document)
*
* @hide
*/
public class RcsGroupThread extends RcsThread {
/**
* Public constructor only for RcsMessageStoreController to initialize new threads.
*
* @hide
*/
public RcsGroupThread(RcsControllerCall rcsControllerCall, int threadId) {
super(rcsControllerCall, threadId);
}
/**
* @return Returns {@code true} as this is always a group thread
*/
@Override
public boolean isGroup() {
return true;
}
/**
* @return Returns the given name of this {@link RcsGroupThread}. Please see US6-2 - GSMA RCC.71
* (RCS Universal Profile Service Definition Document)
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public String getGroupName() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getGroupThreadName(mThreadId, callingPackage));
}
/**
* Sets the name of this {@link RcsGroupThread} and saves it into storage. Please see US6-2 -
* GSMA RCC.71 (RCS Universal Profile Service Definition Document)
*
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setGroupName(String groupName) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setGroupThreadName(mThreadId, groupName,
callingPackage));
}
/**
* @return Returns a URI that points to the group's icon {@link RcsGroupThread}. Please see
* US6-2 - GSMA RCC.71 (RCS Universal Profile Service Definition Document)
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
public Uri getGroupIcon() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getGroupThreadIcon(mThreadId, callingPackage));
}
/**
* Sets the icon for this {@link RcsGroupThread} and saves it into storage. Please see US6-2 -
* GSMA RCC.71 (RCS Universal Profile Service Definition Document)
*
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setGroupIcon(@Nullable Uri groupIcon) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setGroupThreadIcon(mThreadId, groupIcon,
callingPackage));
}
/**
* @return Returns the owner of this thread or {@code null} if there doesn't exist an owner
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public RcsParticipant getOwner() throws RcsMessageStoreException {
return new RcsParticipant(
mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getGroupThreadOwner(mThreadId,
callingPackage)));
}
/**
* Sets the owner of this {@link RcsGroupThread} and saves it into storage. This is intended to
* be used for selecting a new owner for a group thread if the owner leaves the thread. The
* owner needs to be in the list of existing participants.
*
* @param participant The new owner of the thread. {@code null} values are allowed.
* @throws RcsMessageStoreException if the operation could not be persisted into storage
*/
@WorkerThread
public void setOwner(@Nullable RcsParticipant participant) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setGroupThreadOwner(mThreadId, participant.getId(),
callingPackage));
}
/**
* Adds a new {@link RcsParticipant} to this group thread and persists into storage. If the user
* is actively participating in this {@link RcsGroupThread}, an {@link RcsParticipant} on behalf
* of them should be added.
*
* @param participant The new participant to be added to the thread.
* @throws RcsMessageStoreException if the operation could not be persisted into storage
*/
@WorkerThread
public void addParticipant(@NonNull RcsParticipant participant)
throws RcsMessageStoreException {
if (participant == null) {
return;
}
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.addParticipantToGroupThread(mThreadId,
participant.getId(), callingPackage));
}
/**
* Removes an {@link RcsParticipant} from this group thread and persists into storage. If the
* removed participant was the owner of this group, the owner will become null.
*
* @throws RcsMessageStoreException if the operation could not be persisted into storage
*/
@WorkerThread
public void removeParticipant(@NonNull RcsParticipant participant)
throws RcsMessageStoreException {
if (participant == null) {
return;
}
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.removeParticipantFromGroupThread(mThreadId,
participant.getId(), callingPackage));
}
/**
* Returns the set of {@link RcsParticipant}s that contribute to this group thread. The
* returned set does not support modifications, please use
* {@link RcsGroupThread#addParticipant(RcsParticipant)}
* and {@link RcsGroupThread#removeParticipant(RcsParticipant)} instead.
*
* @return the immutable set of {@link RcsParticipant} in this group thread.
* @throws RcsMessageStoreException if the values could not be read from the storage
*/
@WorkerThread
@NonNull
public Set<RcsParticipant> getParticipants() throws RcsMessageStoreException {
RcsParticipantQueryParams queryParameters =
new RcsParticipantQueryParams.Builder().setThread(this).build();
RcsParticipantQueryResult queryResult = new RcsParticipantQueryResult(
mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getParticipants(queryParameters,
callingPackage)));
List<RcsParticipant> participantList = queryResult.getParticipants();
Set<RcsParticipant> participantSet = new LinkedHashSet<>(participantList);
return Collections.unmodifiableSet(participantSet);
}
/**
* Returns the conference URI for this {@link RcsGroupThread}. Please see 4.4.5.2 - GSMA RCC.53
* (RCS Device API 1.6 Specification
*
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public Uri getConferenceUri() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getGroupThreadConferenceUri(mThreadId,
callingPackage));
}
/**
* Sets the conference URI for this {@link RcsGroupThread} and persists into storage. Please see
* 4.4.5.2 - GSMA RCC.53 (RCS Device API 1.6 Specification
*
* @param conferenceUri The URI as String to be used as the conference URI.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@Nullable
@WorkerThread
public void setConferenceUri(Uri conferenceUri) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setGroupThreadConferenceUri(mThreadId, conferenceUri,
callingPackage));
}
}

View File

@@ -1,51 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
/**
* An event that happened on an {@link RcsGroupThread}.
*
* @hide
*/
public abstract class RcsGroupThreadEvent extends RcsEvent {
private final RcsGroupThread mRcsGroupThread;
private final RcsParticipant mOriginatingParticipant;
RcsGroupThreadEvent(long timestamp, RcsGroupThread rcsGroupThread,
RcsParticipant originatingParticipant) {
super(timestamp);
mRcsGroupThread = rcsGroupThread;
mOriginatingParticipant = originatingParticipant;
}
/**
* @return Returns the {@link RcsGroupThread} that this event happened on.
*/
@NonNull
public RcsGroupThread getRcsGroupThread() {
return mRcsGroupThread;
}
/**
* @return Returns the {@link RcsParticipant} that performed the event.
*/
@NonNull
public RcsParticipant getOriginatingParticipant() {
return mOriginatingParticipant;
}
}

View File

@@ -1,19 +0,0 @@
/*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsGroupThreadEventDescriptor;

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.os.Parcel;
/**
* @hide - used only for internal communication with the ircs service
*/
public abstract class RcsGroupThreadEventDescriptor extends RcsEventDescriptor {
protected final int mRcsGroupThreadId;
protected final int mOriginatingParticipantId;
RcsGroupThreadEventDescriptor(long timestamp, int rcsGroupThreadId,
int originatingParticipantId) {
super(timestamp);
mRcsGroupThreadId = rcsGroupThreadId;
mOriginatingParticipantId = originatingParticipantId;
}
RcsGroupThreadEventDescriptor(Parcel in) {
super(in);
mRcsGroupThreadId = in.readInt();
mOriginatingParticipantId = in.readInt();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mRcsGroupThreadId);
dest.writeInt(mOriginatingParticipantId);
}
}

View File

@@ -1,71 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.Uri;
/**
* An event that indicates an {@link RcsGroupThread}'s icon was changed. Please see R6-2-5 - GSMA
* RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent {
private final Uri mNewIcon;
/**
* Creates a new {@link RcsGroupThreadIconChangedEvent}. This event is not persisted into
* storage until {@link RcsMessageStore#persistRcsEvent(RcsEvent)} is called.
*
* @param timestamp The timestamp of when this event happened, in milliseconds passed after
* midnight, January 1st, 1970 UTC
* @param rcsGroupThread The {@link RcsGroupThread} that this event happened on
* @param originatingParticipant The {@link RcsParticipant} that changed the
* {@link RcsGroupThread}'s icon.
* @param newIcon {@link Uri} to the new icon of this {@link RcsGroupThread}
* @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/
public RcsGroupThreadIconChangedEvent(long timestamp,
@NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
@Nullable Uri newIcon) {
super(timestamp, rcsGroupThread, originatingParticipant);
mNewIcon = newIcon;
}
/**
* @return Returns the {@link Uri} to the icon of the {@link RcsGroupThread} after this
* {@link RcsGroupThreadIconChangedEvent} occured.
*/
@Nullable
public Uri getNewIcon() {
return mNewIcon;
}
/**
* Persists the event to the data store.
*
* @hide - not meant for public use.
*/
@Override
void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
// TODO ensure failure throws
rcsControllerCall.call((iRcs, callingPackage) -> iRcs.createGroupThreadIconChangedEvent(
getTimestamp(), getRcsGroupThread().getThreadId(),
getOriginatingParticipant().getId(), mNewIcon, callingPackage));
}
}

View File

@@ -1,19 +0,0 @@
/*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsGroupThreadIconChangedEventDescriptor;

View File

@@ -1,75 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.net.Uri;
import android.os.Parcel;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsGroupThreadIconChangedEventDescriptor extends RcsGroupThreadEventDescriptor {
private final Uri mNewIcon;
public RcsGroupThreadIconChangedEventDescriptor(long timestamp, int rcsGroupThreadId,
int originatingParticipantId, @Nullable Uri newIcon) {
super(timestamp, rcsGroupThreadId, originatingParticipantId);
mNewIcon = newIcon;
}
@Override
@VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadIconChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadIconChangedEvent(mTimestamp,
new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(rcsControllerCall, mOriginatingParticipantId), mNewIcon);
}
public static final @NonNull Creator<RcsGroupThreadIconChangedEventDescriptor> CREATOR =
new Creator<RcsGroupThreadIconChangedEventDescriptor>() {
@Override
public RcsGroupThreadIconChangedEventDescriptor createFromParcel(Parcel in) {
return new RcsGroupThreadIconChangedEventDescriptor(in);
}
@Override
public RcsGroupThreadIconChangedEventDescriptor[] newArray(int size) {
return new RcsGroupThreadIconChangedEventDescriptor[size];
}
};
protected RcsGroupThreadIconChangedEventDescriptor(Parcel in) {
super(in);
mNewIcon = in.readParcelable(Uri.class.getClassLoader());
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeParcelable(mNewIcon, flags);
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
/**
* An event that indicates an {@link RcsGroupThread}'s name was changed. Please see R6-2-5 - GSMA
* RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent {
private final String mNewName;
/**
* Creates a new {@link RcsGroupThreadNameChangedEvent}. This event is not persisted into
* storage until {@link RcsMessageStore#persistRcsEvent(RcsEvent)} is called.
*
* @param timestamp The timestamp of when this event happened, in milliseconds passed after
* midnight, January 1st, 1970 UTC
* @param rcsGroupThread The {@link RcsGroupThread} that this event happened on
* @param originatingParticipant The {@link RcsParticipant} that changed the
* {@link RcsGroupThread}'s icon.
* @param newName The new name of the {@link RcsGroupThread}
* @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/
public RcsGroupThreadNameChangedEvent(long timestamp, @NonNull RcsGroupThread rcsGroupThread,
@NonNull RcsParticipant originatingParticipant, @Nullable String newName) {
super(timestamp, rcsGroupThread, originatingParticipant);
mNewName = newName;
}
/**
* @return Returns the name of this {@link RcsGroupThread} after this
* {@link RcsGroupThreadNameChangedEvent} happened.
*/
@Nullable
public String getNewName() {
return mNewName;
}
/**
* Persists the event to the data store.
*
* @hide - not meant for public use.
*/
@Override
void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
rcsControllerCall.call((iRcs, callingPackage) -> iRcs.createGroupThreadNameChangedEvent(
getTimestamp(), getRcsGroupThread().getThreadId(),
getOriginatingParticipant().getId(), mNewName, callingPackage));
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsGroupThreadNameChangedEventDescriptor;

View File

@@ -1,76 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsGroupThreadNameChangedEventDescriptor extends RcsGroupThreadEventDescriptor {
private final String mNewName;
public RcsGroupThreadNameChangedEventDescriptor(long timestamp, int rcsGroupThreadId,
int originatingParticipantId, @Nullable String newName) {
super(timestamp, rcsGroupThreadId, originatingParticipantId);
mNewName = newName;
}
@Override
@VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadNameChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadNameChangedEvent(
mTimestamp,
new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
mNewName);
}
public static final @NonNull Creator<RcsGroupThreadNameChangedEventDescriptor> CREATOR =
new Creator<RcsGroupThreadNameChangedEventDescriptor>() {
@Override
public RcsGroupThreadNameChangedEventDescriptor createFromParcel(Parcel in) {
return new RcsGroupThreadNameChangedEventDescriptor(in);
}
@Override
public RcsGroupThreadNameChangedEventDescriptor[] newArray(int size) {
return new RcsGroupThreadNameChangedEventDescriptor[size];
}
};
protected RcsGroupThreadNameChangedEventDescriptor(Parcel in) {
super(in);
mNewName = in.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(mNewName);
}
}

View File

@@ -1,70 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
/**
* An event that indicates an RCS participant has joined an {@link RcsThread}. Please see US6-3 -
* GSMA RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEvent {
private final RcsParticipant mJoinedParticipantId;
/**
* Creates a new {@link RcsGroupThreadParticipantJoinedEvent}. This event is not persisted into
* storage until {@link RcsMessageStore#persistRcsEvent(RcsEvent)} is called.
*
* @param timestamp The timestamp of when this event happened, in milliseconds
* passed after
* midnight, January 1st, 1970 UTC
* @param rcsGroupThread The {@link RcsGroupThread} that this event happened on
* @param originatingParticipant The {@link RcsParticipant} that added or invited the new
* {@link RcsParticipant} into the {@link RcsGroupThread}
* @param joinedParticipant The new {@link RcsParticipant} that joined the
* {@link RcsGroupThread}
* @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/
public RcsGroupThreadParticipantJoinedEvent(long timestamp,
@NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
@NonNull RcsParticipant joinedParticipant) {
super(timestamp, rcsGroupThread, originatingParticipant);
mJoinedParticipantId = joinedParticipant;
}
/**
* @return Returns the {@link RcsParticipant} that joined the associated {@link RcsGroupThread}
*/
public RcsParticipant getJoinedParticipant() {
return mJoinedParticipantId;
}
/**
* Persists the event to the data store.
*
* @hide - not meant for public use.
*/
@Override
void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
rcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.createGroupThreadParticipantJoinedEvent(
getTimestamp(),
getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(),
getJoinedParticipant().getId(), callingPackage));
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2018, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsGroupThreadParticipantJoinedEventDescriptor;

View File

@@ -1,76 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.annotation.NonNull;
import android.os.Parcel;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsGroupThreadParticipantJoinedEventDescriptor extends RcsGroupThreadEventDescriptor {
private final int mJoinedParticipantId;
public RcsGroupThreadParticipantJoinedEventDescriptor(long timestamp, int rcsGroupThreadId,
int originatingParticipantId, int joinedParticipantId) {
super(timestamp, rcsGroupThreadId, originatingParticipantId);
mJoinedParticipantId = joinedParticipantId;
}
@Override
@VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadParticipantJoinedEvent createRcsEvent(
RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadParticipantJoinedEvent(
mTimestamp,
new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
new RcsParticipant(rcsControllerCall, mJoinedParticipantId));
}
public static final @NonNull Creator<RcsGroupThreadParticipantJoinedEventDescriptor> CREATOR =
new Creator<RcsGroupThreadParticipantJoinedEventDescriptor>() {
@Override
public RcsGroupThreadParticipantJoinedEventDescriptor createFromParcel(Parcel in) {
return new RcsGroupThreadParticipantJoinedEventDescriptor(in);
}
@Override
public RcsGroupThreadParticipantJoinedEventDescriptor[] newArray(int size) {
return new RcsGroupThreadParticipantJoinedEventDescriptor[size];
}
};
protected RcsGroupThreadParticipantJoinedEventDescriptor(Parcel in) {
super(in);
mJoinedParticipantId = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mJoinedParticipantId);
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
/**
* An event that indicates an RCS participant has left an {@link RcsThread}. Please see US6-23 -
* GSMA RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEvent {
private RcsParticipant mLeavingParticipant;
/**
* Creates a new {@link RcsGroupThreadParticipantLeftEvent}. his event is not persisted into
* storage until {@link RcsMessageStore#persistRcsEvent(RcsEvent)} is called.
*
* @param timestamp The timestamp of when this event happened, in milliseconds passed after
* midnight, January 1st, 1970 UTC
* @param rcsGroupThread The {@link RcsGroupThread} that this event happened on
* @param originatingParticipant The {@link RcsParticipant} that removed the
* {@link RcsParticipant} from the {@link RcsGroupThread}. It is
* possible that originatingParticipant and leavingParticipant are
* the same (i.e. {@link RcsParticipant} left the group
* themselves)
* @param leavingParticipant The {@link RcsParticipant} that left the {@link RcsGroupThread}
* @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/
public RcsGroupThreadParticipantLeftEvent(long timestamp,
@NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
@NonNull RcsParticipant leavingParticipant) {
super(timestamp, rcsGroupThread, originatingParticipant);
mLeavingParticipant = leavingParticipant;
}
/**
* @return Returns the {@link RcsParticipant} that left the associated {@link RcsGroupThread}
* after this {@link RcsGroupThreadParticipantLeftEvent} happened.
*/
@NonNull
public RcsParticipant getLeavingParticipant() {
return mLeavingParticipant;
}
@Override
void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
rcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.createGroupThreadParticipantLeftEvent(getTimestamp(),
getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(),
getLeavingParticipant().getId(), callingPackage));
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2018, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsGroupThreadParticipantLeftEventDescriptor;

View File

@@ -1,77 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsGroupThreadParticipantLeftEventDescriptor extends RcsGroupThreadEventDescriptor {
private int mLeavingParticipantId;
public RcsGroupThreadParticipantLeftEventDescriptor(long timestamp, int rcsGroupThreadId,
int originatingParticipantId, int leavingParticipantId) {
super(timestamp, rcsGroupThreadId, originatingParticipantId);
mLeavingParticipantId = leavingParticipantId;
}
@Override
@VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadParticipantLeftEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadParticipantLeftEvent(
mTimestamp,
new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
new RcsParticipant(rcsControllerCall, mLeavingParticipantId));
}
@NonNull
public static final Parcelable.Creator<RcsGroupThreadParticipantLeftEventDescriptor> CREATOR =
new Creator<RcsGroupThreadParticipantLeftEventDescriptor>() {
@Override
public RcsGroupThreadParticipantLeftEventDescriptor createFromParcel(Parcel in) {
return new RcsGroupThreadParticipantLeftEventDescriptor(in);
}
@Override
public RcsGroupThreadParticipantLeftEventDescriptor[] newArray(int size) {
return new RcsGroupThreadParticipantLeftEventDescriptor[size];
}
};
protected RcsGroupThreadParticipantLeftEventDescriptor(Parcel in) {
super(in);
mLeavingParticipantId = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeInt(mLeavingParticipantId);
}
}

View File

@@ -1,103 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.WorkerThread;
/**
* This is a single instance of a message received over RCS.
*
* @hide
*/
public class RcsIncomingMessage extends RcsMessage {
/**
* @hide
*/
RcsIncomingMessage(RcsControllerCall rcsControllerCall, int id) {
super(rcsControllerCall, id);
}
/**
* Sets the timestamp of arrival for this message and persists into storage. The timestamp is
* defined as milliseconds passed after midnight, January 1, 1970 UTC
*
* @param arrivalTimestamp The timestamp to set to.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setArrivalTimestamp(long arrivalTimestamp) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setMessageArrivalTimestamp(mId, true,
arrivalTimestamp, callingPackage));
}
/**
* @return Returns the timestamp of arrival for this message. The timestamp is defined as
* milliseconds passed after midnight, January 1, 1970 UTC
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getArrivalTimestamp() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageArrivalTimestamp(mId, true,
callingPackage));
}
/**
* Sets the timestamp of when the user saw this message and persists into storage. The timestamp
* is defined as milliseconds passed after midnight, January 1, 1970 UTC
*
* @param notifiedTimestamp The timestamp to set to.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setSeenTimestamp(long notifiedTimestamp) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setMessageSeenTimestamp(mId, true, notifiedTimestamp,
callingPackage));
}
/**
* @return Returns the timestamp of when the user saw this message. The timestamp is defined as
* milliseconds passed after midnight, January 1, 1970 UTC
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getSeenTimestamp() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageSeenTimestamp(mId, true, callingPackage));
}
/**
* @return Returns the sender of this incoming message.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public RcsParticipant getSenderParticipant() throws RcsMessageStoreException {
return new RcsParticipant(
mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getSenderParticipant(mId, callingPackage)));
}
/**
* @return Returns {@code true} as this is an incoming message
*/
@Override
public boolean isIncoming() {
return true;
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsIncomingMessageCreationParams;

View File

@@ -1,181 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.CheckResult;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
/**
* {@link RcsIncomingMessageCreationParams} is a collection of parameters that should be passed
* into {@link RcsThread#addIncomingMessage(RcsIncomingMessageCreationParams)} to generate an
* {@link RcsIncomingMessage} on that {@link RcsThread}
*
* @hide
*/
public final class RcsIncomingMessageCreationParams extends RcsMessageCreationParams implements
Parcelable {
// The arrival timestamp for the RcsIncomingMessage to be created
private final long mArrivalTimestamp;
// The seen timestamp for the RcsIncomingMessage to be created
private final long mSeenTimestamp;
// The participant that sent this incoming message
private final int mSenderParticipantId;
/**
* Builder to help create an {@link RcsIncomingMessageCreationParams}
*
* @see RcsThread#addIncomingMessage(RcsIncomingMessageCreationParams)
*/
public static class Builder extends RcsMessageCreationParams.Builder {
private RcsParticipant mSenderParticipant;
private long mArrivalTimestamp;
private long mSeenTimestamp;
/**
* Creates a {@link Builder} to create an instance of
* {@link RcsIncomingMessageCreationParams}
*
* @param originationTimestamp The timestamp of {@link RcsMessage} creation. The origination
* timestamp value in milliseconds passed after midnight,
* January 1, 1970 UTC
* @param arrivalTimestamp The timestamp of arrival, defined as milliseconds passed after
* midnight, January 1, 1970 UTC
* @param subscriptionId The subscription ID that was used to send or receive this
* {@link RcsMessage}
*/
public Builder(long originationTimestamp, long arrivalTimestamp, int subscriptionId) {
super(originationTimestamp, subscriptionId);
mArrivalTimestamp = arrivalTimestamp;
}
/**
* Sets the {@link RcsParticipant} that send this {@link RcsIncomingMessage}
*
* @param senderParticipant The {@link RcsParticipant} that sent this
* {@link RcsIncomingMessage}
* @return The same instance of {@link Builder} to chain methods.
*/
@CheckResult
public Builder setSenderParticipant(RcsParticipant senderParticipant) {
mSenderParticipant = senderParticipant;
return this;
}
/**
* Sets the time of the arrival of this {@link RcsIncomingMessage}
* @return The same instance of {@link Builder} to chain methods.
* @see RcsIncomingMessage#setArrivalTimestamp(long)
*/
@CheckResult
public Builder setArrivalTimestamp(long arrivalTimestamp) {
mArrivalTimestamp = arrivalTimestamp;
return this;
}
/**
* Sets the time of the when this user saw the {@link RcsIncomingMessage}
* @param seenTimestamp The seen timestamp , defined as milliseconds passed after midnight,
* January 1, 1970 UTC
* @return The same instance of {@link Builder} to chain methods.
* @see RcsIncomingMessage#setSeenTimestamp(long)
*/
@CheckResult
public Builder setSeenTimestamp(long seenTimestamp) {
mSeenTimestamp = seenTimestamp;
return this;
}
/**
* Creates parameters for creating a new incoming message.
* @return A new instance of {@link RcsIncomingMessageCreationParams} to create a new
* {@link RcsIncomingMessage}
*/
public RcsIncomingMessageCreationParams build() {
return new RcsIncomingMessageCreationParams(this);
}
}
private RcsIncomingMessageCreationParams(Builder builder) {
super(builder);
mArrivalTimestamp = builder.mArrivalTimestamp;
mSeenTimestamp = builder.mSeenTimestamp;
mSenderParticipantId = builder.mSenderParticipant.getId();
}
private RcsIncomingMessageCreationParams(Parcel in) {
super(in);
mArrivalTimestamp = in.readLong();
mSeenTimestamp = in.readLong();
mSenderParticipantId = in.readInt();
}
/**
* @return Returns the arrival timestamp for the {@link RcsIncomingMessage} to be created.
* Timestamp is defined as milliseconds passed after midnight, January 1, 1970 UTC
*/
public long getArrivalTimestamp() {
return mArrivalTimestamp;
}
/**
* @return Returns the seen timestamp for the {@link RcsIncomingMessage} to be created.
* Timestamp is defined as milliseconds passed after midnight, January 1, 1970 UTC
*/
public long getSeenTimestamp() {
return mSeenTimestamp;
}
/**
* Helper getter for {@link com.android.internal.telephony.ims.RcsMessageStoreController} to
* create {@link RcsIncomingMessage}s
*
* Since the API doesn't expose any ID's to API users, this should be hidden.
* @hide
*/
public int getSenderParticipantId() {
return mSenderParticipantId;
}
public static final @NonNull Creator<RcsIncomingMessageCreationParams> CREATOR =
new Creator<RcsIncomingMessageCreationParams>() {
@Override
public RcsIncomingMessageCreationParams createFromParcel(Parcel in) {
return new RcsIncomingMessageCreationParams(in);
}
@Override
public RcsIncomingMessageCreationParams[] newArray(int size) {
return new RcsIncomingMessageCreationParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest);
dest.writeLong(mArrivalTimestamp);
dest.writeLong(mSeenTimestamp);
dest.writeInt(mSenderParticipantId);
}
}

View File

@@ -1,358 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* This is a single instance of a message sent or received over RCS.
*
* @hide
*/
public abstract class RcsMessage {
/**
* The value to indicate that this {@link RcsMessage} does not have any location information.
*/
public static final double LOCATION_NOT_SET = Double.MIN_VALUE;
/**
* The status to indicate that this {@link RcsMessage}s status is not set yet.
*/
public static final int NOT_SET = 0;
/**
* The status to indicate that this {@link RcsMessage} is a draft and is not in the process of
* sending yet.
*/
public static final int DRAFT = 1;
/**
* The status to indicate that this {@link RcsMessage} was successfully sent.
*/
public static final int QUEUED = 2;
/**
* The status to indicate that this {@link RcsMessage} is actively being sent.
*/
public static final int SENDING = 3;
/**
* The status to indicate that this {@link RcsMessage} was successfully sent.
*/
public static final int SENT = 4;
/**
* The status to indicate that this {@link RcsMessage} failed to send in an attempt before, and
* now being retried.
*/
public static final int RETRYING = 5;
/**
* The status to indicate that this {@link RcsMessage} has permanently failed to send.
*/
public static final int FAILED = 6;
/**
* The status to indicate that this {@link RcsMessage} was successfully received.
*/
public static final int RECEIVED = 7;
/**
* The status to indicate that this {@link RcsMessage} was seen.
*/
public static final int SEEN = 9;
/**
* @hide
*/
protected final RcsControllerCall mRcsControllerCall;
/**
* @hide
*/
protected final int mId;
@IntDef({
DRAFT, QUEUED, SENDING, SENT, RETRYING, FAILED, RECEIVED, SEEN
})
@Retention(RetentionPolicy.SOURCE)
public @interface RcsMessageStatus {
}
RcsMessage(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id;
}
/**
* Returns the row Id from the common message.
*
* @hide
*/
public int getId() {
return mId;
}
/**
* @return Returns the subscription ID that this {@link RcsMessage} was sent from, or delivered
* to.
* @throws RcsMessageStoreException if the value could not be read from the storage
* @see android.telephony.SubscriptionInfo#getSubscriptionId
*/
public int getSubscriptionId() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageSubId(mId, isIncoming(), callingPackage));
}
/**
* Sets the subscription ID that this {@link RcsMessage} was sent from, or delivered to and
* persists it into storage.
*
* @param subId The subscription ID to persists into storage.
* @throws RcsMessageStoreException if the value could not be persisted into storage
* @see android.telephony.SubscriptionInfo#getSubscriptionId
*/
@WorkerThread
public void setSubscriptionId(int subId) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setMessageSubId(mId, isIncoming(), subId,
callingPackage));
}
/**
* Sets the status of this message and persists it into storage. Please see
* {@link RcsFileTransferPart#setFileTransferStatus(int)} to set statuses around file transfers.
*
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setStatus(@RcsMessageStatus int rcsMessageStatus) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setMessageStatus(mId, isIncoming(), rcsMessageStatus,
callingPackage));
}
/**
* @return Returns the status of this message. Please see
* {@link RcsFileTransferPart#setFileTransferStatus(int)} to set statuses around file transfers.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public @RcsMessageStatus int getStatus() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageStatus(mId, isIncoming(), callingPackage));
}
/**
* Sets the origination timestamp of this message and persists it into storage. Origination is
* defined as when the sender tapped the send button.
*
* @param timestamp The origination timestamp value in milliseconds passed after midnight,
* January 1, 1970 UTC
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setOriginationTimestamp(long timestamp) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setMessageOriginationTimestamp(mId, isIncoming(),
timestamp, callingPackage));
}
/**
* @return Returns the origination timestamp of this message in milliseconds passed after
* midnight, January 1, 1970 UTC. Origination is defined as when the sender tapped the send
* button.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getOriginationTimestamp() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageOriginationTimestamp(mId, isIncoming(),
callingPackage));
}
/**
* Sets the globally unique RCS message identifier for this message and persists it into
* storage. This function does not confirm that this message id is unique. Please see 4.4.5.2
* - GSMA RCC.53 (RCS Device API 1.6 Specification
*
* @param rcsMessageGlobalId The globally RCS message identifier
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setRcsMessageId(String rcsMessageGlobalId) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setGlobalMessageIdForMessage(mId, isIncoming(),
rcsMessageGlobalId, callingPackage));
}
/**
* @return Returns the globally unique RCS message identifier for this message. Please see
* 4.4.5.2 - GSMA RCC.53 (RCS Device API 1.6 Specification
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public String getRcsMessageId() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getGlobalMessageIdForMessage(mId, isIncoming(),
callingPackage));
}
/**
* @return Returns the user visible text included in this message.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public String getText() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getTextForMessage(mId, isIncoming(),
callingPackage));
}
/**
* Sets the user visible text for this message and persists in storage.
*
* @param text The text this message now has
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setText(String text) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setTextForMessage(mId, isIncoming(), text,
callingPackage));
}
/**
* @return Returns the associated latitude for this message, or
* {@link RcsMessage#LOCATION_NOT_SET} if it does not contain a location.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public double getLatitude() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getLatitudeForMessage(mId, isIncoming(),
callingPackage));
}
/**
* Sets the latitude for this message and persists in storage.
*
* @param latitude The latitude for this location message.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setLatitude(double latitude) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setLatitudeForMessage(mId, isIncoming(), latitude,
callingPackage));
}
/**
* @return Returns the associated longitude for this message, or
* {@link RcsMessage#LOCATION_NOT_SET} if it does not contain a location.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public double getLongitude() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getLongitudeForMessage(mId, isIncoming(),
callingPackage));
}
/**
* Sets the longitude for this message and persists in storage.
*
* @param longitude The longitude for this location message.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setLongitude(double longitude) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setLongitudeForMessage(mId, isIncoming(), longitude,
callingPackage));
}
/**
* Attaches an {@link RcsFileTransferPart} to this message and persists into storage.
*
* @param fileTransferCreationParameters The parameters to be used to create the
* {@link RcsFileTransferPart}
* @return A new instance of {@link RcsFileTransferPart}
* @throws RcsMessageStoreException if the file transfer could not be persisted into storage.
*/
@NonNull
@WorkerThread
public RcsFileTransferPart insertFileTransfer(
RcsFileTransferCreationParams fileTransferCreationParameters)
throws RcsMessageStoreException {
return new RcsFileTransferPart(mRcsControllerCall, mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.storeFileTransfer(mId, isIncoming(),
fileTransferCreationParameters, callingPackage)));
}
/**
* @return Returns all the {@link RcsFileTransferPart}s associated with this message in an
* unmodifiable set.
* @throws RcsMessageStoreException if the file transfers could not be read from the storage
*/
@NonNull
@WorkerThread
public Set<RcsFileTransferPart> getFileTransferParts() throws RcsMessageStoreException {
Set<RcsFileTransferPart> fileTransferParts = new HashSet<>();
int[] fileTransferIds = mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getFileTransfersAttachedToMessage(mId, isIncoming(),
callingPackage));
for (int fileTransfer : fileTransferIds) {
fileTransferParts.add(new RcsFileTransferPart(mRcsControllerCall, fileTransfer));
}
return Collections.unmodifiableSet(fileTransferParts);
}
/**
* Removes a {@link RcsFileTransferPart} from this message, and deletes it in storage.
*
* @param fileTransferPart The part to delete.
* @throws RcsMessageStoreException if the file transfer could not be removed from storage
*/
@WorkerThread
public void removeFileTransferPart(@NonNull RcsFileTransferPart fileTransferPart)
throws RcsMessageStoreException {
if (fileTransferPart == null) {
return;
}
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.deleteFileTransfer(fileTransferPart.getId(),
callingPackage));
}
/**
* @return Returns {@code true} if this message was received on this device, {@code false} if it
* was sent.
*/
public abstract boolean isIncoming();
}

View File

@@ -1,242 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static android.telephony.ims.RcsMessage.LOCATION_NOT_SET;
import android.annotation.CheckResult;
import android.annotation.Nullable;
import android.os.Parcel;
/**
* The collection of parameters to be passed into
* {@link RcsThread#addIncomingMessage(RcsIncomingMessageCreationParams)} and
* {@link RcsThread#addOutgoingMessage(RcsOutgoingMessageCreationParams)} to create and persist
* {@link RcsMessage}s on an {@link RcsThread}
*
* @hide
*/
public class RcsMessageCreationParams {
// The globally unique id of the RcsMessage to be created.
private final String mRcsMessageGlobalId;
// The subscription that this message was/will be received/sent from.
private final int mSubId;
// The sending/receiving status of the message
private final @RcsMessage.RcsMessageStatus int mMessageStatus;
// The timestamp of message creation
private final long mOriginationTimestamp;
// The user visible content of the message
private final String mText;
// The latitude of the message if this is a location message
private final double mLatitude;
// The longitude of the message if this is a location message
private final double mLongitude;
/**
* @return Returns the globally unique RCS Message ID for the {@link RcsMessage} to be created.
* Please see 4.4.5.2 - GSMA RCC.53 (RCS Device API 1.6 Specification
*/
@Nullable
public String getRcsMessageGlobalId() {
return mRcsMessageGlobalId;
}
/**
* @return Returns the subscription ID that was used to send or receive the {@link RcsMessage}
* to be created.
*/
public int getSubId() {
return mSubId;
}
/**
* @return Returns the status for the {@link RcsMessage} to be created.
* @see RcsMessage.RcsMessageStatus
*/
public int getMessageStatus() {
return mMessageStatus;
}
/**
* @return Returns the origination timestamp of the {@link RcsMessage} to be created in
* milliseconds passed after midnight, January 1, 1970 UTC. Origination is defined as when
* the sender tapped the send button.
*/
public long getOriginationTimestamp() {
return mOriginationTimestamp;
}
/**
* @return Returns the user visible text contained in the {@link RcsMessage} to be created
*/
@Nullable
public String getText() {
return mText;
}
/**
* @return Returns the latitude of the {@link RcsMessage} to be created, or
* {@link RcsMessage#LOCATION_NOT_SET} if the message does not contain a location.
*/
public double getLatitude() {
return mLatitude;
}
/**
* @return Returns the longitude of the {@link RcsMessage} to be created, or
* {@link RcsMessage#LOCATION_NOT_SET} if the message does not contain a location.
*/
public double getLongitude() {
return mLongitude;
}
/**
* The base builder for creating {@link RcsMessage}s on {@link RcsThread}s.
*
* @see RcsIncomingMessageCreationParams
*/
public static class Builder {
private String mRcsMessageGlobalId;
private int mSubId;
private @RcsMessage.RcsMessageStatus int mMessageStatus;
private long mOriginationTimestamp;
private String mText;
private double mLatitude = LOCATION_NOT_SET;
private double mLongitude = LOCATION_NOT_SET;
/**
* @hide
*/
public Builder(long originationTimestamp, int subscriptionId) {
mOriginationTimestamp = originationTimestamp;
mSubId = subscriptionId;
}
/**
* Sets the status of the {@link RcsMessage} to be built.
*
* @param rcsMessageStatus The status to be set
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#setStatus(int)
*/
@CheckResult
public Builder setStatus(@RcsMessage.RcsMessageStatus int rcsMessageStatus) {
mMessageStatus = rcsMessageStatus;
return this;
}
/**
* Sets the globally unique RCS message identifier for the {@link RcsMessage} to be built.
* This function does not confirm that this message id is unique. Please see 4.4.5.2 - GSMA
* RCC.53 (RCS Device API 1.6 Specification)
*
* @param rcsMessageId The ID to be set
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#setRcsMessageId(String)
*/
@CheckResult
public Builder setRcsMessageId(String rcsMessageId) {
mRcsMessageGlobalId = rcsMessageId;
return this;
}
/**
* Sets the text of the {@link RcsMessage} to be built.
*
* @param text The user visible text of the message
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#setText(String)
*/
@CheckResult
public Builder setText(String text) {
mText = text;
return this;
}
/**
* Sets the latitude of the {@link RcsMessage} to be built. Please see US5-24 - GSMA RCC.71
* (RCS Universal Profile Service Definition Document)
*
* @param latitude The latitude of the location information associated with this message.
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#setLatitude(double)
*/
@CheckResult
public Builder setLatitude(double latitude) {
mLatitude = latitude;
return this;
}
/**
* Sets the longitude of the {@link RcsMessage} to be built. Please see US5-24 - GSMA RCC.71
* (RCS Universal Profile Service Definition Document)
*
* @param longitude The longitude of the location information associated with this message.
* @return The same instance of {@link Builder} to chain methods
* @see RcsMessage#setLongitude(double)
*/
@CheckResult
public Builder setLongitude(double longitude) {
mLongitude = longitude;
return this;
}
/**
* @return Builds and returns a newly created {@link RcsMessageCreationParams}
*/
public RcsMessageCreationParams build() {
return new RcsMessageCreationParams(this);
}
}
protected RcsMessageCreationParams(Builder builder) {
mRcsMessageGlobalId = builder.mRcsMessageGlobalId;
mSubId = builder.mSubId;
mMessageStatus = builder.mMessageStatus;
mOriginationTimestamp = builder.mOriginationTimestamp;
mText = builder.mText;
mLatitude = builder.mLatitude;
mLongitude = builder.mLongitude;
}
/**
* @hide
*/
RcsMessageCreationParams(Parcel in) {
mRcsMessageGlobalId = in.readString();
mSubId = in.readInt();
mMessageStatus = in.readInt();
mOriginationTimestamp = in.readLong();
mText = in.readString();
mLatitude = in.readDouble();
mLongitude = in.readDouble();
}
/**
* @hide
*/
public void writeToParcel(Parcel dest) {
dest.writeString(mRcsMessageGlobalId);
dest.writeInt(mSubId);
dest.writeInt(mMessageStatus);
dest.writeLong(mOriginationTimestamp);
dest.writeString(mText);
dest.writeDouble(mLatitude);
dest.writeDouble(mLongitude);
}
}

View File

@@ -1,281 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemService;
import android.annotation.WorkerThread;
import android.content.Context;
import android.net.Uri;
import java.util.List;
/**
* RcsMessageManager is the application interface to RcsProvider and provides access methods to
* RCS related database tables.
*
* @hide
*/
@SystemService(Context.TELEPHONY_RCS_MESSAGE_SERVICE)
public class RcsMessageManager {
RcsControllerCall mRcsControllerCall;
/**
* Use {@link Context#getSystemService(String)} to get an instance of this service.
* @hide
*/
public RcsMessageManager(Context context) {
mRcsControllerCall = new RcsControllerCall(context);
}
/**
* Returns the first chunk of existing {@link RcsThread}s in the common storage.
*
* @param queryParameters Parameters to specify to return a subset of all RcsThreads.
* Passing a value of null will return all threads.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsThreadQueryResult getRcsThreads(@Nullable RcsThreadQueryParams queryParameters)
throws RcsMessageStoreException {
return new RcsThreadQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getRcsThreads(queryParameters,
callingPackage)));
}
/**
* Returns the next chunk of {@link RcsThread}s in the common storage.
*
* @param continuationToken A token to continue the query to get the next chunk. This is
* obtained through {@link RcsThreadQueryResult#getContinuationToken}.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsThreadQueryResult getRcsThreads(@NonNull RcsQueryContinuationToken continuationToken)
throws RcsMessageStoreException {
return new RcsThreadQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getRcsThreadsWithToken(continuationToken,
callingPackage)));
}
/**
* Returns the first chunk of existing {@link RcsParticipant}s in the common storage.
*
* @param queryParameters Parameters to specify to return a subset of all RcsParticipants.
* Passing a value of null will return all participants.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsParticipantQueryResult getRcsParticipants(
@Nullable RcsParticipantQueryParams queryParameters)
throws RcsMessageStoreException {
return new RcsParticipantQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getParticipants(queryParameters,
callingPackage)));
}
/**
* Returns the next chunk of {@link RcsParticipant}s in the common storage.
*
* @param continuationToken A token to continue the query to get the next chunk. This is
* obtained through
* {@link RcsParticipantQueryResult#getContinuationToken}
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsParticipantQueryResult getRcsParticipants(
@NonNull RcsQueryContinuationToken continuationToken)
throws RcsMessageStoreException {
return new RcsParticipantQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getParticipantsWithToken(continuationToken,
callingPackage)));
}
/**
* Returns the first chunk of existing {@link RcsMessage}s in the common storage.
*
* @param queryParams Parameters to specify to return a subset of all RcsMessages.
* Passing a value of null will return all messages.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsMessageQueryResult getRcsMessages(
@Nullable RcsMessageQueryParams queryParams) throws RcsMessageStoreException {
return new RcsMessageQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessages(queryParams, callingPackage)));
}
/**
* Returns the next chunk of {@link RcsMessage}s in the common storage.
*
* @param continuationToken A token to continue the query to get the next chunk. This is
* obtained through {@link RcsMessageQueryResult#getContinuationToken}
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsMessageQueryResult getRcsMessages(
@NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException {
return new RcsMessageQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessagesWithToken(continuationToken,
callingPackage)));
}
/**
* Returns the first chunk of existing {@link RcsEvent}s in the common storage.
*
* @param queryParams Parameters to specify to return a subset of all RcsEvents.
* Passing a value of null will return all events.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsEventQueryResult getRcsEvents(
@Nullable RcsEventQueryParams queryParams) throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getEvents(queryParams, callingPackage))
.getRcsEventQueryResult(mRcsControllerCall);
}
/**
* Returns the next chunk of {@link RcsEvent}s in the common storage.
*
* @param continuationToken A token to continue the query to get the next chunk. This is
* obtained through {@link RcsEventQueryResult#getContinuationToken}.
* @throws RcsMessageStoreException if the query could not be completed on the storage
*/
@WorkerThread
@NonNull
public RcsEventQueryResult getRcsEvents(
@NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getEventsWithToken(continuationToken,
callingPackage))
.getRcsEventQueryResult(mRcsControllerCall);
}
/**
* Persists an {@link RcsEvent} to common storage.
*
* @param rcsEvent The {@link RcsEvent} to persist into storage.
* @throws RcsMessageStoreException if the query could not be completed on the storage
* @see RcsGroupThreadNameChangedEvent
* @see RcsGroupThreadIconChangedEvent
* @see RcsGroupThreadParticipantJoinedEvent
* @see RcsGroupThreadParticipantLeftEvent
* @see RcsParticipantAliasChangedEvent
*/
@WorkerThread
@NonNull
public void persistRcsEvent(RcsEvent rcsEvent) throws RcsMessageStoreException {
rcsEvent.persist(mRcsControllerCall);
}
/**
* Creates a new 1 to 1 thread with the given participant and persists it in the storage.
*
* @param recipient The {@link RcsParticipant} that will receive the messages in this thread.
* @return The newly created {@link Rcs1To1Thread}
* @throws RcsMessageStoreException if the thread could not be persisted in the storage
*/
@WorkerThread
@NonNull
public Rcs1To1Thread createRcs1To1Thread(@NonNull RcsParticipant recipient)
throws RcsMessageStoreException {
return new Rcs1To1Thread(
mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.createRcs1To1Thread(recipient.getId(),
callingPackage)));
}
/**
* Creates a new group thread with the given participants and persists it in the storage.
*
* @throws RcsMessageStoreException if the thread could not be persisted in the storage
*/
@WorkerThread
@NonNull
public RcsGroupThread createGroupThread(@Nullable List<RcsParticipant> recipients,
@Nullable String groupName, @Nullable Uri groupIcon) throws RcsMessageStoreException {
int[] recipientIds = null;
if (recipients != null) {
recipientIds = new int[recipients.size()];
for (int i = 0; i < recipients.size(); i++) {
recipientIds[i] = recipients.get(i).getId();
}
}
int[] finalRecipientIds = recipientIds;
int threadId = mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.createGroupThread(finalRecipientIds, groupName,
groupIcon, callingPackage));
return new RcsGroupThread(mRcsControllerCall, threadId);
}
/**
* Delete the given {@link RcsThread} from the storage.
*
* @param thread The thread to be deleted.
* @throws RcsMessageStoreException if the thread could not be deleted from the storage
*/
@WorkerThread
public void deleteThread(@NonNull RcsThread thread) throws RcsMessageStoreException {
if (thread == null) {
return;
}
boolean isDeleteSucceeded = mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.deleteThread(thread.getThreadId(),
thread.getThreadType(), callingPackage));
if (!isDeleteSucceeded) {
throw new RcsMessageStoreException("Could not delete RcsThread");
}
}
/**
* Creates a new participant and persists it in the storage.
*
* @param canonicalAddress The defining address (e.g. phone number) of the participant.
* @param alias The RCS alias for the participant.
* @throws RcsMessageStoreException if the participant could not be created on the storage
*/
@WorkerThread
@NonNull
public RcsParticipant createRcsParticipant(String canonicalAddress, @Nullable String alias)
throws RcsMessageStoreException {
return new RcsParticipant(mRcsControllerCall, mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.createRcsParticipant(canonicalAddress, alias,
callingPackage)));
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsMessageQueryParams;

View File

@@ -1,361 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.CheckResult;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.InvalidParameterException;
/**
* The parameters to pass into
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)} in order to select a
* subset of {@link RcsMessage}s present in the message store.
*
* @hide
*/
public final class RcsMessageQueryParams implements Parcelable {
/**
* @hide - not meant for public use
*/
public static final int THREAD_ID_NOT_SET = -1;
/**
* Flag to be used with {@link Builder#setSortProperty(int)} to denote that the results should
* be sorted in the same order of {@link RcsMessage}s that got persisted into storage for faster
* results.
*/
public static final int SORT_BY_CREATION_ORDER = 0;
/**
* Flag to be used with {@link Builder#setSortProperty(int)} to denote that the results should
* be sorted according to the timestamp of {@link RcsMessage#getOriginationTimestamp()}
*/
public static final int SORT_BY_TIMESTAMP = 1;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SORT_BY_CREATION_ORDER, SORT_BY_TIMESTAMP})
public @interface SortingProperty {
}
/**
* Bitmask flag to be used with {@link Builder#setMessageType(int)} to make
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)} return
* {@link RcsIncomingMessage}s.
*/
public static final int MESSAGE_TYPE_INCOMING = 0x0001;
/**
* Bitmask flag to be used with {@link Builder#setMessageType(int)} to make
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)} return
* {@link RcsOutgoingMessage}s.
*/
public static final int MESSAGE_TYPE_OUTGOING = 0x0002;
/**
* Bitmask flag to be used with {@link Builder#setFileTransferPresence(int)} to make
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)} return {@link RcsMessage}s
* that have an {@link RcsFileTransferPart} attached.
*/
public static final int MESSAGES_WITH_FILE_TRANSFERS = 0x0004;
/**
* Bitmask flag to be used with {@link Builder#setFileTransferPresence(int)} to make
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)} return {@link RcsMessage}s
* that don't have an {@link RcsFileTransferPart} attached.
*/
public static final int MESSAGES_WITHOUT_FILE_TRANSFERS = 0x0008;
/**
* @hide - not meant for public use
*/
public static final String MESSAGE_QUERY_PARAMETERS_KEY = "message_query_parameters";
// Whether the result should be filtered against incoming or outgoing messages
private int mMessageType;
// Whether the result should have file transfer messages attached or not
private int mFileTransferPresence;
// The SQL "Like" clause to filter messages
private String mMessageLike;
// The property the messages should be sorted against
private @SortingProperty int mSortingProperty;
// Whether the messages should be sorted in ascending order
private boolean mIsAscending;
// The number of results that should be returned with this query
private int mLimit;
// The thread that the results should be limited to
private int mThreadId;
RcsMessageQueryParams(int messageType, int fileTransferPresence, String messageLike,
int threadId, @SortingProperty int sortingProperty, boolean isAscending, int limit) {
mMessageType = messageType;
mFileTransferPresence = fileTransferPresence;
mMessageLike = messageLike;
mSortingProperty = sortingProperty;
mIsAscending = isAscending;
mLimit = limit;
mThreadId = threadId;
}
/**
* @return Returns the type of {@link RcsMessage}s that this {@link RcsMessageQueryParams}
* is set to query for.
*/
public int getMessageType() {
return mMessageType;
}
/**
* @return Returns whether the result query should return {@link RcsMessage}s with
* {@link RcsFileTransferPart}s or not
*/
public int getFileTransferPresence() {
return mFileTransferPresence;
}
/**
* @return Returns the SQL-inspired "LIKE" clause that will be used to match {@link RcsMessage}s
*/
public String getMessageLike() {
return mMessageLike;
}
/**
* @return Returns the number of {@link RcsThread}s to be returned from the query. A value of
* 0 means there is no set limit.
*/
public int getLimit() {
return mLimit;
}
/**
* @return Returns the property that will be used to sort the result against.
* @see SortingProperty
*/
public @SortingProperty int getSortingProperty() {
return mSortingProperty;
}
/**
* @return Returns {@code true} if the result set will be sorted in ascending order,
* {@code false} if it will be sorted in descending order.
*/
public boolean getSortDirection() {
return mIsAscending;
}
/**
* This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get
* the thread that the result query should be limited to.
*
* As we do not expose any sort of integer ID's to public usage, this should be hidden.
*
* @hide - not meant for public use
*/
public int getThreadId() {
return mThreadId;
}
/**
* A helper class to build the {@link RcsMessageQueryParams}.
*/
public static class Builder {
private @SortingProperty int mSortingProperty;
private int mMessageType;
private int mFileTransferPresence;
private String mMessageLike;
private boolean mIsAscending;
private int mLimit = 100;
private int mThreadId = THREAD_ID_NOT_SET;
/**
* Creates a new builder for {@link RcsMessageQueryParams} to be used in
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)}
*
*/
public Builder() {
// empty implementation
}
/**
* Desired number of threads to be returned from the query. Passing in 0 will return all
* existing threads at once. The limit defaults to 100.
*
* @param limit The number to limit the query result to.
* @return The same instance of the builder to chain parameters.
* @throws InvalidParameterException If the given limit is negative.
*/
@CheckResult
public Builder setResultLimit(@IntRange(from = 0) int limit)
throws InvalidParameterException {
if (limit < 0) {
throw new InvalidParameterException("The query limit must be non-negative");
}
mLimit = limit;
return this;
}
/**
* Sets the type of messages to be returned from the query.
*
* @param messageType The type of message to be returned.
* @return The same instance of the builder to chain parameters.
* @see RcsMessageQueryParams#MESSAGE_TYPE_INCOMING
* @see RcsMessageQueryParams#MESSAGE_TYPE_OUTGOING
*/
@CheckResult
public Builder setMessageType(int messageType) {
mMessageType = messageType;
return this;
}
/**
* Sets whether file transfer messages should be included in the query result or not.
*
* @param fileTransferPresence Whether file transfers should be included in the result
* @return The same instance of the builder to chain parameters.
* @see RcsMessageQueryParams#MESSAGES_WITH_FILE_TRANSFERS
* @see RcsMessageQueryParams#MESSAGES_WITHOUT_FILE_TRANSFERS
*/
@CheckResult
public Builder setFileTransferPresence(int fileTransferPresence) {
mFileTransferPresence = fileTransferPresence;
return this;
}
/**
* Sets an SQL-inspired "like" clause to match with messages. Using a percent sign ('%')
* wildcard matches any sequence of zero or more characters. Using an underscore ('_')
* wildcard matches any single character. Not using any wildcards would only perform a
* string match. The input string is case-insensitive.
*
* The input "Wh%" would match messages "who", "where" and "what", while the input "Wh_"
* would only match "who"
*
* @param messageLike The "like" clause for matching {@link RcsMessage}s.
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setMessageLike(String messageLike) {
mMessageLike = messageLike;
return this;
}
/**
* Sets the property where the results should be sorted against. Defaults to
* {@link RcsMessageQueryParams.SortingProperty#SORT_BY_CREATION_ORDER}
*
* @param sortingProperty against which property the results should be sorted
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortProperty(@SortingProperty int sortingProperty) {
mSortingProperty = sortingProperty;
return this;
}
/**
* Sets whether the results should be sorted ascending or descending
*
* @param isAscending whether the results should be sorted ascending
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortDirection(boolean isAscending) {
mIsAscending = isAscending;
return this;
}
/**
* Limits the results to the given thread.
*
* @param thread the {@link RcsThread} that results should be limited to. If set to
* {@code null}, messages on all threads will be queried
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setThread(@Nullable RcsThread thread) {
if (thread == null) {
mThreadId = THREAD_ID_NOT_SET;
} else {
mThreadId = thread.getThreadId();
}
return this;
}
/**
* Builds the {@link RcsMessageQueryParams} to use in
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)}
*
* @return An instance of {@link RcsMessageQueryParams} to use with the message
* query.
*/
public RcsMessageQueryParams build() {
return new RcsMessageQueryParams(mMessageType, mFileTransferPresence, mMessageLike,
mThreadId, mSortingProperty, mIsAscending, mLimit);
}
}
/**
* Parcelable boilerplate below.
*/
private RcsMessageQueryParams(Parcel in) {
mMessageType = in.readInt();
mFileTransferPresence = in.readInt();
mMessageLike = in.readString();
mSortingProperty = in.readInt();
mIsAscending = in.readBoolean();
mLimit = in.readInt();
mThreadId = in.readInt();
}
public static final @android.annotation.NonNull Creator<RcsMessageQueryParams> CREATOR =
new Creator<RcsMessageQueryParams>() {
@Override
public RcsMessageQueryParams createFromParcel(Parcel in) {
return new RcsMessageQueryParams(in);
}
@Override
public RcsMessageQueryParams[] newArray(int size) {
return new RcsMessageQueryParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mMessageType);
dest.writeInt(mFileTransferPresence);
dest.writeString(mMessageLike);
dest.writeInt(mSortingProperty);
dest.writeBoolean(mIsAscending);
dest.writeInt(mLimit);
dest.writeInt(mThreadId);
}
}

View File

@@ -1,67 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static android.provider.Telephony.RcsColumns.RcsUnifiedMessageColumns.MESSAGE_TYPE_INCOMING;
import android.annotation.NonNull;
import android.annotation.Nullable;
import java.util.List;
import java.util.stream.Collectors;
/**
* The result of a {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)}
* call. This class allows getting the token for querying the next batch of messages in order to
* prevent handling large amounts of data at once.
*
* @hide
*/
public final class RcsMessageQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsMessageQueryResultParcelable mRcsMessageQueryResultParcelable;
RcsMessageQueryResult(RcsControllerCall rcsControllerCall,
RcsMessageQueryResultParcelable rcsMessageQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsMessageQueryResultParcelable = rcsMessageQueryResultParcelable;
}
/**
* Returns a token to call
* {@link RcsMessageStore#getRcsMessages(RcsQueryContinuationToken)}
* to get the next batch of {@link RcsMessage}s.
*/
@Nullable
public RcsQueryContinuationToken getContinuationToken() {
return mRcsMessageQueryResultParcelable.mContinuationToken;
}
/**
* Returns all the {@link RcsMessage}s in the current query result. Call {@link
* RcsMessageStore#getRcsMessages(RcsQueryContinuationToken)} to get the next batch
* of {@link RcsMessage}s.
*/
@NonNull
public List<RcsMessage> getMessages() {
return mRcsMessageQueryResultParcelable.mMessageTypeIdPairs.stream()
.map(typeIdPair -> typeIdPair.getType() == MESSAGE_TYPE_INCOMING
? new RcsIncomingMessage(mRcsControllerCall, typeIdPair.getId())
: new RcsOutgoingMessage(mRcsControllerCall, typeIdPair.getId()))
.collect(Collectors.toList());
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsMessageQueryResultParcelable;

View File

@@ -1,74 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.ims.RcsTypeIdPair;
import java.util.ArrayList;
import java.util.List;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsMessageQueryResultParcelable implements Parcelable {
// The token to continue the query to get the next batch of results
final RcsQueryContinuationToken mContinuationToken;
// The message type and message ID pairs for all the messages in this query result
final List<RcsTypeIdPair> mMessageTypeIdPairs;
public RcsMessageQueryResultParcelable(
RcsQueryContinuationToken continuationToken,
List<RcsTypeIdPair> messageTypeIdPairs) {
mContinuationToken = continuationToken;
mMessageTypeIdPairs = messageTypeIdPairs;
}
private RcsMessageQueryResultParcelable(Parcel in) {
mContinuationToken = in.readParcelable(
RcsQueryContinuationToken.class.getClassLoader());
mMessageTypeIdPairs = new ArrayList<>();
in.readTypedList(mMessageTypeIdPairs, RcsTypeIdPair.CREATOR);
}
public static final Creator<RcsMessageQueryResultParcelable> CREATOR =
new Creator<RcsMessageQueryResultParcelable>() {
@Override
public RcsMessageQueryResultParcelable createFromParcel(Parcel in) {
return new RcsMessageQueryResultParcelable(in);
}
@Override
public RcsMessageQueryResultParcelable[] newArray(int size) {
return new RcsMessageQueryResultParcelable[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mContinuationToken, flags);
dest.writeTypedList(mMessageTypeIdPairs);
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsMessageSnippet;

View File

@@ -1,98 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;
import android.telephony.ims.RcsMessage.RcsMessageStatus;
/**
* An immutable summary of the latest {@link RcsMessage} on an {@link RcsThread}
*
* @hide
*/
public final class RcsMessageSnippet implements Parcelable {
private final String mText;
private final @RcsMessageStatus int mStatus;
private final long mTimestamp;
/**
* @hide
*/
public RcsMessageSnippet(String text, @RcsMessageStatus int status, long timestamp) {
mText = text;
mStatus = status;
mTimestamp = timestamp;
}
/**
* @return Returns the text of the {@link RcsMessage} with highest origination timestamp value
* (i.e. latest) in this thread
*/
@Nullable
public String getSnippetText() {
return mText;
}
/**
* @return Returns the status of the {@link RcsMessage} with highest origination timestamp value
* (i.e. latest) in this thread
*/
public @RcsMessageStatus int getSnippetStatus() {
return mStatus;
}
/**
* @return Returns the timestamp of the {@link RcsMessage} with highest origination timestamp
* value (i.e. latest) in this thread
*/
public long getSnippetTimestamp() {
return mTimestamp;
}
private RcsMessageSnippet(Parcel in) {
mText = in.readString();
mStatus = in.readInt();
mTimestamp = in.readLong();
}
public static final @android.annotation.NonNull Creator<RcsMessageSnippet> CREATOR =
new Creator<RcsMessageSnippet>() {
@Override
public RcsMessageSnippet createFromParcel(Parcel in) {
return new RcsMessageSnippet(in);
}
@Override
public RcsMessageSnippet[] newArray(int size) {
return new RcsMessageSnippet[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mText);
dest.writeInt(mStatus);
dest.writeLong(mTimestamp);
}
}

View File

@@ -1,35 +0,0 @@
/*
* Copyright (c) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
/**
* An exception that happened on {@link RcsMessageStore} or one of the derived storage classes in
* {@link android.telephony.ims}
*
* @hide
*/
public class RcsMessageStoreException extends Exception {
/**
* Constructs an {@link RcsMessageStoreException} with the specified detail message.
* @param message The detail message
* @see Throwable#getMessage()
*/
public RcsMessageStoreException(String message) {
super(message);
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
import java.util.ArrayList;
import java.util.List;
/**
* This is a single instance of a message sent over RCS.
*
* @hide
*/
public class RcsOutgoingMessage extends RcsMessage {
RcsOutgoingMessage(RcsControllerCall rcsControllerCall, int id) {
super(rcsControllerCall, id);
}
/**
* @return Returns the {@link RcsOutgoingMessageDelivery}s associated with this message. Please
* note that the deliveries returned for the {@link RcsOutgoingMessage} may not always match the
* {@link RcsParticipant}s on the {@link RcsGroupThread} as the group recipients may have
* changed.
* @throws RcsMessageStoreException if the outgoing deliveries could not be read from storage.
*/
@NonNull
@WorkerThread
public List<RcsOutgoingMessageDelivery> getOutgoingDeliveries()
throws RcsMessageStoreException {
int[] deliveryParticipants;
List<RcsOutgoingMessageDelivery> messageDeliveries = new ArrayList<>();
deliveryParticipants = mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageRecipients(mId, callingPackage));
if (deliveryParticipants != null) {
for (Integer deliveryParticipant : deliveryParticipants) {
messageDeliveries.add(new RcsOutgoingMessageDelivery(
mRcsControllerCall, deliveryParticipant, mId));
}
}
return messageDeliveries;
}
/**
* @return Returns {@code false} as this is not an incoming message.
*/
@Override
public boolean isIncoming() {
return false;
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsOutgoingMessageCreationParams;

View File

@@ -1,90 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
/**
* {@link RcsOutgoingMessageCreationParams} is a collection of parameters that should be passed
* into {@link RcsThread#addOutgoingMessage(RcsOutgoingMessageCreationParams)} to generate an
* {@link RcsOutgoingMessage} on that {@link RcsThread}
*
* @hide
*/
public final class RcsOutgoingMessageCreationParams extends RcsMessageCreationParams
implements Parcelable {
/**
* A builder to instantiate and persist an {@link RcsOutgoingMessage}
*/
public static class Builder extends RcsMessageCreationParams.Builder {
/**
* Creates a new {@link Builder} to create an instance of
* {@link RcsOutgoingMessageCreationParams}.
*
* @param originationTimestamp The timestamp of {@link RcsMessage} creation. The origination
* timestamp value in milliseconds passed after midnight,
* January 1, 1970 UTC
* @param subscriptionId The subscription ID that was used to send or receive this
* {@link RcsMessage}
* @see android.telephony.SubscriptionInfo#getSubscriptionId()
*/
public Builder(long originationTimestamp, int subscriptionId) {
super(originationTimestamp, subscriptionId);
}
/**
* Creates configuration parameters for a new message.
*/
public RcsOutgoingMessageCreationParams build() {
return new RcsOutgoingMessageCreationParams(this);
}
}
private RcsOutgoingMessageCreationParams(Builder builder) {
super(builder);
}
private RcsOutgoingMessageCreationParams(Parcel in) {
super(in);
}
public static final @NonNull Creator<RcsOutgoingMessageCreationParams> CREATOR =
new Creator<RcsOutgoingMessageCreationParams>() {
@Override
public RcsOutgoingMessageCreationParams createFromParcel(Parcel in) {
return new RcsOutgoingMessageCreationParams(in);
}
@Override
public RcsOutgoingMessageCreationParams[] newArray(int size) {
return new RcsOutgoingMessageCreationParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest);
}
}

View File

@@ -1,140 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
/**
* This class holds the delivery information of an {@link RcsOutgoingMessage} for each
* {@link RcsParticipant} that the message was intended for.
*
* @hide
*/
public class RcsOutgoingMessageDelivery {
private final RcsControllerCall mRcsControllerCall;
// The participant that this delivery is intended for
private final int mRecipientId;
// The message this delivery is associated with
private final int mRcsOutgoingMessageId;
/**
* Constructor to be used with RcsOutgoingMessage.getDelivery()
*
* @hide
*/
RcsOutgoingMessageDelivery(
RcsControllerCall rcsControllerCall, int recipientId, int messageId) {
mRcsControllerCall = rcsControllerCall;
mRecipientId = recipientId;
mRcsOutgoingMessageId = messageId;
}
/**
* Sets the delivery time of this outgoing delivery and persists into storage.
*
* @param deliveredTimestamp The timestamp to set to delivery. It is defined as milliseconds
* passed after midnight, January 1, 1970 UTC
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setDeliveredTimestamp(long deliveredTimestamp) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setOutgoingDeliveryDeliveredTimestamp(
mRcsOutgoingMessageId, mRecipientId, deliveredTimestamp, callingPackage));
}
/**
* @return Returns the delivered timestamp of the associated message to the associated
* participant. Timestamp is defined as milliseconds passed after midnight, January 1, 1970 UTC.
* Returns 0 if the {@link RcsOutgoingMessage} is not delivered yet.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getDeliveredTimestamp() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getOutgoingDeliveryDeliveredTimestamp(
mRcsOutgoingMessageId, mRecipientId, callingPackage));
}
/**
* Sets the seen time of this outgoing delivery and persists into storage.
*
* @param seenTimestamp The timestamp to set to delivery. It is defined as milliseconds
* passed after midnight, January 1, 1970 UTC
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setSeenTimestamp(long seenTimestamp) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setOutgoingDeliverySeenTimestamp(
mRcsOutgoingMessageId, mRecipientId, seenTimestamp, callingPackage));
}
/**
* @return Returns the seen timestamp of the associated message by the associated
* participant. Timestamp is defined as milliseconds passed after midnight, January 1, 1970 UTC.
* Returns 0 if the {@link RcsOutgoingMessage} is not seen yet.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public long getSeenTimestamp() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getOutgoingDeliverySeenTimestamp(
mRcsOutgoingMessageId, mRecipientId, callingPackage));
}
/**
* Sets the status of this outgoing delivery and persists into storage.
*
* @param status The status of the associated {@link RcsMessage}s delivery to the associated
* {@link RcsParticipant}
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setStatus(@RcsMessage.RcsMessageStatus int status) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setOutgoingDeliveryStatus(
mRcsOutgoingMessageId, mRecipientId, status, callingPackage));
}
/**
* @return Returns the status of this outgoing delivery.
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@WorkerThread
public @RcsMessage.RcsMessageStatus int getStatus() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getOutgoingDeliveryStatus(mRcsOutgoingMessageId,
mRecipientId, callingPackage));
}
/**
* @return Returns the recipient associated with this delivery.
*/
@NonNull
public RcsParticipant getRecipient() {
return new RcsParticipant(mRcsControllerCall, mRecipientId);
}
/**
* @return Returns the {@link RcsOutgoingMessage} associated with this delivery.
*/
@NonNull
public RcsOutgoingMessage getMessage() {
return new RcsOutgoingMessage(mRcsControllerCall, mRcsOutgoingMessageId);
}
}

View File

@@ -1,136 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.Nullable;
import android.annotation.WorkerThread;
/**
* RcsParticipant is an RCS capable contact that can participate in {@link RcsThread}s.
*
* @hide
*/
public class RcsParticipant {
private final RcsControllerCall mRcsControllerCall;
// The row ID of this participant in the database
private final int mId;
/**
* Constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController}
* to create instances of participants. This is not meant to be part of the SDK.
*
* @hide
*/
public RcsParticipant(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id;
}
/**
* @return Returns the canonical address (i.e. normalized phone number) for this
* {@link RcsParticipant}
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public String getCanonicalAddress() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getRcsParticipantCanonicalAddress(mId,
callingPackage));
}
/**
* @return Returns the alias for this {@link RcsParticipant}. Alias is usually the real name of
* the person themselves. Please see US5-15 - GSMA RCC.71 (RCS Universal Profile Service
* Definition Document)
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public String getAlias() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getRcsParticipantAlias(mId, callingPackage));
}
/**
* Sets the alias for this {@link RcsParticipant} and persists it in storage. Alias is usually
* the real name of the person themselves. Please see US5-15 - GSMA RCC.71 (RCS Universal
* Profile Service Definition Document)
*
* @param alias The alias to set to.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setAlias(String alias) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setRcsParticipantAlias(mId, alias, callingPackage));
}
/**
* @return Returns the contact ID for this {@link RcsParticipant}. Contact ID is a unique ID for
* an {@link RcsParticipant} that is RCS provisioned. Please see 4.4.5 - GSMA RCC.53 (RCS Device
* API 1.6 Specification)
* @throws RcsMessageStoreException if the value could not be read from the storage
*/
@Nullable
@WorkerThread
public String getContactId() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getRcsParticipantContactId(mId, callingPackage));
}
/**
* Sets the contact ID for this {@link RcsParticipant}. Contact ID is a unique ID for
* an {@link RcsParticipant} that is RCS provisioned. Please see 4.4.5 - GSMA RCC.53 (RCS Device
* API 1.6 Specification)
*
* @param contactId The contact ID to set to.
* @throws RcsMessageStoreException if the value could not be persisted into storage
*/
@WorkerThread
public void setContactId(String contactId) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.setRcsParticipantContactId(mId, contactId,
callingPackage));
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof RcsParticipant)) {
return false;
}
RcsParticipant other = (RcsParticipant) obj;
return mId == other.mId;
}
@Override
public int hashCode() {
return mId;
}
/**
* Returns the row id of this participant. This is not meant to be part of the SDK
*
* @hide
*/
public int getId() {
return mId;
}
}

View File

@@ -1,76 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
/**
* An event that indicates an {@link RcsParticipant}'s alias was changed. Please see US18-2 - GSMA
* RCC.71 (RCS Universal Profile Service Definition Document)
*
* @hide
*/
public final class RcsParticipantAliasChangedEvent extends RcsEvent {
// The participant that changed their alias
private final RcsParticipant mParticipant;
// The new alias of the above participant
private final String mNewAlias;
/**
* Creates a new {@link RcsParticipantAliasChangedEvent}. This event is not persisted into
* storage until {@link RcsMessageStore#persistRcsEvent(RcsEvent)} is called.
*
* @param timestamp The timestamp of when this event happened, in milliseconds passed after
* midnight, January 1st, 1970 UTC
* @param participant The {@link RcsParticipant} that got their alias changed
* @param newAlias The new alias the {@link RcsParticipant} has.
* @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/
public RcsParticipantAliasChangedEvent(long timestamp, @NonNull RcsParticipant participant,
@Nullable String newAlias) {
super(timestamp);
mParticipant = participant;
mNewAlias = newAlias;
}
/**
* @return Returns the {@link RcsParticipant} whose alias was changed.
*/
@NonNull
public RcsParticipant getParticipant() {
return mParticipant;
}
/**
* @return Returns the alias of the associated {@link RcsParticipant} after this event happened
*/
@Nullable
public String getNewAlias() {
return mNewAlias;
}
/**
* Persists the event to the data store.
*
* @hide - not meant for public use.
*/
@Override
void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
rcsControllerCall.call((iRcs, callingPackage) -> iRcs.createParticipantAliasChangedEvent(
getTimestamp(), getParticipant().getId(), getNewAlias(), callingPackage));
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsParticipantAliasChangedEventDescriptor;

View File

@@ -1,79 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import com.android.internal.annotations.VisibleForTesting;
/**
* @hide - used only for internal communication with the ircs service
*/
public class RcsParticipantAliasChangedEventDescriptor extends RcsEventDescriptor {
// The ID of the participant that changed their alias
protected int mParticipantId;
// The new alias of the above participant
protected String mNewAlias;
public RcsParticipantAliasChangedEventDescriptor(long timestamp, int participantId,
@Nullable String newAlias) {
super(timestamp);
mParticipantId = participantId;
mNewAlias = newAlias;
}
@Override
@VisibleForTesting(visibility = PROTECTED)
public RcsParticipantAliasChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsParticipantAliasChangedEvent(
mTimestamp, new RcsParticipant(rcsControllerCall, mParticipantId), mNewAlias);
}
public static final @NonNull Creator<RcsParticipantAliasChangedEventDescriptor> CREATOR =
new Creator<RcsParticipantAliasChangedEventDescriptor>() {
@Override
public RcsParticipantAliasChangedEventDescriptor createFromParcel(Parcel in) {
return new RcsParticipantAliasChangedEventDescriptor(in);
}
@Override
public RcsParticipantAliasChangedEventDescriptor[] newArray(int size) {
return new RcsParticipantAliasChangedEventDescriptor[size];
}
};
protected RcsParticipantAliasChangedEventDescriptor(Parcel in) {
super(in);
mNewAlias = in.readString();
mParticipantId = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
dest.writeString(mNewAlias);
dest.writeInt(mParticipantId);
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsParticipantQueryParams;

View File

@@ -1,310 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.CheckResult;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.InvalidParameterException;
/**
* The parameters to pass into
* {@link RcsMessageStore#getRcsParticipants(RcsParticipantQueryParams)} in order to select a
* subset of {@link RcsThread}s present in the message store.
*
* @hide
*/
public final class RcsParticipantQueryParams implements Parcelable {
/**
* Flag to set with {@link Builder#setSortProperty(int)} to sort the results in the order of
* creation time for faster query results
*/
public static final int SORT_BY_CREATION_ORDER = 0;
/**
* Flag to set with {@link Builder#setSortProperty(int)} to sort depending on the
* {@link RcsParticipant} aliases
*/
public static final int SORT_BY_ALIAS = 1;
/**
* Flag to set with {@link Builder#setSortProperty(int)} to sort depending on the
* {@link RcsParticipant} canonical addresses
*/
public static final int SORT_BY_CANONICAL_ADDRESS = 2;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SORT_BY_CREATION_ORDER, SORT_BY_ALIAS, SORT_BY_CANONICAL_ADDRESS})
public @interface SortingProperty {
}
// The SQL "like" statement to filter against participant aliases
private String mAliasLike;
// The SQL "like" statement to filter against canonical addresses
private String mCanonicalAddressLike;
// The property to sort the result against
private @SortingProperty int mSortingProperty;
// Whether to sort the result in ascending order
private boolean mIsAscending;
// The number of results to be returned from the query
private int mLimit;
// Used to limit the results to participants of a single thread
private int mThreadId;
/**
* @hide
*/
public static final String PARTICIPANT_QUERY_PARAMETERS_KEY = "participant_query_parameters";
RcsParticipantQueryParams(int rcsThreadId, String aliasLike, String canonicalAddressLike,
@SortingProperty int sortingProperty, boolean isAscending,
int limit) {
mThreadId = rcsThreadId;
mAliasLike = aliasLike;
mCanonicalAddressLike = canonicalAddressLike;
mSortingProperty = sortingProperty;
mIsAscending = isAscending;
mLimit = limit;
}
/**
* This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get
* the thread that the result query should be limited to.
*
* As we do not expose any sort of integer ID's to public usage, this should be hidden.
*
* @hide - not meant for public use
*/
public int getThreadId() {
return mThreadId;
}
/**
* @return Returns the SQL-inspired "LIKE" clause that will be used to match
* {@link RcsParticipant}s with respect to their aliases
*
* @see RcsParticipant#getAlias()
*/
public String getAliasLike() {
return mAliasLike;
}
/**
* @return Returns the SQL-inspired "LIKE" clause that will be used to match
* {@link RcsParticipant}s with respect to their canonical addresses.
*
* @see RcsParticipant#getCanonicalAddress()
*/
public String getCanonicalAddressLike() {
return mCanonicalAddressLike;
}
/**
* @return Returns the number of {@link RcsParticipant}s to be returned from the query. A value
* of 0 means there is no set limit.
*/
public int getLimit() {
return mLimit;
}
/**
* @return Returns the property that will be used to sort the result against.
* @see SortingProperty
*/
public int getSortingProperty() {
return mSortingProperty;
}
/**
* @return Returns {@code true} if the result set will be sorted in ascending order,
* {@code false} if it will be sorted in descending order.
*/
public boolean getSortDirection() {
return mIsAscending;
}
/**
* A helper class to build the {@link RcsParticipantQueryParams}.
*/
public static class Builder {
private String mAliasLike;
private String mCanonicalAddressLike;
private @SortingProperty int mSortingProperty;
private boolean mIsAscending;
private int mLimit = 100;
private int mThreadId;
/**
* Creates a new builder for {@link RcsParticipantQueryParams} to be used in
* {@link RcsMessageStore#getRcsParticipants(RcsParticipantQueryParams)}
*/
public Builder() {
// empty implementation
}
/**
* Limits the resulting {@link RcsParticipant}s to only the given {@link RcsThread}
*
* @param rcsThread The thread that the participants should be searched in.
* @return The same {@link Builder} to chain methods.
*/
@CheckResult
public Builder setThread(RcsThread rcsThread) {
mThreadId = rcsThread.getThreadId();
return this;
}
/**
* Sets an SQL-inspired "like" clause to match with participant aliases. Using a percent
* sign ('%') wildcard matches any sequence of zero or more characters. Using an underscore
* ('_') wildcard matches any single character. Not using any wildcards would only perform a
* string match.The input string is case-insensitive.
*
* The input "An%e" would match {@link RcsParticipant}s with names Anne, Annie, Antonie,
* while the input "An_e" would only match Anne.
*
* @param likeClause The like clause to use for matching {@link RcsParticipant} aliases.
* @return The same {@link Builder} to chain methods
*/
@CheckResult
public Builder setAliasLike(String likeClause) {
mAliasLike = likeClause;
return this;
}
/**
* Sets an SQL-inspired "like" clause to match with participant addresses. Using a percent
* sign ('%') wildcard matches any sequence of zero or more characters. Using an underscore
* ('_') wildcard matches any single character. Not using any wildcards would only perform a
* string match. The input string is case-insensitive.
*
* The input "+999%111" would match {@link RcsParticipant}s with addresses like "+9995111"
* or "+99955555111", while the input "+999_111" would only match "+9995111".
*
* @param likeClause The like clause to use for matching {@link RcsParticipant} canonical
* addresses.
* @return The same {@link Builder} to chain methods
*/
@CheckResult
public Builder setCanonicalAddressLike(String likeClause) {
mCanonicalAddressLike = likeClause;
return this;
}
/**
* Desired number of threads to be returned from the query. Passing in 0 will return all
* existing threads at once. The limit defaults to 100.
*
* @param limit The number to limit the query result to.
* @return The same instance of the builder to chain parameters.
* @throws InvalidParameterException If the given limit is negative.
*/
@CheckResult
public Builder setResultLimit(@IntRange(from = 0) int limit)
throws InvalidParameterException {
if (limit < 0) {
throw new InvalidParameterException("The query limit must be non-negative");
}
mLimit = limit;
return this;
}
/**
* Sets the property where the results should be sorted against. Defaults to
* {@link RcsParticipantQueryParams.SortingProperty#SORT_BY_CREATION_ORDER}
*
* @param sortingProperty against which property the results should be sorted
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortProperty(@SortingProperty int sortingProperty) {
mSortingProperty = sortingProperty;
return this;
}
/**
* Sets whether the results should be sorted ascending or descending
*
* @param isAscending whether the results should be sorted ascending
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortDirection(boolean isAscending) {
mIsAscending = isAscending;
return this;
}
/**
* Builds the {@link RcsParticipantQueryParams} to use in
* {@link RcsMessageStore#getRcsParticipants(RcsParticipantQueryParams)}
*
* @return An instance of {@link RcsParticipantQueryParams} to use with the participant
* query.
*/
public RcsParticipantQueryParams build() {
return new RcsParticipantQueryParams(mThreadId, mAliasLike, mCanonicalAddressLike,
mSortingProperty, mIsAscending, mLimit);
}
}
/**
* Parcelable boilerplate below.
*/
private RcsParticipantQueryParams(Parcel in) {
mAliasLike = in.readString();
mCanonicalAddressLike = in.readString();
mSortingProperty = in.readInt();
mIsAscending = in.readByte() == 1;
mLimit = in.readInt();
mThreadId = in.readInt();
}
public static final @android.annotation.NonNull Creator<RcsParticipantQueryParams> CREATOR =
new Creator<RcsParticipantQueryParams>() {
@Override
public RcsParticipantQueryParams createFromParcel(Parcel in) {
return new RcsParticipantQueryParams(in);
}
@Override
public RcsParticipantQueryParams[] newArray(int size) {
return new RcsParticipantQueryParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(mAliasLike);
dest.writeString(mCanonicalAddressLike);
dest.writeInt(mSortingProperty);
dest.writeByte((byte) (mIsAscending ? 1 : 0));
dest.writeInt(mLimit);
dest.writeInt(mThreadId);
}
}

View File

@@ -1,64 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.NonNull;
import android.annotation.Nullable;
import java.util.List;
import java.util.stream.Collectors;
/**
* The result of a {@link RcsMessageStore#getRcsParticipants(RcsParticipantQueryParams)}
* call. This class allows getting the token for querying the next batch of participants in order to
* prevent handling large amounts of data at once.
*
* @hide
*/
public final class RcsParticipantQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsParticipantQueryResultParcelable mRcsParticipantQueryResultParcelable;
RcsParticipantQueryResult(
RcsControllerCall rcsControllerCall,
RcsParticipantQueryResultParcelable rcsParticipantQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsParticipantQueryResultParcelable = rcsParticipantQueryResultParcelable;
}
/**
* Returns a token to call
* {@link RcsMessageStore#getRcsParticipants(RcsQueryContinuationToken)}
* to get the next batch of {@link RcsParticipant}s.
*/
@Nullable
public RcsQueryContinuationToken getContinuationToken() {
return mRcsParticipantQueryResultParcelable.mContinuationToken;
}
/**
* Returns all the {@link RcsParticipant}s in the current query result. Call {@link
* RcsMessageStore#getRcsParticipants(RcsQueryContinuationToken)} to get the next
* batch of {@link RcsParticipant}s.
*/
@NonNull
public List<RcsParticipant> getParticipants() {
return mRcsParticipantQueryResultParcelable.mParticipantIds.stream()
.map(participantId -> new RcsParticipant(mRcsControllerCall, participantId))
.collect(Collectors.toList());
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsParticipantQueryResultParcelable;

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
/**
* @hide
*/
public final class RcsParticipantQueryResultParcelable implements Parcelable {
final RcsQueryContinuationToken mContinuationToken;
final List<Integer> mParticipantIds;
public RcsParticipantQueryResultParcelable(
RcsQueryContinuationToken continuationToken,
List<Integer> participantIds) {
mContinuationToken = continuationToken;
mParticipantIds = participantIds;
}
private RcsParticipantQueryResultParcelable(Parcel in) {
mContinuationToken = in.readParcelable(RcsQueryContinuationToken.class.getClassLoader());
mParticipantIds = new ArrayList<>();
in.readList(mParticipantIds, Integer.class.getClassLoader());
}
public static final Parcelable.Creator<RcsParticipantQueryResultParcelable> CREATOR =
new Parcelable.Creator<RcsParticipantQueryResultParcelable>() {
@Override
public RcsParticipantQueryResultParcelable createFromParcel(Parcel in) {
return new RcsParticipantQueryResultParcelable(in);
}
@Override
public RcsParticipantQueryResultParcelable[] newArray(int size) {
return new RcsParticipantQueryResultParcelable[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mContinuationToken, flags);
dest.writeList(mParticipantIds);
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsQueryContinuationToken;

View File

@@ -1,157 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.IntDef;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* A token for enabling continuation queries. Instances are acquired through
* {@code getContinuationToken} on result objects after initial query is done.
*
* @see RcsEventQueryResult#getContinuationToken()
* @see RcsMessageQueryResult#getContinuationToken()
* @see RcsParticipantQueryResult#getContinuationToken()
* @see RcsThreadQueryResult#getContinuationToken()
*
* @hide
*/
public final class RcsQueryContinuationToken implements Parcelable {
/**
* Denotes that this {@link RcsQueryContinuationToken} token is meant to allow continuing
* {@link RcsEvent} queries
*/
public static final int EVENT_QUERY_CONTINUATION_TOKEN_TYPE = 0;
/**
* Denotes that this {@link RcsQueryContinuationToken} token is meant to allow continuing
* {@link RcsMessage} queries
*/
public static final int MESSAGE_QUERY_CONTINUATION_TOKEN_TYPE = 1;
/**
* Denotes that this {@link RcsQueryContinuationToken} token is meant to allow continuing
* {@link RcsParticipant} queries
*/
public static final int PARTICIPANT_QUERY_CONTINUATION_TOKEN_TYPE = 2;
/**
* Denotes that this {@link RcsQueryContinuationToken} token is meant to allow continuing
* {@link RcsThread} queries
*/
public static final int THREAD_QUERY_CONTINUATION_TOKEN_TYPE = 3;
/**
* @hide - not meant for public use
*/
public static final String QUERY_CONTINUATION_TOKEN = "query_continuation_token";
@Retention(RetentionPolicy.SOURCE)
@IntDef({EVENT_QUERY_CONTINUATION_TOKEN_TYPE, MESSAGE_QUERY_CONTINUATION_TOKEN_TYPE,
PARTICIPANT_QUERY_CONTINUATION_TOKEN_TYPE, THREAD_QUERY_CONTINUATION_TOKEN_TYPE})
public @interface ContinuationTokenType {}
// The type of query this token should allow to continue
private @ContinuationTokenType int mQueryType;
// The raw query string for the initial query
private final String mRawQuery;
// The number of results that is returned with each query
private final int mLimit;
// The offset value that this query should start the query from
private int mOffset;
/**
* @hide
*/
public RcsQueryContinuationToken(@ContinuationTokenType int queryType, String rawQuery,
int limit, int offset) {
mQueryType = queryType;
mRawQuery = rawQuery;
mLimit = limit;
mOffset = offset;
}
/**
* Returns the original raw query used on {@link com.android.providers.telephony.RcsProvider}
* @hide
*/
public String getRawQuery() {
return mRawQuery;
}
/**
* Returns which index this continuation query should start from
* @hide
*/
public int getOffset() {
return mOffset;
}
/**
* Increments the offset by the amount of result rows returned with the continuation query for
* the next query.
* @hide
*/
public void incrementOffset() {
mOffset += mLimit;
}
/**
* Returns the type of query that this {@link RcsQueryContinuationToken} is intended to be used
* to continue.
*/
public @ContinuationTokenType int getQueryType() {
return mQueryType;
}
private RcsQueryContinuationToken(Parcel in) {
mQueryType = in.readInt();
mRawQuery = in.readString();
mLimit = in.readInt();
mOffset = in.readInt();
}
public static final @android.annotation.NonNull Creator<RcsQueryContinuationToken> CREATOR =
new Creator<RcsQueryContinuationToken>() {
@Override
public RcsQueryContinuationToken createFromParcel(Parcel in) {
return new RcsQueryContinuationToken(in);
}
@Override
public RcsQueryContinuationToken[] newArray(int size) {
return new RcsQueryContinuationToken[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mQueryType);
dest.writeString(mRawQuery);
dest.writeInt(mLimit);
dest.writeInt(mOffset);
}
}

View File

@@ -1,148 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static android.provider.Telephony.RcsColumns.RcsUnifiedThreadColumns.THREAD_TYPE_1_TO_1;
import static android.provider.Telephony.RcsColumns.RcsUnifiedThreadColumns.THREAD_TYPE_GROUP;
import android.annotation.NonNull;
import android.annotation.WorkerThread;
import com.android.internal.annotations.VisibleForTesting;
/**
* RcsThread represents a single RCS conversation thread. It holds messages that were sent and
* received and events that occurred on that thread.
*
* @hide
*/
public abstract class RcsThread {
/**
* The rcs_participant_thread_id that represents this thread in the database
*
* @hide
*/
protected int mThreadId;
/**
* @hide
*/
protected final RcsControllerCall mRcsControllerCall;
/**
* @hide
*/
protected RcsThread(RcsControllerCall rcsControllerCall, int threadId) {
mThreadId = threadId;
mRcsControllerCall = rcsControllerCall;
}
/**
* @return Returns the summary of the latest message in this {@link RcsThread} packaged in an
* {@link RcsMessageSnippet} object
*/
@WorkerThread
@NonNull
public RcsMessageSnippet getSnippet() throws RcsMessageStoreException {
return mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessageSnippet(mThreadId, callingPackage));
}
/**
* Adds a new {@link RcsIncomingMessage} to this RcsThread and persists it in storage.
*
* @throws RcsMessageStoreException if the message could not be persisted into storage.
*/
@WorkerThread
@NonNull
public RcsIncomingMessage addIncomingMessage(
@NonNull RcsIncomingMessageCreationParams rcsIncomingMessageCreationParams)
throws RcsMessageStoreException {
int messageId = mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.addIncomingMessage(mThreadId,
rcsIncomingMessageCreationParams, callingPackage));
return new RcsIncomingMessage(mRcsControllerCall, messageId);
}
/**
* Adds a new {@link RcsOutgoingMessage} to this RcsThread and persists it in storage.
*
* @throws RcsMessageStoreException if the message could not be persisted into storage.
*/
@WorkerThread
@NonNull
public RcsOutgoingMessage addOutgoingMessage(
@NonNull RcsOutgoingMessageCreationParams rcsOutgoingMessageCreationParams)
throws RcsMessageStoreException {
int messageId = mRcsControllerCall.call((iRcs, callingPackage) -> iRcs.addOutgoingMessage(
mThreadId, rcsOutgoingMessageCreationParams, callingPackage));
return new RcsOutgoingMessage(mRcsControllerCall, messageId);
}
/**
* Deletes an {@link RcsMessage} from this RcsThread and updates the storage.
*
* @param rcsMessage The message to delete from the thread
* @throws RcsMessageStoreException if the message could not be deleted
*/
@WorkerThread
public void deleteMessage(@NonNull RcsMessage rcsMessage) throws RcsMessageStoreException {
mRcsControllerCall.callWithNoReturn(
(iRcs, callingPackage) -> iRcs.deleteMessage(rcsMessage.getId(),
rcsMessage.isIncoming(), mThreadId,
isGroup(), callingPackage));
}
/**
* Convenience function for loading all the {@link RcsMessage}s in this {@link RcsThread}. For
* a more detailed and paginated query, please use
* {@link RcsMessageStore#getRcsMessages(RcsMessageQueryParams)}
*
* @return Loads the {@link RcsMessage}s in this thread and returns them in an immutable list.
* @throws RcsMessageStoreException if the messages could not be read from the storage
*/
@WorkerThread
@NonNull
public RcsMessageQueryResult getMessages() throws RcsMessageStoreException {
RcsMessageQueryParams queryParams =
new RcsMessageQueryParams.Builder().setThread(this).build();
return new RcsMessageQueryResult(mRcsControllerCall,
mRcsControllerCall.call(
(iRcs, callingPackage) -> iRcs.getMessages(queryParams, callingPackage)));
}
/**
* @return Returns whether this is a group thread or not
*/
public abstract boolean isGroup();
/**
* @hide
*/
@VisibleForTesting
public int getThreadId() {
return mThreadId;
}
/**
* @hide
*/
public int getThreadType() {
return isGroup() ? THREAD_TYPE_GROUP : THREAD_TYPE_1_TO_1;
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsThreadQueryParams;

View File

@@ -1,305 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.annotation.CheckResult;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.os.Parcel;
import android.os.Parcelable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* The parameters to pass into {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)} in
* order to select a subset of {@link RcsThread}s present in the message store.
*
* @hide
*/
public final class RcsThreadQueryParams implements Parcelable {
/**
* Bitmask flag to be used with {@link Builder#setThreadType(int)} to make
* {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)} return
* {@link RcsGroupThread}s.
*/
public static final int THREAD_TYPE_GROUP = 0x0001;
/**
* Bitmask flag to be used with {@link Builder#setThreadType(int)} to make
* {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)} return
* {@link Rcs1To1Thread}s.
*/
public static final int THREAD_TYPE_1_TO_1 = 0x0002;
// The type of threads to be filtered with the query
private final int mThreadType;
// The list of participants that are expected in the resulting threads
private final List<Integer> mRcsParticipantIds;
// The number of RcsThread's that should be returned with this query
private final int mLimit;
// The property which the result of the query should be sorted against
private final @SortingProperty int mSortingProperty;
// Whether the sorting should be done in ascending
private final boolean mIsAscending;
/**
* Flag to be used with {@link Builder#setSortProperty(int)} to denote that the results should
* be sorted in the order of {@link RcsThread} creation time for faster results.
*/
public static final int SORT_BY_CREATION_ORDER = 0;
/**
* Flag to be used with {@link Builder#setSortProperty(int)} to denote that the results should
* be sorted according to the timestamp of {@link RcsThread#getSnippet()}
*/
public static final int SORT_BY_TIMESTAMP = 1;
@Retention(RetentionPolicy.SOURCE)
@IntDef({SORT_BY_CREATION_ORDER, SORT_BY_TIMESTAMP})
public @interface SortingProperty {
}
/**
* @hide
*/
public static final String THREAD_QUERY_PARAMETERS_KEY = "thread_query_parameters";
RcsThreadQueryParams(int threadType, Set<RcsParticipant> participants,
int limit, int sortingProperty, boolean isAscending) {
mThreadType = threadType;
mRcsParticipantIds = convertParticipantSetToIdList(participants);
mLimit = limit;
mSortingProperty = sortingProperty;
mIsAscending = isAscending;
}
private static List<Integer> convertParticipantSetToIdList(Set<RcsParticipant> participants) {
List<Integer> ids = new ArrayList<>(participants.size());
for (RcsParticipant participant : participants) {
ids.add(participant.getId());
}
return ids;
}
/**
* This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get
* the list of participant IDs.
*
* As we don't expose any integer ID's to API users, this should stay hidden
*
* @hide - not meant for public use
*/
public List<Integer> getRcsParticipantsIds() {
return Collections.unmodifiableList(mRcsParticipantIds);
}
/**
* @return Returns the bitmask flag for types of {@link RcsThread}s that this query should
* return.
*/
public int getThreadType() {
return mThreadType;
}
/**
* @return Returns the number of {@link RcsThread}s to be returned from the query. A value
* of 0 means there is no set limit.
*/
public int getLimit() {
return mLimit;
}
/**
* @return Returns the property that will be used to sort the result against.
* @see SortingProperty
*/
public @SortingProperty int getSortingProperty() {
return mSortingProperty;
}
/**
* @return Returns {@code true} if the result set will be sorted in ascending order,
* {@code false} if it will be sorted in descending order.
*/
public boolean getSortDirection() {
return mIsAscending;
}
/**
* A helper class to build the {@link RcsThreadQueryParams}.
*/
public static class Builder {
private int mThreadType;
private Set<RcsParticipant> mParticipants;
private int mLimit = 100;
private @SortingProperty int mSortingProperty;
private boolean mIsAscending;
/**
* Constructs a {@link RcsThreadQueryParams.Builder} to help build an
* {@link RcsThreadQueryParams}
*/
public Builder() {
mParticipants = new HashSet<>();
}
/**
* Limits the query to only return group threads.
*
* @param threadType Whether to limit the query result to group threads.
* @return The same instance of the builder to chain parameters.
* @see RcsThreadQueryParams#THREAD_TYPE_GROUP
* @see RcsThreadQueryParams#THREAD_TYPE_1_TO_1
*/
@CheckResult
public Builder setThreadType(int threadType) {
mThreadType = threadType;
return this;
}
/**
* Limits the query to only return threads that contain the given participant. If this
* property was not set, participants will not be taken into account while querying for
* threads.
*
* @param participant The participant that must be included in all of the returned threads.
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setParticipant(@NonNull RcsParticipant participant) {
mParticipants.add(participant);
return this;
}
/**
* Limits the query to only return threads that contain the given list of participants. If
* this property was not set, participants will not be taken into account while querying
* for threads.
*
* @param participants An iterable list of participants that must be included in all of the
* returned threads.
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setParticipants(@NonNull List<RcsParticipant> participants) {
mParticipants.addAll(participants);
return this;
}
/**
* Desired number of threads to be returned from the query. Passing in 0 will return all
* existing threads at once. The limit defaults to 100.
*
* @param limit The number to limit the query result to.
* @return The same instance of the builder to chain parameters.
* @throws InvalidParameterException If the given limit is negative.
*/
@CheckResult
public Builder setResultLimit(@IntRange(from = 0) int limit)
throws InvalidParameterException {
if (limit < 0) {
throw new InvalidParameterException("The query limit must be non-negative");
}
mLimit = limit;
return this;
}
/**
* Sets the property where the results should be sorted against. Defaults to
* {@link SortingProperty#SORT_BY_CREATION_ORDER}
*
* @param sortingProperty whether to sort in ascending order or not
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortProperty(@SortingProperty int sortingProperty) {
mSortingProperty = sortingProperty;
return this;
}
/**
* Sets whether the results should be sorted ascending or descending
*
* @param isAscending whether the results should be sorted ascending
* @return The same instance of the builder to chain parameters.
*/
@CheckResult
public Builder setSortDirection(boolean isAscending) {
mIsAscending = isAscending;
return this;
}
/**
* Builds the {@link RcsThreadQueryParams} to use in
* {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)}
*
* @return An instance of {@link RcsThreadQueryParams} to use with the thread query.
*/
public RcsThreadQueryParams build() {
return new RcsThreadQueryParams(mThreadType, mParticipants, mLimit,
mSortingProperty, mIsAscending);
}
}
/**
* Parcelable boilerplate below.
*/
private RcsThreadQueryParams(Parcel in) {
mThreadType = in.readInt();
mRcsParticipantIds = new ArrayList<>();
in.readList(mRcsParticipantIds, Integer.class.getClassLoader());
mLimit = in.readInt();
mSortingProperty = in.readInt();
mIsAscending = in.readByte() == 1;
}
public static final @android.annotation.NonNull Creator<RcsThreadQueryParams> CREATOR =
new Creator<RcsThreadQueryParams>() {
@Override
public RcsThreadQueryParams createFromParcel(Parcel in) {
return new RcsThreadQueryParams(in);
}
@Override
public RcsThreadQueryParams[] newArray(int size) {
return new RcsThreadQueryParams[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mThreadType);
dest.writeList(mRcsParticipantIds);
dest.writeInt(mLimit);
dest.writeInt(mSortingProperty);
dest.writeByte((byte) (mIsAscending ? 1 : 0));
}
}

View File

@@ -1,68 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import static android.provider.Telephony.RcsColumns.RcsUnifiedThreadColumns.THREAD_TYPE_1_TO_1;
import android.annotation.NonNull;
import android.annotation.Nullable;
import java.util.List;
import java.util.stream.Collectors;
/**
* The result of a {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)}
* call. This class allows getting the token for querying the next batch of threads in order to
* prevent handling large amounts of data at once.
*
* @hide
*/
public final class RcsThreadQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsThreadQueryResultParcelable mRcsThreadQueryResultParcelable;
RcsThreadQueryResult(RcsControllerCall rcsControllerCall,
RcsThreadQueryResultParcelable rcsThreadQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsThreadQueryResultParcelable = rcsThreadQueryResultParcelable;
}
/**
* Returns a token to call
* {@link RcsMessageStore#getRcsThreads(RcsQueryContinuationToken)}
* to get the next batch of {@link RcsThread}s.
*/
@Nullable
public RcsQueryContinuationToken getContinuationToken() {
return mRcsThreadQueryResultParcelable.mContinuationToken;
}
/**
* Returns all the RcsThreads in the current query result. Call {@link
* RcsMessageStore#getRcsThreads(RcsQueryContinuationToken)} to get the next batch of
* {@link RcsThread}s.
*/
@NonNull
public List<RcsThread> getThreads() {
return mRcsThreadQueryResultParcelable.mRcsThreadIds.stream()
.map(typeIdPair -> typeIdPair.getType() == THREAD_TYPE_1_TO_1
? new Rcs1To1Thread(mRcsControllerCall, typeIdPair.getId())
: new RcsGroupThread(mRcsControllerCall, typeIdPair.getId()))
.collect(Collectors.toList());
}
}

View File

@@ -1,20 +0,0 @@
/*
*
* Copyright 2019, The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
parcelable RcsThreadQueryResultParcelable;

View File

@@ -1,70 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.ims.RcsTypeIdPair;
import java.util.ArrayList;
import java.util.List;
/**
* @hide
*/
public final class RcsThreadQueryResultParcelable implements Parcelable {
final RcsQueryContinuationToken mContinuationToken;
final List<RcsTypeIdPair> mRcsThreadIds;
public RcsThreadQueryResultParcelable(
RcsQueryContinuationToken continuationToken,
List<RcsTypeIdPair> rcsThreadIds) {
mContinuationToken = continuationToken;
mRcsThreadIds = rcsThreadIds;
}
private RcsThreadQueryResultParcelable(Parcel in) {
mContinuationToken = in.readParcelable(RcsQueryContinuationToken.class.getClassLoader());
mRcsThreadIds = new ArrayList<>();
in.readList(mRcsThreadIds, RcsTypeIdPair.class.getClassLoader());
}
public static final Parcelable.Creator<RcsThreadQueryResultParcelable> CREATOR =
new Parcelable.Creator<RcsThreadQueryResultParcelable>() {
@Override
public RcsThreadQueryResultParcelable createFromParcel(Parcel in) {
return new RcsThreadQueryResultParcelable(in);
}
@Override
public RcsThreadQueryResultParcelable[] newArray(int size) {
return new RcsThreadQueryResultParcelable[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(mContinuationToken, flags);
dest.writeList(mRcsThreadIds);
}
}

View File

@@ -1,266 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.telephony.ims.aidl;
import android.net.Uri;
import android.telephony.ims.RcsEventQueryParams;
import android.telephony.ims.RcsEventQueryResultDescriptor;
import android.telephony.ims.RcsFileTransferCreationParams;
import android.telephony.ims.RcsIncomingMessageCreationParams;
import android.telephony.ims.RcsMessageSnippet;
import android.telephony.ims.RcsMessageQueryParams;
import android.telephony.ims.RcsMessageQueryResultParcelable;
import android.telephony.ims.RcsOutgoingMessageCreationParams;
import android.telephony.ims.RcsParticipantQueryParams;
import android.telephony.ims.RcsParticipantQueryResultParcelable;
import android.telephony.ims.RcsQueryContinuationToken;
import android.telephony.ims.RcsThreadQueryParams;
import android.telephony.ims.RcsThreadQueryResultParcelable;
/**
* RPC definition between RCS storage APIs and phone process.
* {@hide}
*/
interface IRcsMessage {
/////////////////////////
// RcsMessageStore APIs
/////////////////////////
RcsThreadQueryResultParcelable getRcsThreads(in RcsThreadQueryParams queryParams, String callingPackage);
RcsThreadQueryResultParcelable getRcsThreadsWithToken(
in RcsQueryContinuationToken continuationToken, String callingPackage);
RcsParticipantQueryResultParcelable getParticipants(in RcsParticipantQueryParams queryParams, String callingPackage);
RcsParticipantQueryResultParcelable getParticipantsWithToken(
in RcsQueryContinuationToken continuationToken, String callingPackage);
RcsMessageQueryResultParcelable getMessages(in RcsMessageQueryParams queryParams, String callingPackage);
RcsMessageQueryResultParcelable getMessagesWithToken(
in RcsQueryContinuationToken continuationToken, String callingPackage);
RcsEventQueryResultDescriptor getEvents(in RcsEventQueryParams queryParams, String callingPackage);
RcsEventQueryResultDescriptor getEventsWithToken(
in RcsQueryContinuationToken continuationToken, String callingPackage);
// returns true if the thread was successfully deleted
boolean deleteThread(int threadId, int threadType, String callingPackage);
// Creates an Rcs1To1Thread and returns its row ID
int createRcs1To1Thread(int participantId, String callingPackage);
// Creates an RcsGroupThread and returns its row ID
int createGroupThread(in int[] participantIds, String groupName, in Uri groupIcon, String callingPackage);
/////////////////////////
// RcsThread APIs
/////////////////////////
// Creates a new RcsIncomingMessage on the given thread and returns its row ID
int addIncomingMessage(int rcsThreadId,
in RcsIncomingMessageCreationParams rcsIncomingMessageCreationParams, String callingPackage);
// Creates a new RcsOutgoingMessage on the given thread and returns its row ID
int addOutgoingMessage(int rcsThreadId,
in RcsOutgoingMessageCreationParams rcsOutgoingMessageCreationParams, String callingPackage);
// TODO: modify RcsProvider URI's to allow deleting a message without specifying its thread
void deleteMessage(int rcsMessageId, boolean isIncoming, int rcsThreadId, boolean isGroup, String callingPackage);
RcsMessageSnippet getMessageSnippet(int rcsThreadId, String callingPackage);
/////////////////////////
// Rcs1To1Thread APIs
/////////////////////////
void set1To1ThreadFallbackThreadId(int rcsThreadId, long fallbackId, String callingPackage);
long get1To1ThreadFallbackThreadId(int rcsThreadId, String callingPackage);
int get1To1ThreadOtherParticipantId(int rcsThreadId, String callingPackage);
/////////////////////////
// RcsGroupThread APIs
/////////////////////////
void setGroupThreadName(int rcsThreadId, String groupName, String callingPackage);
String getGroupThreadName(int rcsThreadId, String callingPackage);
void setGroupThreadIcon(int rcsThreadId, in Uri groupIcon, String callingPackage);
Uri getGroupThreadIcon(int rcsThreadId, String callingPackage);
void setGroupThreadOwner(int rcsThreadId, int participantId, String callingPackage);
int getGroupThreadOwner(int rcsThreadId, String callingPackage);
void setGroupThreadConferenceUri(int rcsThreadId, in Uri conferenceUri, String callingPackage);
Uri getGroupThreadConferenceUri(int rcsThreadId, String callingPackage);
void addParticipantToGroupThread(int rcsThreadId, int participantId, String callingPackage);
void removeParticipantFromGroupThread(int rcsThreadId, int participantId, String callingPackage);
/////////////////////////
// RcsParticipant APIs
/////////////////////////
// Creates a new RcsParticipant and returns its rowId
int createRcsParticipant(String canonicalAddress, String alias, String callingPackage);
String getRcsParticipantCanonicalAddress(int participantId, String callingPackage);
String getRcsParticipantAlias(int participantId, String callingPackage);
void setRcsParticipantAlias(int id, String alias, String callingPackage);
String getRcsParticipantContactId(int participantId, String callingPackage);
void setRcsParticipantContactId(int participantId, String contactId, String callingPackage);
/////////////////////////
// RcsMessage APIs
/////////////////////////
void setMessageSubId(int messageId, boolean isIncoming, int subId, String callingPackage);
int getMessageSubId(int messageId, boolean isIncoming, String callingPackage);
void setMessageStatus(int messageId, boolean isIncoming, int status, String callingPackage);
int getMessageStatus(int messageId, boolean isIncoming, String callingPackage);
void setMessageOriginationTimestamp(int messageId, boolean isIncoming, long originationTimestamp, String callingPackage);
long getMessageOriginationTimestamp(int messageId, boolean isIncoming, String callingPackage);
void setGlobalMessageIdForMessage(int messageId, boolean isIncoming, String globalId, String callingPackage);
String getGlobalMessageIdForMessage(int messageId, boolean isIncoming, String callingPackage);
void setMessageArrivalTimestamp(int messageId, boolean isIncoming, long arrivalTimestamp, String callingPackage);
long getMessageArrivalTimestamp(int messageId, boolean isIncoming, String callingPackage);
void setMessageSeenTimestamp(int messageId, boolean isIncoming, long seenTimestamp, String callingPackage);
long getMessageSeenTimestamp(int messageId, boolean isIncoming, String callingPackage);
void setTextForMessage(int messageId, boolean isIncoming, String text, String callingPackage);
String getTextForMessage(int messageId, boolean isIncoming, String callingPackage);
void setLatitudeForMessage(int messageId, boolean isIncoming, double latitude, String callingPackage);
double getLatitudeForMessage(int messageId, boolean isIncoming, String callingPackage);
void setLongitudeForMessage(int messageId, boolean isIncoming, double longitude, String callingPackage);
double getLongitudeForMessage(int messageId, boolean isIncoming, String callingPackage);
// Returns the ID's of the file transfers attached to the given message
int[] getFileTransfersAttachedToMessage(int messageId, boolean isIncoming, String callingPackage);
int getSenderParticipant(int messageId, String callingPackage);
/////////////////////////
// RcsOutgoingMessageDelivery APIs
/////////////////////////
// Returns the participant ID's that this message is intended to be delivered to
int[] getMessageRecipients(int messageId, String callingPackage);
long getOutgoingDeliveryDeliveredTimestamp(int messageId, int participantId, String callingPackage);
void setOutgoingDeliveryDeliveredTimestamp(int messageId, int participantId, long deliveredTimestamp, String callingPackage);
long getOutgoingDeliverySeenTimestamp(int messageId, int participantId, String callingPackage);
void setOutgoingDeliverySeenTimestamp(int messageId, int participantId, long seenTimestamp, String callingPackage);
int getOutgoingDeliveryStatus(int messageId, int participantId, String callingPackage);
void setOutgoingDeliveryStatus(int messageId, int participantId, int status, String callingPackage);
/////////////////////////
// RcsFileTransferPart APIs
/////////////////////////
// Performs the initial write to storage and returns the row ID.
int storeFileTransfer(int messageId, boolean isIncoming,
in RcsFileTransferCreationParams fileTransferCreationParams, String callingPackage);
void deleteFileTransfer(int partId, String callingPackage);
void setFileTransferSessionId(int partId, String sessionId, String callingPackage);
String getFileTransferSessionId(int partId, String callingPackage);
void setFileTransferContentUri(int partId, in Uri contentUri, String callingPackage);
Uri getFileTransferContentUri(int partId, String callingPackage);
void setFileTransferContentType(int partId, String contentType, String callingPackage);
String getFileTransferContentType(int partId, String callingPackage);
void setFileTransferFileSize(int partId, long fileSize, String callingPackage);
long getFileTransferFileSize(int partId, String callingPackage);
void setFileTransferTransferOffset(int partId, long transferOffset, String callingPackage);
long getFileTransferTransferOffset(int partId, String callingPackage);
void setFileTransferStatus(int partId, int transferStatus, String callingPackage);
int getFileTransferStatus(int partId, String callingPackage);
void setFileTransferWidth(int partId, int width, String callingPackage);
int getFileTransferWidth(int partId, String callingPackage);
void setFileTransferHeight(int partId, int height, String callingPackage);
int getFileTransferHeight(int partId, String callingPackage);
void setFileTransferLength(int partId, long length, String callingPackage);
long getFileTransferLength(int partId, String callingPackage);
void setFileTransferPreviewUri(int partId, in Uri uri, String callingPackage);
Uri getFileTransferPreviewUri(int partId, String callingPackage);
void setFileTransferPreviewType(int partId, String type, String callingPackage);
String getFileTransferPreviewType(int partId, String callingPackage);
/////////////////////////
// RcsEvent APIs
/////////////////////////
int createGroupThreadNameChangedEvent(long timestamp, int threadId, int originationParticipantId, String newName, String callingPackage);
int createGroupThreadIconChangedEvent(long timestamp, int threadId, int originationParticipantId, in Uri newIcon, String callingPackage);
int createGroupThreadParticipantJoinedEvent(long timestamp, int threadId, int originationParticipantId, int participantId, String callingPackage);
int createGroupThreadParticipantLeftEvent(long timestamp, int threadId, int originationParticipantId, int participantId, String callingPackage);
int createParticipantAliasChangedEvent(long timestamp, int participantId, String newAlias, String callingPackage);
}

View File

@@ -1,17 +0,0 @@
android_test {
name: "RcsTests",
// Only compile source java files in this apk.
srcs: ["src/**/*.java"],
platform_apis: true,
certificate: "platform",
libs: [
"android.test.runner",
"android.test.base",
],
static_libs: [
"junit",
"androidx.test.rules",
"mockito-target-minus-junit4",
"truth-prebuilt",
],
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.tests.rcs">
<application android:label="RCS Test">
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.tests.rcs"/>
</manifest>

View File

@@ -1,60 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.net.Uri;
import android.os.Parcel;
import android.telephony.ims.RcsGroupThreadIconChangedEvent;
import android.telephony.ims.RcsGroupThreadIconChangedEventDescriptor;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsGroupThreadIconChangedEventTest {
@Test
public void testCanUnparcel() {
int rcsGroupThreadId = 1;
int rcsParticipantId = 2;
Uri newIconUri = Uri.parse("content://new_icon");
RcsGroupThreadIconChangedEventDescriptor iconChangedEventDescriptor =
new RcsGroupThreadIconChangedEventDescriptor(1234567890, rcsGroupThreadId,
rcsParticipantId, newIconUri);
Parcel parcel = Parcel.obtain();
iconChangedEventDescriptor.writeToParcel(
parcel, iconChangedEventDescriptor.describeContents());
parcel.setDataPosition(0);
iconChangedEventDescriptor =
RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel);
RcsGroupThreadIconChangedEvent iconChangedEvent =
iconChangedEventDescriptor.createRcsEvent(null);
assertThat(iconChangedEvent.getNewIcon()).isEqualTo(newIconUri);
assertThat(iconChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);
assertThat(iconChangedEvent.getOriginatingParticipant().getId()).isEqualTo(2);
assertThat(iconChangedEvent.getTimestamp()).isEqualTo(1234567890);
}
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsGroupThreadNameChangedEvent;
import android.telephony.ims.RcsGroupThreadNameChangedEventDescriptor;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsGroupThreadNameChangedEventTest {
@Test
public void testCanUnparcel() {
String newName = "new name";
int rcsGroupThreadId = 1;
int rcsParticipantId = 2;
RcsGroupThreadNameChangedEventDescriptor nameChangedEventDescriptor =
new RcsGroupThreadNameChangedEventDescriptor(
1234567890, rcsGroupThreadId, rcsParticipantId, newName);
Parcel parcel = Parcel.obtain();
nameChangedEventDescriptor.writeToParcel(
parcel, nameChangedEventDescriptor.describeContents());
parcel.setDataPosition(0);
nameChangedEventDescriptor = RcsGroupThreadNameChangedEventDescriptor.CREATOR
.createFromParcel(parcel);
RcsGroupThreadNameChangedEvent nameChangedEvent =
nameChangedEventDescriptor.createRcsEvent(null);
assertThat(nameChangedEvent.getNewName()).isEqualTo(newName);
assertThat(nameChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);
assertThat(nameChangedEvent.getOriginatingParticipant().getId()).isEqualTo(2);
assertThat(nameChangedEvent.getTimestamp()).isEqualTo(1234567890);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsGroupThreadParticipantJoinedEvent;
import android.telephony.ims.RcsGroupThreadParticipantJoinedEventDescriptor;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsGroupThreadParticipantJoinedEventTest {
@Test
public void testCanUnparcel() {
int rcsGroupThreadId = 1;
int rcsParticipantId = 2;
RcsGroupThreadParticipantJoinedEventDescriptor participantJoinedEventDescriptor =
new RcsGroupThreadParticipantJoinedEventDescriptor(
1234567890, rcsGroupThreadId, rcsParticipantId, rcsParticipantId);
Parcel parcel = Parcel.obtain();
participantJoinedEventDescriptor.writeToParcel(
parcel, participantJoinedEventDescriptor.describeContents());
parcel.setDataPosition(0);
participantJoinedEventDescriptor = RcsGroupThreadParticipantJoinedEventDescriptor.CREATOR
.createFromParcel(parcel);
RcsGroupThreadParticipantJoinedEvent participantJoinedEvent =
participantJoinedEventDescriptor.createRcsEvent(null);
assertThat(participantJoinedEvent.getJoinedParticipant().getId()).isEqualTo(2);
assertThat(participantJoinedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);
assertThat(participantJoinedEvent.getOriginatingParticipant().getId()).isEqualTo(2);
assertThat(participantJoinedEvent.getTimestamp()).isEqualTo(1234567890);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsGroupThreadParticipantLeftEvent;
import android.telephony.ims.RcsGroupThreadParticipantLeftEventDescriptor;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsGroupThreadParticipantLeftEventTest {
@Test
public void testCanUnparcel() {
int rcsGroupThreadId = 1;
int rcsParticipantId = 2;
RcsGroupThreadParticipantLeftEventDescriptor participantLeftEventDescriptor =
new RcsGroupThreadParticipantLeftEventDescriptor(
1234567890, rcsGroupThreadId, rcsParticipantId, rcsParticipantId);
Parcel parcel = Parcel.obtain();
participantLeftEventDescriptor.writeToParcel(
parcel, participantLeftEventDescriptor.describeContents());
parcel.setDataPosition(0);
// create from parcel
parcel.setDataPosition(0);
participantLeftEventDescriptor = RcsGroupThreadParticipantLeftEventDescriptor.CREATOR
.createFromParcel(parcel);
RcsGroupThreadParticipantLeftEvent participantLeftEvent =
participantLeftEventDescriptor.createRcsEvent(null);
assertThat(participantLeftEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);
assertThat(participantLeftEvent.getLeavingParticipant().getId()).isEqualTo(2);
assertThat(participantLeftEvent.getTimestamp()).isEqualTo(1234567890);
}
}

View File

@@ -1,57 +0,0 @@
/*
* Copyright (C) 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsParticipantAliasChangedEvent;
import android.telephony.ims.RcsParticipantAliasChangedEventDescriptor;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsParticipantAliasChangedEventTest {
private static final String OLD_ALIAS = "old alias";
private static final String NEW_ALIAS = "new alias";
private int mParticipantId = 3;
@Test
public void testCanUnparcel() {
RcsParticipantAliasChangedEventDescriptor aliasChangedEventDescriptor =
new RcsParticipantAliasChangedEventDescriptor(
1234567890, mParticipantId, NEW_ALIAS);
Parcel parcel = Parcel.obtain();
aliasChangedEventDescriptor.writeToParcel(
parcel, aliasChangedEventDescriptor.describeContents());
parcel.setDataPosition(0);
aliasChangedEventDescriptor = RcsParticipantAliasChangedEventDescriptor.CREATOR
.createFromParcel(parcel);
RcsParticipantAliasChangedEvent aliasChangedEvent =
aliasChangedEventDescriptor.createRcsEvent(null);
assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId);
assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS);
assertThat(aliasChangedEvent.getTimestamp()).isEqualTo(1234567890);
}
}

View File

@@ -1,58 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsParticipantQueryParams;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsParticipantQueryParamsTest {
@Test
public void testCanUnparcel() {
RcsParticipantQueryParams rcsParticipantQueryParams =
new RcsParticipantQueryParams.Builder()
.setAliasLike("%alias_")
.setCanonicalAddressLike("_canonical%")
.setSortProperty(RcsParticipantQueryParams.SORT_BY_CANONICAL_ADDRESS)
.setSortDirection(true)
.setResultLimit(432)
.build();
Parcel parcel = Parcel.obtain();
rcsParticipantQueryParams.writeToParcel(parcel,
rcsParticipantQueryParams.describeContents());
parcel.setDataPosition(0);
rcsParticipantQueryParams = RcsParticipantQueryParams.CREATOR.createFromParcel(
parcel);
assertThat(rcsParticipantQueryParams.getAliasLike()).isEqualTo("%alias_");
assertThat(rcsParticipantQueryParams.getCanonicalAddressLike()).contains("_canonical%");
assertThat(rcsParticipantQueryParams.getLimit()).isEqualTo(432);
assertThat(rcsParticipantQueryParams.getSortingProperty()).isEqualTo(
RcsParticipantQueryParams.SORT_BY_CANONICAL_ADDRESS);
assertThat(rcsParticipantQueryParams.getSortDirection()).isTrue();
}
}

View File

@@ -1,59 +0,0 @@
/*
* Copyright (C) 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tests.ims;
import static android.telephony.ims.RcsThreadQueryParams.SORT_BY_TIMESTAMP;
import static android.telephony.ims.RcsThreadQueryParams.THREAD_TYPE_GROUP;
import static com.google.common.truth.Truth.assertThat;
import android.os.Parcel;
import android.telephony.ims.RcsParticipant;
import android.telephony.ims.RcsThreadQueryParams;
import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class RcsThreadQueryParamsTest {
@Test
public void testCanUnparcel() {
RcsParticipant rcsParticipant = new RcsParticipant(null, 1);
RcsThreadQueryParams rcsThreadQueryParams = new RcsThreadQueryParams.Builder()
.setThreadType(THREAD_TYPE_GROUP)
.setParticipant(rcsParticipant)
.setResultLimit(50)
.setSortProperty(SORT_BY_TIMESTAMP)
.setSortDirection(true)
.build();
Parcel parcel = Parcel.obtain();
rcsThreadQueryParams.writeToParcel(parcel, rcsThreadQueryParams.describeContents());
parcel.setDataPosition(0);
rcsThreadQueryParams = RcsThreadQueryParams.CREATOR.createFromParcel(parcel);
assertThat(rcsThreadQueryParams.getThreadType()).isEqualTo(THREAD_TYPE_GROUP);
assertThat(rcsThreadQueryParams.getRcsParticipantsIds())
.contains(rcsParticipant.getId());
assertThat(rcsThreadQueryParams.getLimit()).isEqualTo(50);
assertThat(rcsThreadQueryParams.getSortingProperty()).isEqualTo(SORT_BY_TIMESTAMP);
assertThat(rcsThreadQueryParams.getSortDirection()).isTrue();
}
}