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

Commit 057898a9 authored by Jaikumar Ganesh's avatar Jaikumar Ganesh
Browse files

Enable Bluetooth reverse tethering.

Change-Id: I84a508b64f18a1445b8ac424f2a36d56ef432375
parent 15c7439a
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -425,11 +425,13 @@ class BluetoothEventLoop {
            }
        } else if (name.equals("Interface")) {
            String iface = propValues[1];
            if (!iface.equals("")) {
                mBluetoothService.handlePanDeviceStateChange(device, iface,
                                              BluetoothPan.STATE_CONNECTED,
                                              BluetoothPan.LOCAL_PANU_ROLE);
            }
        }
    }

    private String checkPairingRequestAndGetAddress(String objectPath, int nativeData) {
        String address = mBluetoothService.getAddressFromObjectPath(objectPath);
+13 −4
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.bluetooth.BluetoothPan;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothProfileState;
import android.bluetooth.BluetoothSocket;
import android.bluetooth.BluetoothTetheringDataTracker;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.IBluetooth;
import android.bluetooth.IBluetoothCallback;
@@ -54,7 +55,6 @@ import android.os.Message;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemService;
import android.provider.Settings;
import android.util.Log;
import android.util.Pair;
@@ -79,11 +79,9 @@ import java.net.InetAddress;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class BluetoothService extends IBluetooth.Stub {
    private static final String TAG = "BluetoothService";
@@ -169,6 +167,8 @@ public class BluetoothService extends IBluetooth.Stub {
    private static String mDockAddress;
    private String mDockPin;

    private String mIface;

    private int mAdapterConnectionState = BluetoothAdapter.STATE_DISCONNECTED;

    private static class RemoteService {
@@ -1582,7 +1582,6 @@ public class BluetoothService extends IBluetooth.Stub {
        }
        if (prevState == state) return;

        // TODO: We might need this for PANU role too.
        if (role == BluetoothPan.LOCAL_NAP_ROLE) {
            if (state == BluetoothPan.STATE_CONNECTED) {
                ifaceAddr = enableTethering(iface);
@@ -1593,6 +1592,16 @@ public class BluetoothService extends IBluetooth.Stub {
                    ifaceAddr = null;
                }
            }
        } else {
            // PANU Role = reverse Tether
            if (state == BluetoothPan.STATE_CONNECTED) {
                mIface = iface;
                BluetoothTetheringDataTracker.getInstance().startReverseTether(iface, device);
            } else if (state == BluetoothPan.STATE_DISCONNECTED &&
                  (prevState == BluetoothPan.STATE_CONNECTED ||
                  prevState == BluetoothPan.STATE_DISCONNECTING)) {
                BluetoothTetheringDataTracker.getInstance().stopReverseTether(mIface);
            }
        }

        Pair<Integer, String> value = new Pair<Integer, String>(state, ifaceAddr);