diff options
author | Jeff Sharkey <jsharkey@android.com> | 2011-05-28 20:56:34 -0700 |
---|---|---|
committer | Jeff Sharkey <jsharkey@android.com> | 2011-06-07 23:09:25 -0700 |
commit | d2a458750e5a3d490af09cecb5c28370baf0a913 (patch) | |
tree | 72881850dcc70e3b74c52be52ec4858c96a98a8e /telephony/java/android | |
parent | dd82b85677b3556776dbf023ad4fdc22cf075523 (diff) | |
download | frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.zip frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.tar.gz frameworks_base-d2a458750e5a3d490af09cecb5c28370baf0a913.tar.bz2 |
Map network identity using ConnectivityService.
Instead of deriving network identity based on raw subsystem broadcasts,
listen for updates from ConnectivityService. Added atomic view of all
active NetworkState, and build map from "iface" to NetworkIdentity set
for stats tracking.
To avoid exposing internal complexity, INetworkStatsService calls use
general templates. Added TelephonyManager mapping to classify network
types using broad labels like "3G" or "4G", used to drive templates.
Cleaned up Objects and Preconditions.
Change-Id: I1d4c1403f0503bc3635a59bb378841ba42239a91
Diffstat (limited to 'telephony/java/android')
-rw-r--r-- | telephony/java/android/telephony/TelephonyManager.java | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java index 8732e21..7272b08 100644 --- a/telephony/java/android/telephony/TelephonyManager.java +++ b/telephony/java/android/telephony/TelephonyManager.java @@ -469,6 +469,46 @@ public class TelephonyManager { } } + /** Unknown network class. {@hide} */ + public static final int NETWORK_CLASS_UNKNOWN = 0; + /** Class of broadly defined "2G" networks. {@hide} */ + public static final int NETWORK_CLASS_2_G = 1; + /** Class of broadly defined "3G" networks. {@hide} */ + public static final int NETWORK_CLASS_3_G = 2; + /** Class of broadly defined "4G" networks. {@hide} */ + public static final int NETWORK_CLASS_4_G = 3; + + /** + * Return general class of network type, such as "3G" or "4G". In cases + * where classification is contentious, this method is conservative. + * + * @hide + */ + public static int getNetworkClass(int networkType) { + switch (networkType) { + case NETWORK_TYPE_GPRS: + case NETWORK_TYPE_EDGE: + case NETWORK_TYPE_CDMA: + case NETWORK_TYPE_1xRTT: + case NETWORK_TYPE_IDEN: + return NETWORK_CLASS_2_G; + case NETWORK_TYPE_UMTS: + case NETWORK_TYPE_EVDO_0: + case NETWORK_TYPE_EVDO_A: + case NETWORK_TYPE_HSDPA: + case NETWORK_TYPE_HSUPA: + case NETWORK_TYPE_HSPA: + case NETWORK_TYPE_EVDO_B: + case NETWORK_TYPE_EHRPD: + case NETWORK_TYPE_HSPAP: + return NETWORK_CLASS_3_G; + case NETWORK_TYPE_LTE: + return NETWORK_CLASS_4_G; + default: + return NETWORK_CLASS_UNKNOWN; + } + } + /** * Returns a string representation of the radio technology (network type) * currently in use on the device. @@ -477,7 +517,12 @@ public class TelephonyManager { * @hide pending API council review */ public String getNetworkTypeName() { - switch (getNetworkType()) { + return getNetworkTypeName(getNetworkType()); + } + + /** {@hide} */ + public static String getNetworkTypeName(int type) { + switch (type) { case NETWORK_TYPE_GPRS: return "GPRS"; case NETWORK_TYPE_EDGE: |