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

  • 相关阅读:
    HDU 1572 (DFS)
    UVA 439 BFS 骑士的移动
    STL next_permutation 和 prev_permutation
    Fire Net
    HDU 1026
    Awesome CS Courses 超级棒的课程
    Tensorflow 最佳实践样例程序-mnist
    关于交叉熵在loss函数中使用的理解
    神经网络训练程序,tensorflow
    神经网络前向传播算法的tensorflow实现。
  • 原文地址:https://www.cnblogs.com/DonkeyTomy/p/3245193.html
Copyright © 2011-2022 走看看