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

Commit ac4abe2c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Delete unused RcsMessage code for now."

parents f3d1ce01 db6aa1a4
Loading
Loading
Loading
Loading
+0 −92
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.telephony.ims;

import android.annotation.NonNull;
import android.annotation.WorkerThread;

/**
 * Rcs1To1Thread represents a single RCS conversation thread with a total of two
 * {@link RcsParticipant}s. Please see Section 5 (1-to-1 Messaging) - GSMA RCC.71 (RCS Universal
 * Profile Service Definition Document)
 *
 * @hide
 */
public class Rcs1To1Thread extends RcsThread {
    private int mThreadId;

    /**
     * Public constructor only for RcsMessageStoreController to initialize new threads.
     *
     * @hide
     */
    public Rcs1To1Thread(RcsControllerCall rcsControllerCall, int threadId) {
        super(rcsControllerCall, threadId);
        mThreadId = threadId;
    }

    /**
     * @return Returns {@code false} as this is always a 1 to 1 thread.
     */
    @Override
    public boolean isGroup() {
        return false;
    }

    /**
     * {@link Rcs1To1Thread}s can fall back to SMS as a back-up protocol. This function returns the
     * thread id to be used to query {@code content://mms-sms/conversation/#} to get the fallback
     * thread.
     *
     * @return The thread id to be used to query the mms-sms authority
     * @throws RcsMessageStoreException if the value could not be read from the storage
     */
    @WorkerThread
    public long getFallbackThreadId() throws RcsMessageStoreException {
        return mRcsControllerCall.call(
                (iRcs, callingPackage) -> iRcs.get1To1ThreadFallbackThreadId(mThreadId,
                        callingPackage));
    }

    /**
     * If the RCS client allows falling back to SMS, it needs to create an MMS-SMS thread in the
     * SMS/MMS Provider( see {@link android.provider.Telephony.MmsSms#CONTENT_CONVERSATIONS_URI}.
     * Use this function to link the {@link Rcs1To1Thread} to the MMS-SMS thread. This function
     * also updates the storage.
     *
     * @throws RcsMessageStoreException if the value could not be persisted into storage
     */
    @WorkerThread
    public void setFallbackThreadId(long fallbackThreadId) throws RcsMessageStoreException {
        mRcsControllerCall.callWithNoReturn(
                (iRcs, callingPackage) -> iRcs.set1To1ThreadFallbackThreadId(mThreadId,
                        fallbackThreadId, callingPackage));
    }

    /**
     * @return Returns the {@link RcsParticipant} that receives the messages sent in this thread.
     * @throws RcsMessageStoreException if the value could not be read from the storage
     */
    @NonNull
    @WorkerThread
    public RcsParticipant getRecipient() throws RcsMessageStoreException {
        return new RcsParticipant(
                mRcsControllerCall,
                mRcsControllerCall.call(
                        (iRcs, callingPackage) -> iRcs.get1To1ThreadOtherParticipantId(mThreadId,
                                callingPackage)));
    }
}
+0 −69
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

import android.content.Context;
import android.os.RemoteException;
import android.telephony.TelephonyFrameworkInitializer;
import android.telephony.ims.aidl.IRcsMessage;

/**
 * A wrapper class around RPC calls that {@link RcsMessageManager} APIs to minimize boilerplate
 * code.
 *
 * @hide - not meant for public use
 */
class RcsControllerCall {
    private final Context mContext;

    RcsControllerCall(Context context) {
        mContext = context;
    }

    <R> R call(RcsServiceCall<R> serviceCall) throws RcsMessageStoreException {
        IRcsMessage iRcsMessage = IRcsMessage.Stub.asInterface(
                TelephonyFrameworkInitializer
                        .getTelephonyServiceManager()
                        .getTelephonyRcsMessageServiceRegisterer()
                        .get());
        if (iRcsMessage == null) {
            throw new RcsMessageStoreException("Could not connect to RCS storage service");
        }

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

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

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

    interface RcsServiceCallWithNoReturn {
        void methodOnIRcs(IRcsMessage iRcs, String callingPackage) throws RemoteException;
    }
}
+0 −44
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.telephony.ims;

/**
 * The base class for events that can happen on {@link RcsParticipant}s and {@link RcsThread}s.
 *
 * @hide
 */
public abstract class RcsEvent {
    private final long mTimestamp;

    protected RcsEvent(long timestamp) {
        mTimestamp = timestamp;
    }

    /**
     * @return Returns the time of when this event happened. The timestamp is defined as
     * milliseconds passed after midnight, January 1, 1970 UTC
     */
    public long getTimestamp() {
        return mTimestamp;
    }

    /**
     * Persists the event to the data store
     *
     * @hide
     */
    abstract void persist(RcsControllerCall rcsControllerCall) throws RcsMessageStoreException;
}
+0 −20
Original line number Diff line number Diff line
/*
 *
 * Copyright 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.telephony.ims;

parcelable RcsEventDescriptor;
+0 −56
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package android.telephony.ims;

import static com.android.internal.annotations.VisibleForTesting.Visibility.PROTECTED;

import android.os.Parcel;
import android.os.Parcelable;

import com.android.internal.annotations.VisibleForTesting;

/**
 * @hide - used only for internal communication with the ircs service
 */
public abstract class RcsEventDescriptor implements Parcelable {
    protected final long mTimestamp;

    RcsEventDescriptor(long timestamp) {
        mTimestamp = timestamp;
    }

    /**
     * Creates an RcsEvent based on this RcsEventDescriptor. Overriding this method practically
     * allows an injection point for RcsEvent dependencies outside of the values contained in the
     * descriptor.
     */
    @VisibleForTesting(visibility = PROTECTED)
    public abstract RcsEvent createRcsEvent(RcsControllerCall rcsControllerCall);

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

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mTimestamp);
    }

    @Override
    public int describeContents() {
        return 0;
    }
}
Loading