mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
revise wifi signalstrength dumpsys query (#1224)
* revise wifi signalstrength dumpsys query * cleaner index search per willems comment * cleaner index search per willems comment old-commit-hash: 8eff974a417f58b6c5ce953ef1e903a68feeff70
This commit is contained in:
+5
-3
@@ -235,9 +235,11 @@ def get_network_strength(network_type):
|
||||
out = subprocess.check_output('dumpsys connectivity', shell=True).decode('ascii')
|
||||
network_strength = NetworkStrength.unknown
|
||||
for line in out.split('\n'):
|
||||
if "SignalStrength" in line:
|
||||
arr = line.split(' ')
|
||||
lvl = int(arr[53][:-2])
|
||||
signal_str = "SignalStrength: "
|
||||
if signal_str in line:
|
||||
lvl_idx_start = line.find(signal_str) + len(signal_str)
|
||||
lvl_idx_end = line.find(']', lvl_idx_start)
|
||||
lvl = int(line[lvl_idx_start : lvl_idx_end])
|
||||
if lvl >= -50:
|
||||
network_strength = NetworkStrength.great
|
||||
elif lvl >= -60:
|
||||
|
||||
Reference in New Issue
Block a user