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

Commit fcc04ddf authored by Leland Miller's avatar Leland Miller
Browse files

Add calling package parameter to IRcs methods

This will be used for permission handling in the IRcs service.

Test: Existing tests pass, both unit and RcsCtsTestCases
Change-Id: I7f2183cd2f764b8293d29dc2c278479e06d9d8a2
Merged-In: I7f2183cd2f764b8293d29dc2c278479e06d9d8a2
Bug: 123699565
(cherry picked from commit 995c9ad4)
parent 4137a85c
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -56,7 +56,9 @@ public class Rcs1To1Thread extends RcsThread {
     */
    @WorkerThread
    public long getFallbackThreadId() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.get1To1ThreadFallbackThreadId(mThreadId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.get1To1ThreadFallbackThreadId(mThreadId,
                        callingPackage));
    }

    /**
@@ -70,7 +72,8 @@ public class Rcs1To1Thread extends RcsThread {
    @WorkerThread
    public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.set1To1ThreadFallbackThreadId(mThreadId, fallbackThreadId));
                (iRcs, callingPackage) -> iRcs.set1To1ThreadFallbackThreadId(mThreadId,
                        fallbackThreadId, callingPackage));
    }

    /**
@@ -82,6 +85,8 @@ public class Rcs1To1Thread extends RcsThread {
    public RcsParticipant getRecipient() throws RcsMessageStoreException {
        return new RcsParticipant(
                mRcsControllerCall,
                mRcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId)));
                mRcsControllerCall.call(
                        (iRcs, callingPackage) -> iRcs.get1To1ThreadOtherParticipantId(mThreadId,
                                callingPackage)));
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ class RcsControllerCall {
        }

        try {
            return serviceCall.methodOnIRcs(iRcs);
            return serviceCall.methodOnIRcs(iRcs, mContext.getOpPackageName());
        } catch (RemoteException exception) {
            throw new RcsMessageStoreException(exception.getMessage());
        }
@@ -48,17 +48,17 @@ class RcsControllerCall {

    void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
            throws RcsMessageStoreException {
        call(iRcs -> {
            serviceCall.methodOnIRcs(iRcs);
        call((iRcs, callingPackage) -> {
            serviceCall.methodOnIRcs(iRcs, callingPackage);
            return null;
        });
    }

    interface RcsServiceCall<R> {
        R methodOnIRcs(IRcs iRcs) throws RemoteException;
        R methodOnIRcs(IRcs iRcs, String callingPackage) throws RemoteException;
    }

    interface RcsServiceCallWithNoReturn {
        void methodOnIRcs(IRcs iRcs) throws RemoteException;
        void methodOnIRcs(IRcs iRcs, String callingPackage) throws RemoteException;
    }
}
+45 −22
Original line number Diff line number Diff line
@@ -137,7 +137,9 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public void setFileTransferSessionId(String sessionId) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferSessionId(mId, sessionId));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setFileTransferSessionId(mId, sessionId,
                        callingPackage));
    }

    /**
@@ -146,7 +148,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public String getFileTransferSessionId() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferSessionId(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferSessionId(mId, callingPackage));
    }

    /**
@@ -159,7 +162,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setContentUri(Uri contentUri) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferContentUri(mId, contentUri));
                (iRcs, callingPackage) -> iRcs.setFileTransferContentUri(mId, contentUri,
                        callingPackage));
    }

    /**
@@ -169,7 +173,8 @@ public class RcsFileTransferPart {
    @Nullable
    @WorkerThread
    public Uri getContentUri() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferContentUri(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferContentUri(mId, callingPackage));
    }

    /**
@@ -182,7 +187,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setContentMimeType(String contentMimeType) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferContentType(mId, contentMimeType));
                (iRcs, callingPackage) -> iRcs.setFileTransferContentType(mId, contentMimeType,
                        callingPackage));
    }

    /**
@@ -192,7 +198,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    @Nullable
    public String getContentMimeType() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferContentType(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferContentType(mId, callingPackage));
    }

    /**
@@ -204,7 +211,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setFileSize(long contentLength) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferFileSize(mId, contentLength));
                (iRcs, callingPackage) -> iRcs.setFileTransferFileSize(mId, contentLength,
                        callingPackage));
    }

    /**
@@ -213,7 +221,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public long getFileSize() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferFileSize(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferFileSize(mId, callingPackage));
    }

    /**
@@ -227,7 +236,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setTransferOffset(long transferOffset) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferTransferOffset(mId, transferOffset));
                (iRcs, callingPackage) -> iRcs.setFileTransferTransferOffset(mId, transferOffset,
                        callingPackage));
    }

    /**
@@ -236,7 +246,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public long getTransferOffset() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferTransferOffset(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferTransferOffset(mId, callingPackage));
    }

    /**
@@ -248,7 +259,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setFileTransferStatus(@RcsFileTransferStatus int status)
            throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferStatus(mId, status));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setFileTransferStatus(mId, status, callingPackage));
    }

    /**
@@ -257,7 +269,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public @RcsFileTransferStatus int getFileTransferStatus() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferStatus(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferStatus(mId, callingPackage));
    }

    /**
@@ -266,7 +279,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public int getWidth() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferWidth(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferWidth(mId, callingPackage));
    }

    /**
@@ -277,7 +291,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public void setWidth(int width) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferWidth(mId, width));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setFileTransferWidth(mId, width, callingPackage));
    }

    /**
@@ -286,7 +301,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public int getHeight() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferHeight(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferHeight(mId, callingPackage));
    }

    /**
@@ -297,7 +313,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public void setHeight(int height) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferHeight(mId, height));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setFileTransferHeight(mId, height, callingPackage));
    }

    /**
@@ -306,7 +323,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public long getLength() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferLength(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferLength(mId, callingPackage));
    }

    /**
@@ -317,7 +335,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public void setLength(long length) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setFileTransferLength(mId, length));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setFileTransferLength(mId, length, callingPackage));
    }

    /**
@@ -327,7 +346,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public Uri getPreviewUri() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewUri(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferPreviewUri(mId, callingPackage));
    }

    /**
@@ -339,7 +359,8 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setPreviewUri(Uri previewUri) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferPreviewUri(mId, previewUri));
                (iRcs, callingPackage) -> iRcs.setFileTransferPreviewUri(mId, previewUri,
                        callingPackage));
    }

    /**
@@ -348,7 +369,8 @@ public class RcsFileTransferPart {
     */
    @WorkerThread
    public String getPreviewMimeType() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getFileTransferPreviewType(mId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getFileTransferPreviewType(mId, callingPackage));
    }

    /**
@@ -360,6 +382,7 @@ public class RcsFileTransferPart {
    @WorkerThread
    public void setPreviewMimeType(String previewMimeType) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setFileTransferPreviewType(mId, previewMimeType));
                (iRcs, callingPackage) -> iRcs.setFileTransferPreviewType(mId, previewMimeType,
                        callingPackage));
    }
}
+26 −11
Original line number Diff line number Diff line
@@ -58,7 +58,8 @@ public class RcsGroupThread extends RcsThread {
    @Nullable
    @WorkerThread
    public String getGroupName() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadName(mThreadId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getGroupThreadName(mThreadId, callingPackage));
    }

    /**
@@ -69,7 +70,9 @@ public class RcsGroupThread extends RcsThread {
     */
    @WorkerThread
    public void setGroupName(String groupName) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadName(mThreadId, groupName));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setGroupThreadName(mThreadId, groupName,
                        callingPackage));
    }

    /**
@@ -79,7 +82,8 @@ public class RcsGroupThread extends RcsThread {
     */
    @Nullable
    public Uri getGroupIcon() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadIcon(mThreadId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getGroupThreadIcon(mThreadId, callingPackage));
    }

    /**
@@ -90,7 +94,9 @@ public class RcsGroupThread extends RcsThread {
     */
    @WorkerThread
    public void setGroupIcon(@Nullable Uri groupIcon) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(iRcs -> iRcs.setGroupThreadIcon(mThreadId, groupIcon));
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.setGroupThreadIcon(mThreadId, groupIcon,
                        callingPackage));
    }

    /**
@@ -102,7 +108,9 @@ public class RcsGroupThread extends RcsThread {
    public RcsParticipant getOwner() throws RcsMessageStoreException {
        return new RcsParticipant(
                mRcsControllerCall,
                mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadOwner(mThreadId)));
                mRcsControllerCall.call(
                        (iRcs, callingPackage) -> iRcs.getGroupThreadOwner(mThreadId,
                                callingPackage)));
    }

    /**
@@ -116,7 +124,8 @@ public class RcsGroupThread extends RcsThread {
    @WorkerThread
    public void setOwner(@Nullable RcsParticipant participant) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setGroupThreadOwner(mThreadId, participant.getId()));
                (iRcs, callingPackage) -> iRcs.setGroupThreadOwner(mThreadId, participant.getId(),
                        callingPackage));
    }

    /**
@@ -135,7 +144,8 @@ public class RcsGroupThread extends RcsThread {
        }

        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.addParticipantToGroupThread(mThreadId, participant.getId()));
                (iRcs, callingPackage) -> iRcs.addParticipantToGroupThread(mThreadId,
                        participant.getId(), callingPackage));
    }

    /**
@@ -152,7 +162,8 @@ public class RcsGroupThread extends RcsThread {
        }

        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.removeParticipantFromGroupThread(mThreadId, participant.getId()));
                (iRcs, callingPackage) -> iRcs.removeParticipantFromGroupThread(mThreadId,
                        participant.getId(), callingPackage));
    }

    /**
@@ -173,7 +184,8 @@ public class RcsGroupThread extends RcsThread {
        RcsParticipantQueryResult queryResult = new RcsParticipantQueryResult(
                mRcsControllerCall,
                mRcsControllerCall.call(
                        iRcs -> iRcs.getParticipants(queryParameters)));
                        (iRcs, callingPackage) -> iRcs.getParticipants(queryParameters,
                                callingPackage)));

        List<RcsParticipant> participantList = queryResult.getParticipants();
        Set<RcsParticipant> participantSet = new LinkedHashSet<>(participantList);
@@ -189,7 +201,9 @@ public class RcsGroupThread extends RcsThread {
    @Nullable
    @WorkerThread
    public Uri getConferenceUri() throws RcsMessageStoreException {
        return mRcsControllerCall.call(iRcs -> iRcs.getGroupThreadConferenceUri(mThreadId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.getGroupThreadConferenceUri(mThreadId,
                        callingPackage));
    }

    /**
@@ -203,6 +217,7 @@ public class RcsGroupThread extends RcsThread {
    @WorkerThread
    public void setConferenceUri(Uri conferenceUri) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.setGroupThreadConferenceUri(mThreadId, conferenceUri));
                (iRcs, callingPackage) -> iRcs.setGroupThreadConferenceUri(mThreadId, conferenceUri,
                        callingPackage));
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ public final class RcsGroupThreadIconChangedEvent extends RcsGroupThreadEvent {
    @Override
    void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException {
        // TODO ensure failure throws
        rcsControllerCall.call(iRcs -> iRcs.createGroupThreadIconChangedEvent(
        rcsControllerCall.call((iRcs, callingPackage) -> iRcs.createGroupThreadIconChangedEvent(
                getTimestamp(), getRcsGroupThread().getThreadId(),
                getOriginatingParticipant().getId(), mNewIcon));
                getOriginatingParticipant().getId(), mNewIcon, callingPackage));
    }
}
Loading