Skip to content

Injection Architecture

NanoMindExplores edited this page Jul 14, 2026 · 1 revision

Injection Architecture

GameMapperMind uses a 3-path touch injection scheme with automatic failover. Each path tries the previous one first. Unlike earlier versions, Path C is never permanently cached — every call retries A then B then C.

Path Overview

Path Method Reliability Latency Multi-touch
A (primary) IInputManager AIDL via ServiceManager Highest <1ms Full (multi-pointer)
B (fallback) InputManager class via getSystemService + reflection High <1ms Full (multi-pointer)
C (last resort) input tap shell command Guaranteed ~100ms Single-tap only

How It Works

Path A — IInputManager AIDL (Primary)

Uses the same AIDL interface as Android internal input binary. Most reliable because it bypasses hidden API restrictions and accepts concurrent injectInputEvent calls for different pointer IDs.

Path B — InputManager Reflection (Fallback)

Uses the public InputManager instance instead of raw AIDL proxy. Functionally identical to Path A but goes through one extra layer.

Path C — Shell Input (Last Resort)

Runs the input tap shell command. Limitations:

  • Only supports single-pointer DOWN + UP (no MOVE, no multi-pointer)
  • ~100ms latency per call
  • Does NOT fire when other pointers are active (v3 fix) — would hijack the active multi-touch session

Failover Logic (v3)

  1. Build MotionEvent with ALL active pointers
  2. Try Path A — if success, return true
  3. Try Path B — if success, return true
  4. If pointerCount == 1 AND action is DOWN/UP: Fall back to shell input tap (one-shot, NOT cached)
  5. Else (multi-pointer or MOVE): Return false (shell cannot handle this)

Key v3 change: activePath is NEVER set to C. Every call retries A then B first. This ensures transient A/B failures do not permanently kill analog movement.

Shizuku Permission

Shizuku runs the TouchDaemonService as shell uid (2000), which:

  • Bypasses Android hidden API restrictions (Path A/B reflection works)
  • Has INJECT_EVENTS permission (required for injectInputEvent)
  • Can execute shell commands (Path C)

Without Shizuku, none of the paths work.

See Also

  • Multi-Pointer-MotionEvent — How v3 builds correct multi-touch MotionEvents
  • Dual-AIDL-Dispatch-Thread — Why stick and button use separate threads

Clone this wiki locally