diff --git a/README.md b/README.md index 236910f..fe359ac 100644 --- a/README.md +++ b/README.md @@ -85,7 +85,7 @@ Last reviewed **2026-10-27**, on the maintainer's Tianma Mi 8 Lite. The tested camera installation uses **kernel 7.2.12-sdm660, r9 boot plus r11 sensor module**, with signed `platina-libcamera` **0.7.1-r31** and isolated Mesa 26.1.6. The checked-in kernel recipe is the **7.2.12-r25 development candidate**, -with device 5-r32 and the public source firmware recipe 2-r5. That combined kernel +with device 5-r33 and the public source firmware recipe 2-r5. That combined kernel and a new full 0.8.1 image have **not** passed a complete hardware installation test. Camera packages are built/installed separately; `make images` does not yet add them. diff --git a/docs/CELLULAR.md b/docs/CELLULAR.md index a42165d..7799842 100644 --- a/docs/CELLULAR.md +++ b/docs/CELLULAR.md @@ -420,9 +420,9 @@ Tested on the phone over `qmapmux0.0` (strict `SO_BINDTODEVICE` / `-I qmapmux0.0 ICMP + idle single-packet UDP DNS, emitted zero MPSS/SMMU/IPA errors in `dmesg`, and kept USB NCM SSH (`usb0`), EasyTier (`tun0`), `ath10k_snoc` (`wlan0`), and `platina-battery-guard` operational. Route priority follows - Wi-Fi (`metric 600`) > `platina-cellular` (`ipv4.route-metric 700`) > - `platina-usb` (`route-metric=2000`), ensuring unbound traffic uses 4G LTE - rather than USB host sharing when Wi-Fi is disconnected. + `platina-usb` (`route-metric=50`) > Wi-Fi (`route-metric=200`) > + `platina-cellular` (`ipv4.route-metric 700`), preferring USB host networking + when connected, then Wi-Fi, and falling back to 4G LTE when unplugged/offline. ## Completion criteria diff --git a/ports/candidate/device-xiaomi-platina/APKBUILD b/ports/candidate/device-xiaomi-platina/APKBUILD index efacdb8..f08e8ea 100644 --- a/ports/candidate/device-xiaomi-platina/APKBUILD +++ b/ports/candidate/device-xiaomi-platina/APKBUILD @@ -3,7 +3,7 @@ maintainer="Platina local project " pkgname=device-xiaomi-platina pkgdesc="Xiaomi Mi 8 Lite - experimental headless server" pkgver=5 -pkgrel=32 +pkgrel=33 url="https://github.com/macosmojave2-alt/postmarket-mi8lite-platina" license="MIT" arch="aarch64" @@ -56,8 +56,8 @@ b1dec076f65dc1d7b0497aa858c12c520dc92ec53e6df15a4d9bed4b84f16ece639a42d5dfc4f4d0 5095c7617c6fd84a6d29275c01d72b4b0e4196ff2efed7071741845e11cf18be54561c434f323ad449877731c7408e55631c9bab64b58ab0d827ec18f953d290 modules-initfs 53d9813f7537bc7d6f2ff7a623ed36c6f1243f3b66bbbc1ac2ebd55897a638e7867e447bea3b0353500d6b1a9a0142e18c1a708f3ff968f8970beedc1175279a disable-suspend.start afc76d9275689bfa47065a14a2f9b0322576d5c269fa46663f4dab5b7299707450f4bbd7e0e6ea926b6afc7b73642dd33bed449d7c0999de53f48d2300d75f8c gpu-firmware.files -29dacca516ae2a0aea7e1c523131e120a13dca330af7f52b210971cf3613fe8a9267fd100499df8cf64478228f383c69f915092930468e2b3fb95271aa3512c2 platina-networkmanager.conf -2ee857c4e22991b2d77090ac748beb12e80400c1504f9d1d2707aefac6744004f129d1ca01f8bda039a4dd7a777bdc317c96ed5f03ce00d8c324c38fb7e8dd90 platina-usb.nmconnection +0180ff3c007765218a50457ff240b8c813995645e775fc04656e46e304d35cf3989198576ccf717de78c49f3e443edb22304923c5ea1df1615ab02ef781412c6 platina-networkmanager.conf +9dff6456d5354648c6871c0f6d602b9499c41e10970ac01d5cfe83fcb0e25220b6c26aed241960191587588ae95deb0fee051766cf64d067cd3579f6d5cf73f9 platina-usb.nmconnection 82272323ff6feb710f32ff34787cd85ccc189c6a8e77bed0de4dd0855f997939b1fd5952c6ab416be59e77a9f5b96bad67417737ae4361af9365d85f46ea29cc platina-usb-network.start c620fb012b2b24ab25929952af2289caaaea6ac96a080b34b48e640c1d39c5662e1cd77bd26f89a864c127e514401243a41d6b7e53c8004c35cec045949f527f platina-avahi.conf " diff --git a/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf b/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf index 46243ce..0b6357a 100644 --- a/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf +++ b/ports/candidate/device-xiaomi-platina/platina-networkmanager.conf @@ -7,6 +7,11 @@ match-device=interface-name:wlan0 managed=1 wifi.scan-rand-mac-address=no +[connection-platina-wifi] +match-device=interface-name:wlan0 +ipv4.route-metric=200 +ipv6.route-metric=200 + [device-platina-usb] match-device=interface-name:usb0 managed=1 diff --git a/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection b/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection index d1207a2..a2c0f86 100644 --- a/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection +++ b/ports/candidate/device-xiaomi-platina/platina-usb.nmconnection @@ -11,7 +11,7 @@ autoconnect-retries=0 [ipv4] method=manual address1=172.16.42.1/24,172.16.42.2 -route-metric=2000 +route-metric=50 ignore-auto-dns=true [ipv6] diff --git a/project/sources.lock.json b/project/sources.lock.json index 10fcb6f..98831db 100644 --- a/project/sources.lock.json +++ b/project/sources.lock.json @@ -17,7 +17,7 @@ "ports": "ports/candidate", "kernel": "7.2.12", "kernel_package": "7.2.12-r25", - "device_package": "5-r32", + "device_package": "5-r33", "firmware_package": "2-r5" } }, diff --git a/scripts/phone-cellular-setup.py b/scripts/phone-cellular-setup.py index 8de1334..f8160df 100755 --- a/scripts/phone-cellular-setup.py +++ b/scripts/phone-cellular-setup.py @@ -262,6 +262,7 @@ def build_nmcli_setup_commands(con_name=CONNECTION_NAME, apn='cmnet', ifname='*' 'gsm.auto-config', 'yes', 'connection.autoconnect', 'no', 'ipv4.route-metric', '700', + 'ipv6.route-metric', '700', 'connection.interface-name', ifname if ifname != '*' else '']) else: cmd = ['nmcli', 'connection', 'add', @@ -271,7 +272,8 @@ def build_nmcli_setup_commands(con_name=CONNECTION_NAME, apn='cmnet', ifname='*' 'apn', apn, 'gsm.auto-config', 'yes', 'connection.autoconnect', 'no', - 'ipv4.route-metric', '700'] + 'ipv4.route-metric', '700', + 'ipv6.route-metric', '700'] commands.append(cmd) return commands diff --git a/scripts/phone-status-screen.py b/scripts/phone-status-screen.py index f1daa96..6ca0c04 100755 --- a/scripts/phone-status-screen.py +++ b/scripts/phone-status-screen.py @@ -234,9 +234,23 @@ def collect_telemetry(sys_path='/sys', proc_path='/proc', run=subprocess.run): r_def = run(['ip', '-4', 'route', 'show', 'default'], capture_output=True, text=True, timeout=0.8) if r_def.returncode == 0 and r_def.stdout.strip(): - parts = r_def.stdout.splitlines()[0].split() - if 'dev' in parts: - default_dev = parts[parts.index('dev') + 1] + best_metric = None + for line in r_def.stdout.splitlines(): + parts = line.split() + if 'dev' not in parts: + continue + dev = parts[parts.index('dev') + 1] + metric = 0 + if 'metric' in parts: + m_idx = parts.index('metric') + if m_idx + 1 < len(parts): + try: + metric = int(parts[m_idx + 1]) + except ValueError: + metric = 0 + if best_metric is None or metric < best_metric: + best_metric = metric + default_dev = dev except (OSError, subprocess.SubprocessError): pass @@ -470,8 +484,8 @@ def render_dashboard_bgrx(telemetry, mode='status', width=1080, height=2280): net = telemetry['network'] card(1100, 380, 'NETWORK & MESH ROUTING') draw_text(buf, width, height, 92, 1175, f"DEFAULT : {net.get('default_dev') or 'none'}", scale=4, fg_px=COL_TEXT, bg_px=COL_CARD) - draw_text(buf, width, height, 92, 1245, f"WI-FI : {net.get('wlan0_ip') or 'disconnected'} (m 600)", scale=3, fg_px=COL_MUTED, bg_px=COL_CARD) - draw_text(buf, width, height, 92, 1295, f"USB NCM : {net.get('usb0_ip') or 'down'} ({'link' if net.get('usb0_carrier') else 'unplugged'})", scale=3, fg_px=COL_MUTED, bg_px=COL_CARD) + draw_text(buf, width, height, 92, 1245, f"USB NCM : {net.get('usb0_ip') or 'down'} ({'m 50' if net.get('usb0_carrier') else 'unplugged'})", scale=3, fg_px=COL_GREEN if net.get('default_dev') == 'usb0' else COL_MUTED, bg_px=COL_CARD) + draw_text(buf, width, height, 92, 1295, f"WI-FI : {net.get('wlan0_ip') or 'disconnected'} (m 200)", scale=3, fg_px=COL_GREEN if net.get('default_dev') == 'wlan0' else COL_MUTED, bg_px=COL_CARD) draw_text(buf, width, height, 92, 1345, f"EASYTIER: {net.get('tun0_ip') or 'stopped'}", scale=3, fg_px=COL_GREEN if net.get('tun0_ip') else COL_MUTED, bg_px=COL_CARD) # Card 4: Compute diff --git a/tests/test_cellular_setup.py b/tests/test_cellular_setup.py index 3dc07f5..4ccfdec 100644 --- a/tests/test_cellular_setup.py +++ b/tests/test_cellular_setup.py @@ -81,6 +81,9 @@ class CellularSetupTests(unittest.TestCase): self.assertIn('ipv4.route-metric', cmds[0]) m_idx = cmds[0].index('ipv4.route-metric') self.assertEqual(cmds[0][m_idx + 1], '700') + self.assertIn('ipv6.route-metric', cmds[0]) + m6_idx = cmds[0].index('ipv6.route-metric') + self.assertEqual(cmds[0][m6_idx + 1], '700') def test_build_nmcli_setup_commands_existing(self): cmds = cellular.build_nmcli_setup_commands( @@ -99,6 +102,9 @@ class CellularSetupTests(unittest.TestCase): self.assertIn('ipv4.route-metric', cmds[0]) m_idx = cmds[0].index('ipv4.route-metric') self.assertEqual(cmds[0][m_idx + 1], '700') + self.assertIn('ipv6.route-metric', cmds[0]) + m6_idx = cmds[0].index('ipv6.route-metric') + self.assertEqual(cmds[0][m6_idx + 1], '700') def test_configure_cellular_invokes_executor(self): recorded_calls = [] @@ -423,16 +429,28 @@ class CellularSetupTests(unittest.TestCase): self.assertTrue(any('dialing skipped' in log for log in logs)) self.assertTrue(any('waiting for registration' in log for log in logs)) - def test_usb_profile_metric_yields_to_cellular_and_wifi(self): + def test_route_priority_order_usb_gt_wifi_gt_cellular(self): usb_profile = (ROOT / 'ports/candidate/device-xiaomi-platina/platina-usb.nmconnection').read_text() - metric = None + usb_metric = None for line in usb_profile.splitlines(): if line.strip().startswith('route-metric='): - metric = int(line.split('=', 1)[1].strip()) + usb_metric = int(line.split('=', 1)[1].strip()) break - self.assertIsNotNone(metric) - self.assertEqual(metric, 2000) - self.assertGreater(metric, 700) + self.assertEqual(usb_metric, 50) + + nm_conf = (ROOT / 'ports/candidate/device-xiaomi-platina/platina-networkmanager.conf').read_text() + wifi_metrics = [] + for line in nm_conf.splitlines(): + stripped = line.strip() + if stripped.startswith(('ipv4.route-metric=', 'ipv6.route-metric=')): + wifi_metrics.append(int(stripped.split('=', 1)[1].strip())) + self.assertEqual(wifi_metrics, [200, 200]) + + cmds = cellular.build_nmcli_setup_commands(con_name='platina-cellular', apn='3gnet', existing_connections=[]) + cell_metric = int(cmds[0][cmds[0].index('ipv4.route-metric') + 1]) + self.assertEqual(cell_metric, 700) + self.assertLess(usb_metric, wifi_metrics[0]) + self.assertLess(wifi_metrics[0], cell_metric) if __name__ == '__main__': diff --git a/tests/test_status_screen.py b/tests/test_status_screen.py index cc0564a..cee1fce 100644 --- a/tests/test_status_screen.py +++ b/tests/test_status_screen.py @@ -70,6 +70,30 @@ class StatusScreenTests(unittest.TestCase): self.assertTrue(data['cellular']['is_default']) self.assertEqual(data['network']['tun0_ip'], '192.168.20.10') + def test_collect_telemetry_prefers_lowest_metric_default_route(self): + with tempfile.TemporaryDirectory() as tmp: + sys_dir, proc_dir = self._build_fixtures(Path(tmp)) + + def fake_run(cmd, **kwargs): + if cmd[:4] == ['ip', '-4', 'route', 'show']: + return subprocess.CompletedProcess( + cmd, 0, + 'default via 10.75.105.57 dev qmapmux0.0 metric 700\n' + 'default via 192.168.1.1 dev wlan0 metric 200\n' + 'default via 172.16.42.2 dev usb0 metric 50\n', + '') + if cmd[:4] == ['ip', '-4', '-o', 'addr']: + return subprocess.CompletedProcess( + cmd, 0, + '2: usb0 inet 172.16.42.1/24\n' + '3: wlan0 inet 192.168.1.88/24\n' + '6: qmapmux0.0 inet 10.75.105.56/28\n', '') + return subprocess.CompletedProcess(cmd, 1, '', '') + + data = screen.collect_telemetry(sys_path=sys_dir, proc_path=proc_dir, run=fake_run) + self.assertEqual(data['network']['default_dev'], 'usb0') + self.assertFalse(data['cellular']['is_default']) + def test_render_status_and_charger_bgrx_format_and_speed(self): telemetry = { 'timestamp': '2026-11-17 22:30:00',