Modern Android smartphones, tablets, and automotive head units operate across international borders with varying telecommunications regulations. Radio frequency rules—such as available Wi-Fi 5 GHz and 6 GHz UNII channels, allowable transmit power limits, radar detection (DFS) requirements, FM radio tuning steps, and emergency calling numbers—differ significantly between countries. To comply with local legal and spectrum mandates without requiring users to manually select their country in settings, Android employs an internal location synthesis subsystem managed by the CountryDetectorService.
When an Android handset lands in a foreign country or fails to unlock 5 GHz Wi-Fi channels, identifying which sensor source dictates the regulatory domain is critical for troubleshooting. The Android Debug Bridge (ADB) provides direct, low-level insight into this mechanism via dumpsys country_detector, revealing detected country codes, active detection providers, and confidence rankings directly from the terminal.
Understanding Android Country Detection Architecture
The Android CountryDetectorService synthesizes geographic identity by querying a prioritized hierarchy of detection engines:
- Telephony Country Detector: The highest-priority and most reliable source. When connected to a cellular base station, the cellular modem reads the Mobile Country Code (MCC) from the SIM card and the broadcast network operator identity, resolving the two-letter ISO 3166-1 alpha-2 country code (such as
US,GB,DE, orJP). - Location-Based Country Detector: If the device lacks cellular connectivity (e.g. Wi-Fi-only tablets or phones in airplane mode), the system activates GPS, cell tower triangulation, or Wi-Fi BSSID geolocation to query an offline geocoding database or online Google Play Services location provider.
- Comprehensive / Network Country Detector: Evaluates internet routing metadata and visible Wi-Fi access point country beacons (IEEE 802.11d country information elements).
- System Locale Fallback: If all radio signals and geolocation sensors are unreachable, the detector defaults to the country associated with the user’s selected system language and locale.
Connecting via ADB and Verifying Shell Access
Connect your development workstation to the Android handset via USB or Wireless debugging and confirm administrative authorization:
# Verify connected Android device
adb devices -l
# Ensure device shell access is operational
adb get-state
Confirm the device’s telephony and radio status:
# Check active Android release
adb shell getprop ro.build.version.release
# Verify telephony hardware presence
adb shell pm list features | grep -i "android.hardware.telephony"
Executing dumpsys country_detector
To inspect the live country detection subsystem, query the service dump directly via the ADB shell:
# Query the CountryDetectorService diagnostic dump
adb shell dumpsys country_detector
The output presents a structured report detailing the active detector state, historical country transitions, and registered notification listeners across the system.
Analysing Country Detector Output and Provider Confidence
Examine a typical output block from dumpsys country_detector:
-------------------------------------------------------------------------------
COUNTRY DETECTOR SERVICE (dumpsys country_detector)
Current Country:
Country code: GB
Country source: 0
Timestamp: 1731023450000
Total Listeners: 6
Listeners:
com.android.server.wifi
com.android.phone
com.google.android.gms
-------------------------------------------------------------------------------
Key properties to examine during diagnostic audits:
- Country code: The active two-letter ISO code governing system regulations.
- Country source: An integer representing the winning detection provider:
0: COUNTRY_SOURCE_NETWORK: Derived directly from cellular network telephony signals (MCC).1: COUNTRY_SOURCE_LOCATION: Derived from passive or active GPS/Wi-Fi geolocation.2: COUNTRY_SOURCE_SIM: Derived from the SIM card’s home country configuration.3: COUNTRY_SOURCE_LOCALE: Fallback derived from system user interface language.
- Listeners: Core system services that receive immediate callbacks when the country code changes, such as the Wi-Fi service updating regulatory domain tables (
crda/cfg80211).
Auditing Wi-Fi Regulatory Domain Updates
When the country detector resolves a new country code, the Android Wi-Fi service dynamically configures channel masks and transmit power limits. Correlate the country detector output with the Wi-Fi subsystem:
# Inspect active Wi-Fi regulatory domain and country code
adb shell cmd wifi get-country-code
# Query Wi-Fi service diagnostic dump for regulatory channel limits
adb shell dumpsys wifi | grep -iE "mCountryCode|regulatory"
If cmd wifi get-country-code returns an incorrect code or shows null, the device defaults to global conservative regulatory settings, disabling channels 12–14 on 2.4 GHz and high-frequency UNII-3 bands on 5 GHz.
Testing Regulatory Transitions on Staging Devices
When testing location-sensitive applications or validating Wi-Fi band switching across borders, engineers can observe real-time country detection transitions by simulating cellular network changes or toggling Airplane mode:
# Monitor country detector log events in real time
adb shell logcat -s CountryDetector CountryDetectorService
As network or location signals shift, the service outputs chronological transition entries, allowing developers to ensure that internationalization rules and geo-restricted features respond correctly without physically transporting hardware across borders.
By leveraging dumpsys country_detector, Android developers and RF test engineers gain transparent, verified insight into geographic regulation synthesis across all Android hardware platforms.