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

Commit 72cd64b2 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

resolved conflicts for merge of bbb90d13 to master

Change-Id: I85de73f6e11e7547a006d41ca49021bca19af14b
parents 97929aa9 bbb90d13
Loading
Loading
Loading
Loading
+25 −4
Original line number Diff line number Diff line
@@ -156,6 +156,10 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                Message msg = new Message();
                msg.what = AUTO_CONNECT_PROFILES;
                sendMessageDelayed(msg, AUTO_CONNECT_DELAY);
            } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
                // This is technically not needed, but we can get stuck sometimes.
                // For example, if incoming A2DP fails, we are not informed by Bluez
                sendMessage(TRANSITION_TO_STABLE);
            }
      }
    };
@@ -198,6 +202,7 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothInputDevice.ACTION_INPUT_DEVICE_STATE_CHANGED);
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);

        mContext.registerReceiver(mBroadcastReceiver, filter);

@@ -348,7 +353,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                Log.e(TAG, "Error: OutgoingHandsfree state with command:" + mCommand);
            }
            mStatus = processCommand(mCommand);
            if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
            if (!mStatus) {
                sendMessage(TRANSITION_TO_STABLE);
                mService.sendProfileStateMessage(BluetoothProfileState.HFP,
                                                 BluetoothProfileState.TRANSITION_TO_STABLE);
            }
        }

        @Override
@@ -456,7 +465,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                Log.e(TAG, "Error: IncomingHandsfree state with command:" + mCommand);
            }
            mStatus = processCommand(mCommand);
            if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
            if (!mStatus) {
                sendMessage(TRANSITION_TO_STABLE);
                mService.sendProfileStateMessage(BluetoothProfileState.HFP,
                                                 BluetoothProfileState.TRANSITION_TO_STABLE);
            }
        }

        @Override
@@ -531,7 +544,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                Log.e(TAG, "Error: OutgoingA2DP state with command:" + mCommand);
            }
            mStatus = processCommand(mCommand);
            if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
            if (!mStatus) {
                sendMessage(TRANSITION_TO_STABLE);
                mService.sendProfileStateMessage(BluetoothProfileState.A2DP,
                                                 BluetoothProfileState.TRANSITION_TO_STABLE);
            }
        }

        @Override
@@ -636,7 +653,11 @@ public final class BluetoothDeviceProfileState extends HierarchicalStateMachine
                Log.e(TAG, "Error: IncomingA2DP state with command:" + mCommand);
            }
            mStatus = processCommand(mCommand);
            if (!mStatus) sendMessage(TRANSITION_TO_STABLE);
            if (!mStatus) {
                sendMessage(TRANSITION_TO_STABLE);
                mService.sendProfileStateMessage(BluetoothProfileState.A2DP,
                                                 BluetoothProfileState.TRANSITION_TO_STABLE);
            }
        }

        @Override
+7 −1
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ public class BluetoothProfileState extends HierarchicalStateMachine {
    public static final int A2DP = 1;
    public static final int HID = 2;

    private static int TRANSITION_TO_STABLE = 100;
    static final int TRANSITION_TO_STABLE = 100;

    private int mProfile;
    private BluetoothDevice mPendingDevice;
@@ -58,6 +58,7 @@ public class BluetoothProfileState extends HierarchicalStateMachine {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);

            if (action.equals(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED)) {
                int newState = intent.getIntExtra(BluetoothProfile.EXTRA_STATE, 0);
@@ -77,6 +78,10 @@ public class BluetoothProfileState extends HierarchicalStateMachine {
                    newState == BluetoothInputDevice.STATE_DISCONNECTED)) {
                    sendMessage(TRANSITION_TO_STABLE);
                }
            } else if (action.equals(BluetoothDevice.ACTION_ACL_DISCONNECTED)) {
                if (device.equals(mPendingDevice)) {
                    sendMessage(TRANSITION_TO_STABLE);
                }
            }
        }
    };
@@ -92,6 +97,7 @@ public class BluetoothProfileState extends HierarchicalStateMachine {
        filter.addAction(BluetoothA2dp.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothHeadset.ACTION_CONNECTION_STATE_CHANGED);
        filter.addAction(BluetoothInputDevice.ACTION_INPUT_DEVICE_STATE_CHANGED);
        filter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED);
        context.registerReceiver(mBroadcastReceiver, filter);
    }

+8 −1
Original line number Diff line number Diff line
@@ -596,7 +596,14 @@ class BluetoothEventLoop {
            authorized = mA2dp.getPriority(device) > BluetoothProfile.PRIORITY_OFF;
            if (authorized) {
                Log.i(TAG, "Allowing incoming A2DP / AVRCP connection from " + address);
                // Some headsets try to connect AVCTP before AVDTP - against the recommendation
                // If AVCTP connection fails, we get stuck in IncomingA2DP state in the state
                // machine.  We don't handle AVCTP signals currently. We only send
                // intents for AVDTP state changes. We need to handle both of them in
                // some cases. For now, just don't move to incoming state in this case.
                if (!BluetoothUuid.isAvrcpTarget(uuid)) {
                    mBluetoothService.notifyIncomingA2dpConnection(address);
                }
            } else {
                Log.i(TAG, "Rejecting incoming A2DP / AVRCP connection from " + address);
            }
+10 −0
Original line number Diff line number Diff line
@@ -2717,6 +2717,16 @@ public class BluetoothService extends IBluetooth.Stub {
        mA2dpService = a2dpService;
    }

    public void sendProfileStateMessage(int profile, int cmd) {
        Message msg = new Message();
        msg.what = cmd;
        if (profile == BluetoothProfileState.HFP) {
            mHfpProfileState.sendMessage(msg);
        } else if (profile == BluetoothProfileState.A2DP) {
            mA2dpProfileState.sendMessage(msg);
        }
    }

    private static void log(String msg) {
        Log.d(TAG, msg);
    }