当前位置: 编程技术>移动开发
android2.3.5 CDMA/EVDO拨号APN解决方案
来源: 互联网 发布时间:2014-10-13
本文导语: google提供的android2.3里面,只能在GSM/WCDMA情况下才能从“设置”->“无线和网络”->“移动网络”->“接入点名称”中选择不同的apn帐号进行拨号连接,而CDMA/EVDO则没有这个功能。最近看了一下代码,简单实现了这个功能。 1、默...
google提供的android2.3里面,只能在GSM/WCDMA情况下才能从“设置”->“无线和网络”->“移动网络”->“接入点名称”中选择不同的apn帐号进行拨号连接,而CDMA/EVDO则没有这个功能。最近看了一下代码,简单实现了这个功能。
1、默认的CDMA/EVDO里面连apn列表都不显示,要先把这个挖出来。
修改packages/apps/Phone/res/xml/cdma_options.xml
添加如下内容
还有development/data/etc/apns-conf.xml的version值改为原来的加1,原因代码里面找。
2、修改frameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnectiontracker.java的setupData函数
private boolean setupData(String reason) {
CdmaDataConnection conn = findFreeDataConnection();
if (conn == null) {
if (DBG) log("setupData: No free CdmaDataConnection found!");
return false;
}
mActiveDataConnection = conn;
String[] types;
if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
types = new String[1];
types[0] = Phone.APN_TYPE_DUN;
} else {
types = mDefaultApnTypes;
}
//mActiveApn = new ApnSetting(0, "", "", "", "", "", "", "", "", "", "",
// 0, types, "IP", "IP");
Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
ContentResolver cResolver = phone.getContext().getContentResolver();
Cursor cr = cResolver.query(PREFERRED_APN_URI, null, null, null, null);
cr.moveToFirst();
String user = cr.getString(cr.getColumnIndex("user"));
String pass = cr.getString(cr.getColumnIndex("password"));
String apn = cr.getString(cr.getColumnIndex("apn"));
Log.e(LOG_TAG, "get apn : apn=" + apn + ", user=" + user + ", password=" + pass);
mActiveApn = new ApnSetting(0, "", "", apn, "", "", "", "", "", user, pass,
, types, "IP", "IP");
Message msg = obtainMessage();
msg.what = EVENT_DATA_SETUP_COMPLETE;
msg.obj = reason;
conn.connect(msg, mActiveApn);
setState(State.INITING);
phone.notifyDataConnection(reason);
return true;
}
3、修改frameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnection.java的onConnect函数:
phone.mCM.setupDataCall(
Integer.toString(RILConstants.SETUP_DATA_TECH_CDMA),
Integer.toString(dataProfile),
//null, null, null, //原来传进拨号的参数都是空的!!!
cp.apn.apn, cp.apn.user, cp.apn.password,
Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP),
RILConstants.SETUP_DATA_PROTOCOL_IP, msg);
4、修改frameworks/base/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java中对ApnSetting的定义,将其成员类型全部设为public
1、默认的CDMA/EVDO里面连apn列表都不显示,要先把这个挖出来。
修改packages/apps/Phone/res/xml/cdma_options.xml
添加如下内容
代码如下:
还有development/data/etc/apns-conf.xml的version值改为原来的加1,原因代码里面找。
2、修改frameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnectiontracker.java的setupData函数
代码如下:
private boolean setupData(String reason) {
CdmaDataConnection conn = findFreeDataConnection();
if (conn == null) {
if (DBG) log("setupData: No free CdmaDataConnection found!");
return false;
}
mActiveDataConnection = conn;
String[] types;
if (mRequestedApnType.equals(Phone.APN_TYPE_DUN)) {
types = new String[1];
types[0] = Phone.APN_TYPE_DUN;
} else {
types = mDefaultApnTypes;
}
//mActiveApn = new ApnSetting(0, "", "", "", "", "", "", "", "", "", "",
// 0, types, "IP", "IP");
Uri PREFERRED_APN_URI = Uri.parse("content://telephony/carriers/preferapn");
ContentResolver cResolver = phone.getContext().getContentResolver();
Cursor cr = cResolver.query(PREFERRED_APN_URI, null, null, null, null);
cr.moveToFirst();
String user = cr.getString(cr.getColumnIndex("user"));
String pass = cr.getString(cr.getColumnIndex("password"));
String apn = cr.getString(cr.getColumnIndex("apn"));
Log.e(LOG_TAG, "get apn : apn=" + apn + ", user=" + user + ", password=" + pass);
mActiveApn = new ApnSetting(0, "", "", apn, "", "", "", "", "", user, pass,
, types, "IP", "IP");
Message msg = obtainMessage();
msg.what = EVENT_DATA_SETUP_COMPLETE;
msg.obj = reason;
conn.connect(msg, mActiveApn);
setState(State.INITING);
phone.notifyDataConnection(reason);
return true;
}
3、修改frameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnection.java的onConnect函数:
代码如下:
phone.mCM.setupDataCall(
Integer.toString(RILConstants.SETUP_DATA_TECH_CDMA),
Integer.toString(dataProfile),
//null, null, null, //原来传进拨号的参数都是空的!!!
cp.apn.apn, cp.apn.user, cp.apn.password,
Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP),
RILConstants.SETUP_DATA_PROTOCOL_IP, msg);
4、修改frameworks/base/telephony/java/com/android/internal/telephony/gsm/ApnSetting.java中对ApnSetting的定义,将其成员类型全部设为public
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。