mirror of
https://github.com/liberatedsystems/openCom-Companion.git
synced 2024-11-22 05:20:36 +01:00
Added periodic multicast lock check
This commit is contained in:
parent
8727334ba6
commit
5ca3153eff
@ -194,6 +194,7 @@ class SidebandService():
|
||||
def take_locks(self, force_multicast=False):
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
if self.multicast_lock == None or force_multicast:
|
||||
RNS.log("Creating multicast lock", RNS.LOG_DEBUG)
|
||||
self.multicast_lock = self.wifi_manager.createMulticastLock("sideband_service")
|
||||
|
||||
if not self.multicast_lock.isHeld():
|
||||
@ -203,6 +204,7 @@ class SidebandService():
|
||||
RNS.log("Multicast lock already held", RNS.LOG_DEBUG)
|
||||
|
||||
if self.wake_lock == None:
|
||||
RNS.log("Creating wake lock", RNS.LOG_DEBUG)
|
||||
self.wake_lock = self.power_manager.newWakeLock(self.power_manager.PARTIAL_WAKE_LOCK, "sideband_service")
|
||||
|
||||
if not self.wake_lock.isHeld():
|
||||
|
@ -2377,10 +2377,22 @@ class SidebandCore():
|
||||
def _service_jobs(self):
|
||||
if self.is_service:
|
||||
last_usb_discovery = time.time()
|
||||
last_multicast_lock_check = time.time()
|
||||
while True:
|
||||
time.sleep(SidebandCore.SERVICE_JOB_INTERVAL)
|
||||
now = time.time()
|
||||
|
||||
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
|
||||
last_multicast_lock_check = now
|
||||
|
||||
if (now - last_multicast_lock_check > 120):
|
||||
RNS.log("Checking multicast and wake locks", RNS.LOG_DEBUG)
|
||||
self.owner_service.take_locks()
|
||||
last_multicast_lock_check = now
|
||||
|
||||
announce_wanted = self.getstate("wants.announce")
|
||||
announce_attached_interface = None
|
||||
announce_delay = 0
|
||||
@ -2392,10 +2404,6 @@ class SidebandCore():
|
||||
|
||||
if hasattr(self, "interface_local") and self.interface_local != None:
|
||||
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 not self.interface_local.had_peers and have_peers:
|
||||
|
Loading…
Reference in New Issue
Block a user