feat(android): show proxy traffic stats in foreground notification

This commit is contained in:
Dark-Avery
2026-03-16 23:15:12 +03:00
parent 8d43fa25fa
commit da15296f66
6 changed files with 171 additions and 10 deletions

View File

@@ -1,5 +1,6 @@
import sys
import unittest
import json
from pathlib import Path
@@ -8,6 +9,7 @@ sys.path.insert(0, str(
))
import android_proxy_bridge # noqa: E402
import proxy.tg_ws_proxy as tg_ws_proxy # noqa: E402
class FakeJavaArrayList:
@@ -22,6 +24,9 @@ class FakeJavaArrayList:
class AndroidProxyBridgeTests(unittest.TestCase):
def tearDown(self):
tg_ws_proxy.reset_stats()
def test_normalize_dc_ip_list_with_python_iterable(self):
result = android_proxy_bridge._normalize_dc_ip_list([
"2:149.154.167.220",
@@ -34,6 +39,20 @@ class AndroidProxyBridgeTests(unittest.TestCase):
"4:149.154.167.220",
])
def test_get_runtime_stats_json_reports_proxy_counters(self):
tg_ws_proxy.reset_stats()
snapshot = tg_ws_proxy.get_stats_snapshot()
snapshot["bytes_up"] = 1536
snapshot["bytes_down"] = 4096
tg_ws_proxy._stats.bytes_up = snapshot["bytes_up"]
tg_ws_proxy._stats.bytes_down = snapshot["bytes_down"]
result = json.loads(android_proxy_bridge.get_runtime_stats_json())
self.assertEqual(result["bytes_up"], 1536)
self.assertEqual(result["bytes_down"], 4096)
self.assertFalse(result["running"])
def test_normalize_dc_ip_list_with_java_array_list_shape(self):
result = android_proxy_bridge._normalize_dc_ip_list(FakeJavaArrayList([
"2:149.154.167.220",