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

Commit 8c900385 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh Committed by Android (Google) Code Review
Browse files

Merge "Fix PAN bug for reverse tethering."

parents 452f035c 2cbb33c3
Loading
Loading
Loading
Loading
+9 −13
Original line number Original line Diff line number Diff line
@@ -145,13 +145,14 @@ final class BluetoothPanProfileHandler {
            return false;
            return false;
        }
        }


        handlePanDeviceStateChange(device, BluetoothPan.STATE_CONNECTING,
        // Send interface as null as it is not known
        handlePanDeviceStateChange(device, null, BluetoothPan.STATE_CONNECTING,
                                           BluetoothPan.LOCAL_PANU_ROLE);
                                           BluetoothPan.LOCAL_PANU_ROLE);
        if (mBluetoothService.connectPanDeviceNative(objectPath, "nap")) {
        if (mBluetoothService.connectPanDeviceNative(objectPath, "nap")) {
            debugLog("connecting to PAN");
            debugLog("connecting to PAN");
            return true;
            return true;
        } else {
        } else {
            handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTED,
            handlePanDeviceStateChange(device, null, BluetoothPan.STATE_DISCONNECTED,
                                                BluetoothPan.LOCAL_PANU_ROLE);
                                                BluetoothPan.LOCAL_PANU_ROLE);
            errorLog("could not connect to PAN");
            errorLog("could not connect to PAN");
            return false;
            return false;
@@ -168,8 +169,8 @@ final class BluetoothPanProfileHandler {
                    panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) {
                    panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) {
                String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress());
                String objectPath = mBluetoothService.getObjectPathFromAddress(device.getAddress());


                handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING,
                handlePanDeviceStateChange(device, panDevice.mIface,
                        panDevice.mLocalRole);
                        BluetoothPan.STATE_DISCONNECTING, panDevice.mLocalRole);


                if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath,
                if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath,
                        device.getAddress(),
                        device.getAddress(),
@@ -177,7 +178,7 @@ final class BluetoothPanProfileHandler {
                    errorLog("could not disconnect Pan Server Device "+device.getAddress());
                    errorLog("could not disconnect Pan Server Device "+device.getAddress());


                    // Restore prev state
                    // Restore prev state
                    handlePanDeviceStateChange(device, state,
                    handlePanDeviceStateChange(device, panDevice.mIface, state,
                            panDevice.mLocalRole);
                            panDevice.mLocalRole);


                    return false;
                    return false;
@@ -230,19 +231,19 @@ final class BluetoothPanProfileHandler {
            return false;
            return false;
        }
        }


        handlePanDeviceStateChange(device, BluetoothPan.STATE_DISCONNECTING,
        handlePanDeviceStateChange(device, panDevice.mIface, BluetoothPan.STATE_DISCONNECTING,
                                    panDevice.mLocalRole);
                                    panDevice.mLocalRole);
        if (panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) {
        if (panDevice.mLocalRole == BluetoothPan.LOCAL_NAP_ROLE) {
            if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath, device.getAddress(),
            if (!mBluetoothService.disconnectPanServerDeviceNative(objectPath, device.getAddress(),
                    panDevice.mIface)) {
                    panDevice.mIface)) {
                // Restore prev state, this shouldn't happen
                // Restore prev state, this shouldn't happen
                handlePanDeviceStateChange(device, state, panDevice.mLocalRole);
                handlePanDeviceStateChange(device, panDevice.mIface, state, panDevice.mLocalRole);
                return false;
                return false;
            }
            }
        } else {
        } else {
            if (!mBluetoothService.disconnectPanDeviceNative(objectPath)) {
            if (!mBluetoothService.disconnectPanDeviceNative(objectPath)) {
                // Restore prev state, this shouldn't happen
                // Restore prev state, this shouldn't happen
                handlePanDeviceStateChange(device, state, panDevice.mLocalRole);
                handlePanDeviceStateChange(device, panDevice.mIface, state, panDevice.mLocalRole);
                return false;
                return false;
            }
            }
        }
        }
@@ -305,11 +306,6 @@ final class BluetoothPanProfileHandler {
        mBluetoothService.sendConnectionStateChange(device, state, prevState);
        mBluetoothService.sendConnectionStateChange(device, state, prevState);
    }
    }


    void handlePanDeviceStateChange(BluetoothDevice device,
                                                 int state, int role) {
        handlePanDeviceStateChange(device, null, state, role);
    }

    private class BluetoothPanDevice {
    private class BluetoothPanDevice {
        private int mState;
        private int mState;
        private String mIfaceAddr;
        private String mIfaceAddr;