Starting March 27, 2025, we recommend using android-latest-release instead of aosp-main to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
The most severe threat to a user's security and privacy when using a mobile
network is 2G connections. While legitimate 2G cellular networks are being
phased out across the world, devices are still susceptible to attacks from false
base stations (FBS). An adversary with a FBS can trick a device into connecting
to it instead of a legitimate cellular network. This is most often accomplished
by downgrading a device's connection to 2G, and it allows the operator of the
FBS to intercept or inject traffic to a device.
Android allows users to disable 2G at the radio hardware level on any device
that implements the capability constant,
"CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK". This stops a device from
scanning or connecting to 2G networks.
Starting in Android 14, you must have MODIFY_PRIVILEGED_PHONE_STATE to disable
2G with reason ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G. Carrier privileges don't
suffice.
TelephonyManager tm = getSystemService(TelephonyManager.class);
if (tm != null && tm.isRadioInterfaceCapabilitySupported("CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK")) {
long disable2gBitMask = 0xFFFF &~ TelephonyManager.NETWORK_CLASS_BITMASK_2G;
tm.setAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, disable2gBitMask);
}
FAQs
Are users still vulnerable if their carriers no longer support 2G?
Disabling 2G is an important security measure even if the user's carrier no
longer maintains 2G infrastructure. The user's device still supports scanning
and connecting to 2G base stations, so they are still vulnerable to a 2G
downgrade attack if they do not disable 2G on their device.
How does disabling 2G impact roaming?
When 2G is disabled for security purposes it will not be re-enabled, even if the
device is roaming. Certain areas in the world depend on 2G coverage and some
roaming agreements assume devices will be able to connect to 2G. In these
situations, the user will not have connectivity unless they re-enable 2G.
It's not possible to reliably detect 2G roaming because of the lack of mutual
authentication in 2G. Leaving 2G off despite roaming signals, prevents a FBS
from spoofing its network identifiers to convince a device to re-enable 2G.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[],[],null,["# Disable 2G\n\nThe most severe threat to a user's security and privacy when using a mobile\nnetwork is 2G connections. While legitimate 2G cellular networks are being\nphased out across the world, devices are still susceptible to attacks from false\nbase stations (FBS). An adversary with a FBS can trick a device into connecting\nto it instead of a legitimate cellular network. This is most often accomplished\nby downgrading a device's connection to 2G, and it allows the operator of the\nFBS to intercept or inject traffic to a device.\n\nAndroid allows users to disable 2G at the radio hardware level on any device\nthat implements the capability constant,\n\"CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK\". This stops a device from\nscanning or connecting to 2G networks.\n| **Note:** Emergency calling is never impacted. A device still scans and connects to 2G networks for emergency services.\n\nStarting in Android 14, you must have MODIFY_PRIVILEGED_PHONE_STATE to disable\n2G with reason ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G. Carrier privileges don't\nsuffice. \n\n TelephonyManager tm = getSystemService(TelephonyManager.class);\n\n if (tm != null && tm.isRadioInterfaceCapabilitySupported(\"CAPABILITY_USES_ALLOWED_NETWORK_TYPES_BITMASK\")) {\n long disable2gBitMask = 0xFFFF &~ TelephonyManager.NETWORK_CLASS_BITMASK_2G;\n tm.setAllowedNetworkTypesForReason(TelephonyManager.ALLOWED_NETWORK_TYPES_REASON_ENABLE_2G, disable2gBitMask);\n }\n\nFAQs\n----\n\n### Are users still vulnerable if their carriers no longer support 2G?\n\nDisabling 2G is an important security measure even if the user's carrier no\nlonger maintains 2G infrastructure. The user's device still supports scanning\nand connecting to 2G base stations, so they are still vulnerable to a 2G\ndowngrade attack if they do not disable 2G on their device.\n\n### How does disabling 2G impact roaming?\n\nWhen 2G is disabled for security purposes it will not be re-enabled, even if the\ndevice is roaming. Certain areas in the world depend on 2G coverage and some\nroaming agreements assume devices will be able to connect to 2G. In these\nsituations, the user will not have connectivity unless they re-enable 2G.\nIt's not possible to reliably detect 2G roaming because of the lack of mutual\nauthentication in 2G. Leaving 2G off despite roaming signals, prevents a FBS\nfrom spoofing its network identifiers to convince a device to re-enable 2G."]]