How dhangofa/nettoggle works
Purpose and Runtime
NetToggle is a native Android app (API 24–36) that exposes a Quick Settings tile for cycling cellular radio/network modes. It operates entirely on-device, bypassing ordinary telephony APIs through privileged shell commands run as Root (su) or via Shizuku. Android Gradle builds the single app module: app/build.gradle.kts, app/src/main/AndroidManifest.xml.
Android Entry Points
The primary configuration screen is app/src/main/java/com/dhangofa/networktoggle/MainActivity.java. The operational entry point is the system-hosted QS tile service, app/src/main/java/com/dhangofa/networktoggle/NetworkTileService.java, which applies the next configured mode on tile interaction. app/src/main/java/com/dhangofa/networktoggle/BootReceiver.java restores or refreshes relevant tile/application state after device boot.
Persistent Configuration and Cycle State
app/src/main/java/com/dhangofa/networktoggle/config/AppPreferences.java is the local persistence boundary for execution mode, target SIM, configured cycle, and likely current cycle position. app/src/main/java/com/dhangofa/networktoggle/cycle/TileCycleManager.java validates and advances the user-defined two- or three-mode sequence. Core value types keep these decisions explicit: model/ExecutionMode.java, model/NetworkMode.java, and model/TargetSim.java.
Privileged Command Execution
The command package abstracts the privilege provider behind app/src/main/java/com/dhangofa/networktoggle/command/CommandExecutor.java and CommandExecutorFactory.java. Concrete executors select Root or Shizuku: RootCommandExecutor.java and ShizukuCommandExecutor.java. Process output is captured and normalized through ProcessResultReader.java and StreamCollector.java, producing structured results in model/CommandResult.java. This is the critical boundary between app logic and device/ROM-specific shell behavior.
Telephony Resolution and Mode Application
The telephony layer determines what can safely be offered and translates selected modes into platform-appropriate commands. app/src/main/java/com/dhangofa/networktoggle/telephony/NetworkModeController.java is the main application path, while LegacyNetworkModeController.java handles Android 7–11’s headless Java payload approach. NetworkModePayload.java represents command-ready mode data. On Android 12+, the README indicates native shell routing is used.
Before execution, SimResolver.java maps Auto/SIM targets to physical slots using Android subscription APIs, and NetworkModeReader.java reads current state where needed. NetworkCapabilityResolver.java filters unsupported radio modes; LteAndAboveCarrierRegistry.java supplies carrier constraints for 2G/3G sunset cases.
UI, Diagnostics, and External Dependencies
app/src/main/java/com/dhangofa/networktoggle/ui/TileCycleUiController.java binds activity UI interactions to preference/cycle configuration, with layouts rooted at app/src/main/res/layout/activity_main.xml. Failures and captured stdout/stderr are surfaced locally through util/DiagnosticReporter.java and model/DiagnosticError.java.
Material dependencies are Android system services (Quick Settings, telephony/subscription APIs), device Root tooling, or the separately installed/running Shizuku service. There is no app backend, telemetry, or network communication; GitHub/Telegram links are user-initiated only.
Main entry points: AndroidManifest.xml Android manifest · TileCycleUiController.java Tile cycle UI controller · NetworkModeController.java Network mode controller · CommandExecutor.java Command executor
Components 20
Android app
- Gradle app module · Builds the single native app module.
app/build.gradle.kts - Android manifest
app/src/main/AndroidManifest.xml - Main activity
app/src/main/java/com/dhangofa/networktoggle/MainActivity.java - Network tile service · Applies the next configured network mode on tile interaction.
app/src/main/java/com/dhangofa/networktoggle/NetworkTileService.java - Boot receiver · Refreshes tile or app state after boot.
app/src/main/java/com/dhangofa/networktoggle/BootReceiver.java - Tile cycle UI controller
app/src/main/java/com/dhangofa/networktoggle/ui/TileCycleUiController.java - Main layout
app/src/main/res/layout/activity_main.xml - Diagnostic reporter · Surfaces failures and captured command output locally.
Configuration & cycle
- App preferences · Stores execution mode, target SIM, cycle, and cycle position.
app/src/main/java/com/dhangofa/networktoggle/config/AppPreferences.java - Tile cycle manager · Validates and advances two- or three-mode sequences.
app/src/main/java/com/dhangofa/networktoggle/cycle/TileCycleManager.java - Mode and SIM models · Execution mode, network mode, and target SIM decisions.
Telephony application
- Network mode controller · Main path translating a selected mode into device commands.
app/src/main/java/com/dhangofa/networktoggle/telephony/NetworkModeController.java - Legacy mode controller · Uses the headless Java payload approach.
- SIM, state & capability resolution · Resolves slots, reads state, and filters unsupported or carrier-constrained modes.
Privileged commands
- Command executor factory · Selects Root or Shizuku command execution.
- Command executor · Privileged shell boundary for Root and Shizuku executors.
app/src/main/java/com/dhangofa/networktoggle/command/CommandExecutor.java - Process results · Normalized stdout and stderr results.
Device platform
- Android system services
- Root tooling
- Shizuku service · Separately installed and running service.
Connections 22
- Gradle app module → Android manifest: packages
- Android manifest → Main activity: registers
- Android manifest → Network tile service: registers
- Android manifest → Boot receiver: registers
- Main activity → Tile cycle UI controller: hosts
- Tile cycle UI controller → Main layout: binds
- Tile cycle UI controller → App preferences: configures
- Tile cycle UI controller → Tile cycle manager: edits cycle
- Network tile service → Tile cycle manager: advances
- Tile cycle manager → App preferences: reads and saves state
- App preferences → Mode and SIM models: persists
- Network tile service → Network mode controller: applies next mode
- Network mode controller → SIM, state & capability resolution: resolves target and support
- SIM, state & capability resolution → Android system services: uses subscription APIs
- Network mode controller → Legacy mode controller: uses on Android 7–11
- Network mode controller → Command executor factory: requests privileged execution
- Command executor factory → Command executor: creates Root or Shizuku executor
- Command executor → Root tooling: executes via su
- Command executor → Shizuku service: executes via service
- Command executor → Process results: captures output
- Process results → Diagnostic reporter: reports failures
- Boot receiver → Network tile service: refreshes state