How aunchagaonkar/networkswitch works
Purpose and Runtime
Network Switch is a single-module Kotlin Android app (Android 10+) that changes the device’s preferred cellular network mode across 34 2G/3G/4G/5G combinations. It is entirely local: privileged telephony access is obtained through either root or the user-run Shizuku service. Primary Android entry declarations are in app/src/main/AndroidManifest.xml; application DI initialization is in app/src/main/java/com/supernova/networkswitch/NetworkSwitchApplication.kt.
User and System Entry Points
Compose activities provide the interactive configuration and switching flow:
• Main switch state and action: app/src/main/java/com/supernova/networkswitch/presentation/ui/activity/MainActivity.kt
• Two-mode configuration: app/src/main/java/com/supernova/networkswitch/presentation/ui/activity/NetworkModeConfigActivity.kt
• Control-method/settings selection: app/src/main/java/com/supernova/networkswitch/presentation/ui/activity/SettingsActivity.kt
The Quick Settings integration is a separate Android tile-service entry point at app/src/main/java/com/supernova/networkswitch/service/NetworkTileService.kt, enabling switching without launching an activity.
Presentation and Domain Boundary
ViewModels convert UI events into domain operations and expose UI state; screen-specific state owners are app/src/main/java/com/supernova/networkswitch/presentation/viewmodel/MainViewModel.kt, app/src/main/java/com/supernova/networkswitch/presentation/viewmodel/NetworkModeConfigViewModel.kt, and app/src/main/java/com/supernova/networkswitch/presentation/viewmodel/SettingsViewModel.kt.
The domain layer defines the stable business vocabulary—network modes and toggle configuration—and repository contracts, keeping UI independent of privileged Android access:
• app/src/main/java/com/supernova/networkswitch/domain/model/NetworkSwitchModels.kt
• app/src/main/java/com/supernova/networkswitch/domain/repository/Repositories.kt
• app/src/main/java/com/supernova/networkswitch/domain/usecase/NetworkUseCases.kt
Switching Flow
A switch request flows from an activity or tile through a ViewModel/use case to NetworkControlRepositoryImpl, which selects the configured control backend. The selected backend applies the desired Android telephony mode; mode definitions are translated to platform bitmasks before that privileged call.
• Repository orchestration: app/src/main/java/com/supernova/networkswitch/data/repository/NetworkControlRepositoryImpl.kt
• Backend abstraction and implementations: app/src/main/java/com/supernova/networkswitch/data/source/NetworkControlDataSource.kt, app/src/main/java/com/supernova/networkswitch/data/source/RootNetworkControlDataSource.kt, app/src/main/java/com/supernova/networkswitch/data/source/ShizukuNetworkControlDataSource.kt
• Mode-to-bitmask compatibility boundary: app/src/main/java/com/supernova/networkswitch/service/NetworkModeBitmaskMapper.kt, app/src/main/java/com/supernova/networkswitch/service/TelephonyReflection.kt
Privileged-Control Backends
Root control is isolated behind a controller service, while non-root control communicates through Shizuku. Both cross IPC boundaries defined by AIDL rather than exposing telephony implementation details to the rest of the app.
• Root service: app/src/main/java/com/supernova/networkswitch/service/RootNetworkControllerService.kt
• Shizuku service: app/src/main/java/com/supernova/networkswitch/service/ShizukuControllerService.kt
• IPC contracts: app/src/main/aidl/com/supernova/networkswitch/IRootController.aidl, app/src/main/aidl/com/supernova/networkswitch/IShizukuController.aidl
Material external dependencies are libsu/root management, Shizuku binder access, and Android hidden/reflected telephony APIs; device/vendor API compatibility is therefore concentrated in this service layer.
Persistent Configuration and Composition
The configured control method and Mode A/Mode B pairing persist through a preferences source/repository, used by both UI and tile paths. Hilt binds implementations and sources into the domain-facing graph.
• Preferences persistence: app/src/main/java/com/supernova/networkswitch/data/source/PreferencesDataSource.kt, app/src/main/java/com/supernova/networkswitch/data/repository/PreferencesRepositoryImpl.kt
• Dependency graph: app/src/main/java/com/supernova/networkswitch/di/DataModule.kt
Build and Delivery
Gradle builds the Android APK from the app module, with dependency versions centralized in gradle/libs.versions.toml. GitHub Actions separates normal build validation and release delivery in .github/workflows/build.yml and .github/workflows/release.yml; Fastlane metadata supports Android distribution listing content under fastlane/metadata/android.
Main entry points: Repositories.kt Repository contracts · AndroidManifest.xml Android declarations · MainViewModel.kt Screen ViewModels · NetworkControlRepositoryImpl.kt Network control repository
Components 19
Android app
- Android declarations · Declares activities, tile, and services.
app/src/main/AndroidManifest.xml - Application bootstrap · Initializes Hilt dependency injection.
app/src/main/java/com/supernova/networkswitch/NetworkSwitchApplication.kt - Compose activities · Main switching, mode configuration, and settings screens.
app/src/main/java/com/supernova/networkswitch/presentation/ui/activity/MainActivity.kt - Quick Settings tile · Triggers switching without launching an activity.
app/src/main/java/com/supernova/networkswitch/service/NetworkTileService.kt - Screen ViewModels · Maps UI events to use cases and exposes UI state.
app/src/main/java/com/supernova/networkswitch/presentation/viewmodel/MainViewModel.kt
Domain & data
- Network switch models · Network modes and toggle configuration.
app/src/main/java/com/supernova/networkswitch/domain/model/NetworkSwitchModels.kt - Repository contracts · Keeps callers independent of privileged access.
app/src/main/java/com/supernova/networkswitch/domain/repository/Repositories.kt - Network use cases
app/src/main/java/com/supernova/networkswitch/domain/usecase/NetworkUseCases.kt - Network control repository · Selects the configured control backend.
app/src/main/java/com/supernova/networkswitch/data/repository/NetworkControlRepositoryImpl.kt - Preferences repository · Stores control method and Mode A/Mode B pairing.
app/src/main/java/com/supernova/networkswitch/data/repository/PreferencesRepositoryImpl.kt - Hilt data bindings · Binds sources and implementations to domain contracts.
app/src/main/java/com/supernova/networkswitch/di/DataModule.kt
Privileged control
Compatibility-sensitive telephony access is isolated here.
- Control backends · Root and Shizuku implementations of network control.
app/src/main/java/com/supernova/networkswitch/data/source/NetworkControlDataSource.kt - Root controller · Uses libsu/root management behind IPC.
app/src/main/java/com/supernova/networkswitch/service/RootNetworkControllerService.kt - Shizuku controller · Uses Shizuku binder access behind IPC.
app/src/main/java/com/supernova/networkswitch/service/ShizukuControllerService.kt - AIDL controller contracts · Root and Shizuku controller interfaces.
app/src/main/aidl/com/supernova/networkswitch/IRootController.aidl - Telephony compatibility · Maps modes to bitmasks and invokes hidden/reflected APIs.
app/src/main/java/com/supernova/networkswitch/service/NetworkModeBitmaskMapper.kt
Build & delivery
- Android APK build · Builds the Android application.
gradle/libs.versions.toml - GitHub Actions · Separates build validation from release delivery.
.github/workflows/build.yml - Store metadata · Android distribution listing content.
fastlane/metadata/android
Connections 23
- Android declarations → Compose activities: declares
- Android declarations → Quick Settings tile: declares
- Android declarations → Root controller: declares
- Application bootstrap → Hilt data bindings: initializes
- Compose activities → Screen ViewModels: drives
- Quick Settings tile → Network use cases: switches via
- Screen ViewModels → Network use cases: invokes
- Screen ViewModels → Preferences repository: reads and updates
- Network use cases → Repository contracts: depends on
- Repository contracts → Network switch models: uses
- Network control repository → Repository contracts: implements
- Preferences repository → Repository contracts: implements
- Hilt data bindings → Network control repository: binds
- Hilt data bindings → Preferences repository: binds
- Network control repository → Control backends: selects configured
- Control backends → AIDL controller contracts: uses
- AIDL controller contracts → Root controller: connects
- AIDL controller contracts → Shizuku controller: connects
- Root controller → Telephony compatibility: applies mode through
- Shizuku controller → Telephony compatibility: applies mode through
- Network switch models → Telephony compatibility: mode translated by
- Android APK build → GitHub Actions: validated and released by
- GitHub Actions → Store metadata: publishes with