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

Commit 4e22d6dc authored by Christine Hallstrom's avatar Christine Hallstrom
Browse files

Add ability to set supported audio routes on phone accounts and connection

The set audio routes are used by Telecom to restrict where the audio may
be routed to. For example, an account can specify that calls may not be
routed over bluetooth headsets, which will prevent a new call from being
routed to this source.

This is a cherry-pick of abandoned ag/1521009.

Bug: 32958838
Change-Id: Idd5e4d38b157f11454f3d991385644f2f384596e
parent 75bf8145
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -324,6 +324,7 @@ public final class Call {
        private final PhoneAccountHandle mAccountHandle;
        private final int mCallCapabilities;
        private final int mCallProperties;
        private final int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
        private final DisconnectCause mDisconnectCause;
        private final long mConnectTimeMillis;
        private final GatewayInfo mGatewayInfo;
@@ -535,6 +536,15 @@ public final class Call {
            return mCallProperties;
        }

        /**
         * @return a bitmask of the audio routes available for the call.
         *
         * @hide
         */
        public int getSupportedAudioRoutes() {
            return mSupportedAudioRoutes;
        }

        /**
         * @return For a {@link #STATE_DISCONNECTED} {@code Call}, the disconnect cause expressed
         * by {@link android.telecom.DisconnectCause}.
+6 −2
Original line number Diff line number Diff line
@@ -44,8 +44,12 @@ public final class CallAudioState implements Parcelable {
     */
    public static final int ROUTE_WIRED_OR_EARPIECE = ROUTE_EARPIECE | ROUTE_WIRED_HEADSET;

    /** Bit mask of all possible audio routes. */
    private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET |
    /**
     * Bit mask of all possible audio routes.
     *
     * @hide
     **/
    public static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET |
            ROUTE_SPEAKER;

    private final boolean isMuted;
+33 −0
Original line number Diff line number Diff line
@@ -722,6 +722,7 @@ public abstract class Connection extends Conferenceable {
        public void onDestroyed(Connection c) {}
        public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
        public void onConnectionPropertiesChanged(Connection c, int properties) {}
        public void onSupportedAudioRoutesChanged(Connection c, int supportedAudioRoutes) {}
        public void onVideoProviderChanged(
                Connection c, VideoProvider videoProvider) {}
        public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@@ -1428,6 +1429,7 @@ public abstract class Connection extends Conferenceable {
    private boolean mRingbackRequested = false;
    private int mConnectionCapabilities;
    private int mConnectionProperties;
    private int mSupportedAudioRoutes = CallAudioState.ROUTE_ALL;
    private VideoProvider mVideoProvider;
    private boolean mAudioModeIsVoip;
    private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
@@ -1707,6 +1709,15 @@ public abstract class Connection extends Conferenceable {
        return mConnectionProperties;
    }

    /**
     * Returns the connection's supported audio routes.
     *
     * @hide
     */
    public final int getSupportedAudioRoutes() {
        return mSupportedAudioRoutes;
    }

    /**
     * Sets the value of the {@link #getAddress()} property.
     *
@@ -1928,6 +1939,28 @@ public abstract class Connection extends Conferenceable {
        }
    }

    /**
     * Sets the supported audio routes.
     *
     * @param supportedAudioRoutes the supported audio routes as a bitmask.
     *                             See {@link CallAudioState}
     * @hide
     */
    public final void setSupportedAudioRoutes(int supportedAudioRoutes) {
        if ((supportedAudioRoutes
                & (CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_SPEAKER)) == 0) {
            throw new IllegalArgumentException(
                    "supported audio routes must include either speaker or earpiece");
        }

        if (mSupportedAudioRoutes != supportedAudioRoutes) {
            mSupportedAudioRoutes = supportedAudioRoutes;
            for (Listener l : mListeners) {
                l.onSupportedAudioRoutesChanged(this, mSupportedAudioRoutes);
            }
        }
    }

    /**
     * Tears down the Connection object.
     */
+2 −0
Original line number Diff line number Diff line
@@ -776,6 +776,7 @@ public abstract class ConnectionService extends Service {
                        connection.getState(),
                        connection.getConnectionCapabilities(),
                        connection.getConnectionProperties(),
                        connection.getSupportedAudioRoutes(),
                        connection.getAddress(),
                        connection.getAddressPresentation(),
                        connection.getCallerDisplayName(),
@@ -1175,6 +1176,7 @@ public abstract class ConnectionService extends Service {
                    connection.getState(),
                    connection.getConnectionCapabilities(),
                    connection.getConnectionProperties(),
                    connection.getSupportedAudioRoutes(),
                    connection.getAddress(),
                    connection.getAddressPresentation(),
                    connection.getCallerDisplayName(),
+11 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ public final class ParcelableCall implements Parcelable {
    private final List<String> mCannedSmsResponses;
    private final int mCapabilities;
    private final int mProperties;
    private final int mSupportedAudioRoutes;
    private final long mConnectTimeMillis;
    private final Uri mHandle;
    private final int mHandlePresentation;
@@ -64,6 +65,7 @@ public final class ParcelableCall implements Parcelable {
            List<String> cannedSmsResponses,
            int capabilities,
            int properties,
            int supportedAudioRoutes,
            long connectTimeMillis,
            Uri handle,
            int handlePresentation,
@@ -86,6 +88,7 @@ public final class ParcelableCall implements Parcelable {
        mCannedSmsResponses = cannedSmsResponses;
        mCapabilities = capabilities;
        mProperties = properties;
        mSupportedAudioRoutes = supportedAudioRoutes;
        mConnectTimeMillis = connectTimeMillis;
        mHandle = handle;
        mHandlePresentation = handlePresentation;
@@ -137,6 +140,11 @@ public final class ParcelableCall implements Parcelable {
    /** Bitmask of properties of the call. */
    public int getProperties() { return mProperties; }

    /** Bitmask of supported routes of the call */
    public int getSupportedAudioRoutes() {
        return mSupportedAudioRoutes;
    }

    /** The time that the call switched to the active state. */
    public long getConnectTimeMillis() {
        return mConnectTimeMillis;
@@ -292,6 +300,7 @@ public final class ParcelableCall implements Parcelable {
            source.readList(conferenceableCallIds, classLoader);
            Bundle intentExtras = source.readBundle(classLoader);
            Bundle extras = source.readBundle(classLoader);
            int supportedAudioRoutes = source.readInt();
            return new ParcelableCall(
                    id,
                    state,
@@ -299,6 +308,7 @@ public final class ParcelableCall implements Parcelable {
                    cannedSmsResponses,
                    capabilities,
                    properties,
                    supportedAudioRoutes,
                    connectTimeMillis,
                    handle,
                    handlePresentation,
@@ -355,6 +365,7 @@ public final class ParcelableCall implements Parcelable {
        destination.writeList(mConferenceableCallIds);
        destination.writeBundle(mIntentExtras);
        destination.writeBundle(mExtras);
        destination.writeInt(mSupportedAudioRoutes);
    }

    @Override
Loading