Skip to content

SebghatYusuf/android_remote

Repository files navigation

Icon
Flutter Android TV Remote

A beautiful, production-grade Flutter implementation of the Android TV Remote Control V2 Protocol.

Flutter Dart Protocol Riverpod License

This is a complete, working remote control app for Android TV, Google TV, and Android set-top boxes. It uses the modern V2 Protocol (SSL/TLS + Protocol Buffers), bypassing the deprecated Polo TV protocol.


✨ Features

  • 📺 mDNS Discovery: Automatically discovers Android TV devices on your local Wi-Fi network using _androidtvremote2._tcp.
  • 🔐 V2 Protocol Handshake: Implements the complex mutual-TLS (mTLS) certificate exchange.
  • 🔢 Real Pairing Flow: Extracts public key modulus / exponent and correctly computes the cryptographic SHA-256 PIN challenge required by modern Google TVs.
  • ⚡ Protobuf Messaging: Varint-length-delimited Protocol Buffer messages for incredibly fast, low-latency control logic.
  • 🎮 Futuristic "Obsidian" UI: A dark, space-themed, highly-responsive user interface using Google Fonts (Rajdhani) tailored for haptic feedback and smooth animations.
  • 🎛️ Full Remote Capabilities:
    • D-Pad Navigation (Up/Down/Left/Right/OK)
    • System Keys (Home, Back, Menu, Input)
    • Media Controls (Play, Pause, Stop, Prev, Next)
    • Volume Controls (Press or Hold-to-repeat)
  • 🛠️ Built-in Mock TV Server: Includes a local Node.js server to simulate an Android TV for debugging protocol logic locally without requiring physical hardware.

📸 Screenshots

(Replace these with actual screenshots from your running app)

🚀 Getting Started

Prerequisites

  • Flutter SDK (3.10.0 or higher)
  • A physical Android TV / Google TV on the same Wi-Fi network (or use the mock server)

Installation

  1. Clone the repository

    git clone https://github.com/sebghatyusuf/android_remote.git
    cd android_remote
  2. Install Flutter Dependencies

    flutter pub get
  3. Run the App

    flutter run

🧠 How the V2 Protocol Works

Older Android TVs used a protocol called Google Polo. Modern TVs (Google TV, Chromecast with Google TV, Nvidia Shield, Prism+) enforce Protocol V2, which is significantly more complex.

This Flutter app implements the entire chain natively:

  1. Discovery (mDNS): Looks for _androidtvremote2._tcp on Port 6467.
  2. Mutual TLS: The app generates a persistent RSA-2048 self-signed certificate (PKCS#8) and forces a secure socket layer over the connection.
  3. The PIN Handshake: When the TV shows a 6-character Hex code (e.g. A1B2C3), the TV doesn't just check the string. This app automatically pulls the server and client certificate Der keys, extracts the modulus and exponent, appends a binary slice of the PIN, and hashes it using SHA-256 to pass the cryptographic challenge.
  4. Command Protobuf: Once paired, it connects to Port 6466 and starts listening to remotePingRequest/remotePingResponse heartbeats while streaming varint-prefixed Protobuf binary data mapped to RemoteKeyInject commands.

🧪 Local Mock TV Server (For Debugging)

Don't have a TV nearby? We built a Node.js mock server that simulates an Android TV to debug SSL handshakes, protocol buffer schemas, and cryptographic PIN generation.

# Navigate to the mock server folder
cd mock_tv_server

# Install dependencies
npm install

# Start the mock TV
npm start

The server will publish an mDNS service as "Mock Android TV" and will print a PIN in the terminal when your Flutter app initiates the pairing request.

📦 Architecture & Packages Used

  • bonsoir: mDNS / Zeroconf network discovery.
  • flutter_riverpod: Predictable, scalable state management (Scanning -> Pairing -> Connected).
  • basic_utils: X.509 Certificate generation and RSA key extraction.
  • crypto: Cryptographic hashing for the pairing secret.
  • protobuf: Binary message encoding.
  • flutter_secure_storage: Securely stores the client certificate and pairing keys.

🤝 Contributing

Contributions are heavily encouraged! If you're looking to dive into reverse-engineering, network protocols, or Flutter UI, check the 'Issues' tab.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📜 License

Distributed under the MIT License. See LICENSE for more information.

🌟 Acknowledgements

This project was built through reverse engineering references and prior work done by the open-source community:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors