diff options
32 files changed, 672 insertions, 391 deletions
diff --git a/api/current.txt b/api/current.txt index 172140fd653f..ebcc1d7584a6 100755 --- a/api/current.txt +++ b/api/current.txt @@ -43604,12 +43604,9 @@ package android.telephony.ims { @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) @IntDef({android.telephony.ims.RcsEventQueryParams.SORT_BY_CREATION_ORDER, android.telephony.ims.RcsEventQueryParams.SORT_BY_TIMESTAMP}) public static @interface RcsEventQueryParams.SortingProperty { } - public final class RcsEventQueryResult implements android.os.Parcelable { - method public int describeContents(); + public class RcsEventQueryResult { method public android.telephony.ims.RcsQueryContinuationToken getContinuationToken(); method public java.util.List<android.telephony.ims.RcsEvent> getEvents(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsEventQueryResult> CREATOR; } public final class RcsFileTransferCreationParams implements android.os.Parcelable { @@ -43704,37 +43701,25 @@ package android.telephony.ims { method @NonNull public android.telephony.ims.RcsGroupThread getRcsGroupThread(); } - public final class RcsGroupThreadIconChangedEvent extends android.telephony.ims.RcsGroupThreadEvent implements android.os.Parcelable { + public final class RcsGroupThreadIconChangedEvent extends android.telephony.ims.RcsGroupThreadEvent { ctor public RcsGroupThreadIconChangedEvent(long, @NonNull android.telephony.ims.RcsGroupThread, @NonNull android.telephony.ims.RcsParticipant, @Nullable android.net.Uri); - method public int describeContents(); method @Nullable public android.net.Uri getNewIcon(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsGroupThreadIconChangedEvent> CREATOR; } - public final class RcsGroupThreadNameChangedEvent extends android.telephony.ims.RcsGroupThreadEvent implements android.os.Parcelable { + public final class RcsGroupThreadNameChangedEvent extends android.telephony.ims.RcsGroupThreadEvent { ctor public RcsGroupThreadNameChangedEvent(long, @NonNull android.telephony.ims.RcsGroupThread, @NonNull android.telephony.ims.RcsParticipant, @Nullable String); - method public int describeContents(); method @Nullable public String getNewName(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsGroupThreadNameChangedEvent> CREATOR; } - public final class RcsGroupThreadParticipantJoinedEvent extends android.telephony.ims.RcsGroupThreadEvent implements android.os.Parcelable { + public final class RcsGroupThreadParticipantJoinedEvent extends android.telephony.ims.RcsGroupThreadEvent { ctor public RcsGroupThreadParticipantJoinedEvent(long, @NonNull android.telephony.ims.RcsGroupThread, @NonNull android.telephony.ims.RcsParticipant, @NonNull android.telephony.ims.RcsParticipant); - method public int describeContents(); method public android.telephony.ims.RcsParticipant getJoinedParticipant(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsGroupThreadParticipantJoinedEvent> CREATOR; } - public final class RcsGroupThreadParticipantLeftEvent extends android.telephony.ims.RcsGroupThreadEvent implements android.os.Parcelable { + public final class RcsGroupThreadParticipantLeftEvent extends android.telephony.ims.RcsGroupThreadEvent { ctor public RcsGroupThreadParticipantLeftEvent(long, @NonNull android.telephony.ims.RcsGroupThread, @NonNull android.telephony.ims.RcsParticipant, @NonNull android.telephony.ims.RcsParticipant); - method public int describeContents(); - method @NonNull public android.telephony.ims.RcsParticipant getLeavingParticipantId(); + method @NonNull public android.telephony.ims.RcsParticipant getLeavingParticipant(); method public void persist() throws android.telephony.ims.RcsMessageStoreException; - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsGroupThreadParticipantLeftEvent> CREATOR; } public class RcsIncomingMessage extends android.telephony.ims.RcsMessage { @@ -43926,13 +43911,10 @@ package android.telephony.ims { method @WorkerThread public void setContactId(String) throws android.telephony.ims.RcsMessageStoreException; } - public final class RcsParticipantAliasChangedEvent extends android.telephony.ims.RcsEvent implements android.os.Parcelable { + public final class RcsParticipantAliasChangedEvent extends android.telephony.ims.RcsEvent { ctor public RcsParticipantAliasChangedEvent(long, @NonNull android.telephony.ims.RcsParticipant, @Nullable String); - method public int describeContents(); method @Nullable public String getNewAlias(); - method @NonNull public android.telephony.ims.RcsParticipant getParticipantId(); - method public void writeToParcel(android.os.Parcel, int); - field public static final android.os.Parcelable.Creator<android.telephony.ims.RcsParticipantAliasChangedEvent> CREATOR; + method @NonNull public android.telephony.ims.RcsParticipant getParticipant(); } public final class RcsParticipantQueryParams implements android.os.Parcelable { diff --git a/telephony/java/android/telephony/ims/RcsEvent.java b/telephony/java/android/telephony/ims/RcsEvent.java index df62277f9ac1..a547c5c00141 100644 --- a/telephony/java/android/telephony/ims/RcsEvent.java +++ b/telephony/java/android/telephony/ims/RcsEvent.java @@ -15,16 +15,11 @@ */ package android.telephony.ims; -import android.os.Parcel; - /** * The base class for events that can happen on {@link RcsParticipant}s and {@link RcsThread}s. */ public abstract class RcsEvent { - /** - * @hide - */ - protected final long mTimestamp; + private final long mTimestamp; protected RcsEvent(long timestamp) { mTimestamp = timestamp; @@ -44,18 +39,4 @@ public abstract class RcsEvent { * @hide */ abstract void persist() throws RcsMessageStoreException; - - /** - * @hide - */ - RcsEvent(Parcel in) { - mTimestamp = in.readLong(); - } - - /** - * @hide - */ - public void writeToParcel(Parcel dest, int flags) { - dest.writeLong(mTimestamp); - } } diff --git a/telephony/java/android/telephony/ims/RcsEvent.aidl b/telephony/java/android/telephony/ims/RcsEventDescriptor.aidl index 08974e0a771c..ab1c55ec984f 100644 --- a/telephony/java/android/telephony/ims/RcsEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsEventDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsEvent; +parcelable RcsEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsEventDescriptor.java b/telephony/java/android/telephony/ims/RcsEventDescriptor.java new file mode 100644 index 000000000000..8e3f6cd4d889 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsEventDescriptor.java @@ -0,0 +1,56 @@ +/* + * 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(); + + RcsEventDescriptor(Parcel in) { + mTimestamp = in.readLong(); + } + + @Override + public void writeToParcel(Parcel dest, int flags) { + dest.writeLong(mTimestamp); + } + + @Override + public int describeContents() { + return 0; + } +} diff --git a/telephony/java/android/telephony/ims/RcsEventQueryResult.java b/telephony/java/android/telephony/ims/RcsEventQueryResult.java index c30e4ccd7aa2..92bda813f93e 100644 --- a/telephony/java/android/telephony/ims/RcsEventQueryResult.java +++ b/telephony/java/android/telephony/ims/RcsEventQueryResult.java @@ -16,9 +16,6 @@ package android.telephony.ims; -import android.os.Parcel; -import android.os.Parcelable; - import java.util.List; /** @@ -26,7 +23,7 @@ import java.util.List; * 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. */ -public final class RcsEventQueryResult implements Parcelable { +public class RcsEventQueryResult { private RcsQueryContinuationToken mContinuationToken; private List<RcsEvent> mEvents; @@ -60,30 +57,4 @@ public final class RcsEventQueryResult implements Parcelable { public List<RcsEvent> getEvents() { return mEvents; } - - private RcsEventQueryResult(Parcel in) { - mContinuationToken = in.readParcelable(RcsQueryContinuationToken.class.getClassLoader()); - } - - public static final Creator<RcsEventQueryResult> CREATOR = new Creator<RcsEventQueryResult>() { - @Override - public RcsEventQueryResult createFromParcel(Parcel in) { - return new RcsEventQueryResult(in); - } - - @Override - public RcsEventQueryResult[] newArray(int size) { - return new RcsEventQueryResult[size]; - } - }; - - @Override - public int describeContents() { - return 0; - } - - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeParcelable(mContinuationToken, flags); - } } diff --git a/telephony/java/android/telephony/ims/RcsEventQueryResult.aidl b/telephony/java/android/telephony/ims/RcsEventQueryResultDescriptor.aidl index 7d133350973c..0beaaab4f639 100644 --- a/telephony/java/android/telephony/ims/RcsEventQueryResult.aidl +++ b/telephony/java/android/telephony/ims/RcsEventQueryResultDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsEventQueryResult; +parcelable RcsEventQueryResultDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsEventQueryResultDescriptor.java b/telephony/java/android/telephony/ims/RcsEventQueryResultDescriptor.java new file mode 100644 index 000000000000..bba56d319f25 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsEventQueryResultDescriptor.java @@ -0,0 +1,79 @@ +/* + * 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() { + List<RcsEvent> rcsEvents = mEvents.stream() + .map(RcsEventDescriptor::createRcsEvent) + .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 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadEvent.java b/telephony/java/android/telephony/ims/RcsGroupThreadEvent.java index 609b1740a536..99086aaef676 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadEvent.java +++ b/telephony/java/android/telephony/ims/RcsGroupThreadEvent.java @@ -16,7 +16,6 @@ package android.telephony.ims; import android.annotation.NonNull; -import android.os.Parcel; /** * An event that happened on an {@link RcsGroupThread}. @@ -47,22 +46,4 @@ public abstract class RcsGroupThreadEvent extends RcsEvent { public RcsParticipant getOriginatingParticipant() { return new RcsParticipant(mOriginatingParticipantId); } - - /** - * @hide - */ - RcsGroupThreadEvent(Parcel in) { - super(in); - mRcsGroupThreadId = in.readInt(); - mOriginatingParticipantId = in.readInt(); - } - - /** - * @hide - */ - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeInt(mRcsGroupThreadId); - dest.writeInt(mOriginatingParticipantId); - } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadEvent.aidl b/telephony/java/android/telephony/ims/RcsGroupThreadEventDescriptor.aidl index 77a23722f080..6299d8a5eb71 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsGroupThreadEventDescriptor.aidl @@ -16,4 +16,4 @@ package android.telephony.ims; -parcelable RcsGroupThreadEvent; +parcelable RcsGroupThreadEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadEventDescriptor.java b/telephony/java/android/telephony/ims/RcsGroupThreadEventDescriptor.java new file mode 100644 index 000000000000..662a264b6d67 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsGroupThreadEventDescriptor.java @@ -0,0 +1,46 @@ +/* + * 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.java b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.java index e768439d6cfa..cbd762d3032b 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.java +++ b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.java @@ -18,15 +18,12 @@ package android.telephony.ims; import android.annotation.NonNull; import android.annotation.Nullable; import android.net.Uri; -import android.os.Parcel; -import android.os.Parcelable; /** * 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) */ -public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent implements - Parcelable { +public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent { private final Uri mNewIcon; /** @@ -48,15 +45,6 @@ public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent im } /** - * @hide - internal constructor for queries - */ - public RcsGroupThreadIconChangedEvent(long timestamp, int rcsGroupThreadId, - int originatingParticipantId, @Nullable Uri newIcon) { - super(timestamp, rcsGroupThreadId, originatingParticipantId); - mNewIcon = newIcon; - } - - /** * @return Returns the {@link Uri} to the icon of the {@link RcsGroupThread} after this * {@link RcsGroupThreadIconChangedEvent} occured. */ @@ -77,33 +65,4 @@ public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent im getTimestamp(), getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), mNewIcon)); } - - public static final Creator<RcsGroupThreadIconChangedEvent> CREATOR = - new Creator<RcsGroupThreadIconChangedEvent>() { - @Override - public RcsGroupThreadIconChangedEvent createFromParcel(Parcel in) { - return new RcsGroupThreadIconChangedEvent(in); - } - - @Override - public RcsGroupThreadIconChangedEvent[] newArray(int size) { - return new RcsGroupThreadIconChangedEvent[size]; - } - }; - - private RcsGroupThreadIconChangedEvent(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); - } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.aidl b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEventDescriptor.aidl index daea7922f3df..4bcc5a043acd 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEventDescriptor.aidl @@ -16,4 +16,4 @@ package android.telephony.ims; -parcelable RcsGroupThreadIconChangedEvent; +parcelable RcsGroupThreadIconChangedEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEventDescriptor.java b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEventDescriptor.java new file mode 100644 index 000000000000..b7fe4b230d31 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsGroupThreadIconChangedEventDescriptor.java @@ -0,0 +1,73 @@ +/* + * 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.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() { + return new RcsGroupThreadIconChangedEvent(mTimestamp, new RcsGroupThread(mRcsGroupThreadId), + new RcsParticipant(mOriginatingParticipantId), mNewIcon); + } + + public static final 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.java b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.java index 02030bc6a2ec..a2a4fab4f3d2 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.java +++ b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.java @@ -17,15 +17,12 @@ package android.telephony.ims; import android.annotation.NonNull; import android.annotation.Nullable; -import android.os.Parcel; -import android.os.Parcelable; /** * 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) */ -public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent implements - Parcelable { +public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent { private final String mNewName; /** @@ -47,15 +44,6 @@ public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent im } /** - * @hide - internal constructor for queries - */ - public RcsGroupThreadNameChangedEvent(long timestamp, int rcsGroupThreadId, - int originatingParticipantId, @Nullable String newName) { - super(timestamp, rcsGroupThreadId, originatingParticipantId); - mNewName = newName; - } - - /** * @return Returns the name of this {@link RcsGroupThread} after this * {@link RcsGroupThreadNameChangedEvent} happened. */ @@ -75,33 +63,4 @@ public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent im getTimestamp(), getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), mNewName)); } - - public static final Creator<RcsGroupThreadNameChangedEvent> CREATOR = - new Creator<RcsGroupThreadNameChangedEvent>() { - @Override - public RcsGroupThreadNameChangedEvent createFromParcel(Parcel in) { - return new RcsGroupThreadNameChangedEvent(in); - } - - @Override - public RcsGroupThreadNameChangedEvent[] newArray(int size) { - return new RcsGroupThreadNameChangedEvent[size]; - } - }; - - private RcsGroupThreadNameChangedEvent(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); - } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.aidl b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEventDescriptor.aidl index 3ed9bd11dc70..480e86b73ea9 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEventDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsGroupThreadNameChangedEvent; +parcelable RcsGroupThreadNameChangedEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEventDescriptor.java b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEventDescriptor.java new file mode 100644 index 000000000000..4ec641f7a15f --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsGroupThreadNameChangedEventDescriptor.java @@ -0,0 +1,75 @@ +/* + * 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.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() { + return new RcsGroupThreadNameChangedEvent( + mTimestamp, + new RcsGroupThread(mRcsGroupThreadId), + new RcsParticipant(mOriginatingParticipantId), + mNewName); + } + + public static final 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.java b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.java index 0d1a5730f0a0..183cd9a81431 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.java +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.java @@ -16,16 +16,13 @@ package android.telephony.ims; import android.annotation.NonNull; -import android.os.Parcel; -import android.os.Parcelable; /** * 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) */ -public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEvent implements - Parcelable { - private final int mJoinedParticipantId; +public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEvent { + private final RcsParticipant mJoinedParticipantId; /** * Creates a new {@link RcsGroupThreadParticipantJoinedEvent}. This event is not persisted into @@ -44,23 +41,14 @@ public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEv @NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant, @NonNull RcsParticipant joinedParticipant) { super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); - mJoinedParticipantId = joinedParticipant.getId(); - } - - /** - * @hide - internal constructor for queries - */ - public RcsGroupThreadParticipantJoinedEvent(long timestamp, int rcsGroupThreadId, - int originatingParticipantId, int joinedParticipantId) { - super(timestamp, rcsGroupThreadId, originatingParticipantId); - mJoinedParticipantId = joinedParticipantId; + mJoinedParticipantId = joinedParticipant; } /** * @return Returns the {@link RcsParticipant} that joined the associated {@link RcsGroupThread} */ public RcsParticipant getJoinedParticipant() { - return new RcsParticipant(mJoinedParticipantId); + return mJoinedParticipantId; } /** @@ -75,33 +63,4 @@ public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEv getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), getJoinedParticipant().getId())); } - - public static final Creator<RcsGroupThreadParticipantJoinedEvent> CREATOR = - new Creator<RcsGroupThreadParticipantJoinedEvent>() { - @Override - public RcsGroupThreadParticipantJoinedEvent createFromParcel(Parcel in) { - return new RcsGroupThreadParticipantJoinedEvent(in); - } - - @Override - public RcsGroupThreadParticipantJoinedEvent[] newArray(int size) { - return new RcsGroupThreadParticipantJoinedEvent[size]; - } - }; - - private RcsGroupThreadParticipantJoinedEvent(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); - } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.aidl b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEventDescriptor.aidl index 420abffa067a..7210b9f2fab1 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEventDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsGroupThreadParticipantJoinedEvent; +parcelable RcsGroupThreadParticipantJoinedEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEventDescriptor.java b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEventDescriptor.java new file mode 100644 index 000000000000..a4218c293bec --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantJoinedEventDescriptor.java @@ -0,0 +1,74 @@ +/* + * 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 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() { + return new RcsGroupThreadParticipantJoinedEvent( + mTimestamp, + new RcsGroupThread(mRcsGroupThreadId), + new RcsParticipant(mOriginatingParticipantId), + new RcsParticipant(mJoinedParticipantId)); + } + + public static final 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.java b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.java index cd525086749a..c12549b5acbf 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.java +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.java @@ -16,16 +16,13 @@ package android.telephony.ims; import android.annotation.NonNull; -import android.os.Parcel; -import android.os.Parcelable; /** * 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) */ -public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEvent implements - Parcelable { - private final int mLeavingParticipantId; +public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEvent { + private RcsParticipant mLeavingParticipant; /** * Creates a new {@link RcsGroupThreadParticipantLeftEvent}. his event is not persisted into @@ -46,16 +43,7 @@ public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEven @NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant, @NonNull RcsParticipant leavingParticipant) { super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); - mLeavingParticipantId = leavingParticipant.getId(); - } - - /** - * @hide - internal constructor for queries - */ - public RcsGroupThreadParticipantLeftEvent(long timestamp, int rcsGroupThreadId, - int originatingParticipantId, int leavingParticipantId) { - super(timestamp, rcsGroupThreadId, originatingParticipantId); - mLeavingParticipantId = leavingParticipantId; + mLeavingParticipant = leavingParticipant; } /** @@ -63,44 +51,15 @@ public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEven * after this {@link RcsGroupThreadParticipantLeftEvent} happened. */ @NonNull - public RcsParticipant getLeavingParticipantId() { - return new RcsParticipant(mLeavingParticipantId); + public RcsParticipant getLeavingParticipant() { + return mLeavingParticipant; } @Override public void persist() throws RcsMessageStoreException { RcsControllerCall.call( - iRcs -> iRcs.createGroupThreadParticipantJoinedEvent(getTimestamp(), + iRcs -> iRcs.createGroupThreadParticipantLeftEvent(getTimestamp(), getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), - getLeavingParticipantId().getId())); - } - - public static final Creator<RcsGroupThreadParticipantLeftEvent> CREATOR = - new Creator<RcsGroupThreadParticipantLeftEvent>() { - @Override - public RcsGroupThreadParticipantLeftEvent createFromParcel(Parcel in) { - return new RcsGroupThreadParticipantLeftEvent(in); - } - - @Override - public RcsGroupThreadParticipantLeftEvent[] newArray(int size) { - return new RcsGroupThreadParticipantLeftEvent[size]; - } - }; - - private RcsGroupThreadParticipantLeftEvent(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); + getLeavingParticipant().getId())); } } diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.aidl b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEventDescriptor.aidl index ff139ac0ab1e..3ef921001ce7 100644 --- a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEventDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsGroupThreadParticipantLeftEvent; +parcelable RcsGroupThreadParticipantLeftEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEventDescriptor.java b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEventDescriptor.java new file mode 100644 index 000000000000..8e91dda1a60f --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsGroupThreadParticipantLeftEventDescriptor.java @@ -0,0 +1,75 @@ +/* + * 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 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() { + return new RcsGroupThreadParticipantLeftEvent( + mTimestamp, + new RcsGroupThread(mRcsGroupThreadId), + new RcsParticipant(mOriginatingParticipantId), + new RcsParticipant(mLeavingParticipantId)); + } + + 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); + } +} diff --git a/telephony/java/android/telephony/ims/RcsMessageStore.java b/telephony/java/android/telephony/ims/RcsMessageStore.java index d811c6e93a56..31f2983dcf93 100644 --- a/telephony/java/android/telephony/ims/RcsMessageStore.java +++ b/telephony/java/android/telephony/ims/RcsMessageStore.java @@ -118,15 +118,16 @@ public class RcsMessageStore { /** * Returns the first chunk of existing {@link RcsEvent}s in the common storage. * - * @param queryParameters Parameters to specify to return a subset of all RcsEvents. + * @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 queryParameters) throws RcsMessageStoreException { - return RcsControllerCall.call(iRcs -> iRcs.getEvents(queryParameters)); + @Nullable RcsEventQueryParams queryParams) throws RcsMessageStoreException { + return RcsControllerCall.call(iRcs -> iRcs.getEvents(queryParams)) + .getRcsEventQueryResult(); } /** @@ -140,7 +141,8 @@ public class RcsMessageStore { @NonNull public RcsEventQueryResult getRcsEvents( @NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException { - return RcsControllerCall.call(iRcs -> iRcs.getEventsWithToken(continuationToken)); + return RcsControllerCall.call(iRcs -> iRcs.getEventsWithToken(continuationToken)) + .getRcsEventQueryResult(); } /** diff --git a/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.java b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.java index c9a2b0d07bc8..cc2613f9e684 100644 --- a/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.java +++ b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.java @@ -17,16 +17,14 @@ package android.telephony.ims; import android.annotation.NonNull; import android.annotation.Nullable; -import android.os.Parcel; -import android.os.Parcelable; /** * An event that indicates an {@link RcsParticipant}'s alias was changed. Please see US18-2 - GSMA * RCC.71 (RCS Universal Profile Service Definition Document) */ -public final class RcsParticipantAliasChangedEvent extends RcsEvent implements Parcelable { - // The ID of the participant that changed their alias - private final int mParticipantId; +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; @@ -43,17 +41,7 @@ public final class RcsParticipantAliasChangedEvent extends RcsEvent implements P public RcsParticipantAliasChangedEvent(long timestamp, @NonNull RcsParticipant participant, @Nullable String newAlias) { super(timestamp); - mParticipantId = participant.getId(); - mNewAlias = newAlias; - } - - /** - * @hide - internal constructor for queries - */ - public RcsParticipantAliasChangedEvent(long timestamp, int participantId, - @Nullable String newAlias) { - super(timestamp); - mParticipantId = participantId; + mParticipant = participant; mNewAlias = newAlias; } @@ -61,8 +49,8 @@ public final class RcsParticipantAliasChangedEvent extends RcsEvent implements P * @return Returns the {@link RcsParticipant} whose alias was changed. */ @NonNull - public RcsParticipant getParticipantId() { - return new RcsParticipant(mParticipantId); + public RcsParticipant getParticipant() { + return mParticipant; } /** @@ -81,37 +69,6 @@ public final class RcsParticipantAliasChangedEvent extends RcsEvent implements P @Override public void persist() throws RcsMessageStoreException { RcsControllerCall.call(iRcs -> iRcs.createParticipantAliasChangedEvent( - getTimestamp(), getParticipantId().getId(), getNewAlias())); - } - - public static final Creator<RcsParticipantAliasChangedEvent> CREATOR = - new Creator<RcsParticipantAliasChangedEvent>() { - @Override - public RcsParticipantAliasChangedEvent createFromParcel(Parcel in) { - return new RcsParticipantAliasChangedEvent(in); - } - - @Override - public RcsParticipantAliasChangedEvent[] newArray(int size) { - return new RcsParticipantAliasChangedEvent[size]; - } - }; - - private RcsParticipantAliasChangedEvent(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); + getTimestamp(), getParticipant().getId(), getNewAlias())); } } diff --git a/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.aidl b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEventDescriptor.aidl index b9d819054527..64fe3b891572 100644 --- a/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEvent.aidl +++ b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEventDescriptor.aidl @@ -17,4 +17,4 @@ package android.telephony.ims; -parcelable RcsParticipantAliasChangedEvent; +parcelable RcsParticipantAliasChangedEventDescriptor; diff --git a/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEventDescriptor.java b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEventDescriptor.java new file mode 100644 index 000000000000..a32e5522c851 --- /dev/null +++ b/telephony/java/android/telephony/ims/RcsParticipantAliasChangedEventDescriptor.java @@ -0,0 +1,78 @@ +/* + * 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.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() { + return new RcsParticipantAliasChangedEvent( + mTimestamp, new RcsParticipant(mParticipantId), mNewAlias); + } + + public static final 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); + } +} diff --git a/telephony/java/android/telephony/ims/aidl/IRcs.aidl b/telephony/java/android/telephony/ims/aidl/IRcs.aidl index 2478f8cff6b7..6ab01c2a0eea 100644 --- a/telephony/java/android/telephony/ims/aidl/IRcs.aidl +++ b/telephony/java/android/telephony/ims/aidl/IRcs.aidl @@ -18,7 +18,7 @@ package android.telephony.ims.aidl; import android.net.Uri; import android.telephony.ims.RcsEventQueryParams; -import android.telephony.ims.RcsEventQueryResult; +import android.telephony.ims.RcsEventQueryResultDescriptor; import android.telephony.ims.RcsFileTransferCreationParams; import android.telephony.ims.RcsIncomingMessageCreationParams; import android.telephony.ims.RcsMessageSnippet; @@ -54,9 +54,9 @@ interface IRcs { RcsMessageQueryResult getMessagesWithToken( in RcsQueryContinuationToken continuationToken); - RcsEventQueryResult getEvents(in RcsEventQueryParams queryParams); + RcsEventQueryResultDescriptor getEvents(in RcsEventQueryParams queryParams); - RcsEventQueryResult getEventsWithToken( + RcsEventQueryResultDescriptor getEventsWithToken( in RcsQueryContinuationToken continuationToken); // returns true if the thread was successfully deleted diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java index 915a260f5c79..89d32ab5a925 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadIconChangedEventTest.java @@ -20,9 +20,8 @@ import static com.google.common.truth.Truth.assertThat; import android.net.Uri; import android.os.Parcel; import android.support.test.runner.AndroidJUnit4; -import android.telephony.ims.RcsGroupThread; import android.telephony.ims.RcsGroupThreadIconChangedEvent; -import android.telephony.ims.RcsParticipant; +import android.telephony.ims.RcsGroupThreadIconChangedEventDescriptor; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +31,27 @@ public class RcsGroupThreadIconChangedEventTest { @Test public void testCanUnparcel() { - RcsGroupThread rcsGroupThread = new RcsGroupThread(1); - RcsParticipant rcsParticipant = new RcsParticipant(2); + int rcsGroupThreadId = 1; + int rcsParticipantId = 2; Uri newIconUri = Uri.parse("content://new_icon"); - RcsGroupThreadIconChangedEvent iconChangedEvent = - new RcsGroupThreadIconChangedEvent(1234567890, rcsGroupThread, rcsParticipant, - newIconUri); + RcsGroupThreadIconChangedEventDescriptor iconChangedEventDescriptor = + new RcsGroupThreadIconChangedEventDescriptor(1234567890, rcsGroupThreadId, + rcsParticipantId, newIconUri); Parcel parcel = Parcel.obtain(); - iconChangedEvent.writeToParcel(parcel, iconChangedEvent.describeContents()); + iconChangedEventDescriptor.writeToParcel( + parcel, iconChangedEventDescriptor.describeContents()); parcel.setDataPosition(0); - iconChangedEvent = RcsGroupThreadIconChangedEvent.CREATOR.createFromParcel(parcel); + iconChangedEventDescriptor = + RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel); + + RcsGroupThreadIconChangedEvent iconChangedEvent = + iconChangedEventDescriptor.createRcsEvent(); + + assertThat(iconChangedEvent.getNewIcon()).isEqualTo(newIconUri); assertThat(iconChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java index 1384c016daa8..726b9cd6641f 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadNameChangedEventTest.java @@ -19,9 +19,8 @@ import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import android.support.test.runner.AndroidJUnit4; -import android.telephony.ims.RcsGroupThread; import android.telephony.ims.RcsGroupThreadNameChangedEvent; -import android.telephony.ims.RcsParticipant; +import android.telephony.ims.RcsGroupThreadNameChangedEventDescriptor; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,20 +31,24 @@ public class RcsGroupThreadNameChangedEventTest { public void testCanUnparcel() { String newName = "new name"; - RcsGroupThread rcsGroupThread = new RcsGroupThread(1); - RcsParticipant rcsParticipant = new RcsParticipant(2); + int rcsGroupThreadId = 1; + int rcsParticipantId = 2; - RcsGroupThreadNameChangedEvent nameChangedEvent = - new RcsGroupThreadNameChangedEvent(1234567890, rcsGroupThread, rcsParticipant, - newName); + RcsGroupThreadNameChangedEventDescriptor nameChangedEventDescriptor = + new RcsGroupThreadNameChangedEventDescriptor( + 1234567890, rcsGroupThreadId, rcsParticipantId, newName); Parcel parcel = Parcel.obtain(); - nameChangedEvent.writeToParcel(parcel, nameChangedEvent.describeContents()); + nameChangedEventDescriptor.writeToParcel( + parcel, nameChangedEventDescriptor.describeContents()); parcel.setDataPosition(0); - nameChangedEvent = RcsGroupThreadNameChangedEvent.CREATOR.createFromParcel( - parcel); + nameChangedEventDescriptor = RcsGroupThreadNameChangedEventDescriptor.CREATOR + .createFromParcel(parcel); + + RcsGroupThreadNameChangedEvent nameChangedEvent = + nameChangedEventDescriptor.createRcsEvent(); assertThat(nameChangedEvent.getNewName()).isEqualTo(newName); assertThat(nameChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java index d0af7db90627..a109310076d2 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantJoinedEventTest.java @@ -19,9 +19,8 @@ import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import android.support.test.runner.AndroidJUnit4; -import android.telephony.ims.RcsGroupThread; import android.telephony.ims.RcsGroupThreadParticipantJoinedEvent; -import android.telephony.ims.RcsParticipant; +import android.telephony.ims.RcsGroupThreadParticipantJoinedEventDescriptor; import org.junit.Test; import org.junit.runner.RunWith; @@ -31,20 +30,24 @@ public class RcsGroupThreadParticipantJoinedEventTest { @Test public void testCanUnparcel() { - RcsGroupThread rcsGroupThread = new RcsGroupThread(1); - RcsParticipant rcsParticipant = new RcsParticipant(2); + int rcsGroupThreadId = 1; + int rcsParticipantId = 2; - RcsGroupThreadParticipantJoinedEvent participantJoinedEvent = - new RcsGroupThreadParticipantJoinedEvent(1234567890, rcsGroupThread, rcsParticipant, - rcsParticipant); + RcsGroupThreadParticipantJoinedEventDescriptor participantJoinedEventDescriptor = + new RcsGroupThreadParticipantJoinedEventDescriptor( + 1234567890, rcsGroupThreadId, rcsParticipantId, rcsParticipantId); Parcel parcel = Parcel.obtain(); - participantJoinedEvent.writeToParcel(parcel, participantJoinedEvent.describeContents()); + participantJoinedEventDescriptor.writeToParcel( + parcel, participantJoinedEventDescriptor.describeContents()); parcel.setDataPosition(0); - participantJoinedEvent = RcsGroupThreadParticipantJoinedEvent.CREATOR.createFromParcel( - parcel); + participantJoinedEventDescriptor = RcsGroupThreadParticipantJoinedEventDescriptor.CREATOR + .createFromParcel(parcel); + + RcsGroupThreadParticipantJoinedEvent participantJoinedEvent = + participantJoinedEventDescriptor.createRcsEvent(); assertThat(participantJoinedEvent.getJoinedParticipant().getId()).isEqualTo(2); assertThat(participantJoinedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java index 7ba5fa653258..de2688c5b8c8 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsGroupThreadParticipantLeftEventTest.java @@ -19,9 +19,8 @@ import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import android.support.test.runner.AndroidJUnit4; -import android.telephony.ims.RcsGroupThread; import android.telephony.ims.RcsGroupThreadParticipantLeftEvent; -import android.telephony.ims.RcsParticipant; +import android.telephony.ims.RcsGroupThreadParticipantLeftEventDescriptor; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,24 +29,29 @@ import org.junit.runner.RunWith; public class RcsGroupThreadParticipantLeftEventTest { @Test public void testCanUnparcel() { - RcsGroupThread rcsGroupThread = new RcsGroupThread(1); - RcsParticipant rcsParticipant = new RcsParticipant(2); + int rcsGroupThreadId = 1; + int rcsParticipantId = 2; - RcsGroupThreadParticipantLeftEvent participantLeftEvent = - new RcsGroupThreadParticipantLeftEvent(1234567890, rcsGroupThread, rcsParticipant, - rcsParticipant); + RcsGroupThreadParticipantLeftEventDescriptor participantLeftEventDescriptor = + new RcsGroupThreadParticipantLeftEventDescriptor( + 1234567890, rcsGroupThreadId, rcsParticipantId, rcsParticipantId); Parcel parcel = Parcel.obtain(); - participantLeftEvent.writeToParcel(parcel, participantLeftEvent.describeContents()); + participantLeftEventDescriptor.writeToParcel( + parcel, participantLeftEventDescriptor.describeContents()); parcel.setDataPosition(0); // create from parcel parcel.setDataPosition(0); - participantLeftEvent = RcsGroupThreadParticipantLeftEvent.CREATOR.createFromParcel( - parcel); + participantLeftEventDescriptor = RcsGroupThreadParticipantLeftEventDescriptor.CREATOR + .createFromParcel(parcel); + + RcsGroupThreadParticipantLeftEvent participantLeftEvent = + participantLeftEventDescriptor.createRcsEvent(); + assertThat(participantLeftEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); - assertThat(participantLeftEvent.getLeavingParticipantId().getId()).isEqualTo(2); + assertThat(participantLeftEvent.getLeavingParticipant().getId()).isEqualTo(2); assertThat(participantLeftEvent.getTimestamp()).isEqualTo(1234567890); } } diff --git a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java index 3e2bbbf8256c..57240545e5d8 100644 --- a/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java +++ b/tests/RcsTests/src/com/android/tests/ims/RcsParticipantAliasChangedEventTest.java @@ -19,10 +19,9 @@ import static com.google.common.truth.Truth.assertThat; import android.os.Parcel; import android.support.test.runner.AndroidJUnit4; -import android.telephony.ims.RcsParticipant; import android.telephony.ims.RcsParticipantAliasChangedEvent; +import android.telephony.ims.RcsParticipantAliasChangedEventDescriptor; -import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -30,27 +29,27 @@ import org.junit.runner.RunWith; public class RcsParticipantAliasChangedEventTest { private static final String OLD_ALIAS = "old alias"; private static final String NEW_ALIAS = "new alias"; - private RcsParticipant mParticipant; - - @Before - public void setUp() { - mParticipant = new RcsParticipant(3); - } + private int mParticipantId = 3; @Test public void testCanUnparcel() { - RcsParticipantAliasChangedEvent aliasChangedEvent = - new RcsParticipantAliasChangedEvent(1234567890, mParticipant, NEW_ALIAS); + RcsParticipantAliasChangedEventDescriptor aliasChangedEventDescriptor = + new RcsParticipantAliasChangedEventDescriptor( + 1234567890, mParticipantId, NEW_ALIAS); Parcel parcel = Parcel.obtain(); - aliasChangedEvent.writeToParcel(parcel, aliasChangedEvent.describeContents()); + aliasChangedEventDescriptor.writeToParcel( + parcel, aliasChangedEventDescriptor.describeContents()); parcel.setDataPosition(0); - aliasChangedEvent = RcsParticipantAliasChangedEvent.CREATOR.createFromParcel( - parcel); + aliasChangedEventDescriptor = RcsParticipantAliasChangedEventDescriptor.CREATOR + .createFromParcel(parcel); + + RcsParticipantAliasChangedEvent aliasChangedEvent = + aliasChangedEventDescriptor.createRcsEvent(); - assertThat(aliasChangedEvent.getParticipantId().getId()).isEqualTo(3); + assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId); assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS); assertThat(aliasChangedEvent.getTimestamp()).isEqualTo(1234567890); } |