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

Commit a60b738a authored by Yuyang Huang's avatar Yuyang Huang
Browse files

If sink audio policy makes the device active for a call, then after call ends,...

If sink audio policy makes the device active for a call, then after call ends, resume previous active device

Bug: 305636605
Bug: 333562819
Test: m manual with BluetoothSinkAudioPolicy watches
Change-Id: I4210b3b106f1da64942e32fe00b8091daa7e73f0
parent 0551cac0
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -1900,12 +1900,25 @@ public class HeadsetService extends ProfileService {
                if (currentPolicy != null && currentPolicy.getActiveDevicePolicyAfterConnection()
                        == BluetoothSinkAudioPolicy.POLICY_NOT_ALLOWED) {
                    /**
                     * If the active device was set because of the pick up audio policy
                     * and the connecting policy is NOT_ALLOWED, then after the call is
                     * terminated, we must de-activate this device.
                     * If there is a fallback mechanism, we should follow it.
                     * If the active device was set because of the pick up audio policy and the
                     * connecting policy is NOT_ALLOWED, then after the call is terminated, we must
                     * de-activate this device. If there is a fallback mechanism, we should follow
                     * it to set fallback device be active.
                     */
                    removeActiveDevice();
                    if (Flags.sinkAudioPolicyHandover()) {
                        BluetoothDevice fallbackDevice = getFallbackDevice();
                        if (fallbackDevice != null
                                && getConnectionState(fallbackDevice)
                                        == BluetoothProfile.STATE_CONNECTED) {
                            Log.d(
                                    TAG,
                                    "BluetoothSinkAudioPolicy set fallbackDevice="
                                            + fallbackDevice
                                            + " active");
                            setActiveDevice(fallbackDevice);
                        }
                    }
                }
            }
        }