• 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;
    }
    }

  • 相关阅读:
    Linux进程状态——top,ps中看到进程状态D,S,Z的含义
    openstack-neutron基本的网络类型以及分析
    openstack octavia的实现与分析(二)·原理,架构与基本流程
    网络虚拟化基础协议·Geneve
    openstack octavia的实现与分析(一)·openstack负载均衡的现状与发展以及lvs,Nginx,Haproxy三种负载均衡机制的基本架构和对比
    Linux下多网卡绑定bond及模式介绍
    Python调试器-pdb的使用
    DELL R720服务器安装Windows Server 2008 R2 操作系统图文详解
    JAVA WEB实现前端加密后台解密
    JAVA实现AES和MD5加密
  • 原文地址:https://www.cnblogs.com/DonkeyTomy/p/3245193.html
Copyright © 2020-2023  润新知