tablet-login-protection.md 4.47 KB

Tablet Login Protection — Root Cause Analysis & Rules

Background

The Pixel device achieves WeChat tablet login via an Xposed module (WeChatHook, LSPosed mid=42) that hooks WeChat internals to make WeChat believe this phone is a tablet. This enables multi-device login without the primary phone needing to stay online.

The tablet login session is fragile — it survives normal app backgrounding but is destroyed by any of the following.

Root Cause Chain: What Hermes Broke (2026-07-03)

Three independently dangerous operations combined to kill tablet login:

1. am force-stop com.tencent.mm — KILLS TABLET LOGIN

Location: ~/pixelphone/event_bus/wechat_send.py, line 363:

_run("am force-stop com.tencent.mm", timeout=10)

This is inside send_wechat_message_ui(). The intent is noble — force-stop guarantees LauncherUI starts fresh so the search icon is reachable. But the side effect is fatal: force-stopping WeChat destroys the tablet login session instantly.

Every call to mcp_android_phone_send_wechat_message() → force-stops WeChat → kills tablet login.

The send_wechat_message_ui function also appears in:

  • connectors.py → WeChatConnector.send_message()
  • Cron jobs that send WeChat messages
  • The daily digest pipeline

2. killall lspd — KILLS LSPOSED PERMANENTLY

On JingMatrix Vector LSPosed for Android 16, the daemon (lspd) does NOT auto-restart when killed. Once killed, the daemon is dead until the next full device reboot.

This means all Xposed modules (WeChatHook mid=42, xhshook mid=8) stop working until reboot.

3. SQLite toggle on modules_config.db — CAN DELETE MODULE ENTRIES

Direct SQLite operations on /data/adb/lspd/config/modules_config.db (toggling the enabled field of mid=42) triggered LSPosed's FileObserver to detect the change and potentially delete the entire module record (mid=42 disappeared from the DB).

Never write to modules_config.db directly. Use LSPosed Manager's UI or pm install -r + LSPosed Manager scope configuration.

Protection Rules (MUST FOLLOW)

Rule 1: NEVER force-stop WeChat

  • am force-stop com.tencent.mm is forbidden unless the user explicitly approves it
  • For sending messages, the send_wechat_message_ui() function in wechat_send.py calls force-stop automatically — do not use this function if tablet login is active
  • Alternative: use ADBKeyboard manual workflow WITHOUT force-stop (open WeChat, navigate, type, send — but skip the force-stop preamble)

Rule 2: NEVER kill LSPosed daemon

  • killall lspd / pkill lspd / kill <lspd_pid> are ALL forbidden
  • JingMatrix Vector LSPosed on Android 16 does NOT auto-restart
  • Only recovery: full device reboot
  • Verify lspd is alive with: pgrep -f lspd

Rule 3: NEVER write to modules_config.db

  • Do not use sqlcipher/sqlite3 to modify /data/adb/lspd/config/modules_config.db
  • Do not toggle enabled field via SQL
  • Do not insert/delete module or scope rows
  • LSPosed Manager is the only supported way to configure modules
  • If a module isn't loading, diagnose via logcat and LSPosed logs, not DB surgery

Rule 4: Always check tablet login status FIRST

  • Before any WeChat operation, verify tablet login is intact:
    1. Check WeChat is in foreground (not on login/verification screen)
    2. Check lspd is running: pgrep -f lspd
    3. Check WeChatHook module is injected: grep /proc/<wechat_pid>/maps for lspd .so
  • If any check fails, report to user BEFORE taking action

Rule 5: Never restart WeChat without user OK

  • am force-stop com.tencent.mm kills login session
  • am start alone won't kill login but can still disrupt hooks
  • Always ask user before any WeChat process manipulation

Recovery Steps (if tablet login is lost)

  1. Tell the user immediately — don't try to fix silently
  2. User must re-authenticate in WeChat (password or SMS verification)
  3. After re-login, verify LSPosed modules are loaded
  4. Confirm tablet login is showing again

Code Locations to Be Aware Of

File What it does Risk to tablet login
wechat_send.py:363 am force-stop before send KILLS login on every send
wechat_send.py:321 send_wechat_message_ui() entry Calls force-stop
android_mcp.py:824 send_wechat_message MCP tool Delegates to send_wechat_message_ui
connectors.py:257 WeChatConnector.send_message() Can also trigger force-stop path
/data/adb/lspd/config/modules_config.db LSPosed module DB DO NOT TOUCH