Merge "Use injected instance of RcsControllerCall"

am: f545515ee6

Change-Id: Id364fe89943027eb1ec9f60b7457126ff8945b16
This commit is contained in:
Leland Miller
2019-04-24 17:15:18 -07:00
committed by android-build-merger
36 changed files with 253 additions and 202 deletions

View File

@@ -555,7 +555,7 @@ final class SystemServiceRegistry {
new CachedServiceFetcher<RcsManager>() { new CachedServiceFetcher<RcsManager>() {
@Override @Override
public RcsManager createService(ContextImpl ctx) { public RcsManager createService(ContextImpl ctx) {
return new RcsManager(); return new RcsManager(ctx.getOuterContext());
} }
}); });

View File

@@ -33,8 +33,8 @@ public class Rcs1To1Thread extends RcsThread {
* *
* @hide * @hide
*/ */
public Rcs1To1Thread(int threadId) { public Rcs1To1Thread(RcsControllerCall rcsControllerCall, int threadId) {
super(threadId); super(rcsControllerCall, threadId);
mThreadId = threadId; mThreadId = threadId;
} }
@@ -56,7 +56,7 @@ public class Rcs1To1Thread extends RcsThread {
*/ */
@WorkerThread @WorkerThread
public long getFallbackThreadId() throws RcsMessageStoreException { public long getFallbackThreadId() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.get1To1ThreadFallbackThreadId(mThreadId)); return mRcsControllerCall.call(iRcs -> iRcs.get1To1ThreadFallbackThreadId(mThreadId));
} }
/** /**
@@ -69,7 +69,7 @@ public class Rcs1To1Thread extends RcsThread {
*/ */
@WorkerThread @WorkerThread
public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException { public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.set1To1ThreadFallbackThreadId(mThreadId, fallbackThreadId)); iRcs -> iRcs.set1To1ThreadFallbackThreadId(mThreadId, fallbackThreadId));
} }
@@ -81,6 +81,7 @@ public class Rcs1To1Thread extends RcsThread {
@WorkerThread @WorkerThread
public RcsParticipant getRecipient() throws RcsMessageStoreException { public RcsParticipant getRecipient() throws RcsMessageStoreException {
return new RcsParticipant( return new RcsParticipant(
RcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId))); mRcsControllerCall,
mRcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId)));
} }
} }

View File

@@ -27,7 +27,13 @@ import android.telephony.ims.aidl.IRcs;
* @hide - not meant for public use * @hide - not meant for public use
*/ */
class RcsControllerCall { class RcsControllerCall {
static <R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException { private final Context mContext;
RcsControllerCall(Context context) {
mContext = context;
}
<R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException {
IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_RCS_SERVICE)); IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_RCS_SERVICE));
if (iRcs == null) { if (iRcs == null) {
throw new RcsMessageStoreException("Could not connect to RCS storage service"); throw new RcsMessageStoreException("Could not connect to RCS storage service");
@@ -40,18 +46,12 @@ class RcsControllerCall {
} }
} }
static void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall) void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
throws RcsMessageStoreException { throws RcsMessageStoreException {
IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_RCS_SERVICE)); call(iRcs -> {
if (iRcs == null) {
throw new RcsMessageStoreException("Could not connect to RCS storage service");
}
try {
serviceCall.methodOnIRcs(iRcs); serviceCall.methodOnIRcs(iRcs);
} catch (RemoteException exception) { return null;
throw new RcsMessageStoreException(exception.getMessage()); });
}
} }
interface RcsServiceCall<R> { interface RcsServiceCall<R> {

View File

@@ -40,5 +40,5 @@ public abstract class RcsEvent {
* *
* @hide * @hide
*/ */
abstract void persist() throws RcsMessageStoreException; abstract void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException;
} }

View File

@@ -38,7 +38,7 @@ public abstract class RcsEventDescriptor implements Parcelable {
* descriptor. * descriptor.
*/ */
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public abstract RcsEvent createRcsEvent(); public abstract RcsEvent createRcsEvent(RcsControllerCall rcsControllerCall);
RcsEventDescriptor(Parcel in) { RcsEventDescriptor(Parcel in) {
mTimestamp = in.readLong(); mTimestamp = in.readLong();

View File

@@ -39,9 +39,9 @@ public class RcsEventQueryResultDescriptor implements Parcelable {
mEvents = events; mEvents = events;
} }
protected RcsEventQueryResult getRcsEventQueryResult() { protected RcsEventQueryResult getRcsEventQueryResult(RcsControllerCall rcsControllerCall) {
List<RcsEvent> rcsEvents = mEvents.stream() List<RcsEvent> rcsEvents = mEvents.stream()
.map(RcsEventDescriptor::createRcsEvent) .map(rcsEvent -> rcsEvent.createRcsEvent(rcsControllerCall))
.collect(Collectors.toList()); .collect(Collectors.toList());
return new RcsEventQueryResult(mContinuationToken, rcsEvents); return new RcsEventQueryResult(mContinuationToken, rcsEvents);

View File

@@ -103,12 +103,15 @@ public class RcsFileTransferPart {
public @interface RcsFileTransferStatus { public @interface RcsFileTransferStatus {
} }
private final RcsControllerCall mRcsControllerCall;
private int mId; private int mId;
/** /**
* @hide * @hide
*/ */
RcsFileTransferPart(int id) { RcsFileTransferPart(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id; mId = id;
} }
@@ -134,7 +137,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setFileTransferSessionId(String sessionId) throws RcsMessageStoreException { public void setFileTransferSessionId(String sessionId) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferSessionId(mId, sessionId)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferSessionId(mId, sessionId));
} }
/** /**
@@ -143,7 +146,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public String getFileTransferSessionId() throws RcsMessageStoreException { public String getFileTransferSessionId() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferSessionId(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferSessionId(mId));
} }
/** /**
@@ -155,7 +158,8 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setContentUri(Uri contentUri) throws RcsMessageStoreException { public void setContentUri(Uri contentUri) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferContentUri(mId, contentUri)); mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferContentUri(mId, contentUri));
} }
/** /**
@@ -165,7 +169,7 @@ public class RcsFileTransferPart {
@Nullable @Nullable
@WorkerThread @WorkerThread
public Uri getContentUri() throws RcsMessageStoreException { public Uri getContentUri() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferContentUri(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferContentUri(mId));
} }
/** /**
@@ -177,7 +181,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setContentMimeType(String contentMimeType) throws RcsMessageStoreException { public void setContentMimeType(String contentMimeType) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferContentType(mId, contentMimeType)); iRcs -> iRcs.setFileTransferContentType(mId, contentMimeType));
} }
@@ -188,7 +192,7 @@ public class RcsFileTransferPart {
@WorkerThread @WorkerThread
@Nullable @Nullable
public String getContentMimeType() throws RcsMessageStoreException { public String getContentMimeType() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferContentType(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferContentType(mId));
} }
/** /**
@@ -199,7 +203,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setFileSize(long contentLength) throws RcsMessageStoreException { public void setFileSize(long contentLength) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferFileSize(mId, contentLength)); iRcs -> iRcs.setFileTransferFileSize(mId, contentLength));
} }
@@ -209,7 +213,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public long getFileSize() throws RcsMessageStoreException { public long getFileSize() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferFileSize(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferFileSize(mId));
} }
/** /**
@@ -222,7 +226,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setTransferOffset(long transferOffset) throws RcsMessageStoreException { public void setTransferOffset(long transferOffset) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferTransferOffset(mId, transferOffset)); iRcs -> iRcs.setFileTransferTransferOffset(mId, transferOffset));
} }
@@ -232,7 +236,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public long getTransferOffset() throws RcsMessageStoreException { public long getTransferOffset() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferTransferOffset(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferTransferOffset(mId));
} }
/** /**
@@ -244,7 +248,7 @@ public class RcsFileTransferPart {
@WorkerThread @WorkerThread
public void setFileTransferStatus(@RcsFileTransferStatus int status) public void setFileTransferStatus(@RcsFileTransferStatus int status)
throws RcsMessageStoreException { throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferStatus(mId, status)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferStatus(mId, status));
} }
/** /**
@@ -253,7 +257,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public @RcsFileTransferStatus int getFileTransferStatus() throws RcsMessageStoreException { public @RcsFileTransferStatus int getFileTransferStatus() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferStatus(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferStatus(mId));
} }
/** /**
@@ -262,7 +266,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public int getWidth() throws RcsMessageStoreException { public int getWidth() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferWidth(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferWidth(mId));
} }
/** /**
@@ -273,7 +277,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setWidth(int width) throws RcsMessageStoreException { public void setWidth(int width) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferWidth(mId, width)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferWidth(mId, width));
} }
/** /**
@@ -282,7 +286,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public int getHeight() throws RcsMessageStoreException { public int getHeight() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferHeight(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferHeight(mId));
} }
/** /**
@@ -293,7 +297,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setHeight(int height) throws RcsMessageStoreException { public void setHeight(int height) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferHeight(mId, height)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferHeight(mId, height));
} }
/** /**
@@ -302,7 +306,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public long getLength() throws RcsMessageStoreException { public long getLength() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferLength(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferLength(mId));
} }
/** /**
@@ -313,7 +317,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setLength(long length) throws RcsMessageStoreException { public void setLength(long length) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferLength(mId, length)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferLength(mId, length));
} }
/** /**
@@ -323,7 +327,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public Uri getPreviewUri() throws RcsMessageStoreException { public Uri getPreviewUri() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewUri(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewUri(mId));
} }
/** /**
@@ -334,7 +338,8 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setPreviewUri(Uri previewUri) throws RcsMessageStoreException { public void setPreviewUri(Uri previewUri) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferPreviewUri(mId, previewUri)); mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferPreviewUri(mId, previewUri));
} }
/** /**
@@ -343,7 +348,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public String getPreviewMimeType() throws RcsMessageStoreException { public String getPreviewMimeType() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewType(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewType(mId));
} }
/** /**
@@ -354,7 +359,7 @@ public class RcsFileTransferPart {
*/ */
@WorkerThread @WorkerThread
public void setPreviewMimeType(String previewMimeType) throws RcsMessageStoreException { public void setPreviewMimeType(String previewMimeType) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setFileTransferPreviewType(mId, previewMimeType)); iRcs -> iRcs.setFileTransferPreviewType(mId, previewMimeType));
} }
} }

View File

@@ -38,8 +38,8 @@ public class RcsGroupThread extends RcsThread {
* *
* @hide * @hide
*/ */
public RcsGroupThread(int threadId) { public RcsGroupThread(RcsControllerCall rcsControllerCall, int threadId) {
super(threadId); super(rcsControllerCall, threadId);
} }
/** /**
@@ -58,7 +58,7 @@ public class RcsGroupThread extends RcsThread {
@Nullable @Nullable
@WorkerThread @WorkerThread
public String getGroupName() throws RcsMessageStoreException { public String getGroupName() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getGroupThreadName(mThreadId)); return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadName(mThreadId));
} }
/** /**
@@ -69,7 +69,7 @@ public class RcsGroupThread extends RcsThread {
*/ */
@WorkerThread @WorkerThread
public void setGroupName(String groupName) throws RcsMessageStoreException { public void setGroupName(String groupName) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadName(mThreadId, groupName)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadName(mThreadId, groupName));
} }
/** /**
@@ -79,7 +79,7 @@ public class RcsGroupThread extends RcsThread {
*/ */
@Nullable @Nullable
public Uri getGroupIcon() throws RcsMessageStoreException { public Uri getGroupIcon() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getGroupThreadIcon(mThreadId)); return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadIcon(mThreadId));
} }
/** /**
@@ -90,7 +90,7 @@ public class RcsGroupThread extends RcsThread {
*/ */
@WorkerThread @WorkerThread
public void setGroupIcon(@Nullable Uri groupIcon) throws RcsMessageStoreException { public void setGroupIcon(@Nullable Uri groupIcon) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadIcon(mThreadId, groupIcon)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadIcon(mThreadId, groupIcon));
} }
/** /**
@@ -100,8 +100,9 @@ public class RcsGroupThread extends RcsThread {
@Nullable @Nullable
@WorkerThread @WorkerThread
public RcsParticipant getOwner() throws RcsMessageStoreException { public RcsParticipant getOwner() throws RcsMessageStoreException {
return new RcsParticipant(RcsControllerCall.call( return new RcsParticipant(
iRcs -> iRcs.getGroupThreadOwner(mThreadId))); mRcsControllerCall,
mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadOwner(mThreadId)));
} }
/** /**
@@ -114,7 +115,7 @@ public class RcsGroupThread extends RcsThread {
*/ */
@WorkerThread @WorkerThread
public void setOwner(@Nullable RcsParticipant participant) throws RcsMessageStoreException { public void setOwner(@Nullable RcsParticipant participant) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setGroupThreadOwner(mThreadId, participant.getId())); iRcs -> iRcs.setGroupThreadOwner(mThreadId, participant.getId()));
} }
@@ -133,7 +134,7 @@ public class RcsGroupThread extends RcsThread {
return; return;
} }
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.addParticipantToGroupThread(mThreadId, participant.getId())); iRcs -> iRcs.addParticipantToGroupThread(mThreadId, participant.getId()));
} }
@@ -150,7 +151,7 @@ public class RcsGroupThread extends RcsThread {
return; return;
} }
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.removeParticipantFromGroupThread(mThreadId, participant.getId())); iRcs -> iRcs.removeParticipantFromGroupThread(mThreadId, participant.getId()));
} }
@@ -170,7 +171,8 @@ public class RcsGroupThread extends RcsThread {
new RcsParticipantQueryParams.Builder().setThread(this).build(); new RcsParticipantQueryParams.Builder().setThread(this).build();
RcsParticipantQueryResult queryResult = new RcsParticipantQueryResult( RcsParticipantQueryResult queryResult = new RcsParticipantQueryResult(
RcsControllerCall.call( mRcsControllerCall,
mRcsControllerCall.call(
iRcs -> iRcs.getParticipants(queryParameters))); iRcs -> iRcs.getParticipants(queryParameters)));
List<RcsParticipant> participantList = queryResult.getParticipants(); List<RcsParticipant> participantList = queryResult.getParticipants();
@@ -187,7 +189,7 @@ public class RcsGroupThread extends RcsThread {
@Nullable @Nullable
@WorkerThread @WorkerThread
public Uri getConferenceUri() throws RcsMessageStoreException { public Uri getConferenceUri() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getGroupThreadConferenceUri(mThreadId)); return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadConferenceUri(mThreadId));
} }
/** /**
@@ -200,7 +202,7 @@ public class RcsGroupThread extends RcsThread {
@Nullable @Nullable
@WorkerThread @WorkerThread
public void setConferenceUri(Uri conferenceUri) throws RcsMessageStoreException { public void setConferenceUri(Uri conferenceUri) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setGroupThreadConferenceUri(mThreadId, conferenceUri)); iRcs -> iRcs.setGroupThreadConferenceUri(mThreadId, conferenceUri));
} }
} }

View File

@@ -23,14 +23,14 @@ import android.annotation.NonNull;
* @hide * @hide
*/ */
public abstract class RcsGroupThreadEvent extends RcsEvent { public abstract class RcsGroupThreadEvent extends RcsEvent {
private final int mRcsGroupThreadId; private final RcsGroupThread mRcsGroupThread;
private final int mOriginatingParticipantId; private final RcsParticipant mOriginatingParticipant;
RcsGroupThreadEvent(long timestamp, int rcsGroupThreadId, RcsGroupThreadEvent(long timestamp, RcsGroupThread rcsGroupThread,
int originatingParticipantId) { RcsParticipant originatingParticipant) {
super(timestamp); super(timestamp);
mRcsGroupThreadId = rcsGroupThreadId; mRcsGroupThread = rcsGroupThread;
mOriginatingParticipantId = originatingParticipantId; mOriginatingParticipant = originatingParticipant;
} }
/** /**
@@ -38,7 +38,7 @@ public abstract class RcsGroupThreadEvent extends RcsEvent {
*/ */
@NonNull @NonNull
public RcsGroupThread getRcsGroupThread() { public RcsGroupThread getRcsGroupThread() {
return new RcsGroupThread(mRcsGroupThreadId); return mRcsGroupThread;
} }
/** /**
@@ -46,6 +46,6 @@ public abstract class RcsGroupThreadEvent extends RcsEvent {
*/ */
@NonNull @NonNull
public RcsParticipant getOriginatingParticipant() { public RcsParticipant getOriginatingParticipant() {
return new RcsParticipant(mOriginatingParticipantId); return mOriginatingParticipant;
} }
} }

View File

@@ -40,9 +40,10 @@ public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent {
* @param newIcon {@link Uri} to the new icon of this {@link RcsGroupThread} * @param newIcon {@link Uri} to the new icon of this {@link RcsGroupThread}
* @see RcsMessageStore#persistRcsEvent(RcsEvent) * @see RcsMessageStore#persistRcsEvent(RcsEvent)
*/ */
public RcsGroupThreadIconChangedEvent(long timestamp, @NonNull RcsGroupThread rcsGroupThread, public RcsGroupThreadIconChangedEvent(long timestamp,
@NonNull RcsParticipant originatingParticipant, @Nullable Uri newIcon) { @NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); @Nullable Uri newIcon) {
super(timestamp, rcsGroupThread, originatingParticipant);
mNewIcon = newIcon; mNewIcon = newIcon;
} }
@@ -61,9 +62,9 @@ public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent {
* @hide - not meant for public use. * @hide - not meant for public use.
*/ */
@Override @Override
public void persist() throws RcsMessageStoreException { void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
// TODO ensure failure throws // TODO ensure failure throws
RcsControllerCall.call(iRcs -> iRcs.createGroupThreadIconChangedEvent( rcsControllerCall.call(iRcs -> iRcs.createGroupThreadIconChangedEvent(
getTimestamp(), getRcsGroupThread().getThreadId(), getTimestamp(), getRcsGroupThread().getThreadId(),
getOriginatingParticipant().getId(), mNewIcon)); getOriginatingParticipant().getId(), mNewIcon));
} }

View File

@@ -38,9 +38,10 @@ public class RcsGroupThreadIconChangedEventDescriptor extends RcsGroupThreadEven
@Override @Override
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadIconChangedEvent createRcsEvent() { public RcsGroupThreadIconChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadIconChangedEvent(mTimestamp, new RcsGroupThread(mRcsGroupThreadId), return new RcsGroupThreadIconChangedEvent(mTimestamp,
new RcsParticipant(mOriginatingParticipantId), mNewIcon); new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(rcsControllerCall, mOriginatingParticipantId), mNewIcon);
} }
public static final @NonNull Creator<RcsGroupThreadIconChangedEventDescriptor> CREATOR = public static final @NonNull Creator<RcsGroupThreadIconChangedEventDescriptor> CREATOR =

View File

@@ -41,7 +41,7 @@ public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent {
*/ */
public RcsGroupThreadNameChangedEvent(long timestamp, @NonNull RcsGroupThread rcsGroupThread, public RcsGroupThreadNameChangedEvent(long timestamp, @NonNull RcsGroupThread rcsGroupThread,
@NonNull RcsParticipant originatingParticipant, @Nullable String newName) { @NonNull RcsParticipant originatingParticipant, @Nullable String newName) {
super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); super(timestamp, rcsGroupThread, originatingParticipant);
mNewName = newName; mNewName = newName;
} }
@@ -60,8 +60,8 @@ public final class RcsGroupThreadNameChangedEvent extends RcsGroupThreadEvent {
* @hide - not meant for public use. * @hide - not meant for public use.
*/ */
@Override @Override
public void persist() throws RcsMessageStoreException { void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
RcsControllerCall.call(iRcs -> iRcs.createGroupThreadNameChangedEvent( rcsControllerCall.call(iRcs -> iRcs.createGroupThreadNameChangedEvent(
getTimestamp(), getRcsGroupThread().getThreadId(), getTimestamp(), getRcsGroupThread().getThreadId(),
getOriginatingParticipant().getId(), mNewName)); getOriginatingParticipant().getId(), mNewName));
} }

View File

@@ -37,11 +37,11 @@ public class RcsGroupThreadNameChangedEventDescriptor extends RcsGroupThreadEven
@Override @Override
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadNameChangedEvent createRcsEvent() { public RcsGroupThreadNameChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadNameChangedEvent( return new RcsGroupThreadNameChangedEvent(
mTimestamp, mTimestamp,
new RcsGroupThread(mRcsGroupThreadId), new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(mOriginatingParticipantId), new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
mNewName); mNewName);
} }

View File

@@ -42,7 +42,7 @@ public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEv
public RcsGroupThreadParticipantJoinedEvent(long timestamp, public RcsGroupThreadParticipantJoinedEvent(long timestamp,
@NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant, @NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
@NonNull RcsParticipant joinedParticipant) { @NonNull RcsParticipant joinedParticipant) {
super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); super(timestamp, rcsGroupThread, originatingParticipant);
mJoinedParticipantId = joinedParticipant; mJoinedParticipantId = joinedParticipant;
} }
@@ -59,8 +59,8 @@ public final class RcsGroupThreadParticipantJoinedEvent extends RcsGroupThreadEv
* @hide - not meant for public use. * @hide - not meant for public use.
*/ */
@Override @Override
public void persist() throws RcsMessageStoreException { void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
RcsControllerCall.call( rcsControllerCall.call(
iRcs -> iRcs.createGroupThreadParticipantJoinedEvent(getTimestamp(), iRcs -> iRcs.createGroupThreadParticipantJoinedEvent(getTimestamp(),
getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(),
getJoinedParticipant().getId())); getJoinedParticipant().getId()));

View File

@@ -36,12 +36,13 @@ public class RcsGroupThreadParticipantJoinedEventDescriptor extends RcsGroupThre
@Override @Override
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadParticipantJoinedEvent createRcsEvent() { public RcsGroupThreadParticipantJoinedEvent createRcsEvent(
RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadParticipantJoinedEvent( return new RcsGroupThreadParticipantJoinedEvent(
mTimestamp, mTimestamp,
new RcsGroupThread(mRcsGroupThreadId), new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(mOriginatingParticipantId), new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
new RcsParticipant(mJoinedParticipantId)); new RcsParticipant(rcsControllerCall, mJoinedParticipantId));
} }
public static final @NonNull Creator<RcsGroupThreadParticipantJoinedEventDescriptor> CREATOR = public static final @NonNull Creator<RcsGroupThreadParticipantJoinedEventDescriptor> CREATOR =

View File

@@ -44,7 +44,7 @@ public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEven
public RcsGroupThreadParticipantLeftEvent(long timestamp, public RcsGroupThreadParticipantLeftEvent(long timestamp,
@NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant, @NonNull RcsGroupThread rcsGroupThread, @NonNull RcsParticipant originatingParticipant,
@NonNull RcsParticipant leavingParticipant) { @NonNull RcsParticipant leavingParticipant) {
super(timestamp, rcsGroupThread.getThreadId(), originatingParticipant.getId()); super(timestamp, rcsGroupThread, originatingParticipant);
mLeavingParticipant = leavingParticipant; mLeavingParticipant = leavingParticipant;
} }
@@ -58,8 +58,8 @@ public final class RcsGroupThreadParticipantLeftEvent extends RcsGroupThreadEven
} }
@Override @Override
public void persist() throws RcsMessageStoreException { void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
RcsControllerCall.call( rcsControllerCall.call(
iRcs -> iRcs.createGroupThreadParticipantLeftEvent(getTimestamp(), iRcs -> iRcs.createGroupThreadParticipantLeftEvent(getTimestamp(),
getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(), getRcsGroupThread().getThreadId(), getOriginatingParticipant().getId(),
getLeavingParticipant().getId())); getLeavingParticipant().getId()));

View File

@@ -37,12 +37,12 @@ public class RcsGroupThreadParticipantLeftEventDescriptor extends RcsGroupThread
@Override @Override
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public RcsGroupThreadParticipantLeftEvent createRcsEvent() { public RcsGroupThreadParticipantLeftEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsGroupThreadParticipantLeftEvent( return new RcsGroupThreadParticipantLeftEvent(
mTimestamp, mTimestamp,
new RcsGroupThread(mRcsGroupThreadId), new RcsGroupThread(rcsControllerCall, mRcsGroupThreadId),
new RcsParticipant(mOriginatingParticipantId), new RcsParticipant(rcsControllerCall, mOriginatingParticipantId),
new RcsParticipant(mLeavingParticipantId)); new RcsParticipant(rcsControllerCall, mLeavingParticipantId));
} }
@NonNull @NonNull

View File

@@ -26,8 +26,8 @@ public class RcsIncomingMessage extends RcsMessage {
/** /**
* @hide * @hide
*/ */
RcsIncomingMessage(int id) { RcsIncomingMessage(RcsControllerCall rcsControllerCall, int id) {
super(id); super(rcsControllerCall, id);
} }
/** /**
@@ -39,7 +39,7 @@ public class RcsIncomingMessage extends RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setArrivalTimestamp(long arrivalTimestamp) throws RcsMessageStoreException { public void setArrivalTimestamp(long arrivalTimestamp) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setMessageArrivalTimestamp(mId, true, arrivalTimestamp)); iRcs -> iRcs.setMessageArrivalTimestamp(mId, true, arrivalTimestamp));
} }
@@ -50,7 +50,7 @@ public class RcsIncomingMessage extends RcsMessage {
*/ */
@WorkerThread @WorkerThread
public long getArrivalTimestamp() throws RcsMessageStoreException { public long getArrivalTimestamp() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getMessageArrivalTimestamp(mId, true)); return mRcsControllerCall.call(iRcs -> iRcs.getMessageArrivalTimestamp(mId, true));
} }
/** /**
@@ -62,7 +62,7 @@ public class RcsIncomingMessage extends RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setSeenTimestamp(long notifiedTimestamp) throws RcsMessageStoreException { public void setSeenTimestamp(long notifiedTimestamp) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setMessageSeenTimestamp(mId, true, notifiedTimestamp)); iRcs -> iRcs.setMessageSeenTimestamp(mId, true, notifiedTimestamp));
} }
@@ -73,7 +73,7 @@ public class RcsIncomingMessage extends RcsMessage {
*/ */
@WorkerThread @WorkerThread
public long getSeenTimestamp() throws RcsMessageStoreException { public long getSeenTimestamp() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getMessageSeenTimestamp(mId, true)); return mRcsControllerCall.call(iRcs -> iRcs.getMessageSeenTimestamp(mId, true));
} }
/** /**
@@ -83,7 +83,8 @@ public class RcsIncomingMessage extends RcsMessage {
@WorkerThread @WorkerThread
public RcsParticipant getSenderParticipant() throws RcsMessageStoreException { public RcsParticipant getSenderParticipant() throws RcsMessageStoreException {
return new RcsParticipant( return new RcsParticipant(
RcsControllerCall.call(iRcs -> iRcs.getSenderParticipant(mId))); mRcsControllerCall,
mRcsControllerCall.call(iRcs -> iRcs.getSenderParticipant(mId)));
} }
/** /**

View File

@@ -25,20 +25,19 @@ import android.content.Context;
*/ */
@SystemService(Context.TELEPHONY_RCS_SERVICE) @SystemService(Context.TELEPHONY_RCS_SERVICE)
public class RcsManager { public class RcsManager {
private final RcsMessageStore mRcsMessageStore;
/** /**
* @hide * @hide
*/ */
public RcsManager() { public RcsManager(Context context) {
// empty constructor mRcsMessageStore = new RcsMessageStore(context);
} }
private static final RcsMessageStore sRcsMessageStoreInstance = new RcsMessageStore();
/** /**
* Returns an instance of {@link RcsMessageStore} * Returns an instance of {@link RcsMessageStore}
*/ */
public RcsMessageStore getRcsMessageStore() { public RcsMessageStore getRcsMessageStore() {
return sRcsMessageStoreInstance; return mRcsMessageStore;
} }
} }

View File

@@ -83,6 +83,11 @@ public abstract class RcsMessage {
*/ */
public static final int SEEN = 9; public static final int SEEN = 9;
/**
* @hide
*/
protected final RcsControllerCall mRcsControllerCall;
/** /**
* @hide * @hide
*/ */
@@ -95,7 +100,8 @@ public abstract class RcsMessage {
public @interface RcsMessageStatus { public @interface RcsMessageStatus {
} }
RcsMessage(int id) { RcsMessage(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id; mId = id;
} }
@@ -115,7 +121,7 @@ public abstract class RcsMessage {
* @see android.telephony.SubscriptionInfo#getSubscriptionId * @see android.telephony.SubscriptionInfo#getSubscriptionId
*/ */
public int getSubscriptionId() throws RcsMessageStoreException { public int getSubscriptionId() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getMessageSubId(mId, isIncoming())); return mRcsControllerCall.call(iRcs -> iRcs.getMessageSubId(mId, isIncoming()));
} }
/** /**
@@ -128,7 +134,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setSubscriptionId(int subId) throws RcsMessageStoreException { public void setSubscriptionId(int subId) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setMessageSubId(mId, isIncoming(), subId)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setMessageSubId(mId, isIncoming(), subId));
} }
/** /**
@@ -139,7 +145,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setStatus(@RcsMessageStatus int rcsMessageStatus) throws RcsMessageStoreException { public void setStatus(@RcsMessageStatus int rcsMessageStatus) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setMessageStatus(mId, isIncoming(), rcsMessageStatus)); iRcs -> iRcs.setMessageStatus(mId, isIncoming(), rcsMessageStatus));
} }
@@ -150,7 +156,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public @RcsMessageStatus int getStatus() throws RcsMessageStoreException { public @RcsMessageStatus int getStatus() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getMessageStatus(mId, isIncoming())); return mRcsControllerCall.call(iRcs -> iRcs.getMessageStatus(mId, isIncoming()));
} }
/** /**
@@ -163,7 +169,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setOriginationTimestamp(long timestamp) throws RcsMessageStoreException { public void setOriginationTimestamp(long timestamp) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setMessageOriginationTimestamp(mId, isIncoming(), timestamp)); iRcs -> iRcs.setMessageOriginationTimestamp(mId, isIncoming(), timestamp));
} }
@@ -175,7 +181,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public long getOriginationTimestamp() throws RcsMessageStoreException { public long getOriginationTimestamp() throws RcsMessageStoreException {
return RcsControllerCall.call( return mRcsControllerCall.call(
iRcs -> iRcs.getMessageOriginationTimestamp(mId, isIncoming())); iRcs -> iRcs.getMessageOriginationTimestamp(mId, isIncoming()));
} }
@@ -189,7 +195,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setRcsMessageId(String rcsMessageGlobalId) throws RcsMessageStoreException { public void setRcsMessageId(String rcsMessageGlobalId) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setGlobalMessageIdForMessage(mId, isIncoming(), rcsMessageGlobalId)); iRcs -> iRcs.setGlobalMessageIdForMessage(mId, isIncoming(), rcsMessageGlobalId));
} }
@@ -200,7 +206,8 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public String getRcsMessageId() throws RcsMessageStoreException { public String getRcsMessageId() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getGlobalMessageIdForMessage(mId, isIncoming())); return mRcsControllerCall.call(
iRcs -> iRcs.getGlobalMessageIdForMessage(mId, isIncoming()));
} }
/** /**
@@ -209,7 +216,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public String getText() throws RcsMessageStoreException { public String getText() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getTextForMessage(mId, isIncoming())); return mRcsControllerCall.call(iRcs -> iRcs.getTextForMessage(mId, isIncoming()));
} }
/** /**
@@ -220,7 +227,8 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setText(String text) throws RcsMessageStoreException { public void setText(String text) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setTextForMessage(mId, isIncoming(), text)); mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setTextForMessage(mId, isIncoming(), text));
} }
/** /**
@@ -231,7 +239,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public double getLatitude() throws RcsMessageStoreException { public double getLatitude() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getLatitudeForMessage(mId, isIncoming())); return mRcsControllerCall.call(iRcs -> iRcs.getLatitudeForMessage(mId, isIncoming()));
} }
/** /**
@@ -242,7 +250,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setLatitude(double latitude) throws RcsMessageStoreException { public void setLatitude(double latitude) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setLatitudeForMessage(mId, isIncoming(), latitude)); iRcs -> iRcs.setLatitudeForMessage(mId, isIncoming(), latitude));
} }
@@ -254,7 +262,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public double getLongitude() throws RcsMessageStoreException { public double getLongitude() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getLongitudeForMessage(mId, isIncoming())); return mRcsControllerCall.call(iRcs -> iRcs.getLongitudeForMessage(mId, isIncoming()));
} }
/** /**
@@ -265,7 +273,7 @@ public abstract class RcsMessage {
*/ */
@WorkerThread @WorkerThread
public void setLongitude(double longitude) throws RcsMessageStoreException { public void setLongitude(double longitude) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setLongitudeForMessage(mId, isIncoming(), longitude)); iRcs -> iRcs.setLongitudeForMessage(mId, isIncoming(), longitude));
} }
@@ -282,7 +290,7 @@ public abstract class RcsMessage {
public RcsFileTransferPart insertFileTransfer( public RcsFileTransferPart insertFileTransfer(
RcsFileTransferCreationParams fileTransferCreationParameters) RcsFileTransferCreationParams fileTransferCreationParameters)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsFileTransferPart(RcsControllerCall.call( return new RcsFileTransferPart(mRcsControllerCall, mRcsControllerCall.call(
iRcs -> iRcs.storeFileTransfer(mId, isIncoming(), fileTransferCreationParameters))); iRcs -> iRcs.storeFileTransfer(mId, isIncoming(), fileTransferCreationParameters)));
} }
@@ -296,11 +304,11 @@ public abstract class RcsMessage {
public Set<RcsFileTransferPart> getFileTransferParts() throws RcsMessageStoreException { public Set<RcsFileTransferPart> getFileTransferParts() throws RcsMessageStoreException {
Set<RcsFileTransferPart> fileTransferParts = new HashSet<>(); Set<RcsFileTransferPart> fileTransferParts = new HashSet<>();
int[] fileTransferIds = RcsControllerCall.call( int[] fileTransferIds = mRcsControllerCall.call(
iRcs -> iRcs.getFileTransfersAttachedToMessage(mId, isIncoming())); iRcs -> iRcs.getFileTransfersAttachedToMessage(mId, isIncoming()));
for (int fileTransfer : fileTransferIds) { for (int fileTransfer : fileTransferIds) {
fileTransferParts.add(new RcsFileTransferPart(fileTransfer)); fileTransferParts.add(new RcsFileTransferPart(mRcsControllerCall, fileTransfer));
} }
return Collections.unmodifiableSet(fileTransferParts); return Collections.unmodifiableSet(fileTransferParts);
@@ -319,7 +327,7 @@ public abstract class RcsMessage {
return; return;
} }
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.deleteFileTransfer(fileTransferPart.getId())); iRcs -> iRcs.deleteFileTransfer(fileTransferPart.getId()));
} }

View File

@@ -32,9 +32,12 @@ import java.util.stream.Collectors;
* @hide * @hide
*/ */
public final class RcsMessageQueryResult { public final class RcsMessageQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsMessageQueryResultParcelable mRcsMessageQueryResultParcelable; private final RcsMessageQueryResultParcelable mRcsMessageQueryResultParcelable;
RcsMessageQueryResult(RcsMessageQueryResultParcelable rcsMessageQueryResultParcelable) { RcsMessageQueryResult(RcsControllerCall rcsControllerCall,
RcsMessageQueryResultParcelable rcsMessageQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsMessageQueryResultParcelable = rcsMessageQueryResultParcelable; mRcsMessageQueryResultParcelable = rcsMessageQueryResultParcelable;
} }
@@ -57,8 +60,8 @@ public final class RcsMessageQueryResult {
public List<RcsMessage> getMessages() { public List<RcsMessage> getMessages() {
return mRcsMessageQueryResultParcelable.mMessageTypeIdPairs.stream() return mRcsMessageQueryResultParcelable.mMessageTypeIdPairs.stream()
.map(typeIdPair -> typeIdPair.getType() == MESSAGE_TYPE_INCOMING .map(typeIdPair -> typeIdPair.getType() == MESSAGE_TYPE_INCOMING
? new RcsIncomingMessage(typeIdPair.getId()) ? new RcsIncomingMessage(mRcsControllerCall, typeIdPair.getId())
: new RcsOutgoingMessage(typeIdPair.getId())) : new RcsOutgoingMessage(mRcsControllerCall, typeIdPair.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@@ -19,6 +19,7 @@ package android.telephony.ims;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.annotation.WorkerThread; import android.annotation.WorkerThread;
import android.content.Context;
import android.net.Uri; import android.net.Uri;
import java.util.List; import java.util.List;
@@ -30,6 +31,12 @@ import java.util.List;
* @hide * @hide
*/ */
public class RcsMessageStore { public class RcsMessageStore {
RcsControllerCall mRcsControllerCall;
RcsMessageStore(Context context) {
mRcsControllerCall = new RcsControllerCall(context);
}
/** /**
* Returns the first chunk of existing {@link RcsThread}s in the common storage. * Returns the first chunk of existing {@link RcsThread}s in the common storage.
* *
@@ -41,8 +48,8 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsThreadQueryResult getRcsThreads(@Nullable RcsThreadQueryParams queryParameters) public RcsThreadQueryResult getRcsThreads(@Nullable RcsThreadQueryParams queryParameters)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsThreadQueryResult( return new RcsThreadQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getRcsThreads(queryParameters))); mRcsControllerCall.call(iRcs -> iRcs.getRcsThreads(queryParameters)));
} }
/** /**
@@ -56,8 +63,8 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsThreadQueryResult getRcsThreads(@NonNull RcsQueryContinuationToken continuationToken) public RcsThreadQueryResult getRcsThreads(@NonNull RcsQueryContinuationToken continuationToken)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsThreadQueryResult( return new RcsThreadQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getRcsThreadsWithToken(continuationToken))); mRcsControllerCall.call(iRcs -> iRcs.getRcsThreadsWithToken(continuationToken)));
} }
/** /**
@@ -72,8 +79,8 @@ public class RcsMessageStore {
public RcsParticipantQueryResult getRcsParticipants( public RcsParticipantQueryResult getRcsParticipants(
@Nullable RcsParticipantQueryParams queryParameters) @Nullable RcsParticipantQueryParams queryParameters)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsParticipantQueryResult( return new RcsParticipantQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getParticipants(queryParameters))); mRcsControllerCall.call(iRcs -> iRcs.getParticipants(queryParameters)));
} }
/** /**
@@ -89,23 +96,23 @@ public class RcsMessageStore {
public RcsParticipantQueryResult getRcsParticipants( public RcsParticipantQueryResult getRcsParticipants(
@NonNull RcsQueryContinuationToken continuationToken) @NonNull RcsQueryContinuationToken continuationToken)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsParticipantQueryResult( return new RcsParticipantQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getParticipantsWithToken(continuationToken))); mRcsControllerCall.call(iRcs -> iRcs.getParticipantsWithToken(continuationToken)));
} }
/** /**
* Returns the first chunk of existing {@link RcsMessage}s in the common storage. * Returns the first chunk of existing {@link RcsMessage}s in the common storage.
* *
* @param queryParameters Parameters to specify to return a subset of all RcsMessages. * @param queryParams Parameters to specify to return a subset of all RcsMessages.
* Passing a value of null will return all messages. * Passing a value of null will return all messages.
* @throws RcsMessageStoreException if the query could not be completed on the storage * @throws RcsMessageStoreException if the query could not be completed on the storage
*/ */
@WorkerThread @WorkerThread
@NonNull @NonNull
public RcsMessageQueryResult getRcsMessages( public RcsMessageQueryResult getRcsMessages(
@Nullable RcsMessageQueryParams queryParameters) throws RcsMessageStoreException { @Nullable RcsMessageQueryParams queryParams) throws RcsMessageStoreException {
return new RcsMessageQueryResult( return new RcsMessageQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getMessages(queryParameters))); mRcsControllerCall.call(iRcs -> iRcs.getMessages(queryParams)));
} }
/** /**
@@ -119,8 +126,8 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsMessageQueryResult getRcsMessages( public RcsMessageQueryResult getRcsMessages(
@NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException { @NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException {
return new RcsMessageQueryResult( return new RcsMessageQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getMessagesWithToken(continuationToken))); mRcsControllerCall.call(iRcs -> iRcs.getMessagesWithToken(continuationToken)));
} }
/** /**
@@ -134,8 +141,8 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsEventQueryResult getRcsEvents( public RcsEventQueryResult getRcsEvents(
@Nullable RcsEventQueryParams queryParams) throws RcsMessageStoreException { @Nullable RcsEventQueryParams queryParams) throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getEvents(queryParams)) return mRcsControllerCall.call(iRcs -> iRcs.getEvents(queryParams))
.getRcsEventQueryResult(); .getRcsEventQueryResult(mRcsControllerCall);
} }
/** /**
@@ -149,14 +156,14 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsEventQueryResult getRcsEvents( public RcsEventQueryResult getRcsEvents(
@NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException { @NonNull RcsQueryContinuationToken continuationToken) throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getEventsWithToken(continuationToken)) return mRcsControllerCall.call(iRcs -> iRcs.getEventsWithToken(continuationToken))
.getRcsEventQueryResult(); .getRcsEventQueryResult(mRcsControllerCall);
} }
/** /**
* Persists an {@link RcsEvent} to common storage. * Persists an {@link RcsEvent} to common storage.
* *
* @param persistableEvent The {@link RcsEvent} to persist into storage. * @param rcsEvent The {@link RcsEvent} to persist into storage.
* @throws RcsMessageStoreException if the query could not be completed on the storage * @throws RcsMessageStoreException if the query could not be completed on the storage
* @see RcsGroupThreadNameChangedEvent * @see RcsGroupThreadNameChangedEvent
* @see RcsGroupThreadIconChangedEvent * @see RcsGroupThreadIconChangedEvent
@@ -166,8 +173,8 @@ public class RcsMessageStore {
*/ */
@WorkerThread @WorkerThread
@NonNull @NonNull
public void persistRcsEvent(RcsEvent persistableEvent) throws RcsMessageStoreException { public void persistRcsEvent(RcsEvent rcsEvent) throws RcsMessageStoreException {
persistableEvent.persist(); rcsEvent.persist(mRcsControllerCall);
} }
/** /**
@@ -182,7 +189,8 @@ public class RcsMessageStore {
public Rcs1To1Thread createRcs1To1Thread(@NonNull RcsParticipant recipient) public Rcs1To1Thread createRcs1To1Thread(@NonNull RcsParticipant recipient)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new Rcs1To1Thread( return new Rcs1To1Thread(
RcsControllerCall.call(iRcs -> iRcs.createRcs1To1Thread(recipient.getId()))); mRcsControllerCall,
mRcsControllerCall.call(iRcs -> iRcs.createRcs1To1Thread(recipient.getId())));
} }
/** /**
@@ -204,8 +212,11 @@ public class RcsMessageStore {
} }
int[] finalRecipientIds = recipientIds; int[] finalRecipientIds = recipientIds;
return new RcsGroupThread(RcsControllerCall.call(
iRcs -> iRcs.createGroupThread(finalRecipientIds, groupName, groupIcon))); int threadId = mRcsControllerCall.call(
iRcs -> iRcs.createGroupThread(finalRecipientIds, groupName, groupIcon));
return new RcsGroupThread(mRcsControllerCall, threadId);
} }
/** /**
@@ -220,7 +231,7 @@ public class RcsMessageStore {
return; return;
} }
boolean isDeleteSucceeded = RcsControllerCall.call( boolean isDeleteSucceeded = mRcsControllerCall.call(
iRcs -> iRcs.deleteThread(thread.getThreadId(), thread.getThreadType())); iRcs -> iRcs.deleteThread(thread.getThreadId(), thread.getThreadType()));
if (!isDeleteSucceeded) { if (!isDeleteSucceeded) {
@@ -239,7 +250,7 @@ public class RcsMessageStore {
@NonNull @NonNull
public RcsParticipant createRcsParticipant(String canonicalAddress, @Nullable String alias) public RcsParticipant createRcsParticipant(String canonicalAddress, @Nullable String alias)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsParticipant( return new RcsParticipant(mRcsControllerCall, mRcsControllerCall.call(
RcsControllerCall.call(iRcs -> iRcs.createRcsParticipant(canonicalAddress, alias))); iRcs -> iRcs.createRcsParticipant(canonicalAddress, alias)));
} }
} }

View File

@@ -27,8 +27,8 @@ import java.util.List;
* @hide * @hide
*/ */
public class RcsOutgoingMessage extends RcsMessage { public class RcsOutgoingMessage extends RcsMessage {
RcsOutgoingMessage(int id) { RcsOutgoingMessage(RcsControllerCall rcsControllerCall, int id) {
super(id); super(rcsControllerCall, id);
} }
/** /**
@@ -45,12 +45,13 @@ public class RcsOutgoingMessage extends RcsMessage {
int[] deliveryParticipants; int[] deliveryParticipants;
List<RcsOutgoingMessageDelivery> messageDeliveries = new ArrayList<>(); List<RcsOutgoingMessageDelivery> messageDeliveries = new ArrayList<>();
deliveryParticipants = RcsControllerCall.call( deliveryParticipants = mRcsControllerCall.call(
iRcs -> iRcs.getMessageRecipients(mId)); iRcs -> iRcs.getMessageRecipients(mId));
if (deliveryParticipants != null) { if (deliveryParticipants != null) {
for (Integer deliveryParticipant : deliveryParticipants) { for (Integer deliveryParticipant : deliveryParticipants) {
messageDeliveries.add(new RcsOutgoingMessageDelivery(deliveryParticipant, mId)); messageDeliveries.add(new RcsOutgoingMessageDelivery(
mRcsControllerCall, deliveryParticipant, mId));
} }
} }

View File

@@ -25,6 +25,7 @@ import android.annotation.WorkerThread;
* @hide * @hide
*/ */
public class RcsOutgoingMessageDelivery { public class RcsOutgoingMessageDelivery {
private final RcsControllerCall mRcsControllerCall;
// The participant that this delivery is intended for // The participant that this delivery is intended for
private final int mRecipientId; private final int mRecipientId;
// The message this delivery is associated with // The message this delivery is associated with
@@ -35,7 +36,9 @@ public class RcsOutgoingMessageDelivery {
* *
* @hide * @hide
*/ */
RcsOutgoingMessageDelivery(int recipientId, int messageId) { RcsOutgoingMessageDelivery(
RcsControllerCall rcsControllerCall, int recipientId, int messageId) {
mRcsControllerCall = rcsControllerCall;
mRecipientId = recipientId; mRecipientId = recipientId;
mRcsOutgoingMessageId = messageId; mRcsOutgoingMessageId = messageId;
} }
@@ -49,7 +52,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public void setDeliveredTimestamp(long deliveredTimestamp) throws RcsMessageStoreException { public void setDeliveredTimestamp(long deliveredTimestamp) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliveryDeliveredTimestamp( mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliveryDeliveredTimestamp(
mRcsOutgoingMessageId, mRecipientId, deliveredTimestamp)); mRcsOutgoingMessageId, mRecipientId, deliveredTimestamp));
} }
@@ -61,7 +64,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public long getDeliveredTimestamp() throws RcsMessageStoreException { public long getDeliveredTimestamp() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getOutgoingDeliveryDeliveredTimestamp( return mRcsControllerCall.call(iRcs -> iRcs.getOutgoingDeliveryDeliveredTimestamp(
mRcsOutgoingMessageId, mRecipientId)); mRcsOutgoingMessageId, mRecipientId));
} }
@@ -74,7 +77,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public void setSeenTimestamp(long seenTimestamp) throws RcsMessageStoreException { public void setSeenTimestamp(long seenTimestamp) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliverySeenTimestamp( mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliverySeenTimestamp(
mRcsOutgoingMessageId, mRecipientId, seenTimestamp)); mRcsOutgoingMessageId, mRecipientId, seenTimestamp));
} }
@@ -86,7 +89,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public long getSeenTimestamp() throws RcsMessageStoreException { public long getSeenTimestamp() throws RcsMessageStoreException {
return RcsControllerCall.call( return mRcsControllerCall.call(
iRcs -> iRcs.getOutgoingDeliverySeenTimestamp(mRcsOutgoingMessageId, mRecipientId)); iRcs -> iRcs.getOutgoingDeliverySeenTimestamp(mRcsOutgoingMessageId, mRecipientId));
} }
@@ -99,7 +102,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public void setStatus(@RcsMessage.RcsMessageStatus int status) throws RcsMessageStoreException { public void setStatus(@RcsMessage.RcsMessageStatus int status) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliveryStatus( mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setOutgoingDeliveryStatus(
mRcsOutgoingMessageId, mRecipientId, status)); mRcsOutgoingMessageId, mRecipientId, status));
} }
@@ -109,7 +112,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@WorkerThread @WorkerThread
public @RcsMessage.RcsMessageStatus int getStatus() throws RcsMessageStoreException { public @RcsMessage.RcsMessageStatus int getStatus() throws RcsMessageStoreException {
return RcsControllerCall.call( return mRcsControllerCall.call(
iRcs -> iRcs.getOutgoingDeliveryStatus(mRcsOutgoingMessageId, mRecipientId)); iRcs -> iRcs.getOutgoingDeliveryStatus(mRcsOutgoingMessageId, mRecipientId));
} }
@@ -118,7 +121,7 @@ public class RcsOutgoingMessageDelivery {
*/ */
@NonNull @NonNull
public RcsParticipant getRecipient() { public RcsParticipant getRecipient() {
return new RcsParticipant(mRecipientId); return new RcsParticipant(mRcsControllerCall, mRecipientId);
} }
/** /**
@@ -126,6 +129,6 @@ public class RcsOutgoingMessageDelivery {
*/ */
@NonNull @NonNull
public RcsOutgoingMessage getMessage() { public RcsOutgoingMessage getMessage() {
return new RcsOutgoingMessage(mRcsOutgoingMessageId); return new RcsOutgoingMessage(mRcsControllerCall, mRcsOutgoingMessageId);
} }
} }

View File

@@ -24,8 +24,9 @@ import android.annotation.WorkerThread;
* @hide * @hide
*/ */
public class RcsParticipant { public class RcsParticipant {
private final RcsControllerCall mRcsControllerCall;
// The row ID of this participant in the database // The row ID of this participant in the database
private int mId; private final int mId;
/** /**
* Constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController} * Constructor for {@link com.android.internal.telephony.ims.RcsMessageStoreController}
@@ -33,7 +34,8 @@ public class RcsParticipant {
* *
* @hide * @hide
*/ */
public RcsParticipant(int id) { public RcsParticipant(RcsControllerCall rcsControllerCall, int id) {
mRcsControllerCall = rcsControllerCall;
mId = id; mId = id;
} }
@@ -45,7 +47,7 @@ public class RcsParticipant {
@Nullable @Nullable
@WorkerThread @WorkerThread
public String getCanonicalAddress() throws RcsMessageStoreException { public String getCanonicalAddress() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getRcsParticipantCanonicalAddress(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getRcsParticipantCanonicalAddress(mId));
} }
/** /**
@@ -57,7 +59,7 @@ public class RcsParticipant {
@Nullable @Nullable
@WorkerThread @WorkerThread
public String getAlias() throws RcsMessageStoreException { public String getAlias() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getRcsParticipantAlias(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getRcsParticipantAlias(mId));
} }
/** /**
@@ -70,7 +72,7 @@ public class RcsParticipant {
*/ */
@WorkerThread @WorkerThread
public void setAlias(String alias) throws RcsMessageStoreException { public void setAlias(String alias) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setRcsParticipantAlias(mId, alias)); mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setRcsParticipantAlias(mId, alias));
} }
/** /**
@@ -82,7 +84,7 @@ public class RcsParticipant {
@Nullable @Nullable
@WorkerThread @WorkerThread
public String getContactId() throws RcsMessageStoreException { public String getContactId() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getRcsParticipantContactId(mId)); return mRcsControllerCall.call(iRcs -> iRcs.getRcsParticipantContactId(mId));
} }
/** /**
@@ -95,7 +97,8 @@ public class RcsParticipant {
*/ */
@WorkerThread @WorkerThread
public void setContactId(String contactId) throws RcsMessageStoreException { public void setContactId(String contactId) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn(iRcs -> iRcs.setRcsParticipantContactId(mId, contactId)); mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.setRcsParticipantContactId(mId, contactId));
} }
@Override @Override

View File

@@ -69,8 +69,8 @@ public final class RcsParticipantAliasChangedEvent extends RcsEvent {
* @hide - not meant for public use. * @hide - not meant for public use.
*/ */
@Override @Override
public void persist() throws RcsMessageStoreException { void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
RcsControllerCall.call(iRcs -> iRcs.createParticipantAliasChangedEvent( rcsControllerCall.call(iRcs -> iRcs.createParticipantAliasChangedEvent(
getTimestamp(), getParticipant().getId(), getNewAlias())); getTimestamp(), getParticipant().getId(), getNewAlias()));
} }
} }

View File

@@ -41,9 +41,9 @@ public class RcsParticipantAliasChangedEventDescriptor extends RcsEventDescripto
@Override @Override
@VisibleForTesting(visibility = PROTECTED) @VisibleForTesting(visibility = PROTECTED)
public RcsParticipantAliasChangedEvent createRcsEvent() { public RcsParticipantAliasChangedEvent createRcsEvent(RcsControllerCall rcsControllerCall) {
return new RcsParticipantAliasChangedEvent( return new RcsParticipantAliasChangedEvent(
mTimestamp, new RcsParticipant(mParticipantId), mNewAlias); mTimestamp, new RcsParticipant(rcsControllerCall, mParticipantId), mNewAlias);
} }
public static final @NonNull Creator<RcsParticipantAliasChangedEventDescriptor> CREATOR = public static final @NonNull Creator<RcsParticipantAliasChangedEventDescriptor> CREATOR =

View File

@@ -30,10 +30,13 @@ import java.util.stream.Collectors;
* @hide * @hide
*/ */
public final class RcsParticipantQueryResult { public final class RcsParticipantQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsParticipantQueryResultParcelable mRcsParticipantQueryResultParcelable; private final RcsParticipantQueryResultParcelable mRcsParticipantQueryResultParcelable;
RcsParticipantQueryResult( RcsParticipantQueryResult(
RcsControllerCall rcsControllerCall,
RcsParticipantQueryResultParcelable rcsParticipantQueryResultParcelable) { RcsParticipantQueryResultParcelable rcsParticipantQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsParticipantQueryResultParcelable = rcsParticipantQueryResultParcelable; mRcsParticipantQueryResultParcelable = rcsParticipantQueryResultParcelable;
} }
@@ -55,7 +58,7 @@ public final class RcsParticipantQueryResult {
@NonNull @NonNull
public List<RcsParticipant> getParticipants() { public List<RcsParticipant> getParticipants() {
return mRcsParticipantQueryResultParcelable.mParticipantIds.stream() return mRcsParticipantQueryResultParcelable.mParticipantIds.stream()
.map(RcsParticipant::new) .map(participantId -> new RcsParticipant(mRcsControllerCall, participantId))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@@ -41,8 +41,14 @@ public abstract class RcsThread {
/** /**
* @hide * @hide
*/ */
protected RcsThread(int threadId) { protected final RcsControllerCall mRcsControllerCall;
/**
* @hide
*/
protected RcsThread(RcsControllerCall rcsControllerCall, int threadId) {
mThreadId = threadId; mThreadId = threadId;
mRcsControllerCall = rcsControllerCall;
} }
/** /**
@@ -52,7 +58,7 @@ public abstract class RcsThread {
@WorkerThread @WorkerThread
@NonNull @NonNull
public RcsMessageSnippet getSnippet() throws RcsMessageStoreException { public RcsMessageSnippet getSnippet() throws RcsMessageStoreException {
return RcsControllerCall.call(iRcs -> iRcs.getMessageSnippet(mThreadId)); return mRcsControllerCall.call(iRcs -> iRcs.getMessageSnippet(mThreadId));
} }
/** /**
@@ -65,8 +71,9 @@ public abstract class RcsThread {
public RcsIncomingMessage addIncomingMessage( public RcsIncomingMessage addIncomingMessage(
@NonNull RcsIncomingMessageCreationParams rcsIncomingMessageCreationParams) @NonNull RcsIncomingMessageCreationParams rcsIncomingMessageCreationParams)
throws RcsMessageStoreException { throws RcsMessageStoreException {
return new RcsIncomingMessage(RcsControllerCall.call(iRcs -> iRcs.addIncomingMessage( int messageId = mRcsControllerCall.call(
mThreadId, rcsIncomingMessageCreationParams))); iRcs -> iRcs.addIncomingMessage(mThreadId, rcsIncomingMessageCreationParams));
return new RcsIncomingMessage(mRcsControllerCall, messageId);
} }
/** /**
@@ -79,10 +86,10 @@ public abstract class RcsThread {
public RcsOutgoingMessage addOutgoingMessage( public RcsOutgoingMessage addOutgoingMessage(
@NonNull RcsOutgoingMessageCreationParams rcsOutgoingMessageCreationParams) @NonNull RcsOutgoingMessageCreationParams rcsOutgoingMessageCreationParams)
throws RcsMessageStoreException { throws RcsMessageStoreException {
int messageId = RcsControllerCall.call(iRcs -> iRcs.addOutgoingMessage( int messageId = mRcsControllerCall.call(iRcs -> iRcs.addOutgoingMessage(
mThreadId, rcsOutgoingMessageCreationParams)); mThreadId, rcsOutgoingMessageCreationParams));
return new RcsOutgoingMessage(messageId); return new RcsOutgoingMessage(mRcsControllerCall, messageId);
} }
/** /**
@@ -93,7 +100,7 @@ public abstract class RcsThread {
*/ */
@WorkerThread @WorkerThread
public void deleteMessage(@NonNull RcsMessage rcsMessage) throws RcsMessageStoreException { public void deleteMessage(@NonNull RcsMessage rcsMessage) throws RcsMessageStoreException {
RcsControllerCall.callWithNoReturn( mRcsControllerCall.callWithNoReturn(
iRcs -> iRcs.deleteMessage(rcsMessage.getId(), rcsMessage.isIncoming(), mThreadId, iRcs -> iRcs.deleteMessage(rcsMessage.getId(), rcsMessage.isIncoming(), mThreadId,
isGroup())); isGroup()));
} }
@@ -109,10 +116,10 @@ public abstract class RcsThread {
@WorkerThread @WorkerThread
@NonNull @NonNull
public RcsMessageQueryResult getMessages() throws RcsMessageStoreException { public RcsMessageQueryResult getMessages() throws RcsMessageStoreException {
RcsMessageQueryParams queryParameters = RcsMessageQueryParams queryParams =
new RcsMessageQueryParams.Builder().setThread(this).build(); new RcsMessageQueryParams.Builder().setThread(this).build();
return new RcsMessageQueryResult( return new RcsMessageQueryResult(mRcsControllerCall,
RcsControllerCall.call(iRcs -> iRcs.getMessages(queryParameters))); mRcsControllerCall.call(iRcs -> iRcs.getMessages(queryParams)));
} }
/** /**

View File

@@ -33,9 +33,12 @@ import java.util.stream.Collectors;
* @hide * @hide
*/ */
public final class RcsThreadQueryResult { public final class RcsThreadQueryResult {
private final RcsControllerCall mRcsControllerCall;
private final RcsThreadQueryResultParcelable mRcsThreadQueryResultParcelable; private final RcsThreadQueryResultParcelable mRcsThreadQueryResultParcelable;
RcsThreadQueryResult(RcsThreadQueryResultParcelable rcsThreadQueryResultParcelable) { RcsThreadQueryResult(RcsControllerCall rcsControllerCall,
RcsThreadQueryResultParcelable rcsThreadQueryResultParcelable) {
mRcsControllerCall = rcsControllerCall;
mRcsThreadQueryResultParcelable = rcsThreadQueryResultParcelable; mRcsThreadQueryResultParcelable = rcsThreadQueryResultParcelable;
} }
@@ -58,8 +61,8 @@ public final class RcsThreadQueryResult {
public List<RcsThread> getThreads() { public List<RcsThread> getThreads() {
return mRcsThreadQueryResultParcelable.mRcsThreadIds.stream() return mRcsThreadQueryResultParcelable.mRcsThreadIds.stream()
.map(typeIdPair -> typeIdPair.getType() == THREAD_TYPE_1_TO_1 .map(typeIdPair -> typeIdPair.getType() == THREAD_TYPE_1_TO_1
? new Rcs1To1Thread(typeIdPair.getId()) ? new Rcs1To1Thread(mRcsControllerCall, typeIdPair.getId())
: new RcsGroupThread(typeIdPair.getId())) : new RcsGroupThread(mRcsControllerCall, typeIdPair.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View File

@@ -49,9 +49,7 @@ public class RcsGroupThreadIconChangedEventTest {
RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel); RcsGroupThreadIconChangedEventDescriptor.CREATOR.createFromParcel(parcel);
RcsGroupThreadIconChangedEvent iconChangedEvent = RcsGroupThreadIconChangedEvent iconChangedEvent =
iconChangedEventDescriptor.createRcsEvent(); iconChangedEventDescriptor.createRcsEvent(null);
assertThat(iconChangedEvent.getNewIcon()).isEqualTo(newIconUri); assertThat(iconChangedEvent.getNewIcon()).isEqualTo(newIconUri);
assertThat(iconChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); assertThat(iconChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);

View File

@@ -48,7 +48,7 @@ public class RcsGroupThreadNameChangedEventTest {
.createFromParcel(parcel); .createFromParcel(parcel);
RcsGroupThreadNameChangedEvent nameChangedEvent = RcsGroupThreadNameChangedEvent nameChangedEvent =
nameChangedEventDescriptor.createRcsEvent(); nameChangedEventDescriptor.createRcsEvent(null);
assertThat(nameChangedEvent.getNewName()).isEqualTo(newName); assertThat(nameChangedEvent.getNewName()).isEqualTo(newName);
assertThat(nameChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); assertThat(nameChangedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);

View File

@@ -47,7 +47,7 @@ public class RcsGroupThreadParticipantJoinedEventTest {
.createFromParcel(parcel); .createFromParcel(parcel);
RcsGroupThreadParticipantJoinedEvent participantJoinedEvent = RcsGroupThreadParticipantJoinedEvent participantJoinedEvent =
participantJoinedEventDescriptor.createRcsEvent(); participantJoinedEventDescriptor.createRcsEvent(null);
assertThat(participantJoinedEvent.getJoinedParticipant().getId()).isEqualTo(2); assertThat(participantJoinedEvent.getJoinedParticipant().getId()).isEqualTo(2);
assertThat(participantJoinedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); assertThat(participantJoinedEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);

View File

@@ -48,7 +48,7 @@ public class RcsGroupThreadParticipantLeftEventTest {
.createFromParcel(parcel); .createFromParcel(parcel);
RcsGroupThreadParticipantLeftEvent participantLeftEvent = RcsGroupThreadParticipantLeftEvent participantLeftEvent =
participantLeftEventDescriptor.createRcsEvent(); participantLeftEventDescriptor.createRcsEvent(null);
assertThat(participantLeftEvent.getRcsGroupThread().getThreadId()).isEqualTo(1); assertThat(participantLeftEvent.getRcsGroupThread().getThreadId()).isEqualTo(1);
assertThat(participantLeftEvent.getLeavingParticipant().getId()).isEqualTo(2); assertThat(participantLeftEvent.getLeavingParticipant().getId()).isEqualTo(2);

View File

@@ -47,7 +47,7 @@ public class RcsParticipantAliasChangedEventTest {
.createFromParcel(parcel); .createFromParcel(parcel);
RcsParticipantAliasChangedEvent aliasChangedEvent = RcsParticipantAliasChangedEvent aliasChangedEvent =
aliasChangedEventDescriptor.createRcsEvent(); aliasChangedEventDescriptor.createRcsEvent(null);
assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId); assertThat(aliasChangedEvent.getParticipant().getId()).isEqualTo(mParticipantId);
assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS); assertThat(aliasChangedEvent.getNewAlias()).isEqualTo(NEW_ALIAS);

View File

@@ -33,7 +33,7 @@ public class RcsThreadQueryParamsTest {
@Test @Test
public void testCanUnparcel() { public void testCanUnparcel() {
RcsParticipant rcsParticipant = new RcsParticipant(1); RcsParticipant rcsParticipant = new RcsParticipant(null, 1);
RcsThreadQueryParams rcsThreadQueryParams = new RcsThreadQueryParams.Builder() RcsThreadQueryParams rcsThreadQueryParams = new RcsThreadQueryParams.Builder()
.setThreadType(THREAD_TYPE_GROUP) .setThreadType(THREAD_TYPE_GROUP)
.setParticipant(rcsParticipant) .setParticipant(rcsParticipant)