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

Commit a591149c authored by Hall Liu's avatar Hall Liu Committed by android-build-merger
Browse files

Merge "Update Telecom APIs to include multi-hfp" am: 025718e8 am: 3dd41b7b

am: 518a82c9

Change-Id: I0309cfd98f38a54b741a9dc09d1fb65159d5a4b7
parents 288536b6 518a82c9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -39326,7 +39326,9 @@ package android.telecom {
    ctor public CallAudioState(boolean, int, int);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public android.bluetooth.BluetoothDevice getActiveBluetoothDevice();
    method public int getRoute();
    method public java.util.Collection<android.bluetooth.BluetoothDevice> getSupportedBluetoothDevices();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
@@ -39458,6 +39460,7 @@ package android.telecom {
    method public final void putExtras(android.os.Bundle);
    method public final void removeExtras(java.util.List<java.lang.String>);
    method public final void removeExtras(java.lang.String...);
    method public void requestBluetoothAudio(java.lang.String);
    method public void sendConnectionEvent(java.lang.String, android.os.Bundle);
    method public final void setActive();
    method public final void setAddress(android.net.Uri, int);
@@ -39648,6 +39651,7 @@ package android.telecom {
    method public void onCanAddCallChanged(boolean);
    method public void onConnectionEvent(android.telecom.Call, java.lang.String, android.os.Bundle);
    method public void onSilenceRinger();
    method public final void requestBluetoothAudio(java.lang.String);
    method public final void setAudioRoute(int);
    method public final void setMuted(boolean);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.InCallService";
+5 −0
Original line number Diff line number Diff line
@@ -42652,7 +42652,9 @@ package android.telecom {
    ctor public CallAudioState(boolean, int, int);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public android.bluetooth.BluetoothDevice getActiveBluetoothDevice();
    method public int getRoute();
    method public java.util.Collection<android.bluetooth.BluetoothDevice> getSupportedBluetoothDevices();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
@@ -42791,6 +42793,7 @@ package android.telecom {
    method public final void putExtras(android.os.Bundle);
    method public final void removeExtras(java.util.List<java.lang.String>);
    method public final void removeExtras(java.lang.String...);
    method public void requestBluetoothAudio(java.lang.String);
    method public void sendConnectionEvent(java.lang.String, android.os.Bundle);
    method public final void setActive();
    method public final void setAddress(android.net.Uri, int);
@@ -42984,6 +42987,7 @@ package android.telecom {
    method public deprecated void onPhoneCreated(android.telecom.Phone);
    method public deprecated void onPhoneDestroyed(android.telecom.Phone);
    method public void onSilenceRinger();
    method public final void requestBluetoothAudio(java.lang.String);
    method public final void setAudioRoute(int);
    method public final void setMuted(boolean);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.InCallService";
@@ -43122,6 +43126,7 @@ package android.telecom {
    method public final android.telecom.CallAudioState getCallAudioState();
    method public final java.util.List<android.telecom.Call> getCalls();
    method public final void removeListener(android.telecom.Phone.Listener);
    method public void requestBluetoothAudio(java.lang.String);
    method public final void setAudioRoute(int);
    method public final void setMuted(boolean);
  }
+4 −0
Original line number Diff line number Diff line
@@ -39717,7 +39717,9 @@ package android.telecom {
    ctor public CallAudioState(boolean, int, int);
    method public static java.lang.String audioRouteToString(int);
    method public int describeContents();
    method public android.bluetooth.BluetoothDevice getActiveBluetoothDevice();
    method public int getRoute();
    method public java.util.Collection<android.bluetooth.BluetoothDevice> getSupportedBluetoothDevices();
    method public int getSupportedRouteMask();
    method public boolean isMuted();
    method public void writeToParcel(android.os.Parcel, int);
@@ -39852,6 +39854,7 @@ package android.telecom {
    method public final void putExtras(android.os.Bundle);
    method public final void removeExtras(java.util.List<java.lang.String>);
    method public final void removeExtras(java.lang.String...);
    method public void requestBluetoothAudio(java.lang.String);
    method public void sendConnectionEvent(java.lang.String, android.os.Bundle);
    method public final void sendRemoteRttRequest();
    method public final void sendRttInitiationFailure(int);
@@ -40055,6 +40058,7 @@ package android.telecom {
    method public void onCanAddCallChanged(boolean);
    method public void onConnectionEvent(android.telecom.Call, java.lang.String, android.os.Bundle);
    method public void onSilenceRinger();
    method public final void requestBluetoothAudio(java.lang.String);
    method public final void setAudioRoute(int);
    method public final void setMuted(boolean);
    field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.InCallService";
+83 −7
Original line number Diff line number Diff line
@@ -16,16 +16,35 @@

package android.telecom;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.bluetooth.BluetoothDevice;
import android.os.Parcel;
import android.os.Parcelable;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 *  Encapsulates the telecom audio state, including the current audio routing, supported audio
 *  routing and mute.
 */
public final class CallAudioState implements Parcelable {
    /** @hide */
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(value={ROUTE_EARPIECE, ROUTE_BLUETOOTH, ROUTE_WIRED_HEADSET, ROUTE_SPEAKER},
            flag=true)
    public @interface CallAudioRoute {}

    /** Direct the audio stream through the device's earpiece. */
    public static final int ROUTE_EARPIECE      = 0x00000001;

@@ -55,6 +74,8 @@ public final class CallAudioState implements Parcelable {
    private final boolean isMuted;
    private final int route;
    private final int supportedRouteMask;
    private final BluetoothDevice activeBluetoothDevice;
    private final Collection<BluetoothDevice> supportedBluetoothDevices;

    /**
     * Constructor for a {@link CallAudioState} object.
@@ -73,10 +94,21 @@ public final class CallAudioState implements Parcelable {
     * {@link #ROUTE_WIRED_HEADSET}
     * {@link #ROUTE_SPEAKER}
     */
    public CallAudioState(boolean muted, int route, int supportedRouteMask) {
        this.isMuted = muted;
    public CallAudioState(boolean muted, @CallAudioRoute int route,
            @CallAudioRoute int supportedRouteMask) {
        this(muted, route, supportedRouteMask, null, Collections.emptyList());
    }

    /** @hide */
    public CallAudioState(boolean isMuted, @CallAudioRoute int route,
            @CallAudioRoute int supportedRouteMask,
            @Nullable BluetoothDevice activeBluetoothDevice,
            @NonNull Collection<BluetoothDevice> supportedBluetoothDevices) {
        this.isMuted = isMuted;
        this.route = route;
        this.supportedRouteMask = supportedRouteMask;
        this.activeBluetoothDevice = activeBluetoothDevice;
        this.supportedBluetoothDevices = supportedBluetoothDevices;
    }

    /** @hide */
@@ -84,6 +116,8 @@ public final class CallAudioState implements Parcelable {
        isMuted = state.isMuted();
        route = state.getRoute();
        supportedRouteMask = state.getSupportedRouteMask();
        activeBluetoothDevice = state.activeBluetoothDevice;
        supportedBluetoothDevices = state.getSupportedBluetoothDevices();
    }

    /** @hide */
@@ -92,6 +126,8 @@ public final class CallAudioState implements Parcelable {
        isMuted = state.isMuted();
        route = state.getRoute();
        supportedRouteMask = state.getSupportedRouteMask();
        activeBluetoothDevice = null;
        supportedBluetoothDevices = Collections.emptyList();
    }

    @Override
@@ -103,17 +139,32 @@ public final class CallAudioState implements Parcelable {
            return false;
        }
        CallAudioState state = (CallAudioState) obj;
        return isMuted() == state.isMuted() && getRoute() == state.getRoute() &&
                getSupportedRouteMask() == state.getSupportedRouteMask();
        if (supportedBluetoothDevices.size() != state.supportedBluetoothDevices.size()) {
            return false;
        }
        for (BluetoothDevice device : supportedBluetoothDevices) {
            if (!state.supportedBluetoothDevices.contains(device)) {
                return false;
            }
        }
        return Objects.equals(activeBluetoothDevice, state.activeBluetoothDevice) && isMuted() ==
                state.isMuted() && getRoute() == state.getRoute() && getSupportedRouteMask() ==
                state.getSupportedRouteMask();
    }

    @Override
    public String toString() {
        String bluetoothDeviceList = supportedBluetoothDevices.stream()
                .map(BluetoothDevice::getAddress).collect(Collectors.joining(", "));

        return String.format(Locale.US,
                "[AudioState isMuted: %b, route: %s, supportedRouteMask: %s]",
                "[AudioState isMuted: %b, route: %s, supportedRouteMask: %s, " +
                        "activeBluetoothDevice: [%s], supportedBluetoothDevices: [%s]]",
                isMuted,
                audioRouteToString(route),
                audioRouteToString(supportedRouteMask));
                audioRouteToString(supportedRouteMask),
                activeBluetoothDevice,
                bluetoothDeviceList);
    }

    /**
@@ -126,6 +177,7 @@ public final class CallAudioState implements Parcelable {
    /**
     * @return The current audio route being used.
     */
    @CallAudioRoute
    public int getRoute() {
        return route;
    }
@@ -133,10 +185,26 @@ public final class CallAudioState implements Parcelable {
    /**
     * @return Bit mask of all routes supported by this call.
     */
    @CallAudioRoute
    public int getSupportedRouteMask() {
        return supportedRouteMask;
    }

    /**
     * @return The {@link BluetoothDevice} through which audio is being routed.
     *         Will not be {@code null} if {@link #getRoute()} returns {@link #ROUTE_BLUETOOTH}.
     */
    public BluetoothDevice getActiveBluetoothDevice() {
        return activeBluetoothDevice;
    }

    /**
     * @return {@link List} of {@link BluetoothDevice}s that can be used for this call.
     */
    public Collection<BluetoothDevice> getSupportedBluetoothDevices() {
        return supportedBluetoothDevices;
    }

    /**
     * Converts the provided audio route into a human readable string representation.
     *
@@ -177,7 +245,13 @@ public final class CallAudioState implements Parcelable {
            boolean isMuted = source.readByte() == 0 ? false : true;
            int route = source.readInt();
            int supportedRouteMask = source.readInt();
            return new CallAudioState(isMuted, route, supportedRouteMask);
            BluetoothDevice activeBluetoothDevice = source.readParcelable(
                    ClassLoader.getSystemClassLoader());
            List<BluetoothDevice> supportedBluetoothDevices = new ArrayList<>();
            source.readParcelableList(supportedBluetoothDevices,
                    ClassLoader.getSystemClassLoader());
            return new CallAudioState(isMuted, route,
                    supportedRouteMask, activeBluetoothDevice, supportedBluetoothDevices);
        }

        @Override
@@ -202,6 +276,8 @@ public final class CallAudioState implements Parcelable {
        destination.writeByte((byte) (isMuted ? 1 : 0));
        destination.writeInt(route);
        destination.writeInt(supportedRouteMask);
        destination.writeParcelable(activeBluetoothDevice, 0);
        destination.writeParcelableList(new ArrayList<>(supportedBluetoothDevices), 0);
    }

    private static void listAppend(StringBuffer buffer, String str) {
+25 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.app.Notification;
import android.bluetooth.BluetoothDevice;
import android.content.Intent;
import android.hardware.camera2.CameraManager;
import android.net.Uri;
@@ -819,7 +820,7 @@ public abstract class Connection extends Conferenceable {
        public void onConnectionEvent(Connection c, String event, Bundle extras) {}
        /** @hide */
        public void onConferenceSupportedChanged(Connection c, boolean isConferenceSupported) {}
        public void onAudioRouteChanged(Connection c, int audioRoute) {}
        public void onAudioRouteChanged(Connection c, int audioRoute, String bluetoothAddress) {}
        public void onRttInitiationSuccess(Connection c) {}
        public void onRttInitiationFailure(Connection c, int reason) {}
        public void onRttSessionRemotelyTerminated(Connection c) {}
@@ -2576,7 +2577,29 @@ public abstract class Connection extends Conferenceable {
     */
    public final void setAudioRoute(int route) {
        for (Listener l : mListeners) {
            l.onAudioRouteChanged(this, route);
            l.onAudioRouteChanged(this, route, null);
        }
    }

    /**
     *
     * Request audio routing to a specific bluetooth device. Calling this method may result in
     * the device routing audio to a different bluetooth device than the one specified if the
     * bluetooth stack is unable to route audio to the requested device.
     * A list of available devices can be obtained via
     * {@link CallAudioState#getSupportedBluetoothDevices()}
     *
     * <p>
     * Used by self-managed {@link ConnectionService}s which wish to use bluetooth audio for a
     * self-managed {@link Connection} (see {@link PhoneAccount#CAPABILITY_SELF_MANAGED}.)
     * <p>
     * See also {@link InCallService#requestBluetoothAudio(String)}
     * @param bluetoothAddress The address of the bluetooth device to connect to, as returned by
     *                         {@link BluetoothDevice#getAddress()}.
     */
    public void requestBluetoothAudio(@NonNull String bluetoothAddress) {
        for (Listener l : mListeners) {
            l.onAudioRouteChanged(this, CallAudioState.ROUTE_BLUETOOTH, bluetoothAddress);
        }
    }

Loading