$ show JZ-Darkal/AndroidHttpCapture
This is an Android application for network traffic capture and diagnostics, functioning as a mobile proxy similar to Fiddler. The core functionality revolves around intercepting HTTP/HTTPS traffic via a locally running BrowserMobProxy instance, capturing requests/responses in HAR format, and providing tools for modifying traffic (via response injection rules), exporting captures, and performing network diagnostics (ping, DNS, traceroute). The architecture follows standard Android patterns with Activities, Fragments, Services, and Utils classes, but integrates deeply with modified versions of Netty, BrowserMob Proxy, and LittleProxy for MITM capabilities. Key entry points include MainActivity (UI launcher), SysApplication (proxy initialization), MyVpnService (system-wide traffic capture via VPN), and LDNetDiagnoService (diagnostic tasks). The application requires manual installation of a CA certificate for HTTPS interception and stores configuration in SharedPreferences. While functional, the codebase exhibits maintenance challenges including reflection-heavy Android version-specific code, complex SSL/TLS management, static state risks, and dependencies on forked libraries that may lag upstream.
The LLM identified 4 files worth highlighting for reuse:
Abstract base class for background tasks that safely updates UI via Handler/Runnable. Encapsulates the pattern of running work on a background thread and posting results to the main thread. Self-contained with only Android Handler/Context dependencies, making it easily extractable for any Android app needing similar async task patterns.
Custom EditText subclass that adds a clear (x) button to remove text. Implements touch handling to show/hide the button and clear text on click. A self-contained UI component with no external dependencies beyond Android View, reusable in any Android app needing a clearable text field.
Utility for storing and retrieving Java objects as JSON in SharedPreferences using Gson. Provides type-safe put/getObject methods with automatic serialization/deserialization. Isolatable with only Gson and Android Context dependencies, offering a reusable pattern for complex preference storage beyond primitives.
Custom X509ExtendedTrustManager that trusts all certificates, enabling MITM interception for HTTPS traffic. A self-contained Java class with no dependencies, demonstrating a pattern for bypassing certificate validation in controlled environments (e.g., debugging). While posing security risks if misused, it is a reusable component for applications requiring custom trust logic.