diff --git a/telephony/java/android/telephony/ims/Rcs1To1Thread.java b/telephony/java/android/telephony/ims/Rcs1To1Thread.java index 5122c7daafe6706c86f68152be38988a9cd501ed..709b3aa0f8045cbc9afa9bb28c73afe42eb3305f 100644 --- a/telephony/java/android/telephony/ims/Rcs1To1Thread.java +++ b/telephony/java/android/telephony/ims/Rcs1To1Thread.java @@ -23,6 +23,10 @@ import android.os.Parcel; * @hide - TODO(sahinc) make this public */ public class Rcs1To1Thread extends RcsThread { + public Rcs1To1Thread(int threadId) { + super(threadId); + } + public static final Creator<Rcs1To1Thread> CREATOR = new Creator<Rcs1To1Thread>() { @Override public Rcs1To1Thread createFromParcel(Parcel in) { @@ -36,6 +40,7 @@ public class Rcs1To1Thread extends RcsThread { }; protected Rcs1To1Thread(Parcel in) { + super(in); } @Override @@ -45,5 +50,7 @@ public class Rcs1To1Thread extends RcsThread { @Override public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(RCS_1_TO_1_TYPE); + super.writeToParcel(dest, flags); } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThread.java b/telephony/java/android/telephony/ims/RcsGroupThread.java index 150c4d49757ca5ed4b9cbc27576b8aac142188d6..d954b2d70ac3b6bb333cf011a6bc60a902cd1a47 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThread.java +++ b/telephony/java/android/telephony/ims/RcsGroupThread.java @@ -36,6 +36,7 @@ public class RcsGroupThread extends RcsThread { }; protected RcsGroupThread(Parcel in) { + super(in); } @Override @@ -45,5 +46,7 @@ public class RcsGroupThread extends RcsThread { @Override public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(RCS_GROUP_TYPE); + super.writeToParcel(dest, flags); } } diff --git a/telephony/java/android/telephony/ims/RcsMessageStore.java b/telephony/java/android/telephony/ims/RcsMessageStore.java index 4198c78a81910ff4eb65e71b1c20832c09d25dcb..1bf6ffd81ca01e1e2198c86ee418225a48790f84 100644 --- a/telephony/java/android/telephony/ims/RcsMessageStore.java +++ b/telephony/java/android/telephony/ims/RcsMessageStore.java @@ -16,6 +16,8 @@ package android.telephony.ims; +import android.annotation.Nullable; +import android.annotation.WorkerThread; import android.os.RemoteException; import android.os.ServiceManager; import android.telephony.Rlog; @@ -27,26 +29,93 @@ import android.telephony.ims.aidl.IRcs; * @hide - TODO make this public */ public class RcsMessageStore { - private static final String TAG = "RcsMessageStore"; - private static final boolean VDBG = false; + static final String TAG = "RcsMessageStore"; /** - * Delete the RcsThread identified by the given threadId. + * 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. + */ + @WorkerThread + public RcsThreadQueryResult getRcsThreads(@Nullable RcsThreadQueryParameters queryParameters) { + try { + IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); + if (iRcs != null) { + return iRcs.getRcsThreads(queryParameters); + } + } catch (RemoteException re) { + Rlog.e(TAG, "RcsMessageStore: Exception happened during getRcsThreads", re); + } + + return null; + } + + /** + * 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#nextChunkToken}. + */ + @WorkerThread + public RcsThreadQueryResult getRcsThreads(RcsThreadQueryContinuationToken continuationToken) { + try { + IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); + if (iRcs != null) { + return iRcs.getRcsThreadsWithToken(continuationToken); + } + } catch (RemoteException re) { + Rlog.e(TAG, "RcsMessageStore: Exception happened during getRcsThreads", re); + } + + return null; + } + + /** + * Creates a new 1 to 1 thread with the given participant and persists it in the storage. + */ + @WorkerThread + public Rcs1To1Thread createRcs1To1Thread(RcsParticipant recipient) { + try { + IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); + if (iRcs != null) { + return iRcs.createRcs1To1Thread(recipient); + } + } catch (RemoteException re) { + Rlog.e(TAG, "RcsMessageStore: Exception happened during createRcs1To1Thread", re); + } + + return null; + } + + /** + * Delete the {@link RcsThread} identified by the given threadId. * @param threadId threadId of the thread to be deleted. */ + @WorkerThread public void deleteThread(int threadId) { - if (VDBG) logd("deleteThread: threadId: " + threadId); try { IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); if (iRcs != null) { iRcs.deleteThread(threadId); } } catch (RemoteException re) { - + Rlog.e(TAG, "RcsMessageStore: Exception happened during deleteThread", re); } } - private static void logd(String msg) { - Rlog.d(TAG, msg); + /** + * Creates a new participant and persists it in the storage. + * @param canonicalAddress The defining address (e.g. phone number) of the participant. + */ + public RcsParticipant createRcsParticipant(String canonicalAddress) { + try { + IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService("ircs")); + if (iRcs != null) { + return iRcs.createRcsParticipant(canonicalAddress); + } + } catch (RemoteException re) { + Rlog.e(TAG, "RcsMessageStore: Exception happened during createRcsParticipant", re); + } + + return null; } } diff --git a/telephony/java/android/telephony/ims/RcsParticipant.java b/telephony/java/android/telephony/ims/RcsParticipant.java index 318dba3fcbca6fe122807ee7377415f4a37c0874..70500aaa2e8b5e257b4e792a5a0d050396fe335a 100644 --- a/telephony/java/android/telephony/ims/RcsParticipant.java +++ b/telephony/java/android/telephony/ims/RcsParticipant.java @@ -23,6 +23,16 @@ import android.os.Parcelable; * @hide - TODO(sahinc) make this public */ public class RcsParticipant implements Parcelable { + /** + * Returns the row id of this participant. + * + * TODO(sahinc) implement + * @hide + */ + public int getId() { + return 12345; + } + public static final Creator<RcsParticipant> CREATOR = new Creator<RcsParticipant>() { @Override public RcsParticipant createFromParcel(Parcel in) { diff --git a/telephony/java/android/telephony/ims/RcsThread.java b/telephony/java/android/telephony/ims/RcsThread.java index 2969ffdda0e8981a1547f923829dfe1e825b5027..c0a0d946d204691f247839bc187a97103a8cae7d 100644 --- a/telephony/java/android/telephony/ims/RcsThread.java +++ b/telephony/java/android/telephony/ims/RcsThread.java @@ -16,7 +16,9 @@ package android.telephony.ims; +import android.os.Parcel; import android.os.Parcelable; +import android.util.Log; /** * RcsThread represents a single RCS conversation thread. It holds messages that were sent and @@ -24,5 +26,50 @@ import android.os.Parcelable; * @hide - TODO(sahinc) make this public */ public abstract class RcsThread implements Parcelable { + // Since this is an abstract class that gets parcelled, the sub-classes need to write these + // magic values into the parcel so that we know which type to unparcel into. + protected static final int RCS_1_TO_1_TYPE = 998; + protected static final int RCS_GROUP_TYPE = 999; + protected int mThreadId; + + protected RcsThread(int threadId) { + mThreadId = threadId; + } + + protected RcsThread(Parcel in) { + mThreadId = in.readInt(); + } + + public static final Creator<RcsThread> CREATOR = new Creator<RcsThread>() { + @Override + public RcsThread createFromParcel(Parcel in) { + int type = in.readInt(); + + switch (type) { + case RCS_1_TO_1_TYPE: + return new Rcs1To1Thread(in); + case RCS_GROUP_TYPE: + return new RcsGroupThread(in); + default: + Log.e(RcsMessageStore.TAG, "Cannot unparcel RcsThread, wrong type: " + type); + } + return null; + } + + @Override + public RcsThread[] newArray(int size) { + return new RcsThread[0]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeInt(mThreadId); + } } diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.aidl b/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.aidl new file mode 100644 index 0000000000000000000000000000000000000000..7bcebfa08fcb32eadbf5c9195d1ab6237150101d --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.aidl @@ -0,0 +1,20 @@ +/* +** +** 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 RcsThreadQueryContinuationToken; diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.java b/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.java new file mode 100644 index 0000000000000000000000000000000000000000..931e93dc8bf1316eb7c83543bc65e0d1455fa28b --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryContinuationToken.java @@ -0,0 +1,52 @@ +/* + * 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.os.Parcel; +import android.os.Parcelable; + +/** + * A continuation token to provide for {@link RcsMessageStore#getRcsThreads}. Use this token to + * break large queries into manageable chunks + * @hide - TODO make this public + */ +public class RcsThreadQueryContinuationToken implements Parcelable { + protected RcsThreadQueryContinuationToken(Parcel in) { + } + + public static final Creator<RcsThreadQueryContinuationToken> CREATOR = + new Creator<RcsThreadQueryContinuationToken>() { + @Override + public RcsThreadQueryContinuationToken createFromParcel(Parcel in) { + return new RcsThreadQueryContinuationToken(in); + } + + @Override + public RcsThreadQueryContinuationToken[] newArray(int size) { + return new RcsThreadQueryContinuationToken[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + } +} diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryParameters.aidl b/telephony/java/android/telephony/ims/RcsThreadQueryParameters.aidl new file mode 100644 index 0000000000000000000000000000000000000000..feb2d4dec094488796fcfae5be98c96dd1cd9075 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryParameters.aidl @@ -0,0 +1,20 @@ +/* +** +** 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 RcsThreadQueryParameters; diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryParameters.java b/telephony/java/android/telephony/ims/RcsThreadQueryParameters.java new file mode 100644 index 0000000000000000000000000000000000000000..f2c4ab1884ca88f19fa694cbe8a7d85245a85807 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryParameters.java @@ -0,0 +1,225 @@ +/* + * 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.CheckResult; +import android.os.Parcel; +import android.os.Parcelable; + +import java.security.InvalidParameterException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Set; + +/** + * The parameters to pass into {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParameters)} in + * order to select a subset of {@link RcsThread}s present in the message store. + * @hide TODO - make the Builder and builder() public. The rest should stay internal only. + */ +public class RcsThreadQueryParameters implements Parcelable { + private final boolean mIsGroup; + private final Set<RcsParticipant> mRcsParticipants; + private final int mLimit; + private final boolean mIsAscending; + + RcsThreadQueryParameters(boolean isGroup, Set<RcsParticipant> participants, int limit, + boolean isAscending) { + mIsGroup = isGroup; + mRcsParticipants = participants; + mLimit = limit; + mIsAscending = isAscending; + } + + /** + * Returns a new builder to build a query with. + * TODO - make public + */ + public static Builder builder() { + return new Builder(); + } + + /** + * This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get + * the list of participants. + * @hide + */ + public Set<RcsParticipant> getRcsParticipants() { + return mRcsParticipants; + } + + /** + * This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get + * whether group threads should be queried + * @hide + */ + public boolean isGroupThread() { + return mIsGroup; + } + + /** + * This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to get + * the number of tuples the result query should be limited to. + */ + public int getLimit() { + return mLimit; + } + + /** + * This is used in {@link com.android.internal.telephony.ims.RcsMessageStoreController} to + * determine the sort order. + */ + public boolean isAscending() { + return mIsAscending; + } + + /** + * A helper class to build the {@link RcsThreadQueryParameters}. + */ + public static class Builder { + private boolean mIsGroupThread; + private Set<RcsParticipant> mParticipants; + private int mLimit = 100; + private boolean mIsAscending; + + /** + * Package private constructor for {@link RcsThreadQueryParameters.Builder}. To obtain this, + * {@link RcsThreadQueryParameters#builder()} needs to be called. + */ + Builder() { + mParticipants = new HashSet<>(); + } + + /** + * Limits the query to only return group threads. + * @param isGroupThread Whether to limit the query result to group threads. + * @return The same instance of the builder to chain parameters. + */ + @CheckResult + public Builder isGroupThread(boolean isGroupThread) { + mIsGroupThread = isGroupThread; + return this; + } + + /** + * Limits the query to only return threads that contain the given participant. + * @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 withParticipant(RcsParticipant participant) { + mParticipants.add(participant); + return this; + } + + /** + * Limits the query to only return threads that contain the given list of participants. + * @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 withParticipants(Iterable<RcsParticipant> participants) { + for (RcsParticipant participant : participants) { + mParticipants.add(participant); + } + 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 limitResultsTo(int limit) throws InvalidParameterException { + if (limit < 0) { + throw new InvalidParameterException("The query limit must be non-negative"); + } + + mLimit = limit; + return this; + } + + /** + * Sorts the results returned from the query via thread IDs. + * + * TODO - add sorting support for other fields + * + * @param isAscending whether to sort in ascending order or not + * @return The same instance of the builder to chain parameters. + */ + @CheckResult + public Builder sort(boolean isAscending) { + mIsAscending = isAscending; + return this; + } + + /** + * Builds the {@link RcsThreadQueryParameters} to use in + * {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParameters)} + * + * @return An instance of {@link RcsThreadQueryParameters} to use with the thread query. + */ + public RcsThreadQueryParameters build() { + return new RcsThreadQueryParameters( + mIsGroupThread, mParticipants, mLimit, mIsAscending); + } + } + + /** + * Parcelable boilerplate below. + */ + protected RcsThreadQueryParameters(Parcel in) { + mIsGroup = in.readBoolean(); + + ArrayList<RcsParticipant> participantArrayList = new ArrayList<>(); + in.readTypedList(participantArrayList, RcsParticipant.CREATOR); + mRcsParticipants = new HashSet<>(participantArrayList); + + mLimit = in.readInt(); + mIsAscending = in.readBoolean(); + } + + public static final Creator<RcsThreadQueryParameters> CREATOR = + new Creator<RcsThreadQueryParameters>() { + @Override + public RcsThreadQueryParameters createFromParcel(Parcel in) { + return new RcsThreadQueryParameters(in); + } + + @Override + public RcsThreadQueryParameters[] newArray(int size) { + return new RcsThreadQueryParameters[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeBoolean(mIsGroup); + dest.writeTypedList(new ArrayList<>(mRcsParticipants)); + dest.writeInt(mLimit); + dest.writeBoolean(mIsAscending); + } + +} diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryResult.aidl b/telephony/java/android/telephony/ims/RcsThreadQueryResult.aidl new file mode 100644 index 0000000000000000000000000000000000000000..4b06529d1294ce4e65ca19b8c4ebf1ec847de33b --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryResult.aidl @@ -0,0 +1,20 @@ +/* +** +** 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 RcsThreadQueryResult; diff --git a/telephony/java/android/telephony/ims/RcsThreadQueryResult.java b/telephony/java/android/telephony/ims/RcsThreadQueryResult.java new file mode 100644 index 0000000000000000000000000000000000000000..47715f8410d677efdb3793a2784b8df323b78381 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsThreadQueryResult.java @@ -0,0 +1,92 @@ +/* + * 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.os.Parcel; +import android.os.Parcelable; + +import java.util.List; + +/** + * The result of a {@link RcsMessageStore#getRcsThreads(RcsThreadQueryContinuationToken, + * RcsThreadQueryParameters)} + * 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 class RcsThreadQueryResult implements Parcelable { + private RcsThreadQueryContinuationToken mContinuationToken; + private List<RcsThread> mRcsThreads; + + /** + * Internal constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController} + * to create query results + * + * @hide + */ + public RcsThreadQueryResult( + RcsThreadQueryContinuationToken continuationToken, List<RcsThread> rcsThreads) { + mContinuationToken = continuationToken; + mRcsThreads = rcsThreads; + } + + /** + * Returns a token to call + * {@link RcsMessageStore#getRcsThreads(RcsThreadQueryContinuationToken)} + * to get the next batch of {@link RcsThread}s. + */ + public RcsThreadQueryContinuationToken nextChunkToken() { + return mContinuationToken; + } + + /** + * Returns all the RcsThreads in the current query result. Call {@link + * RcsMessageStore#getRcsThreads(RcsThreadQueryContinuationToken)} to get the next batch of + * {@link RcsThread}s. + */ + public List<RcsThread> getThreads() { + return mRcsThreads; + } + + protected RcsThreadQueryResult(Parcel in) { + // TODO - implement + } + + public static final Creator<RcsThreadQueryResult> CREATOR = + new Creator<RcsThreadQueryResult>() { + @Override + public RcsThreadQueryResult createFromParcel(Parcel in) { + return new RcsThreadQueryResult(in); + } + + @Override + public RcsThreadQueryResult[] newArray(int size) { + return new RcsThreadQueryResult[size]; + } + }; + + @Override + public int describeContents() { + return 0; + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + // TODO - implement + } +} diff --git a/telephony/java/android/telephony/ims/aidl/IRcs.aidl b/telephony/java/android/telephony/ims/aidl/IRcs.aidl index b2e2fadca138df0e7f93f45e5d3580a13335e396..9badac5be2301a09d5328559fa9309c5e1c1b727 100644 --- a/telephony/java/android/telephony/ims/aidl/IRcs.aidl +++ b/telephony/java/android/telephony/ims/aidl/IRcs.aidl @@ -16,14 +16,29 @@ package android.telephony.ims.aidl; +import android.telephony.ims.RcsParticipant; +import android.telephony.ims.Rcs1To1Thread; +import android.telephony.ims.RcsThreadQueryContinuationToken; +import android.telephony.ims.RcsThreadQueryParameters; +import android.telephony.ims.RcsThreadQueryResult; + /** * RPC definition between RCS storage APIs and phone process. * {@hide} */ interface IRcs { // RcsMessageStore APIs + RcsThreadQueryResult getRcsThreads(in RcsThreadQueryParameters queryParameters); + + RcsThreadQueryResult getRcsThreadsWithToken( + in RcsThreadQueryContinuationToken continuationToken); + void deleteThread(int threadId); + Rcs1To1Thread createRcs1To1Thread(in RcsParticipant participant); + + RcsParticipant createRcsParticipant(String canonicalAddress); + // RcsThread APIs int getMessageCount(int rcsThreadId); } \ No newline at end of file diff --git a/tests/RcsTests/Android.mk b/tests/RcsTests/Android.mk index adc7cab9138947992af4514c252094256a05fd0d..7b348d73747a462385c1a371bbc60b73ba117177 100644 --- a/tests/RcsTests/Android.mk +++ b/tests/RcsTests/Android.mk @@ -11,7 +11,7 @@ LOCAL_PRIVATE_PLATFORM_APIS := true LOCAL_CERTIFICATE := platform LOCAL_JAVA_LIBRARIES := android.test.runner android.test.base -LOCAL_STATIC_JAVA_LIBRARIES := junit android-support-test mockito-target-minus-junit4 +LOCAL_STATIC_JAVA_LIBRARIES := junit android-support-test mockito-target-minus-junit4 truth-prebuilt include $(BUILD_PACKAGE) diff --git a/tests/RcsTests/src/com/android/tests/rcs/RcsMessageStoreTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsMessageStoreTest.java similarity index 97% rename from tests/RcsTests/src/com/android/tests/rcs/RcsMessageStoreTest.java rename to tests/RcsTests/src/com/android/tests/ims/RcsMessageStoreTest.java index 290e04ce8abbe49578ac6a16e3daeb62f7398091..44277edcdb8c787693e21614a9a7402abca9d45b 100644 --- a/tests/RcsTests/src/com/android/tests/rcs/RcsMessageStoreTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsMessageStoreTest.java @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.tests.rcs; +package com.android.tests.ims; import android.support.test.runner.AndroidJUnit4; import android.telephony.ims.RcsMessageStore; diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParametersTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParametersTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a890a389bdfcf8504348f4ed70f4f4876f3a1456 --- /dev/null +++ b/tests/RcsTests/src/com/android/tests/ims/RcsThreadQueryParametersTest.java @@ -0,0 +1,53 @@ +/* + * 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.Bundle; +import android.support.test.runner.AndroidJUnit4; +import android.telephony.ims.RcsParticipant; +import android.telephony.ims.RcsThreadQueryParameters; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; + +@RunWith(AndroidJUnit4.class) +public class RcsThreadQueryParametersTest { + private RcsThreadQueryParameters mRcsThreadQueryParameters; + @Mock RcsParticipant mMockParticipant; + + @Test + public void testUnparceling() { + String key = "some key"; + mRcsThreadQueryParameters = RcsThreadQueryParameters.builder() + .isGroupThread(true) + .withParticipant(mMockParticipant) + .limitResultsTo(50) + .sort(true) + .build(); + + Bundle bundle = new Bundle(); + bundle.putParcelable(key, mRcsThreadQueryParameters); + mRcsThreadQueryParameters = bundle.getParcelable(key); + + assertThat(mRcsThreadQueryParameters.isGroupThread()).isTrue(); + assertThat(mRcsThreadQueryParameters.getRcsParticipants()).contains(mMockParticipant); + assertThat(mRcsThreadQueryParameters.getLimit()).isEqualTo(50); + assertThat(mRcsThreadQueryParameters.isAscending()).isTrue(); + } +}