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

Commit 7cc0bb44 authored by Hall Liu's avatar Hall Liu Committed by Android (Google) Code Review
Browse files

Merge "Integrate the BT multi-hfp apis with Telecom" into pi-dev

parents 195e669f 67eb3b08
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -60,11 +60,18 @@ public class BluetoothHeadsetProxy {
        return mBluetoothHeadset.isAudioConnected(device);
    }

    public boolean connectAudio(String deviceAddress) {
        // TODO: update once the BT stack has this api.
    public boolean connectAudio() {
        return mBluetoothHeadset.connectAudio();
    }

    public boolean setActiveDevice(BluetoothDevice device) {
        return mBluetoothHeadset.setActiveDevice(device);
    }

    public boolean isAudioOn() {
        return mBluetoothHeadset.isAudioOn();
    }

    public boolean disconnectAudio() {
        return mBluetoothHeadset.disconnectAudio();
    }
+2 −0
Original line number Diff line number Diff line
@@ -778,6 +778,8 @@ public class CallAudioRouteStateMachine extends StateMachine {
                    // Send ringer mode change because we transit to ActiveBluetoothState even
                    // when HFP is connecting
                    mCallAudioManager.onRingerModeChange();
                    // Update the in-call app on the new active BT device in case that changed.
                    updateSystemAudioState();
                    return HANDLED;
                case SWITCH_BLUETOOTH:
                case USER_SWITCH_BLUETOOTH:
+4 −0
Original line number Diff line number Diff line
@@ -129,6 +129,10 @@ public class BluetoothDeviceManager {
        mBluetoothHeadsetService = bluetoothHeadset;
    }

    public BluetoothDevice getDeviceFromAddress(String address) {
        return mConnectedDevicesByAddress.get(address);
    }

    void onDeviceConnected(BluetoothDevice device) {
        synchronized (mLock) {
            if (!mConnectedDevicesByAddress.containsKey(device.getAddress())) {
+14 −5
Original line number Diff line number Diff line
@@ -17,11 +17,7 @@
package com.android.server.telecom.bluetooth;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadset;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Message;
import android.telecom.Log;
import android.telecom.Logging.Session;
@@ -712,7 +708,20 @@ public class BluetoothRouteManager extends StateMachine {
            Log.w(this, "Trying to connect audio but no headset service exists.");
            return false;
        }
        return bluetoothHeadset.connectAudio(address);
        BluetoothDevice device = mDeviceManager.getDeviceFromAddress(address);
        if (device == null) {
            Log.w(this, "Attempting to turn on audio for a disconnected device");
            return false;
        }
        boolean success = bluetoothHeadset.setActiveDevice(device);
        if (!success) {
            Log.w(LOG_TAG, "Couldn't set active device to %s", address);
            return false;
        }
        if (!bluetoothHeadset.isAudioOn()) {
            return bluetoothHeadset.connectAudio();
        }
        return true;
    }

    private void disconnectAudio() {
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@
        android:minSdkVersion="23"
        android:targetSdkVersion="23" />

    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE" />
Loading