zoukankan      html  css  js  c++  java
  • 从android 4.1.1 到android 4.2 telephony的变化

     首先,最大的变化是代码路径的变化:

    从原来的frameworks/base/telephony 到 frameworks/opt/telephony, 这样,telephony就可以有独立的分支(branch).

    把常量放到一个类文件中

    例如把GsmDataConnectionTracker.java中的常量放到DctConstants.java中。
    把Phone.java中的常量放到PhoneConstants.java中。

    Move the following code from PhoneFactory.java to TelephonyManager.java.

    public static int getPhoneType(int networkMode) {
            switch(networkMode) {
            case RILConstants.NETWORK_MODE_CDMA:
            case RILConstants.NETWORK_MODE_CDMA_NO_EVDO:
            case RILConstants.NETWORK_MODE_EVDO_NO_CDMA:
                return Phone.PHONE_TYPE_CDMA;

            case RILConstants.NETWORK_MODE_WCDMA_PREF:
            case RILConstants.NETWORK_MODE_GSM_ONLY:
            case RILConstants.NETWORK_MODE_WCDMA_ONLY:
            case RILConstants.NETWORK_MODE_GSM_UMTS:
                return Phone.PHONE_TYPE_GSM;

            // Use CDMA Phone for the global mode including CDMA
            case RILConstants.NETWORK_MODE_GLOBAL:
            case RILConstants.NETWORK_MODE_LTE_CDMA_EVDO:
            case RILConstants.NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA:
                return Phone.PHONE_TYPE_CDMA;

            case RILConstants.NETWORK_MODE_LTE_ONLY:
                if (BaseCommands.getLteOnCdmaModeStatic() == Phone.LTE_ON_CDMA_TRUE) {
                    return Phone.PHONE_TYPE_CDMA;
                } else {
                    return Phone.PHONE_TYPE_GSM;
                }
            default:
                return Phone.PHONE_TYPE_GSM;
            }

    Move the following code from both of CDMAPhone and GSMPhone to PhoneBase.

    public SignalStrength getSignalStrength() {
            return mSST.mSignalStrength;
        }
    void  notifySignalStrength() {
            mNotifier.notifySignalStrength(this);
        }

    Move the following code from CommandsInterface.java to TelephonyManager.java

    public static int getLteOnCdmaModeStatic() {
            int retVal;
            int curVal;
            String productType = "";

            curVal = SystemProperties.getInt(TelephonyProperties.PROPERTY_LTE_ON_CDMA_DEVICE,
                        Phone.LTE_ON_CDMA_UNKNOWN);
            retVal = curVal;
            if (retVal == Phone.LTE_ON_CDMA_UNKNOWN) {
                Matcher matcher = sProductTypePattern.matcher(sKernelCmdLine);
                if (matcher.find()) {
                    productType = matcher.group(1);
                    if (sLteOnCdmaProductType.equals(productType)) {
                        retVal = Phone.LTE_ON_CDMA_TRUE;
                    } else {
                        retVal = Phone.LTE_ON_CDMA_FALSE;
                    }
                } else {
                    retVal = Phone.LTE_ON_CDMA_FALSE;
                }
            }

            Log.d(LOG_TAG, "getLteOnCdmaMode=" + retVal + " curVal=" + curVal +
                    " product_type='" + productType +
                    "' lteOnCdmaProductType='" + sLteOnCdmaProductType + "'");
            return retVal;
        }

    private static String getProcCmdLine()
        {
            String cmdline = "";
            FileInputStream is = null;
            try {
                is = new FileInputStream("/proc/cmdline");
                byte [] buffer = new byte[2048];
                int count = is.read(buffer);
                if (count > 0) {
                    cmdline = new String(buffer, 0, count);
                }
            } catch (IOException e) {
                Log.d(LOG_TAG, "No /proc/cmdline exception=" + e);
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (IOException e) {
                    }
                }
            }
            Log.d(LOG_TAG, "/proc/cmdline=" + cmdline);
            return cmdline;
        }
  • 相关阅读:
    ListView的优化
    RotateAnimation详解
    Unable to execute dex: java.nio.BufferOverflowException. Check the Eclipse log for stack trace.
    Java 完美判断中文字符的方法
    详细解析Java中抽象类和接口的区别
    Android中如何实现多行、水平滚动的分页的Gridview?
    Android实现多页左右滑动效果,支持子view动态创建和cache
    android 自定义ViewGroup和对view进行切图动画实现滑动菜单SlidingMenu
    Android TextView文字横向自动滚动(跑马灯)
    android自定义TabWidget样式
  • 原文地址:https://www.cnblogs.com/kangyi/p/2781040.html
Copyright © 2011-2022 走看看