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

Commit e58438d8 authored by Bryce Lee's avatar Bryce Lee Committed by android-build-merger
Browse files

Allow for automatic routing on HF AG to be disabled.

am: 9e1b34b2

* commit '9e1b34b2':
  Allow for automatic routing on HF AG to be disabled.
parents c3da0f7b 9e1b34b2
Loading
Loading
Loading
Loading
+23 −0
Original line number Original line Diff line number Diff line
@@ -243,6 +243,21 @@ public class HeadsetService extends ProfileService {
            return service.disconnectAudio();
            return service.disconnectAudio();
        }
        }


        public void setAudioRouteAllowed(boolean allowed) {
            HeadsetService service = getService();
            if (service == null) return;
            service.setAudioRouteAllowed(allowed);
        }

        public boolean getAudioRouteAllowed() {
            HeadsetService service = getService();
            if (service != null) {
                return service.getAudioRouteAllowed();
            }

            return false;
        }

        public boolean startScoUsingVirtualVoiceCall(BluetoothDevice device) {
        public boolean startScoUsingVirtualVoiceCall(BluetoothDevice device) {
            HeadsetService service = getService();
            HeadsetService service = getService();
            if (service == null) return false;
            if (service == null) return false;
@@ -448,6 +463,14 @@ public class HeadsetService extends ProfileService {
        return mStateMachine.getAudioState(device);
        return mStateMachine.getAudioState(device);
    }
    }


    public void setAudioRouteAllowed(boolean allowed) {
        mStateMachine.setAudioRouteAllowed(allowed);
    }

    public boolean getAudioRouteAllowed() {
        return mStateMachine.getAudioRouteAllowed();
    }

    boolean connectAudio() {
    boolean connectAudio() {
        // TODO(BT) BLUETOOTH or BLUETOOTH_ADMIN permission
        // TODO(BT) BLUETOOTH or BLUETOOTH_ADMIN permission
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
+12 −1
Original line number Original line Diff line number Diff line
@@ -162,6 +162,9 @@ final class HeadsetStateMachine extends StateMachine {
    private IBluetoothHeadsetPhone mPhoneProxy;
    private IBluetoothHeadsetPhone mPhoneProxy;
    private boolean mNativeAvailable;
    private boolean mNativeAvailable;


    // Indicates whether audio can be routed to the device.
    private boolean mAudioRouteAllowed = true;

    // mCurrentDevice is the device connected before the state changes
    // mCurrentDevice is the device connected before the state changes
    // mTargetDevice is the device to be connected
    // mTargetDevice is the device to be connected
    // mIncomingDevice is the device connecting to us, valid only in Pending state
    // mIncomingDevice is the device connecting to us, valid only in Pending state
@@ -2153,6 +2156,14 @@ final class HeadsetStateMachine extends StateMachine {
        return false;
        return false;
    }
    }


    public void setAudioRouteAllowed(boolean allowed) {
        mAudioRouteAllowed = allowed;
    }

    public boolean getAudioRouteAllowed() {
        return mAudioRouteAllowed;
    }

    int getAudioState(BluetoothDevice device) {
    int getAudioState(BluetoothDevice device) {
        synchronized(this) {
        synchronized(this) {
            if (mConnectedDevicesList.size() == 0) {
            if (mConnectedDevicesList.size() == 0) {
@@ -3292,7 +3303,7 @@ final class HeadsetStateMachine extends StateMachine {
    // Accept incoming SCO only when there is active call, VR activated,
    // Accept incoming SCO only when there is active call, VR activated,
    // active VOIP call
    // active VOIP call
    private boolean isScoAcceptable() {
    private boolean isScoAcceptable() {
        return (mVoiceRecognitionStarted || isInCall());
        return mAudioRouteAllowed && (mVoiceRecognitionStarted || isInCall());
    }
    }


    boolean isConnected() {
    boolean isConnected() {