zoukankan      html  css  js  c++  java
  • Android 源码 判断网络数据类型

    private final void updateDataNetType(int slotId) {
    int tempDataNetType;
    NetworkType tempDataNetType3G = NetworkType.Type_G;

    if (slotId == Phone.GEMINI_SIM_1) {
    tempDataNetType = mDataNetType;
    } else {
    tempDataNetType = mDataNetTypeGemini;
    }
    Xlog.d(TAG, "updateDataNetType(" + slotId + "), DataNetType=" + tempDataNetType + ".");

    int simColorId = SIMHelper.getSIMColorIdBySlot(mContext, slotId);
    if (simColorId == -1) {
    return;
    }
    Xlog.d(TAG, "updateDataNetType(" + slotId + "), simColorId=" + simColorId);

    boolean tempIsRoaming = false;
    if ((isCdma(slotId) && isCdmaEri(slotId))
    || mPhone.isNetworkRoamingGemini(slotId)) {
    int tempRoamingId = 0;

    if (simColorId > -1 && simColorId < 4) {
    tempRoamingId = TelephonyIconsGemini.ROAMING[simColorId];
    }
    Xlog.d(TAG, "updateDataNetType(" + slotId + ") RoamingresId= " + tempRoamingId + " simColorId = " + simColorId);
    if (slotId == Phone.GEMINI_SIM_1) {
    mIsRoaming = true;
    mIsRoamingId = tempRoamingId;
    } else {
    mIsRoamingGemini = true;
    mIsRoamingGeminiId = tempRoamingId;
    }
    tempIsRoaming = true;
    } else {
    if (slotId == Phone.GEMINI_SIM_1) {
    mIsRoaming = false;
    mIsRoamingId = 0;
    } else {
    mIsRoamingGemini = false;
    mIsRoamingGeminiId = 0;
    }
    }

    DataType tempDateType;

    String tempContentDescriptionDataType;
    if (mIsWimaxEnabled && mWimaxConnected) {
    // wimax is a special 4g network not handled by telephony
    tempDateType = DataType.Type_4G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_4g);
    } else {
    switch (tempDataNetType) {
    case TelephonyManager.NETWORK_TYPE_UNKNOWN:
    if (!mShowAtLeastThreeGees) {
    tempDateType = DataType.Type_G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_gprs);
    break;
    } else {
    // fall through
    }
    case TelephonyManager.NETWORK_TYPE_EDGE:
    if (!mShowAtLeastThreeGees) {
    tempDateType = DataType.Type_E;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_edge);
    break;
    } else {
    // fall through
    }
    case TelephonyManager.NETWORK_TYPE_UMTS:
    tempDataNetType3G = NetworkType.Type_3G;
    tempDateType = DataType.Type_3G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_3g);
    break;
    case TelephonyManager.NETWORK_TYPE_HSDPA:
    case TelephonyManager.NETWORK_TYPE_HSUPA:
    case TelephonyManager.NETWORK_TYPE_HSPA:
    case TelephonyManager.NETWORK_TYPE_HSPAP:
    tempDataNetType3G = NetworkType.Type_3G;
    if (mHspaDataDistinguishable) {
    tempDateType = DataType.Type_H;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_3_5g);
    } else {
    tempDateType = DataType.Type_3G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_3g);
    }
    break;
    case TelephonyManager.NETWORK_TYPE_CDMA:
    // display 1xRTT for IS95A/B
    tempDataNetType3G = NetworkType.Type_1X;
    tempDateType = DataType.Type_1X;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_cdma);
    break;
    case TelephonyManager.NETWORK_TYPE_1xRTT:
    tempDataNetType3G = NetworkType.Type_1X;
    tempDateType = DataType.Type_1X;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_cdma);
    break;
    case TelephonyManager.NETWORK_TYPE_EVDO_0: //fall through
    case TelephonyManager.NETWORK_TYPE_EVDO_A:
    case TelephonyManager.NETWORK_TYPE_EVDO_B:
    case TelephonyManager.NETWORK_TYPE_EHRPD:
    tempDataNetType3G = NetworkType.Type_1X3G;
    tempDateType = DataType.Type_3G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_3g);
    break;
    case TelephonyManager.NETWORK_TYPE_LTE:
    tempDateType = DataType.Type_4G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_4g);
    break;
    default:
    if (!mShowAtLeastThreeGees) {
    tempDataNetType3G = NetworkType.Type_G;
    tempDateType = DataType.Type_G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_gprs);
    } else {
    tempDataNetType3G = NetworkType.Type_3G;
    tempDateType = DataType.Type_3G;
    tempContentDescriptionDataType = mContext.getString(
    R.string.accessibility_data_connection_3g);
    }
    break;
    }
    }

  • 相关阅读:
    nginx 编译参数详解(运维不得不看)
    nginx安装(1) – ttlsa教程系列之nginx
    Nginx配置文件详细说明
    ubuntu下nginx的启停等常用命令
    Ubuntu 14.04 安装最新稳定版Nginx 1.6.0
    nginx启动、重启、关闭
    Ubuntu下基于Nginx实现Tomcat集群负载均衡
    在Ubuntu 14.04安装Nginx
    ubuntu完全卸载nginx
    ubuntu 下mysql中文乱码问题解决方案
  • 原文地址:https://www.cnblogs.com/DonkeyTomy/p/3245193.html
Copyright © 2011-2022 走看看