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

Commit 7f38c642 authored by Sanket Agarwal's avatar Sanket Agarwal Committed by Android (Google) Code Review
Browse files

Merge "Use UUIDs for call management in Headset Client (HF)"

parents ff962c86 40bb6f3f
Loading
Loading
Loading
Loading
+14 −59
Original line number Original line Diff line number Diff line
@@ -27,6 +27,7 @@ import android.util.Log;


import java.util.ArrayList;
import java.util.ArrayList;
import java.util.List;
import java.util.List;
import java.util.UUID;


/**
/**
 * Public API to control Hands Free Profile (HFP role only).
 * Public API to control Hands Free Profile (HFP role only).
@@ -799,7 +800,9 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
     * Works only when Extended Call Control is supported by Audio Gateway.
     * Works only when Extended Call Control is supported by Audio Gateway.
     *
     *
     * @param device    remote device
     * @param device    remote device
     * @param index     index of the call to be terminated
     * @param call      Handle of call obtained in {@link dial()} or obtained via
     *                  {@link ACTION_CALL_CHANGED}. {@code call} may be null in which
     *                  case we will hangup all active calls.
     * @return          <code>true</code> if command has been issued successfully;
     * @return          <code>true</code> if command has been issued successfully;
     *                   <code>false</code> otherwise;
     *                   <code>false</code> otherwise;
     *                   upon completion HFP sends {@link #ACTION_CALL_CHANGED}
     *                   upon completion HFP sends {@link #ACTION_CALL_CHANGED}
@@ -809,12 +812,12 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
     * {@link #EXTRA_AG_FEATURE_ECC}.
     * {@link #EXTRA_AG_FEATURE_ECC}.
     * This method invocation will fail silently when feature is not supported.</p>
     * This method invocation will fail silently when feature is not supported.</p>
     */
     */
    public boolean terminateCall(BluetoothDevice device, int index) {
    public boolean terminateCall(BluetoothDevice device, BluetoothHeadsetClientCall call) {
        if (DBG) log("terminateCall()");
        if (DBG) log("terminateCall()");
        if (mService != null && isEnabled() &&
        if (mService != null && isEnabled() &&
                isValidDevice(device)) {
                isValidDevice(device)) {
            try {
            try {
                return mService.terminateCall(device, index);
                return mService.terminateCall(device, call);
            } catch (RemoteException e) {
            } catch (RemoteException e) {
                Log.e(TAG,  Log.getStackTraceString(new Throwable()));
                Log.e(TAG,  Log.getStackTraceString(new Throwable()));
            }
            }
@@ -882,42 +885,19 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
        return false;
        return false;
    }
    }


    /**
     * Redials last number from Audio Gateway.
     *
     * @param device    remote device
     * @return          <code>true</code> if command has been issued successfully;
     *                   <code>false</code> otherwise;
     *                   upon completion HFP sends {@link #ACTION_CALL_CHANGED}
     *                   intent in case of success; {@link #ACTION_RESULT} is sent
     *                   otherwise;
     */
    public boolean redial(BluetoothDevice device) {
        if (DBG) log("redial()");
        if (mService != null && isEnabled() &&
                isValidDevice(device)) {
            try {
                return mService.redial(device);
            } catch (RemoteException e) {
                Log.e(TAG,  Log.getStackTraceString(new Throwable()));
            }
        }
        if (mService == null) Log.w(TAG, "Proxy not attached to service");
        return false;
    }

    /**
    /**
     * Places a call with specified number.
     * Places a call with specified number.
     *
     *
     * @param device    remote device
     * @param device    remote device
     * @param number    valid phone number
     * @param number    valid phone number
     * @return          <code>true</code> if command has been issued successfully;
     * @return          <code>{@link BluetoothHeadsetClientCall} call</code> if command has been
     *                   <code>false</code> otherwise;
     *                  issued successfully;
     *                  <code>{@link null}</code> otherwise;
     *                  upon completion HFP sends {@link #ACTION_CALL_CHANGED}
     *                  upon completion HFP sends {@link #ACTION_CALL_CHANGED}
     *                  intent in case of success; {@link #ACTION_RESULT} is sent
     *                  intent in case of success; {@link #ACTION_RESULT} is sent
     *                  otherwise;
     *                  otherwise;
     */
     */
    public boolean dial(BluetoothDevice device, String number) {
    public BluetoothHeadsetClientCall dial(BluetoothDevice device, String number) {
        if (DBG) log("dial()");
        if (DBG) log("dial()");
        if (mService != null && isEnabled() &&
        if (mService != null && isEnabled() &&
                isValidDevice(device)) {
                isValidDevice(device)) {
@@ -928,32 +908,7 @@ public final class BluetoothHeadsetClient implements BluetoothProfile {
            }
            }
        }
        }
        if (mService == null) Log.w(TAG, "Proxy not attached to service");
        if (mService == null) Log.w(TAG, "Proxy not attached to service");
        return false;
        return null;
    }

    /**
     * Places a call to the number under specified memory location.
     *
     * @param device    remote device
     * @param location  valid memory location
     * @return          <code>true</code> if command has been issued successfully;
     *                   <code>false</code> otherwise;
     *                   upon completion HFP sends {@link #ACTION_CALL_CHANGED}
     *                   intent in case of success; {@link #ACTION_RESULT} is sent
     *                   otherwise;
     */
    public boolean dialMemory(BluetoothDevice device, int location) {
        if (DBG) log("dialMemory()");
        if (mService != null && isEnabled() &&
                isValidDevice(device)) {
            try {
                return mService.dialMemory(device, location);
            } catch (RemoteException e) {
                Log.e(TAG,  Log.getStackTraceString(new Throwable()));
            }
        }
        if (mService == null) Log.w(TAG, "Proxy not attached to service");
        return false;
    }
    }


    /**
    /**
+12 −0
Original line number Original line Diff line number Diff line
@@ -18,6 +18,7 @@ package android.bluetooth;


import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.SystemClock;


import java.util.UUID;
import java.util.UUID;


@@ -70,6 +71,7 @@ public final class BluetoothHeadsetClientCall implements Parcelable {
    private boolean mMultiParty;
    private boolean mMultiParty;
    private final boolean mOutgoing;
    private final boolean mOutgoing;
    private final UUID mUUID;
    private final UUID mUUID;
    private final long mCreationElapsedMilli;


    /**
    /**
     * Creates BluetoothHeadsetClientCall instance.
     * Creates BluetoothHeadsetClientCall instance.
@@ -88,6 +90,7 @@ public final class BluetoothHeadsetClientCall implements Parcelable {
        mNumber = number != null ? number : "";
        mNumber = number != null ? number : "";
        mMultiParty = multiParty;
        mMultiParty = multiParty;
        mOutgoing = outgoing;
        mOutgoing = outgoing;
        mCreationElapsedMilli = SystemClock.elapsedRealtime();
    }
    }


    /**
    /**
@@ -170,6 +173,15 @@ public final class BluetoothHeadsetClientCall implements Parcelable {
        return mNumber;
        return mNumber;
    }
    }


    /**
     * Gets call's creation time in millis since epoch.
     *
     * @return long representing the creation time.
     */
    public long getCreationElapsedMilli() {
        return mCreationElapsedMilli;
    }

    /**
    /**
     * Checks if call is an active call in a conference mode (aka multi party).
     * Checks if call is an active call in a conference mode (aka multi party).
     *
     *
+2 −4
Original line number Original line Diff line number Diff line
@@ -47,14 +47,12 @@ interface IBluetoothHeadsetClient {
    boolean acceptCall(in BluetoothDevice device, int flag);
    boolean acceptCall(in BluetoothDevice device, int flag);
    boolean holdCall(in BluetoothDevice device);
    boolean holdCall(in BluetoothDevice device);
    boolean rejectCall(in BluetoothDevice device);
    boolean rejectCall(in BluetoothDevice device);
    boolean terminateCall(in BluetoothDevice device, int index);
    boolean terminateCall(in BluetoothDevice device, in BluetoothHeadsetClientCall call);


    boolean enterPrivateMode(in BluetoothDevice device, int index);
    boolean enterPrivateMode(in BluetoothDevice device, int index);
    boolean explicitCallTransfer(in BluetoothDevice device);
    boolean explicitCallTransfer(in BluetoothDevice device);


    boolean redial(in BluetoothDevice device);
    BluetoothHeadsetClientCall dial(in BluetoothDevice device, String number);
    boolean dial(in BluetoothDevice device, String number);
    boolean dialMemory(in BluetoothDevice device, int location);


    boolean sendDTMF(in BluetoothDevice device, byte code);
    boolean sendDTMF(in BluetoothDevice device, byte code);
    boolean getLastVoiceTagNumber(in BluetoothDevice device);
    boolean getLastVoiceTagNumber(in BluetoothDevice device);