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

Commit f6ba1b69 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "PAN: Notify PAN devices connection state to UI"

parents c0c653b4 fa205287
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -137,10 +137,18 @@ public class PanService extends ProfileService {
            mNativeAvailable = false;
        }
        if (mPanDevices != null) {
            List<BluetoothDevice> devList = getConnectedDevices();
            for (BluetoothDevice dev : devList) {
                handlePanDeviceStateChange(dev, mPanIfName, BluetoothProfile.STATE_DISCONNECTED,
                        BluetoothPan.LOCAL_PANU_ROLE, BluetoothPan.REMOTE_NAP_ROLE);
           int[] desiredStates = {BluetoothProfile.STATE_CONNECTING, BluetoothProfile.STATE_CONNECTED,
                                  BluetoothProfile.STATE_DISCONNECTING};
           List<BluetoothDevice> devList =
                   getDevicesMatchingConnectionStates(desiredStates);
           for (BluetoothDevice device : devList) {
                BluetoothPanDevice panDevice = mPanDevices.get(device);
                Log.d(TAG, "panDevice: " + panDevice + " device address: " + device);
                if (panDevice != null) {
                    handlePanDeviceStateChange(device, mPanIfName,
                        BluetoothProfile.STATE_DISCONNECTED,
                        panDevice.mLocalRole, panDevice.mRemoteRole);
                }
            }
            mPanDevices.clear();
        }
@@ -497,12 +505,13 @@ public class PanService extends ProfileService {
        if (panDevice == null) {
            Log.i(TAG, "state " + state + " Num of connected pan devices: " + mPanDevices.size());
            prevState = BluetoothProfile.STATE_DISCONNECTED;
            panDevice = new BluetoothPanDevice(state, iface, localRole);
            panDevice = new BluetoothPanDevice(state, iface, localRole, remoteRole);
            mPanDevices.put(device, panDevice);
        } else {
            prevState = panDevice.mState;
            panDevice.mState = state;
            panDevice.mLocalRole = localRole;
            panDevice.mRemoteRole = remoteRole;
            panDevice.mIface = iface;
        }

@@ -689,11 +698,13 @@ public class PanService extends ProfileService {
        private int mState;
        private String mIface;
        private int mLocalRole; // Which local role is this PAN device bound to
        private int mRemoteRole; // Which remote role is this PAN device bound to

        BluetoothPanDevice(int state, String iface, int localRole) {
        BluetoothPanDevice(int state, String iface, int localRole, int remoteRole) {
            mState = state;
            mIface = iface;
            mLocalRole = localRole;
            mRemoteRole = remoteRole;
        }
    }