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

Commit ad3c74ad authored by Santos Cordon's avatar Santos Cordon Committed by Android (Google) Code Review
Browse files

Merge "Remote Connection implementation."

parents baffd0f8 52d8a15e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -333,6 +333,7 @@ LOCAL_SRC_FILES += \
	telecomm/java/com/android/internal/telecomm/IInCallAdapter.aidl \
	telecomm/java/com/android/internal/telecomm/IInCallService.aidl \
	telecomm/java/com/android/internal/telecomm/ITelecommService.aidl \
	telecomm/java/com/android/internal/telecomm/RemoteServiceCallback.aidl \
	telephony/java/com/android/internal/telephony/IPhoneStateListener.aidl \
	telephony/java/com/android/internal/telephony/IPhoneSubInfo.aidl \
	telephony/java/com/android/internal/telephony/ITelephony.aidl \
+58 −1
Original line number Diff line number Diff line
@@ -27595,8 +27595,9 @@ package android.telecomm {
    method public abstract void unhold(java.lang.String);
  }
  public final class CallServiceAdapter {
  public final class CallServiceAdapter implements android.os.IBinder.DeathRecipient {
    method public void addConferenceCall(java.lang.String);
    method public void binderDied();
    method public void handleFailedOutgoingCall(android.telecomm.ConnectionRequest, int, java.lang.String);
    method public void handleSuccessfulOutgoingCall(java.lang.String);
    method public void handoffCall(java.lang.String);
@@ -27728,10 +27729,12 @@ package android.telecomm {
  public final class ConnectionRequest implements android.os.Parcelable {
    ctor public ConnectionRequest(android.net.Uri, android.os.Bundle);
    ctor public ConnectionRequest(java.lang.String, android.net.Uri, android.os.Bundle);
    ctor public ConnectionRequest(android.telecomm.Subscription, java.lang.String, android.net.Uri, android.os.Bundle);
    method public int describeContents();
    method public java.lang.String getCallId();
    method public android.os.Bundle getExtras();
    method public android.net.Uri getHandle();
    method public android.telecomm.Subscription getSubscription();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator CREATOR;
  }
@@ -27741,9 +27744,12 @@ package android.telecomm {
    method public final void abort(java.lang.String);
    method public final void answer(java.lang.String);
    method public final void call(android.telecomm.CallInfo);
    method public void createRemoteOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.SimpleResponse<android.telecomm.ConnectionRequest, android.telecomm.RemoteConnection>);
    method public final void disconnect(java.lang.String);
    method public java.util.Collection<android.telecomm.Connection> getAllConnections();
    method public final void hold(java.lang.String);
    method public void lookupRemoteSubscriptions(android.net.Uri, android.telecomm.SimpleResponse<android.net.Uri, java.util.List<android.telecomm.Subscription>>);
    method public void maybeRespondToSubscriptionLookup();
    method public final void onAudioStateChanged(java.lang.String, android.telecomm.CallAudioState);
    method public void onConnectionAdded(android.telecomm.Connection);
    method public void onConnectionRemoved(android.telecomm.Connection);
@@ -27813,11 +27819,46 @@ package android.telecomm {
    method protected abstract void updateCall(android.telecomm.InCallCall);
  }
  public final class RemoteConnection {
    method public void addListener(android.telecomm.RemoteConnection.Listener);
    method public void answer();
    method public void disconnect();
    method public int getDisconnectCause();
    method public java.lang.String getDisconnectMessage();
    method public void hold();
    method public void playDtmf(char);
    method public void postDialContinue(boolean);
    method public void reject();
    method public void removeListener(android.telecomm.RemoteConnection.Listener);
    method public void stopDtmf();
    method public void unhold();
  }
  public static abstract interface RemoteConnection.Listener {
    method public abstract void onAudioStateChanged(android.telecomm.RemoteConnection, android.telecomm.CallAudioState);
    method public abstract void onDestroyed(android.telecomm.RemoteConnection);
    method public abstract void onDisconnected(android.telecomm.RemoteConnection, int, java.lang.String);
    method public abstract void onPostDialWait(android.telecomm.RemoteConnection, java.lang.String);
    method public abstract void onRequestingRingback(android.telecomm.RemoteConnection, boolean);
    method public abstract void onStateChanged(android.telecomm.RemoteConnection, int);
  }
  public class RemoteConnectionService implements android.os.IBinder.DeathRecipient {
    method public void binderDied();
    method public void createOutgoingConnection(android.telecomm.ConnectionRequest, android.telecomm.SimpleResponse<android.telecomm.ConnectionRequest, android.telecomm.RemoteConnection>);
    method public java.util.List<android.telecomm.Subscription> lookupSubscriptions(android.net.Uri);
  }
  public abstract interface Response {
    method public abstract void onError(IN, int, java.lang.String);
    method public abstract void onResult(IN, OUT...);
  }
  public abstract interface SimpleResponse {
    method public abstract void onError(IN);
    method public abstract void onResult(IN, OUT);
  }
  public class Subscription implements android.os.Parcelable {
    ctor public Subscription(android.content.ComponentName, java.lang.String, android.net.Uri, int, int, int, boolean, boolean);
    method public int describeContents();
@@ -38354,6 +38395,22 @@ package android.widget {
}
package com.android.internal.telecomm {
  public abstract interface RemoteServiceCallback implements android.os.IInterface {
    method public abstract void onError() throws android.os.RemoteException;
    method public abstract void onResult(java.util.List<android.content.ComponentName>, java.util.List<android.os.IBinder>) throws android.os.RemoteException;
  }
  public static abstract class RemoteServiceCallback.Stub extends android.os.Binder implements com.android.internal.telecomm.RemoteServiceCallback {
    ctor public RemoteServiceCallback.Stub();
    method public android.os.IBinder asBinder();
    method public static com.android.internal.telecomm.RemoteServiceCallback asInterface(android.os.IBinder);
    method public boolean onTransact(int, android.os.Parcel, android.os.Parcel, int) throws android.os.RemoteException;
  }
}
package com.android.internal.util {
  public abstract interface Predicate {
+2 −4
Original line number Diff line number Diff line
@@ -27,8 +27,6 @@ import com.android.internal.os.SomeArgs;
import com.android.internal.telecomm.ICallService;
import com.android.internal.telecomm.ICallServiceAdapter;

import java.util.List;

/**
 * Base implementation of CallService which can be used to provide calls for the system
 * in-call UI. CallService is a one-way service from the framework's CallsManager to any app
@@ -72,7 +70,7 @@ public abstract class CallService extends Service {
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MSG_SET_CALL_SERVICE_ADAPTER:
                    mAdapter = new CallServiceAdapter((ICallServiceAdapter) msg.obj);
                    mAdapter.addAdapter((ICallServiceAdapter) msg.obj);
                    onAdapterAttached(mAdapter);
                    break;
                case MSG_CALL:
@@ -259,7 +257,7 @@ public abstract class CallService extends Service {
     */
    private final CallServiceBinder mBinder = new CallServiceBinder();

    private CallServiceAdapter mAdapter = null;
    private CallServiceAdapter mAdapter = new CallServiceAdapter();

    /** {@inheritDoc} */
    @Override
+146 −55
Original line number Diff line number Diff line
@@ -16,40 +16,88 @@

package android.telecomm;

import android.content.ComponentName;
import android.os.IBinder;
import android.os.IBinder.DeathRecipient;
import android.os.RemoteException;

import com.android.internal.telecomm.ICallService;
import com.android.internal.telecomm.ICallServiceAdapter;
import com.android.internal.telecomm.RemoteServiceCallback;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

/**
 * Provides methods for ICallService implementations to interact with the system phone app.
 * TODO(santoscordon): Need final public-facing comments in this file.
 * TODO(santoscordon): Rename this to CallServiceAdapterDemultiplexer (or something).
 */
public final class CallServiceAdapter {
    private final ICallServiceAdapter mAdapter;
public final class CallServiceAdapter implements DeathRecipient {
    private final Set<ICallServiceAdapter> mAdapters = new HashSet<>();

    /**
     * {@hide}
     * @hide
     */
    public CallServiceAdapter() {
    }

    /**
     * @hide
     */
    public CallServiceAdapter(ICallServiceAdapter adapter) {
        mAdapter = adapter;
    public void addAdapter(ICallServiceAdapter adapter) {
        if (mAdapters.add(adapter)) {
            try {
                adapter.asBinder().linkToDeath(this, 0);
            } catch (RemoteException e) {
                mAdapters.remove(adapter);
            }
        }
    }

    /**
     * @hide
     */
    public void removeAdapter(ICallServiceAdapter adapter) {
        if (mAdapters.remove(adapter)) {
            adapter.asBinder().unlinkToDeath(this, 0);
        }
    }

    /** ${inheritDoc} */
    @Override
    public void binderDied() {
        ICallServiceAdapter adapterToRemove = null;
        for (ICallServiceAdapter adapter : mAdapters) {
            if (!adapter.asBinder().isBinderAlive()) {
                adapterToRemove = adapter;
                break;
            }
        }

        if (adapterToRemove != null) {
            removeAdapter(adapterToRemove);
        }
    }

    /**
     * Provides Telecomm with the details of an incoming call. An invocation of this method must
     * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon
     * the invocation of this method, Telecomm will bring up the incoming-call interface where the
     * user can elect to answer or reject a call.
     * follow {@link CallService#setIncomingCallId} and use the call ID specified therein. Upon the
     * invocation of this method, Telecomm will bring up the incoming-call interface where the user
     * can elect to answer or reject a call.
     *
     * @param callInfo The details of the relevant call.
     */
    public void notifyIncomingCall(CallInfo callInfo) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.notifyIncomingCall(callInfo);
                adapter.notifyIncomingCall(callInfo);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Tells Telecomm that an attempt to place the specified outgoing call succeeded.
@@ -59,11 +107,13 @@ public final class CallServiceAdapter {
     * @param callId The ID of the outgoing call.
     */
    public void handleSuccessfulOutgoingCall(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.handleSuccessfulOutgoingCall(callId);
                adapter.handleSuccessfulOutgoingCall(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Tells Telecomm that an attempt to place the specified outgoing call failed.
@@ -76,11 +126,13 @@ public final class CallServiceAdapter {
            ConnectionRequest request,
            int errorCode,
            String errorMsg) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.handleFailedOutgoingCall(request, errorCode, errorMsg);
                adapter.handleFailedOutgoingCall(request, errorCode, errorMsg);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to active (e.g., an ongoing call where two parties can actively
@@ -89,11 +141,13 @@ public final class CallServiceAdapter {
     * @param callId The unique ID of the call whose state is changing to active.
     */
    public void setActive(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setActive(callId);
                adapter.setActive(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to ringing (e.g., an inbound ringing call).
@@ -101,11 +155,13 @@ public final class CallServiceAdapter {
     * @param callId The unique ID of the call whose state is changing to ringing.
     */
    public void setRinging(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setRinging(callId);
                adapter.setRinging(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to dialing (e.g., dialing an outbound call).
@@ -113,11 +169,13 @@ public final class CallServiceAdapter {
     * @param callId The unique ID of the call whose state is changing to dialing.
     */
    public void setDialing(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setDialing(callId);
                adapter.setDialing(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to disconnected.
@@ -128,11 +186,13 @@ public final class CallServiceAdapter {
     * @param disconnectMessage Optional call-service-provided message about the disconnect.
     */
    public void setDisconnected(String callId, int disconnectCause, String disconnectMessage) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setDisconnected(callId, disconnectCause, disconnectMessage);
                adapter.setDisconnected(callId, disconnectCause, disconnectMessage);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to be on hold.
@@ -140,11 +200,13 @@ public final class CallServiceAdapter {
     * @param callId - The unique ID of the call whose state is changing to be on hold.
     */
    public void setOnHold(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setOnHold(callId);
                adapter.setOnHold(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Asks Telecomm to start or stop a ringback tone for a call.
@@ -153,11 +215,13 @@ public final class CallServiceAdapter {
     * @param ringback Whether Telecomm should start playing a ringback tone.
     */
    public void setRequestingRingback(String callId, boolean ringback) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setRequestingRingback(callId, ringback);
                adapter.setRequestingRingback(callId, ringback);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Indicates that the specified call can conference with any of the specified list of calls.
@@ -167,11 +231,13 @@ public final class CallServiceAdapter {
     * @hide
     */
    public void setCanConference(String callId, boolean canConference) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setCanConference(callId, canConference);
                adapter.setCanConference(callId, canConference);
            } catch (RemoteException ignored) {
            }
        }
    }

    /**
     * Indicates whether or not the specified call is currently conferenced into the specified
@@ -183,11 +249,13 @@ public final class CallServiceAdapter {
     * @hide
     */
    public void setIsConferenced(String callId, String conferenceCallId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.setIsConferenced(callId, conferenceCallId);
                adapter.setIsConferenced(callId, conferenceCallId);
            } catch (RemoteException ignored) {
            }
        }
    }

    /**
     * Indicates that the call no longer exists. Can be used with either a call or a conference
@@ -197,18 +265,22 @@ public final class CallServiceAdapter {
     * @hide
     */
    public void removeCall(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.removeCall(callId);
                adapter.removeCall(callId);
            } catch (RemoteException ignored) {
            }
        }
    }

    public void onPostDialWait(String callId, String remaining) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.onPostDialWait(callId, remaining);
                adapter.onPostDialWait(callId, remaining);
            } catch (RemoteException ignored) {
            }
        }
    }

    /**
     * Instructs Telecomm to handoff the call to another call service.
@@ -216,11 +288,13 @@ public final class CallServiceAdapter {
     * @param callId The identifier of the call to handoff.
     */
    public void handoffCall(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.handoffCall(callId);
                adapter.handoffCall(callId);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Indicates that a new conference call has been created.
@@ -228,9 +302,26 @@ public final class CallServiceAdapter {
     * @param callId The unique ID of the conference call.
     */
    public void addConferenceCall(String callId) {
        for (ICallServiceAdapter adapter : mAdapters) {
            try {
            mAdapter.addConferenceCall(callId, null);
                adapter.addConferenceCall(callId, null);
            } catch (RemoteException ignored) {
            }
        }
    }

    /**
     * Retrieves a list of remote connection services usable to place calls.
     * @hide
     */
    public void queryRemoteConnectionServices(RemoteServiceCallback callback) {
        // Only supported when there is only one adapter.
        if (mAdapters.size() == 1) {
            try {
                mAdapters.iterator().next().queryRemoteConnectionServices(callback);
            } catch (RemoteException e) {
                Log.e(this, e, "Exception trying to query for remote CSs");
            }
        }
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -33,17 +33,28 @@ public final class ConnectionRequest implements Parcelable {
    private final String mCallId;
    private final Uri mHandle;
    private final Bundle mExtras;
    private final Subscription mSubscription;

    public ConnectionRequest(Uri handle, Bundle extras) {
        this(null, handle, extras);
    }

    public ConnectionRequest(String callId, Uri handle, Bundle extras) {
        this(null, callId, handle, extras);
    }

    public ConnectionRequest(Subscription subscription, String callId, Uri handle, Bundle extras) {
        mCallId = callId;
        mHandle = handle;
        mExtras = extras;
        mSubscription = subscription;
    }

    /**
     * The subscription which should be used to place the call.
     */
    public Subscription getSubscription() { return mSubscription; }

    /**
     * An identifier for this call.
     */
Loading