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