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

Commit de92fb78 authored by Shuo Qian's avatar Shuo Qian Committed by Gerrit Code Review
Browse files

Merge "Call Redirection Service enhancement"

parents 40aa75d3 27136a70
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -41302,10 +41302,10 @@ package android.telecom {
    ctor public CallRedirectionService();
    method public final void cancelCall();
    method public final android.os.IBinder onBind(android.content.Intent);
    method public abstract void onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle);
    method public abstract void onPlaceCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean);
    method public final boolean onUnbind(android.content.Intent);
    method public final void placeCallUnmodified();
    method public final void redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle);
    method public final void redirectCall(android.net.Uri, android.telecom.PhoneAccountHandle, boolean);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.CallRedirectionService";
  }
+53 −23
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.telecom;

import android.annotation.NonNull;
import android.annotation.SdkConstant;
import android.app.Service;
import android.content.Intent;
@@ -27,8 +28,8 @@ import android.os.Message;
import android.os.RemoteException;

import com.android.internal.os.SomeArgs;
import com.android.internal.telecom.ICallRedirectionService;
import com.android.internal.telecom.ICallRedirectionAdapter;
import com.android.internal.telecom.ICallRedirectionService;

/**
 * This service can be implemented to interact between Telecom and its implementor
@@ -62,22 +63,35 @@ public abstract class CallRedirectionService extends Service {

    /**
     * Telecom calls this method to inform the implemented {@link CallRedirectionService} of
     * a new outgoing call which is being placed.
     * a new outgoing call which is being placed. Telecom does not request to redirect emergency
     * calls and does not request to redirect calls with gateway information.
     *
     * The implemented {@link CallRedirectionService} can call {@link #placeCallUnmodified()},
     * {@link #redirectCall(Uri, PhoneAccountHandle)}, and {@link #cancelCall()} only from here.
     * <p>Telecom will cancel the call if Telecom does not receive a response in 5 seconds from
     * the implemented {@link CallRedirectionService} set by users.
     *
     * @param handle the phone number dialed by the user
     * @param targetPhoneAccount the {@link PhoneAccountHandle} on which the call will be placed.
     * <p>The implemented {@link CallRedirectionService} can call {@link #placeCallUnmodified()},
     * {@link #redirectCall(Uri, PhoneAccountHandle, boolean)}, and {@link #cancelCall()} only
     * from here.
     *
     * @param handle the phone number dialed by the user, represented in E.164 format if possible
     * @param initialPhoneAccount the {@link PhoneAccountHandle} on which the call will be placed.
     * @param allowInteractiveResponse a boolean to tell if the implemented
     *                                 {@link CallRedirectionService} should allow interactive
     *                                 responses with users. Will be {@code false} if, for example
     *                                 the device is in car mode and the user would not be able to
     *                                 interact with their device.
     */
    public abstract void onPlaceCall(Uri handle, PhoneAccountHandle targetPhoneAccount);
    public abstract void onPlaceCall(@NonNull Uri handle,
                                     @NonNull PhoneAccountHandle initialPhoneAccount,
                                     boolean allowInteractiveResponse);

    /**
     * The implemented {@link CallRedirectionService} calls this method to response a request
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle)} to inform Telecom that no changes
     * are required to the outgoing call, and that the call should be placed as-is.
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)} to inform Telecom that
     * no changes are required to the outgoing call, and that the call should be placed as-is.
     *
     * This can only be called from implemented {@link #onPlaceCall(Uri, PhoneAccountHandle)}.
     * <p>This can only be called from implemented
     * {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)}.
     *
     */
    public final void placeCallUnmodified() {
@@ -89,29 +103,39 @@ public abstract class CallRedirectionService extends Service {

    /**
     * The implemented {@link CallRedirectionService} calls this method to response a request
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle)} to inform Telecom that changes
     * are required to the phone number or/and {@link PhoneAccountHandle} for the outgoing call.
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)} to inform Telecom that
     * changes are required to the phone number or/and {@link PhoneAccountHandle} for the outgoing
     * call. Telecom will cancel the call if the implemented {@link CallRedirectionService}
     * replies Telecom a handle for an emergency number.
     *
     * This can only be called from implemented {@link #onPlaceCall(Uri, PhoneAccountHandle)}.
     * <p>This can only be called from implemented
     * {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)}.
     *
     * @param handle the new phone number to dial
     * @param targetPhoneAccount the {@link PhoneAccountHandle} to use when placing the call.
     *                           If {@code null}, no change will be made to the
     *                           {@link PhoneAccountHandle} used to place the call.
     * @param confirmFirst Telecom will ask users to confirm the redirection via a yes/no dialog
     *                     if the confirmFirst is true, and if the redirection request of this
     *                     response was sent with a true flag of allowInteractiveResponse via
     *                     {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)}
     */
    public final void redirectCall(Uri handle, PhoneAccountHandle targetPhoneAccount) {
    public final void redirectCall(@NonNull Uri handle,
                                   @NonNull PhoneAccountHandle targetPhoneAccount,
                                   boolean confirmFirst) {
        try {
            mCallRedirectionAdapter.redirectCall(handle, targetPhoneAccount);
            mCallRedirectionAdapter.redirectCall(handle, targetPhoneAccount, confirmFirst);
        } catch (RemoteException e) {
        }
    }

    /**
     * The implemented {@link CallRedirectionService} calls this method to response a request
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle)} to inform Telecom that an outgoing
     * call should be canceled entirely.
     * received via {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)} to inform Telecom that
     * an outgoing call should be canceled entirely.
     *
     * This can only be called from implemented {@link #onPlaceCall(Uri, PhoneAccountHandle)}.
     * <p>This can only be called from implemented
     * {@link #onPlaceCall(Uri, PhoneAccountHandle, boolean)}.
     *
     */
    public final void cancelCall() {
@@ -137,7 +161,8 @@ public abstract class CallRedirectionService extends Service {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        mCallRedirectionAdapter = (ICallRedirectionAdapter) args.arg1;
                        onPlaceCall((Uri) args.arg2, (PhoneAccountHandle) args.arg3);
                        onPlaceCall((Uri) args.arg2, (PhoneAccountHandle) args.arg3,
                                (boolean) args.arg4);
                    } finally {
                        args.recycle();
                    }
@@ -152,15 +177,20 @@ public abstract class CallRedirectionService extends Service {
         * Telecom calls this method to inform the CallRedirectionService of a new outgoing call
         * which is about to be placed.
         * @param handle the phone number dialed by the user
         * @param targetPhoneAccount the URI of the number the user dialed
         * @param initialPhoneAccount the URI of the number the user dialed
         * @param allowInteractiveResponse a boolean to tell if the implemented
         *                                 {@link CallRedirectionService} should allow interactive
         *                                 responses with users.
         */
        @Override
        public void placeCall(ICallRedirectionAdapter adapter, Uri handle,
                              PhoneAccountHandle targetPhoneAccount) {
        public void placeCall(@NonNull ICallRedirectionAdapter adapter, @NonNull Uri handle,
                              @NonNull PhoneAccountHandle initialPhoneAccount,
                              boolean allowInteractiveResponse) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = adapter;
            args.arg2 = handle;
            args.arg3 = targetPhoneAccount;
            args.arg3 = initialPhoneAccount;
            args.arg4 = allowInteractiveResponse;
            mHandler.obtainMessage(MSG_PLACE_CALL, args).sendToTarget();
        }
    }
+2 −1
Original line number Diff line number Diff line
@@ -31,5 +31,6 @@ oneway interface ICallRedirectionAdapter {

    void placeCallUnmodified();

    void redirectCall(in Uri handle, in PhoneAccountHandle targetPhoneAccount);
    void redirectCall(in Uri handle, in PhoneAccountHandle targetPhoneAccount,
            boolean confirmFirst);
}
+1 −1
Original line number Diff line number Diff line
@@ -30,5 +30,5 @@ import com.android.internal.telecom.ICallRedirectionAdapter;
 */
oneway interface ICallRedirectionService {
    void placeCall(in ICallRedirectionAdapter adapter, in Uri handle,
            in PhoneAccountHandle targetPhoneAccount);
            in PhoneAccountHandle initialPhoneAccount, boolean allowInteractiveResponse);
}