Channel Analysis
Relevant source files
The following files were used as context for generating this wiki page:
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/ChannelDistributionScreen.kt
- app/src/main/kotlin/com/shadowcheck/mobile/ui/screens/security/ChannelAnalysisScreen.kt
- app/src/main/kotlin/com/shadowcheck/mobile/ChannelGraph.kt
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/service/CompleteScannerService.kt
- app/src/main/kotlin/com/shadowcheck/mobile/data/WifiNetwork.kt (referenced via data structures)
- app/src/main/kotlin/com/shadowcheck/mobile/rebuilt/ui/screens/NetworkDetailScreen.kt
The Channel Analysis module in ShadowCheckMobile is a critical diagnostic and security feature designed to provide a comprehensive overview of WiFi spectrum utilization. It aggregates data from the environment to visualize network congestion, signal distribution, and frequency occupancy across the 2.4 GHz and 5 GHz bands. This module assists users in identifying optimal channels for network configuration and serves as a tool for Threat Detection by highlighting unusual signal density or rogue access points operating on non-standard frequencies.
Sources: ChannelAnalysisScreen.kt, ChannelDistributionScreen.kt, README.md:5-15
Architectural Overview
The system operates on a reactive architecture where background scanning services feed a local SQLite database, which in turn populates the UI via Kotlin Flows. The data flows from the physical hardware through the Android WiFi API, into the Room database, and is finally rendered using Jetpack Compose Canvas components.
Data Acquisition Flow
The CompleteScannerService is responsible for the raw collection of frequency data. It calculates the channel index from the center frequency of detected signals and stores this alongside signal level (RSSI) and bandwidth information.
The diagram above shows the lifecycle of frequency data from initial scan to visual representation.
Sources: CompleteScannerService.kt:50-80, ChannelDistributionScreen.kt:35-45
Key Components
Frequency Analysis Logic
The system uses a mathematical mapping to convert raw MHz frequencies into standard WiFi channel numbers. This is handled by internal utility functions that distinguish between the 2.4 GHz and 5 GHz bands.
| Range | Calculation Formula | Common Channels |
|---|---|---|
| 2.4 GHz (2412-2484 MHz) | (freq - 2407) / 5 | 1, 6, 11 |
| 5 GHz (5170-5825 MHz) | Static Mapping (36-165) | 36, 44, 149, 161 |
Sources: ChannelDistributionScreen.kt:130-150, CompleteScannerService.kt:315-320
Recommended Channel Selection
The module includes a findBestChannels algorithm that identifies the least congested frequencies based on current environmental data. This logic compares available channels against a predefined list of "recommended" (non-overlapping) channels to suggest the best configuration.
private fun findBestChannels(
channelData: Map<Int, Int>,
recommendedChannels: List<Int>,
count: Int
): List<Int> {
return recommendedChannels
.sortedBy { channelData[it] ?: 0 }
.take(count)
}
Sources: ChannelAnalysisScreen.kt:143-150
Visualization and UI Components
Channel Graphs
Visualization is performed using the ChannelGraph Composable, which leverages the androidx.compose.foundation.Canvas API to draw histograms of network distribution.
- Congestion Coloring: The bars change color based on the count of networks detected on a specific channel relative to the maximum detected count.
- Green: Low congestion (0-30% of max).
- Yellow: Medium congestion (30-60% of max).
- Red: High congestion (>60% of max).
- Recommended Highlights: Recommended channels (like 1, 6, and 11) are highlighted with a distinct overlay to indicate optimal configuration points.
Sources: ChannelAnalysisScreen.kt:98-130, ChannelDistributionScreen.kt:100-120
Temporal Heatmap
Beyond immediate distribution, the system tracks "Activity by Day/Hour" using a temporal heatmap. This helps identify patterns of network usage or intermittent interference sources.
Sources: HeatmapScreen.kt:150-180
Implementation Details
Signal Strength Over Time
For specific network analysis, the SignalGraph component tracks the RSSI values of a BSSID across its sighting history. It normalizes signal levels between the minimum and maximum recorded dBm to plot a relative performance curve.
val points = sightings.mapIndexed { index, sighting ->
val x = (index.toFloat() / (sightings.size - 1)) * size.width
val normalizedSignal = if (range > 0) (sighting.signalLevel - minSignal) / range else 0.5f
val y = size.height - (normalizedSignal * size.height)
Offset(x, y)
}
Sources: NetworkDetailScreen.kt:125-145
Summary
Channel Analysis in ShadowCheckMobile provides both real-time and historical insights into WiFi spectrum usage. By combining raw frequency mapping, congestion-based heuristics, and graphical histograms, it allows for effective network optimization and environmental signal monitoring. The integration with background scanning services ensures that the analysis remains current with the user's physical surroundings.
Sources: ChannelAnalysisScreen.kt, ChannelDistributionScreen.kt, CompleteScannerService.kt