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

Commit f8b69887 authored by Ihab Awad's avatar Ihab Awad
Browse files

Connection creation and service wiring for WiFi call managers (1/3)

Bug: 16469413
Change-Id: I019922f76f54d2fa376513a6284d6322959a8235
parent 5ad92c52
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -5382,7 +5382,6 @@ package android.app.admin {
    method public android.os.UserHandle createUser(android.content.ComponentName, java.lang.String);
    method public void enableSystemApp(android.content.ComponentName, java.lang.String);
    method public int enableSystemApp(android.content.ComponentName, android.content.Intent);
    method public void setTrustAgentFeaturesEnabled(android.content.ComponentName, android.content.ComponentName, java.util.List<java.lang.String>);
    method public java.lang.String[] getAccountTypesWithManagementDisabled();
    method public java.util.List<android.content.ComponentName> getActiveAdmins();
    method public android.os.Bundle getApplicationRestrictions(android.content.ComponentName, java.lang.String);
@@ -5454,6 +5453,7 @@ package android.app.admin {
    method public void setScreenCaptureDisabled(android.content.ComponentName, boolean);
    method public void setSecureSetting(android.content.ComponentName, java.lang.String, java.lang.String);
    method public int setStorageEncryption(android.content.ComponentName, boolean);
    method public void setTrustAgentFeaturesEnabled(android.content.ComponentName, android.content.ComponentName, java.util.List<java.lang.String>);
    method public boolean switchUser(android.content.ComponentName, android.os.UserHandle);
    method public void uninstallCaCert(android.content.ComponentName, byte[]);
    method public void wipeData(int);
@@ -28729,15 +28729,15 @@ package android.telecomm {
  public abstract class ConnectionService extends android.app.Service {
    ctor public ConnectionService();
    method public final android.telecomm.RemoteConnection createRemoteIncomingConnection(android.telecomm.ConnectionRequest);
    method public final android.telecomm.RemoteConnection createRemoteOutgoingConnection(android.telecomm.ConnectionRequest);
    method public final android.telecomm.RemoteConnection createRemoteIncomingConnection(android.telecomm.PhoneAccountHandle, android.telecomm.ConnectionRequest);
    method public final android.telecomm.RemoteConnection createRemoteOutgoingConnection(android.telecomm.PhoneAccountHandle, android.telecomm.ConnectionRequest);
    method public final java.util.Collection<android.telecomm.Connection> getAllConnections();
    method public final android.os.IBinder onBind(android.content.Intent);
    method public void onConnectionAdded(android.telecomm.Connection);
    method public void onConnectionRemoved(android.telecomm.Connection);
    method public void onCreateConferenceConnection(java.lang.String, android.telecomm.Connection, android.telecomm.Response<java.lang.String, android.telecomm.Connection>);
    method public android.telecomm.Connection onCreateIncomingConnection(android.telecomm.ConnectionRequest);
    method public android.telecomm.Connection onCreateOutgoingConnection(android.telecomm.ConnectionRequest);
    method public android.telecomm.Connection onCreateIncomingConnection(android.telecomm.PhoneAccountHandle, android.telecomm.ConnectionRequest);
    method public android.telecomm.Connection onCreateOutgoingConnection(android.telecomm.PhoneAccountHandle, android.telecomm.ConnectionRequest);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecomm.ConnectionService";
  }
@@ -28855,7 +28855,7 @@ package android.telecomm {
  }
  public class PhoneAccount implements android.os.Parcelable {
    ctor public PhoneAccount(android.telecomm.PhoneAccountHandle, android.net.Uri, java.lang.String, int, int, java.lang.CharSequence, java.lang.CharSequence, boolean);
    ctor public PhoneAccount(android.telecomm.PhoneAccountHandle, android.net.Uri, java.lang.String, int, int, java.lang.CharSequence, java.lang.CharSequence);
    method public int describeContents();
    method public android.telecomm.PhoneAccountHandle getAccountHandle();
    method public int getCapabilities();
@@ -28865,10 +28865,10 @@ package android.telecomm {
    method public java.lang.CharSequence getLabel();
    method public java.lang.CharSequence getShortDescription();
    method public java.lang.String getSubscriptionNumber();
    method public boolean isVideoCallingSupported();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final int CAPABILITY_SIM_CALL_MANAGER = 1; // 0x1
    field public static final int CAPABILITY_CONNECTION_MANAGER = 1; // 0x1
    field public static final int CAPABILITY_SIM_SUBSCRIPTION = 4; // 0x4
    field public static final int CAPABILITY_VIDEO_CALLING = 8; // 0x8
    field public static final android.os.Parcelable.Creator CREATOR;
  }
+98 −25
Original line number Diff line number Diff line
@@ -121,9 +121,15 @@ public abstract class ConnectionService extends Service {
        }

        @Override
        public void createConnection(ConnectionRequest request, boolean isIncoming) {
            mHandler.obtainMessage(
                    MSG_CREATE_CONNECTION, isIncoming ? 1 : 0, 0, request).sendToTarget();
        public void createConnection(
                PhoneAccountHandle connectionManagerPhoneAccount,
                ConnectionRequest request,
                boolean isIncoming) {
            SomeArgs args = SomeArgs.obtain();
            args.arg1 = connectionManagerPhoneAccount;
            args.arg2 = request;
            args.argi1 = isIncoming ? 1 : 0;
            mHandler.obtainMessage(MSG_CREATE_CONNECTION, args).sendToTarget();
        }

        @Override
@@ -217,9 +223,19 @@ public abstract class ConnectionService extends Service {
                    mAdapter.addAdapter((IConnectionServiceAdapter) msg.obj);
                    onAdapterAttached();
                    break;
                case MSG_CREATE_CONNECTION:
                    createConnection((ConnectionRequest) msg.obj, msg.arg1 == 1);
                case MSG_CREATE_CONNECTION: {
                    SomeArgs args = (SomeArgs) msg.obj;
                    try {
                        PhoneAccountHandle connectionManagerPhoneAccount =
                                (PhoneAccountHandle) args.arg1;
                        ConnectionRequest request = (ConnectionRequest) args.arg2;
                        boolean isIncoming = args.argi1 == 1;
                        createConnection(connectionManagerPhoneAccount, request, isIncoming);
                    } finally {
                        args.recycle();
                    }
                    break;
                }
                case MSG_ABORT:
                    abort((String) msg.obj);
                    break;
@@ -428,14 +444,17 @@ public abstract class ConnectionService extends Service {
     * incoming call. In either case, telecomm will cycle through a set of services and call
     * createConnection util a connection service cancels the process or completes it successfully.
     */
    private void createConnection(final ConnectionRequest request, boolean isIncoming) {
    private void createConnection(
            final PhoneAccountHandle callManagerAccount,
            final ConnectionRequest request,
            boolean isIncoming) {
        Log.d(this, "call %s", request);

        final Connection createdConnection;
        if (isIncoming) {
            createdConnection = onCreateIncomingConnection(request);
            createdConnection = onCreateIncomingConnection(callManagerAccount, request);
        } else {
            createdConnection = onCreateOutgoingConnection(request);
            createdConnection = onCreateOutgoingConnection(callManagerAccount, request);
        }

        if (createdConnection != null) {
@@ -641,40 +660,94 @@ public abstract class ConnectionService extends Service {
        });
    }

    public final RemoteConnection createRemoteIncomingConnection(ConnectionRequest request) {
        return mRemoteConnectionManager.createRemoteConnection(request, true);
    /**
     * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
     * incoming request. This is used to attach to existing incoming calls.
     *
     * @param connectionManagerPhoneAccount See description at
     *         {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
     * @param request Details about the incoming call.
     * @return The {@code Connection} object to satisfy this call, or {@code null} to
     *         not handle the call.
     */
    public final RemoteConnection createRemoteIncomingConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request) {
        return mRemoteConnectionManager.createRemoteConnection(
                connectionManagerPhoneAccount, request, true);
    }

    public final RemoteConnection createRemoteOutgoingConnection(ConnectionRequest request) {
        return mRemoteConnectionManager.createRemoteConnection(request, false);
    /**
     * Ask some other {@code ConnectionService} to create a {@code RemoteConnection} given an
     * outgoing request. This is used to initiate new outgoing calls.
     *
     * @param connectionManagerPhoneAccount See description at
     *         {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
     * @param request Details about the incoming call.
     * @return The {@code Connection} object to satisfy this call, or {@code null} to
     *         not handle the call.
     */
    public final RemoteConnection createRemoteOutgoingConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request) {
        return mRemoteConnectionManager.createRemoteConnection(
                connectionManagerPhoneAccount, request, false);
    }

    /**
     * Returns all connections currently associated with this connection service.
     * Returns all the active {@code Connection}s for which this {@code ConnectionService}
     * has taken responsibility.
     *
     * @return A collection of {@code Connection}s created by this {@code ConnectionService}.
     */
    public final Collection<Connection> getAllConnections() {
        return mConnectionById.values();
    }

    /**
     * Create a Connection given an incoming request. This is used to attach to existing incoming
     * calls.
     * @param request Details about the incoming call.
     * Create a {@code Connection} given an incoming request. This is used to attach to existing
     * incoming calls.
     *
     * @return The {@link Connection} object to satisfy this call, or {@code null} to not handle
     * the call.
     * @param connectionManagerPhoneAccount See description at
     *         {@link #onCreateOutgoingConnection(PhoneAccountHandle, ConnectionRequest)}.
     * @param request Details about the incoming call.
     * @return The {@code Connection} object to satisfy this call, or {@code null} to
     *         not handle the call.
     */
    public Connection onCreateIncomingConnection(ConnectionRequest request) { return null; }
    public Connection onCreateIncomingConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request) {
        return null;
    }

    /**
     * Create a Connection given an outgoing request. This is used to initiate new outgoing calls.
     *  @param request Details about the outgoing call.
     *
     * @return The {@link Connection} object to satisfy this request,
     * or null to not handle the call.
     * Create a {@code Connection} given an outgoing request. This is used to initiate new
     * outgoing calls.
     *
     * @param connectionManagerPhoneAccount The connection manager account to use for managing
     *         this call.
     *         <p>
     *         If this parameter is not {@code null}, it means that this {@code ConnectionService}
     *         has registered one or more {@code PhoneAccount}s having
     *         {@link PhoneAccount#CAPABILITY_CONNECTION_MANAGER}. This parameter will contain
     *         one of these {@code PhoneAccount}s, while the {@code request} will contain another
     *         (usually but not always distinct) {@code PhoneAccount} to be used for actually
     *         making the connection.
     *         <p>
     *         If this parameter is {@code null}, it means that this {@code ConnectionService} is
     *         being asked to make a direct connection. The
     *         {@link ConnectionRequest#getAccountHandle()} of parameter {@code request} will be
     *         a {@code PhoneAccount} registered by this {@code ConnectionService} to use for
     *         making the connection.
     * @param request Details about the outgoing call.
     * @return The {@code Connection} object to satisfy this call, or the result of an invocation
     *         of {@link Connection#getFailedConnection(int, String)} to not handle the call.
     */
    public Connection onCreateOutgoingConnection(ConnectionRequest request) { return null; }
    public Connection onCreateOutgoingConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request) {
        return null;
    }

    /**
     * Returns a new or existing conference connection when the the user elects to convert the
+14 −23
Original line number Diff line number Diff line
@@ -32,24 +32,24 @@ import java.util.MissingResourceException;
public class PhoneAccount implements Parcelable {

    /**
     * Flag indicating that this {@code PhoneAccount} can act as a call manager for
     * traditional SIM-based telephony calls. The {@link ConnectionService} associated with this
     * phone-account will be allowed to manage SIM-based phone calls including using its own
     * proprietary phone-call implementation (like VoIP calling) to make calls instead of the
     * telephony stack.
     * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
     * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
     * will be allowed to manage phone calls including using its own proprietary phone-call
     * implementation (like VoIP calling) to make calls instead of the telephony stack.
     * <p>
     * When a user opts to place a call using the SIM-based telephony stack, the connection-service
     * associated with this phone-account will be attempted first if the user has explicitly
     * selected it to be used as the default call-manager.
     * selected it to be used as the default connection manager.
     * <p>
     * See {@link #getCapabilities}
     */
    public static final int CAPABILITY_SIM_CALL_MANAGER = 0x1;
    public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;

    /**
     * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
     * traditional SIM-based telephony calls. This account will be treated as a distinct method
     * for placing calls alongside the traditional SIM-based telephony stack. This flag is
     * distinct from {@link #CAPABILITY_SIM_CALL_MANAGER} in that it is not allowed to manage
     * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
     * calls from or use the built-in telephony stack to place its calls.
     * <p>
     * See {@link #getCapabilities}
@@ -66,6 +66,11 @@ public class PhoneAccount implements Parcelable {
     */
    public static final int CAPABILITY_SIM_SUBSCRIPTION = 0x4;

    /**
     * Flag indicating that this {@code PhoneAccount} is capable of video calling.
     */
    public static final int CAPABILITY_VIDEO_CALLING = 0x8;

    private final PhoneAccountHandle mAccountHandle;
    private final Uri mHandle;
    private final String mSubscriptionNumber;
@@ -73,7 +78,6 @@ public class PhoneAccount implements Parcelable {
    private final int mIconResId;
    private final CharSequence mLabel;
    private final CharSequence mShortDescription;
    private boolean mVideoCallingSupported;

    public PhoneAccount(
            PhoneAccountHandle account,
@@ -82,8 +86,7 @@ public class PhoneAccount implements Parcelable {
            int capabilities,
            int iconResId,
            CharSequence label,
            CharSequence shortDescription,
            boolean supportsVideoCalling) {
            CharSequence shortDescription) {
        mAccountHandle = account;
        mHandle = handle;
        mSubscriptionNumber = subscriptionNumber;
@@ -91,7 +94,6 @@ public class PhoneAccount implements Parcelable {
        mIconResId = iconResId;
        mLabel = label;
        mShortDescription = shortDescription;
        mVideoCallingSupported = supportsVideoCalling;
    }

    /**
@@ -189,15 +191,6 @@ public class PhoneAccount implements Parcelable {
        }
    }

    /**
     * Determines whether this {@code PhoneAccount} supports video calling.
     *
     * @return {@code true} if this {@code PhoneAccount} supports video calling.
     */
    public boolean isVideoCallingSupported() {
        return mVideoCallingSupported;
    }

    //
    // Parcelable implementation
    //
@@ -216,7 +209,6 @@ public class PhoneAccount implements Parcelable {
        out.writeInt(mIconResId);
        out.writeCharSequence(mLabel);
        out.writeCharSequence(mShortDescription);
        out.writeInt(mVideoCallingSupported ? 1 : 0);
    }

    public static final Creator<PhoneAccount> CREATOR
@@ -240,6 +232,5 @@ public class PhoneAccount implements Parcelable {
        mIconResId = in.readInt();
        mLabel = in.readCharSequence();
        mShortDescription = in.readCharSequence();
        mVideoCallingSupported = in.readInt() == 1;
    }
}
+3 −1
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@ public class RemoteConnectionManager {
    }

    public RemoteConnection createRemoteConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request,
            boolean isIncoming) {
        PhoneAccountHandle accountHandle = request.getAccountHandle();
@@ -65,7 +66,8 @@ public class RemoteConnectionManager {

        RemoteConnectionService remoteService = mRemoteConnectionServices.get(componentName);
        if (remoteService != null) {
            return remoteService.createRemoteConnection(request, isIncoming);
            return remoteService.createRemoteConnection(
                    connectionManagerPhoneAccount, request, isIncoming);
        }
        return null;
    }
+8 −4
Original line number Diff line number Diff line
@@ -32,8 +32,6 @@ import com.android.internal.telecomm.IConnectionServiceAdapter;
import com.android.internal.telecomm.IVideoCallProvider;
import com.android.internal.telecomm.RemoteServiceCallback;

import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

/**
@@ -421,7 +419,10 @@ final class RemoteConnectionService implements DeathRecipient {
        release();
    }

    final RemoteConnection createRemoteConnection(ConnectionRequest request, boolean isIncoming) {
    final RemoteConnection createRemoteConnection(
            PhoneAccountHandle connectionManagerPhoneAccount,
            ConnectionRequest request,
            boolean isIncoming) {
        if (mConnectionId == null) {
            String id = UUID.randomUUID().toString();
            ConnectionRequest newRequest = new ConnectionRequest(
@@ -433,7 +434,10 @@ final class RemoteConnectionService implements DeathRecipient {
                    request.getVideoState());
            mConnection = new RemoteConnection(mConnectionService, request, isIncoming);
            try {
                mConnectionService.createConnection(newRequest, isIncoming);
                mConnectionService.createConnection(
                        connectionManagerPhoneAccount,
                        newRequest,
                        isIncoming);
                mConnectionId = id;
            } catch (RemoteException e) {
                mConnection = RemoteConnection.failure(DisconnectCause.ERROR_UNSPECIFIED,
Loading