summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/tethering
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-03-07 01:04:19 +0100
committercyBerta <cyberta@riseup.net>2020-03-07 01:04:19 +0100
commit649635bc8f8178aba36f07b59ada813f55dc34a0 (patch)
tree45c5bff6f52b8aaff87d2cfc98f151d176bdefff /app/src/main/java/se/leap/bitmaskclient/tethering
parent2a8d82d85f4cfd34143d87174ee022966e364f69 (diff)
fix bluetooth tethering
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/tethering')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/tethering/TetheringObservable.java13
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java15
2 files changed, 24 insertions, 4 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/TetheringStateManager.java b/app/src/main/java/se/leap/bitmaskclient/tethering/TetheringStateManager.java
index 1a11945b..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,6 +111,10 @@ public class TetheringStateManager {
return getInterfaceName(getUsbInterface());
}
+ private static String getBluetoothInterfaceName() {
+ return getInterfaceName(getBluetoothInterface());
+ }
+
private static NetworkInterface getWlanInterface() {
return getNetworkInterface(new String[]{"wlan", "eth"});
}
@@ -114,6 +123,10 @@ public class TetheringStateManager {
return getNetworkInterface(new String[]{"rndis"});
}
+ private static NetworkInterface getBluetoothInterface() {
+ return getNetworkInterface(new String[]{"bt-pan"});
+ }
+
private static boolean isBluetoothTetheringEnabled() {
StringBuilder log = new StringBuilder();
boolean hasBtPan = false;