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

Commit ddee5f0e authored by Gubbala Venugopal Rao's avatar Gubbala Venugopal Rao Committed by Gaurav Asati
Browse files

Bluetooth: Check for last connected A2dp Sep type

Changes made to check last connected A2dp Sep type before
sending conection Request as A2dp SRC.

CRs-fixed: 599358
Change-Id: Ibb8aad022520f73a6f041cb8ab06bd535f0ef516
parent 936fb9c8
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -201,6 +201,28 @@ public class A2dpService extends ProfileService {
        return priority;
    }

    public boolean setLastConnectedA2dpSepType(BluetoothDevice device, int sepType) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                       "Need BLUETOOTH_ADMIN permission");

        Log.d(TAG,"setLastConnectedA2dpSepType: " + sepType);

        Settings.Global.putInt(getContentResolver(),
            Settings.Global.getBluetoothLastConnectedA2dpSepTypeKey(device.getAddress()),
            sepType);
        return true;
    }

    public int getLastConnectedA2dpSepType(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM,
                                       "Need BLUETOOTH_ADMIN permission");
        int sepType = Settings.Global.getInt(getContentResolver(),
            Settings.Global.getBluetoothLastConnectedA2dpSepTypeKey(device.getAddress()),
            BluetoothProfile.PROFILE_A2DP_UNDEFINED);
        return sepType;
    }


    /* Absolute volume implementation */
    public boolean isAvrcpAbsoluteVolumeSupported() {
        return mAvrcp.isAbsoluteVolumeSupported();
+8 −0
Original line number Diff line number Diff line
@@ -773,10 +773,18 @@ final class A2dpStateMachine extends StateMachine {
        if (!isSrcNative(getByteAddress(device))) {
            delay = mAudioManager.setBluetoothA2dpDeviceConnectionState(device, newState);
            log("Peer Device is SNK");
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                mService.setLastConnectedA2dpSepType (device,
                                    BluetoothProfile.PROFILE_A2DP_SNK);
            }
        }
        else {
            delay = 0;
            log("Peer Device is SRC");
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                mService.setLastConnectedA2dpSepType (device,
                                    BluetoothProfile.PROFILE_A2DP_SRC);
            }
        }
        mWakeLock.acquire();
        mIntentBroadcastHandler.sendMessageDelayed(mIntentBroadcastHandler.obtainMessage(
+1 −0
Original line number Diff line number Diff line
@@ -1279,6 +1279,7 @@ public class AdapterService extends Service {
        }
        else if((a2dpConnDevList.isEmpty()) &&
            (a2dpService.getPriority(device) >= BluetoothProfile.PRIORITY_ON) &&
            (a2dpService.getLastConnectedA2dpSepType(device) == BluetoothProfile.PROFILE_A2DP_SNK)&&
            (hsConnected || (hsService.getPriority(device) == BluetoothProfile.PRIORITY_OFF))) {
            a2dpService.connect(device);
        }