欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  移动技术

android2.3.5 CDMA/EVDO拨号APN解决方案

程序员文章站 2023-12-14 17:44:40
google提供的android2.3里面,只能在gsm/wcdma情况下才能从“设置”->“无线和网络”->“移动网络”->“接入点名称”中选择不同的a...
google提供的android2.3里面,只能在gsm/wcdma情况下才能从“设置”->“无线和网络”->“移动网络”->“接入点名称”中选择不同的apn帐号进行拨号连接,而cdma/evdo则没有这个功能。最近看了一下代码,简单实现了这个功能。

1、默认的cdma/evdo里面连apn列表都不显示,要先把这个挖出来。
修改packages/apps/phone/res/xml/cdma_options.xml
添加如下内容
复制代码 代码如下:

<preferencescreen
android:key="button_apn_key"
android:title="@string/apn_settings"
android:persistent="false">
<intent android:action="android.intent.action.main"
android:targetpackage="com.android.settings"
android:targetclass="com.android.settings.apnsettings" />
</preferencescreen>

还有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

上一篇:

下一篇: