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

Commit 3e90221e authored by Leland Miller's avatar Leland Miller
Browse files

Create new RcsParticipantQueryResultParcelable

This parcelable class now backes RcsParticipantQueryResult. This change
will allow injection of API layer dependencies into
RcsParticipantQueryResult.

Change-Id: I6d002d1e9b61831169eee66f76fed743beffc446
Test: Existing tests pass
Bug: 123699565
parent 9f80ec1d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -169,8 +169,9 @@ public class RcsGroupThread extends RcsThread {
        RcsParticipantQueryParams queryParameters =
                new RcsParticipantQueryParams.Builder().setThread(this).build();

        RcsParticipantQueryResult queryResult = RcsControllerCall.call(
                iRcs -> iRcs.getParticipants(queryParameters));
        RcsParticipantQueryResult queryResult = new RcsParticipantQueryResult(
                RcsControllerCall.call(
                        iRcs -> iRcs.getParticipants(queryParameters)));

        List<RcsParticipant> participantList = queryResult.getParticipants();
        Set<RcsParticipant> participantSet = new LinkedHashSet<>(participantList);
+5 −4
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ public class RcsMessageStore {
    public RcsParticipantQueryResult getRcsParticipants(
            @Nullable RcsParticipantQueryParams queryParameters)
            throws RcsMessageStoreException {
        return RcsControllerCall.call(iRcs -> iRcs.getParticipants(queryParameters));
        return new RcsParticipantQueryResult(
                RcsControllerCall.call(iRcs -> iRcs.getParticipants(queryParameters)));
    }

    /**
@@ -86,7 +87,8 @@ public class RcsMessageStore {
    public RcsParticipantQueryResult getRcsParticipants(
            @NonNull RcsQueryContinuationToken continuationToken)
            throws RcsMessageStoreException {
        return RcsControllerCall.call(iRcs -> iRcs.getParticipantsWithToken(continuationToken));
        return new RcsParticipantQueryResult(
                RcsControllerCall.call(iRcs -> iRcs.getParticipantsWithToken(continuationToken)));
    }

    /**
@@ -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
+10 −54
Original line number Diff line number Diff line
@@ -18,11 +18,9 @@ package android.telephony.ims;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * The result of a {@link RcsMessageStore#getRcsParticipants(RcsParticipantQueryParams)}
@@ -31,23 +29,12 @@ import java.util.List;
 *
 * @hide
 */
public final class RcsParticipantQueryResult implements Parcelable {
    // A token for the caller to continue their query for the next batch of results
    private RcsQueryContinuationToken mContinuationToken;
    // The list of participant IDs returned with this query
    private List<Integer> mParticipants;
public final class RcsParticipantQueryResult {
    private final RcsParticipantQueryResultParcelable mRcsParticipantQueryResultParcelable;

    /**
     * Internal constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController}
     * to create query results
     *
     * @hide
     */
    public RcsParticipantQueryResult(
            RcsQueryContinuationToken continuationToken,
            List<Integer> participants) {
        mContinuationToken = continuationToken;
        mParticipants = participants;
    RcsParticipantQueryResult(
            RcsParticipantQueryResultParcelable rcsParticipantQueryResultParcelable) {
        mRcsParticipantQueryResultParcelable = rcsParticipantQueryResultParcelable;
    }

    /**
@@ -57,7 +44,7 @@ public final class RcsParticipantQueryResult implements Parcelable {
     */
    @Nullable
    public RcsQueryContinuationToken getContinuationToken() {
        return mContinuationToken;
        return mRcsParticipantQueryResultParcelable.mContinuationToken;
    }

    /**
@@ -67,39 +54,8 @@ public final class RcsParticipantQueryResult implements Parcelable {
     */
    @NonNull
    public List<RcsParticipant> getParticipants() {
        List<RcsParticipant> participantList = new ArrayList<>();
        for (Integer participantId : mParticipants) {
            participantList.add(new RcsParticipant(participantId));
        }

        return participantList;
    }

    private RcsParticipantQueryResult(Parcel in) {
        mContinuationToken = in.readParcelable(
                RcsQueryContinuationToken.class.getClassLoader());
    }

    public static final @android.annotation.NonNull Creator<RcsParticipantQueryResult> CREATOR =
            new Creator<RcsParticipantQueryResult>() {
                @Override
                public RcsParticipantQueryResult createFromParcel(Parcel in) {
                    return new RcsParticipantQueryResult(in);
                }

                @Override
                public RcsParticipantQueryResult[] newArray(int size) {
                    return new RcsParticipantQueryResult[size];
                }
            };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(mContinuationToken, flags);
        return mRcsParticipantQueryResultParcelable.mParticipantIds.stream()
                .map(RcsParticipant::new)
                .collect(Collectors.toList());
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -17,4 +17,4 @@

package android.telephony.ims;

parcelable RcsParticipantQueryResult;
parcelable RcsParticipantQueryResultParcelable;
+68 −0
Original line number Diff line number Diff line
/*
 * 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);
    }
}
Loading