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

Commit 5df2e3e7 authored by Leland Miller's avatar Leland Miller Committed by Android (Google) Code Review
Browse files

Merge changes from topic "permissions" into qt-dev

* changes:
  Add calling package parameter to IRcs methods
  Use injected instance of RcsControllerCall
  Create new RcsMessageQueryResultParcelable
  Create new RcsParticipantQueryResultParcelable
  Create new RcsThreadQueryResultParcelable
parents 940edc7a fcc04ddf
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -618,7 +618,7 @@ final class SystemServiceRegistry {
                new CachedServiceFetcher<RcsManager>() {
                    @Override
                    public RcsManager createService(ContextImpl ctx) {
                        return new RcsManager();
                        return new RcsManager(ctx.getOuterContext());
                    }
                });

+12 −6
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,9 @@ public class Rcs1To1Thread extends RcsThread {
     */
    @WorkerThread
    public long getFallbackThreadId() throws RcsMessageStoreException {
        return RcsControllerCall.call(iRcs -> iRcs.get1To1ThreadFallbackThreadId(mThreadId));
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.get1To1ThreadFallbackThreadId(mThreadId,
                        callingPackage));
    }

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

    /**
@@ -81,6 +84,9 @@ public class Rcs1To1Thread extends RcsThread {
    @WorkerThread
    public RcsParticipant getRecipient() throws RcsMessageStoreException {
        return new RcsParticipant(
                RcsControllerCall.call(iRcs -> iRcs.get1To1ThreadOtherParticipantId(mThreadId)));
                mRcsControllerCall,
                mRcsControllerCall.call(
                        (iRcs, callingPackage) -> iRcs.get1To1ThreadOtherParticipantId(mThreadId,
                                callingPackage)));
    }
}
+15 −15
Original line number Diff line number Diff line
@@ -27,38 +27,38 @@ import android.telephony.ims.aidl.IRcs;
 * @hide - not meant for public use
 */
class RcsControllerCall {
    static <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");
        }
    private final Context mContext;

        try {
            return serviceCall.methodOnIRcs(iRcs);
        } catch (RemoteException exception) {
            throw new RcsMessageStoreException(exception.getMessage());
        }
    RcsControllerCall(Context context) {
        mContext = context;
    }

    static void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
            throws RcsMessageStoreException {
    <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");
        }

        try {
            serviceCall.methodOnIRcs(iRcs);
            return serviceCall.methodOnIRcs(iRcs, mContext.getOpPackageName());
        } catch (RemoteException exception) {
            throw new RcsMessageStoreException(exception.getMessage());
        }
    }

    void callWithNoReturn(RcsServiceCallWithNoReturn serviceCall)
            throws RcsMessageStoreException {
        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;
    }
}
+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