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

Commit f545515e authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Use injected instance of RcsControllerCall"

parents b3fded4d a3d9f76b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -555,7 +555,7 @@ final class SystemServiceRegistry {
                new CachedServiceFetcher<RcsManager>() {
                    @Override
                    public RcsManager createService(ContextImpl ctx) {
                        return new RcsManager();
                        return new RcsManager(ctx.getOuterContext());
                    }
                });

+6 −5
Original line number Diff line number Diff line
@@ -33,8 +33,8 @@ public class Rcs1To1Thread extends RcsThread {
     *
     * @hide
     */
    public Rcs1To1Thread(int threadId) {
        super(threadId);
    public Rcs1To1Thread(RcsControllerCall rcsControllerCall, int threadId) {
        super(rcsControllerCall, threadId);
        mThreadId = threadId;
    }

@@ -56,7 +56,7 @@ public class Rcs1To1Thread extends RcsThread {
     */
    @WorkerThread
    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
    public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException {
        RcsControllerCall.callWithNoReturn(
        mRcsControllerCall.callWithNoReturn(
                iRcs -> iRcs.set1To1ThreadFallbackThreadId(mThreadId, fallbackThreadId));
    }

@@ -81,6 +81,7 @@ public class Rcs1To1Thread extends RcsThread {
    @WorkerThread
    public RcsParticipant getRecipient() throws RcsMessageStoreException {
        return new RcsParticipant(
                RcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId)));
                mRcsControllerCall,
                mRcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId)));
    }
}
+11 −11
Original line number Diff line number Diff line
@@ -27,7 +27,13 @@ import android.telephony.ims.aidl.IRcs;
 * @hide - not meant for public use
 */
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));
        if (iRcs == null) {
            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 {
        IRcs iRcs = IRcs.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_RCS_SERVICE));
        if (iRcs == null) {
            throw new RcsMessageStoreException("Could not connect to RCS storage service");
        }

        try {
        call(iRcs -> {
            serviceCall.methodOnIRcs(iRcs);
        } catch (RemoteException exception) {
            throw new RcsMessageStoreException(exception.getMessage());
        }
            return null;
        });
    }

    interface RcsServiceCall<R> {
+1 −1
Original line number Diff line number Diff line
@@ -40,5 +40,5 @@ public abstract class RcsEvent {
     *
     * @hide
     */
    abstract void persist() throws RcsMessageStoreException;
    abstract void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException;
}
+1 −1
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ public abstract class RcsEventDescriptor implements Parcelable {
     * descriptor.
     */
    @VisibleForTesting(visibility = PROTECTED)
    public abstract RcsEvent createRcsEvent();
    public abstract RcsEvent createRcsEvent(RcsControllerCall rcsControllerCall);

    RcsEventDescriptor(Parcel in) {
        mTimestamp = in.readLong();
Loading