Merge "Create new RcsThreadQueryResultParcelable"
am: ad2928ac86
Change-Id: Ife195a2760bf81bf5da0cc9d72fde1b6038778d4
This commit is contained in:
@@ -41,7 +41,8 @@ public class RcsMessageStore {
|
||||
@NonNull
|
||||
public RcsThreadQueryResult getRcsThreads(@Nullable RcsThreadQueryParams queryParameters)
|
||||
throws RcsMessageStoreException {
|
||||
return RcsControllerCall.call(iRcs -> iRcs.getRcsThreads(queryParameters));
|
||||
return new RcsThreadQueryResult(
|
||||
RcsControllerCall.call(iRcs -> iRcs.getRcsThreads(queryParameters)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +56,8 @@ public class RcsMessageStore {
|
||||
@NonNull
|
||||
public RcsThreadQueryResult getRcsThreads(@NonNull RcsQueryContinuationToken continuationToken)
|
||||
throws RcsMessageStoreException {
|
||||
return RcsControllerCall.call(iRcs -> iRcs.getRcsThreadsWithToken(continuationToken));
|
||||
return new RcsThreadQueryResult(
|
||||
RcsControllerCall.call(iRcs -> iRcs.getRcsThreadsWithToken(continuationToken)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,7 +123,7 @@ public class RcsMessageStore {
|
||||
* 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.
|
||||
* Passing a value of null will return all events.
|
||||
* @throws RcsMessageStoreException if the query could not be completed on the storage
|
||||
*/
|
||||
@WorkerThread
|
||||
@@ -152,7 +154,6 @@ public class RcsMessageStore {
|
||||
*
|
||||
* @param persistableEvent 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
|
||||
|
||||
@@ -20,13 +20,10 @@ import static android.provider.Telephony.RcsColumns.RcsUnifiedThreadColumns.THRE
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import com.android.ims.RcsTypeIdPair;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* The result of a {@link RcsMessageStore#getRcsThreads(RcsThreadQueryParams)}
|
||||
@@ -35,23 +32,11 @@ import java.util.List;
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final class RcsThreadQueryResult implements Parcelable {
|
||||
// A token for the caller to continue their query for the next batch of results
|
||||
private RcsQueryContinuationToken mContinuationToken;
|
||||
// The list of thread IDs returned with this query
|
||||
private List<RcsTypeIdPair> mRcsThreadIds;
|
||||
public final class RcsThreadQueryResult {
|
||||
private final RcsThreadQueryResultParcelable mRcsThreadQueryResultParcelable;
|
||||
|
||||
/**
|
||||
* Internal constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController}
|
||||
* to create query results
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public RcsThreadQueryResult(
|
||||
RcsQueryContinuationToken continuationToken,
|
||||
List<RcsTypeIdPair> rcsThreadIds) {
|
||||
mContinuationToken = continuationToken;
|
||||
mRcsThreadIds = rcsThreadIds;
|
||||
RcsThreadQueryResult(RcsThreadQueryResultParcelable rcsThreadQueryResultParcelable) {
|
||||
mRcsThreadQueryResultParcelable = rcsThreadQueryResultParcelable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +46,7 @@ public final class RcsThreadQueryResult implements Parcelable {
|
||||
*/
|
||||
@Nullable
|
||||
public RcsQueryContinuationToken getContinuationToken() {
|
||||
return mContinuationToken;
|
||||
return mRcsThreadQueryResultParcelable.mContinuationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,47 +56,10 @@ public final class RcsThreadQueryResult implements Parcelable {
|
||||
*/
|
||||
@NonNull
|
||||
public List<RcsThread> getThreads() {
|
||||
List<RcsThread> rcsThreads = new ArrayList<>();
|
||||
|
||||
for (RcsTypeIdPair typeIdPair : mRcsThreadIds) {
|
||||
if (typeIdPair.getType() == THREAD_TYPE_1_TO_1) {
|
||||
rcsThreads.add(new Rcs1To1Thread(typeIdPair.getId()));
|
||||
} else {
|
||||
rcsThreads.add(new RcsGroupThread(typeIdPair.getId()));
|
||||
}
|
||||
}
|
||||
|
||||
return rcsThreads;
|
||||
}
|
||||
|
||||
private RcsThreadQueryResult(Parcel in) {
|
||||
mContinuationToken = in.readParcelable(
|
||||
RcsQueryContinuationToken.class.getClassLoader());
|
||||
mRcsThreadIds = new ArrayList<>();
|
||||
in.readList(mRcsThreadIds, Integer.class.getClassLoader());
|
||||
}
|
||||
|
||||
public static final @android.annotation.NonNull 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) {
|
||||
dest.writeParcelable(mContinuationToken, flags);
|
||||
dest.writeList(mRcsThreadIds);
|
||||
return mRcsThreadQueryResultParcelable.mRcsThreadIds.stream()
|
||||
.map(typeIdPair -> typeIdPair.getType() == THREAD_TYPE_1_TO_1
|
||||
? new Rcs1To1Thread(typeIdPair.getId())
|
||||
: new RcsGroupThread(typeIdPair.getId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@
|
||||
|
||||
package android.telephony.ims;
|
||||
|
||||
parcelable RcsThreadQueryResult;
|
||||
parcelable RcsThreadQueryResultParcelable;
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ import android.telephony.ims.RcsParticipantQueryParams;
|
||||
import android.telephony.ims.RcsParticipantQueryResult;
|
||||
import android.telephony.ims.RcsQueryContinuationToken;
|
||||
import android.telephony.ims.RcsThreadQueryParams;
|
||||
import android.telephony.ims.RcsThreadQueryResult;
|
||||
import android.telephony.ims.RcsThreadQueryResultParcelable;
|
||||
|
||||
/**
|
||||
* RPC definition between RCS storage APIs and phone process.
|
||||
@@ -39,9 +39,9 @@ interface IRcs {
|
||||
/////////////////////////
|
||||
// RcsMessageStore APIs
|
||||
/////////////////////////
|
||||
RcsThreadQueryResult getRcsThreads(in RcsThreadQueryParams queryParams);
|
||||
RcsThreadQueryResultParcelable getRcsThreads(in RcsThreadQueryParams queryParams);
|
||||
|
||||
RcsThreadQueryResult getRcsThreadsWithToken(
|
||||
RcsThreadQueryResultParcelable getRcsThreadsWithToken(
|
||||
in RcsQueryContinuationToken continuationToken);
|
||||
|
||||
RcsParticipantQueryResult getParticipants(in RcsParticipantQueryParams queryParams);
|
||||
|
||||
Reference in New Issue
Block a user