diff options
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/tethering')
3 files changed, 32 insertions, 5 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java index 75d29417..9bca25e9 100644 --- a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java +++ b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java @@ -91,9 +91,16 @@ public class TetheringObservable extends Observable { } } - static void setBluetoothTethering(boolean enabled) { - if (getInstance().tetheringState.isBluetoothTetheringEnabled != enabled) { - getInstance().tetheringState.isBluetoothTetheringEnabled = enabled; + static void setBluetoothTethering(boolean enabled, @NonNull String address, @NonNull String interfaceName) { + if (getInstance().tetheringState.isBluetoothTetheringEnabled != enabled || + !getInstance().tetheringState.bluetoothAddress.equals(address) || + !getInstance().tetheringState.bluetoothInterface.equals(interfaceName)) { + TetheringState state = getInstance().tetheringState; + state.isBluetoothTetheringEnabled = enabled; + state.bluetoothAddress = address; + state.bluetoothInterface = interfaceName; + state.lastSeenBluetoothAddress = address.isEmpty() ? state.lastSeenBluetoothAddress : address; + state.lastSeenBluetoothInterface = interfaceName.isEmpty() ? state.lastSeenBluetoothInterface : interfaceName; getInstance().setChanged(); getInstance().notifyObservers(); } diff --git a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringState.java b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringState.java index 8ef237c6..21c378ee 100644 --- a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringState.java +++ b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringState.java @@ -1,5 +1,8 @@ package se.leap.bitmaskclient.tethering; +import de.blinkt.openvpn.core.VpnStatus; +import se.leap.bitmaskclient.eip.EipStatus; + public class TetheringState implements Cloneable { public boolean isWifiTetheringEnabled; public boolean isUsbTetheringEnabled; @@ -41,5 +44,9 @@ public class TetheringState implements Cloneable { return isVpnWifiTetheringAllowed || isVpnUsbTetheringAllowed || isVpnBluetoothTetheringAllowed; } + public boolean isVpnTetheringRunning() { + return (tetherWifiVpn() || tetherUsbVpn() || tetherBluetoothVpn()) && (EipStatus.getInstance().isConnecting() || EipStatus.getInstance().isConnected() || EipStatus.getInstance().isBlocking()); + } + } diff --git a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java index d3c934f6..0af4c357 100644 --- a/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java +++ b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java @@ -85,7 +85,7 @@ public class TetheringStateManager { } static void updateBluetoothTetheringState() { - //TetheringObservable.setBluetoothTethering(isBluetoothTetheringEnabled()); + TetheringObservable.setBluetoothTethering(isBluetoothTetheringEnabled(), getBluetoothAddressRange(), getBluetoothInterfaceName()); } private static String getWifiAddressRange() { @@ -98,6 +98,11 @@ public class TetheringStateManager { return getAddressRange(interfaceAddress); } + private static String getBluetoothAddressRange() { + String interfaceAddress = getInterfaceAddress(getBluetoothInterface()); + return getAddressRange(interfaceAddress); + } + private static String getWlanInterfaceName() { return getInterfaceName(getWlanInterface()); } @@ -106,12 +111,20 @@ public class TetheringStateManager { return getInterfaceName(getUsbInterface()); } + private static String getBluetoothInterfaceName() { + return getInterfaceName(getBluetoothInterface()); + } + private static NetworkInterface getWlanInterface() { return getNetworkInterface(new String[]{"wlan", "eth"}); } private static NetworkInterface getUsbInterface() { - return getNetworkInterface(new String[]{"rndis", "usb"}); + return getNetworkInterface(new String[]{"rndis"}); + } + + private static NetworkInterface getBluetoothInterface() { + return getNetworkInterface(new String[]{"bt-pan"}); } private static boolean isBluetoothTetheringEnabled() { |