Retake multicast lock on WiFi carrier change
This commit is contained in:
parent
ee3ed7a017
commit
dd97dba7df
|
@ -136,12 +136,12 @@ class SidebandService():
|
||||||
self.update_connectivity_type()
|
self.update_connectivity_type()
|
||||||
|
|
||||||
if RNS.vendor.platformutils.is_android():
|
if RNS.vendor.platformutils.is_android():
|
||||||
RNS.log("Discovered USB devices: "+str(self.usb_devices), RNS.LOG_DEBUG)
|
RNS.log("Discovered USB devices: "+str(self.usb_devices), RNS.LOG_EXTREME)
|
||||||
|
|
||||||
|
|
||||||
def discover_usb_devices(self):
|
def discover_usb_devices(self):
|
||||||
self.usb_devices = []
|
self.usb_devices = []
|
||||||
RNS.log("Discovering attached USB devices...", RNS.LOG_DEBUG)
|
RNS.log("Discovering attached USB devices...", RNS.LOG_EXTREME)
|
||||||
try:
|
try:
|
||||||
devices = usb.get_usb_device_list()
|
devices = usb.get_usb_device_list()
|
||||||
for device in devices:
|
for device in devices:
|
||||||
|
@ -165,21 +165,25 @@ class SidebandService():
|
||||||
def stop(self):
|
def stop(self):
|
||||||
self.should_run = False
|
self.should_run = False
|
||||||
|
|
||||||
def take_locks(self):
|
def take_locks(self, force_multicast=False):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
if self.multicast_lock == None:
|
if self.multicast_lock == None or force_multicast:
|
||||||
self.multicast_lock = self.wifi_manager.createMulticastLock("sideband_service")
|
self.multicast_lock = self.wifi_manager.createMulticastLock("sideband_service")
|
||||||
|
|
||||||
if not self.multicast_lock.isHeld():
|
if not self.multicast_lock.isHeld():
|
||||||
RNS.log("Taking multicast lock")
|
RNS.log("Taking multicast lock", RNS.LOG_DEBUG)
|
||||||
self.multicast_lock.acquire()
|
self.multicast_lock.acquire()
|
||||||
|
else:
|
||||||
|
RNS.log("Multicast lock already held", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
if self.wake_lock == None:
|
if self.wake_lock == None:
|
||||||
self.wake_lock = self.power_manager.newWakeLock(self.power_manager.PARTIAL_WAKE_LOCK, "sideband_service")
|
self.wake_lock = self.power_manager.newWakeLock(self.power_manager.PARTIAL_WAKE_LOCK, "sideband_service")
|
||||||
|
|
||||||
if not self.wake_lock.isHeld():
|
if not self.wake_lock.isHeld():
|
||||||
RNS.log("Taking wake lock")
|
RNS.log("Taking wake lock", RNS.LOG_DEBUG)
|
||||||
self.wake_lock.acquire()
|
self.wake_lock.acquire()
|
||||||
|
else:
|
||||||
|
RNS.log("Wake lock already held", RNS.LOG_DEBUG)
|
||||||
|
|
||||||
def release_locks(self):
|
def release_locks(self):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
|
|
|
@ -1282,6 +1282,11 @@ class SidebandCore():
|
||||||
|
|
||||||
if hasattr(self, "interface_local") and self.interface_local != None:
|
if hasattr(self, "interface_local") and self.interface_local != None:
|
||||||
have_peers = len(self.interface_local.peers) > 0
|
have_peers = len(self.interface_local.peers) > 0
|
||||||
|
if self.interface_local.carrier_changed:
|
||||||
|
RNS.log("AutoInterface carrier change detected, retaking wake locks", RNS.LOG_DEBUG)
|
||||||
|
self.owner_service.take_locks(force_multicast=True)
|
||||||
|
self.interface_local.carrier_changed = False
|
||||||
|
|
||||||
if hasattr(self.interface_local, "had_peers"):
|
if hasattr(self.interface_local, "had_peers"):
|
||||||
if not self.interface_local.had_peers and have_peers:
|
if not self.interface_local.had_peers and have_peers:
|
||||||
RNS.log("Peers became reachable on the interface "+str(self.interface_local), RNS.LOG_DEBUG)
|
RNS.log("Peers became reachable on the interface "+str(self.interface_local), RNS.LOG_DEBUG)
|
||||||
|
|
Loading…
Reference in New Issue