android系统之apn相关

来源:互联网 发布:windows引导命令 编辑:程序博客网 时间:2024/05/21 15:45

工作一年了,好久没来,默默地当颗小螺丝钉。今天借此机会把学习的写一下,记录下。最近工作在交接,正好总结回顾,这一年,主要和三个字母打交道A,P,N。

APN概述:

APN 的类型分为web(internet),wap,mms三种类型,用于手机中上网时数据交换的接入点名称配置与显示。

APN配置的时候,出现的type的值主要有:defaultmms,supl,dunDefault常用于一般的数据业务,主要有internet,wap,web.mms类型用于彩信接收发送的业务;supl用于gprs上网;dun用于wifi等上网类型。

配置时注意事项:

1、在合入完成之后注意检查authtype=  authtype=“” 这种字串是不允许在apns-conf.xml 文件中出现的,会导致所有项目apn读取失败。

2、Type=””这个也不能为空,需求有时会省略它的配置,apnType=””值主要分为default,*,mms, supl等,在不确定的情况下,与需求工程师沟通清楚再合入。

3、注释的错误,在xml文件中,注释的格式为如  <!--- V9 Telia end-->  ,注意后面的必须是-->,否则会有编译不过的错误。

4、mcc和mnc一般合起来为五位,其中mnc的位数为2,如果出现个位数应该自动补全,如1,补为01。

5、如果需求中存在Authenticationnormal说明没有用户名和密码的话,这个鉴权是不需要的。

6、注意检查wapweb一般不涉及彩信等相关端口的配置,没有mmsport,mmsproxy..注意端口写正确。

7、关于authtype需求表中没有注明的情况下置为PAP or CHAP或者空(没有authtype这一项)都可以的。

authtype这一项未填写,不管有无用户名,会自动默认为PAP or CHAP

8dun类型的apn 就是专门用做tethering的。

如果没有dun类型的apn,默认用default的。dun后面加上default,是为了在tethering模式下可以进行下载操作。目前很多需求上明确写明只有dun,则按照需求处理。


检查方法:

1、验证其语法的正确性,可以直接双击用浏览器自带的编译xml检查其语法格式的正确性,不正确的会在浏览器末尾报错。

2、验证其读取的正确性:

请将配置文件替换到手机,验证一下配置文件的正确性:

方法:adb push apns-conf.xml system/etc 

然后在apnsetting界面 点击reset to default

3、修改手机预设apn的方法:

预设的文件在手机的 system/etc 目录

文件名字叫 apns-conf.xml ,可以使用 rm apns-conf.xml 命令将这个删了

然后到apn设置的界面去,恢复下默认设置,这个预设的就没有了,就可以手动设置了。


常见故障:

1、开发故障,APN没有拷贝在手机中

故障描述: APN没有拷贝在手机中,APN设置页面列表为空

故障分析:发现已经有APN文件,但是在版本中却没有发现相应的文件合入,检查

在相应的编译文件中分析是否有APN配置文件的添加语句。

代码修改:在项目分支APN文件所在目录下

app\ZTE_CUSTOM\XXX\android\device\zte\products\XXX.mk中添加语句:

PRODUCT_COPY_FILES += device/zte/products/apns-conf.xml:system/etc/apns-conf.xml

就可保证相应的APN文件添加到手机中。


2、自测,APN文件读取失败

故障描述:自测时,push APN配置文件到system/etc/后,执行“重置为默认APN”操作。

APN列表为空,说明APN文件读取失败。

故障分析APN文件参数配置错误,导致读取失败,可能的原因有

代码修改:检查1authtype若无需求,则不在配置表中列出该项,即不可以出现authtype “”authtype参数项中“”内不可为空);2Type项也不可为空。常见的Type值有default,mms,supl,*等。在不确定的情况下,和需求工程师沟通后再合入。


3、前方故障,APN参数错误导致彩信无法发送

故障描述:彩信无法发送,但可以成功接收

故障分析APN文件参数配置错误,注意检查彩信涉及的相关端口配置

mmsport,mmsproxy是否正确

代码修改:与需求工程师核对apn需求,若不确定参数正确与否,可请前方测试人员在局方网络下使用对比机对比,参考其apn配置,进行修改。

 

4、前方故障,APN参数Authentication前方实测与需求不符

故障描述:前方测试,APN参数中authtype项实际为PAP or CHAP,而需求为Authentication:normal

故障分析:当需求中存在签权项Authentication: normal时,若无用户名和密码参数,该鉴权是不需要的,APN配置中可以没有该项;当配置文件中authype为空时,代码中默认会将其设置为PAP or CHAP

代码修改Authentication参数值在需求文件中写为 normal,且无用户名和密码参数,则在APN配置文件中不写该项,代码中会默认设置为PAP or CHAP,不做为故障处理。


5、定制需求,漫游时,仍使用原卡MCC/MNC匹配的APN参数

故障描述:当设备漫游到其它网络时,仍然使用卡中原MNC/MCC对应的APN设置

   故障分析APN列表中的APN参数是根据当前网络提供商的MCC/MNCAPN配置表

   中匹配获得的。Operator numeric值中前三位为MCC(国家码),接着的三位为MNC(网

   络码)。一般当设备漫游时,opeartor numeric为当前网络提供商的值,而该需求要求使

   用原卡的MCC/MNCAPN配置,则需要在读取operator numeric处做相应的修改(参

   7x27GB项目宏ZTE_RLNC)。

代码修改SIMRecords.java文件中,一般情况下,operator 是由PROPERTY_ICC_OPERATOR_NUMBERIC定义;而此处定义为numeric SystemProperties.get(gsm.operator.numeric.home)

   createAllApnList()中,读取operator根据numeric.home进行APN匹配,完成APN装载。

 

6、前方故障,无法自动激活APN列表中的默认APN选项

故障描述:首次开机后,APN列表正常显示,但无法自动激活默认APN;手动激活后,再次开机则可正常激活。

故障分析:该项目APN需求中,有两组MCC/MNC号相同的APN配置,需要通过spn参数进行区别。通过匹配卡中读出的spn参数和APN配置文件中的spn进行默认APN的选择。而出错项目中,需求spn参数与实际不符,导致无法正常匹配,默认APN无法激活。

代码修改:请前方测试人员提供日志,确认正确的spn参数,修改APN配置文件。  

目前代码增加了根据spn值进行APN匹配的功能,类似APN,将从卡中读取的spn保存在PREFERSPN_URI.

createAllApnList()代码中,若mSelectSpn getPreferredSpn(),若spn不为空,则和operator作为selection,在Telephony.Carriers.CONTENT_URI中定位,选择适当的Apn参数加载到allApns中。

接着在buildWaitingApns()中,将卡中读出的spn参数值和APN配置表中读出的spn参数值进行比较,匹配spn相同的Apn配置作为waitingApn

 

7、定制需求,APN子网过滤功能

故障描述:当一张卡有多组APN时,除了用SPN区分外,需求要求通过子网(subnet)来区分,实现APN的子网过滤。

故障分析:从卡中读取子网号码:IMSI MCC MNC +子网码 +用户码,将APN配置文件中的SPN参数项用子网码来替代。通过匹配卡中的子网码和APN配置文件的子网码参数,区分不同的APN选项。

代码修改:

SIMRecord.java中读取subnet值,并设置接口property名字为gsm.operator.numeric.subnet

 从卡上读取了subnet信息了后,在GsmDataConnectionTracker.java中的buildWaitingApn()中,进行subnet匹配,选取APN添加到APN列表中。

 

8、前方故障,在丢失pdp后无法自动恢复,必须手动关闭再打开数据业务后才能恢复。 

故障描述:在P743VV项目中,接到外籍投诉,手机上网状态,当转移到信号较弱的地方,会失去数据链接,如果回到信号较强的地方后,无法自动回复数据链接,必须手动关闭再打开才能恢复。

故障分析:该项目在国内虽然没有复现,但是外籍复现此故障的概率较高,分析日志,发现在丢失后没有自动进行重新连接。

代码修改:分析日志,出现这句话:“onDataSetupComplete: Not all permanent failures, retry,使执行这句话的操作失效,在if中添加宏控制

  修改代码:

https://10.67.129.15/7x27-Gingerbread/develop/app/frameworks/base/telephony/java/com/android/internal/telephony/gsm

GsmDataConnectionTracker.java中:


9、数据连接图标显示有误

   故障描述ZTE-C N766维护项目_印度SSTL 测试使用过程中,启用数据业务,待机不显示数据业务图标

   解决方法:在使能数据连接时,StatusBarPolicy(Context context) 里面监听器PhoneStateListener.LISTEN_DATA_CONNECTION_STATE会获得这个参数并上传,图标显示。

跟踪了代码,打了LOG,编译了framwork.发现在框架层Phonestatelistener.java里面走到了case LISTEN_DATA_CONNECTION_STATE,这个函数onDataConnectionStateChanged(int state, int networkType)也被调用,LISTEN_DATA_CONNECTION_STATE也被赋值。



***********************************************************************************************************************************

***********************************************************************************************************************************


APN(default、mms、supl、dun、hipri接入点类型的区别)

设置APN上网时,大家可能经常遇到这个问题:
为什么有时要填写default有时要填写supl,而彩信又偏偏要mms?
这个问题留到最后,让我们看看每个接入点类型的含义:
英文原文来自于Google Android Developers
原文连接:http://developer.android.com/reference/android/net/ConnectivityManager.html
我尽量用通俗易懂的语言来解释每个类型的含义,若您是开发者,请尽量阅读英文原文。

1、default

‍默认网络连接,当激活时所有数据传输都使用该连接,不能与其他网络连接同时使用

<span style="color: rgb(8, 0, 0); font-style: italic; font-weight: bold;">/**  * The Default Mobile data connection. When active, all data traffic  * will use this connection by default. Should not coexist with other  * default connections.  */</span>   <span style="color: rgb(0, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">final</span> <span style="color: rgb(0, 102, 0); font-weight: bold;">int</span> TYPE_MOBILE <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(204, 102, 204);">0</span><span style="color: rgb(51, 153, 51);">;</span> 
<span style="color:#880000;font-style: italic; font-weight: bold;">/**   * The Default Mobile data connection. When active, all data traffic   * will use this connection by default. Should not coexist with other   * default connections.   */</span>    <span style="color:#000000;font-weight: bold;">public</span> <span style="color:#000000;font-weight: bold;">static</span> <span style="color:#000000;font-weight: bold;">final</span> <span style="color:#0660;font-weight: bold;">int</span> TYPE_MOBILE <span style="color:#339933;">=</span> <span style="color:#cc66cc;">0</span><span style="color:#339933;">;</span> 

适用场合:绝大部分正常上网时可以使用2、mms

彩信专用连接,此连接与default类似,用于与载体的多媒体信息服务器对话的应用程序,此连接能与default连接同时使用

<span style="color: rgb(8, 0, 0); font-style: italic; font-weight: bold;">/**  * An MMS-specific Mobile data connection. This connection may be the  * same as TYPE_MOBILE but it may be different. This is used  * by applications needing to talk to the carrier's Multimedia Messaging  * Service servers. It may coexist with default data connections.  */</span>   <span style="color: rgb(0, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">final</span> <span style="color: rgb(0, 102, 0); font-weight: bold;">int</span> TYPE_MOBILE_MMS <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(204, 102, 204);">2</span><span style="color: rgb(51, 153, 51);">;</span> 

<span style="color:#880000;font-style: italic; font-weight: bold;">/**   * An MMS-specific Mobile data connection. This connection may be the   * same as TYPE_MOBILE but it may be different. This is used   * by applications needing to talk to the carrier's Multimedia Messaging   * Service servers. It may coexist with default data connections.   */</span>    <span style="color:#000000;font-weight: bold;">public</span> <span style="color:#000000;font-weight: bold;">static</span> <span style="color:#000000;font-weight: bold;">final</span> <span style="color:#0660;font-weight: bold;">int</span> TYPE_MOBILE_MMS <span style="color:#339933;">=</span> <span style="color:#cc66cc;">2</span><span style="color:#339933;">;</span>  
适用场合:使用彩信服务时,必须有mms类型的接入点,不必选中,应用程序会自动使用此接入点3、supl

是Secure User Plane Location“安全用户面定位”的简写,此连接与default类似,用于帮助定位设备与载体的安全用户面定位服务器对话的应用程序,此连接能与default连接同时使用

<span style="color: rgb(8, 0, 0); font-style: italic; font-weight: bold;">/**  * A SUPL-specific Mobile data connection. This connection may be the  * same as {@link #TYPEMOBILE} but it may be different. This is used  * by applications needing to talk to the carrier's Secure User Plane  * Location servers for help locating the device. It may coexist with  * default data connections.  * {@hide}  */</span>   <span style="color: rgb(0, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(0, 0, 0); font-weight:

<span style="color:#880000;font-style: italic; font-weight: bold;">/**   * A SUPL-specific Mobile data connection. This connection may be the   * same as {@link #TYPEMOBILE} but it may be different. This is used   * by applications needing to talk to the carrier's Secure User Plane   * Location servers for help locating the device. It may coexist with   * default data connections.   * {@hide}   */</span>    <span style="color:#000000;font-weight: bold;">public</span> <span style="color:#000000;font-weight: bold;">static</span> <span style="color:#000000;font-weight: bold;">final</span> <span style="color:#0660;font-weight: bold;">int</span> TYPE_MOBILE_SUPL <span style="color:#339933;">=</span> <span style="color:#cc66cc;">3</span><span style="color:#339933;">;</span>
适用场合:需要自动切换wap与net接入点的、需要把手机当临时AP的
对SUPL技术感兴趣的朋友,不妨看下以下文章
SUPL技术(一)http://blog.sina.com.cn/s/blog_537f4a11010008tw.html
SUPL技术(二)http://blog.sina.com.cn/s/blog_537f4a11010008uf.html
SUPL技术(三)http://blog.sina.com.cn/s/blog_537f4a11010008ws.html
SUPL技术(四)http://blog.sina.com.cn/s/blog_537f4a11010008yf.html
4、dun

Dial Up Networking拨号网络的简称,此连接与default连接类似,用于执行一个拨号网络网桥,使载体能知道拨号网络流量的应用程序,此连接能与default连接同时使用

<span style="color: rgb(8, 0, 0); font-style: italic; font-weight: bold;">/**  * A DUN-specific Mobile data connection. This connection may be the  * same as {@link #TYPEMOBILE} but it may be different. This is used  * by applicaitons performing a Dial Up Networking bridge so that  * the carrier is aware of DUN traffic. It may coexist with default data  * connections.  */</span>   <span style="color: rgb(0, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">final</span> <span style="color: rgb(0, 102, 0); font-weight: bold;">int</span> TYPE_MOBILE_DUN <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(204, 102, 204);">4</span><span style="color: rgb(51, 153, 51);">;</span>
<span style="color:#880000;font-style: italic; font-weight: bold;">/**   * A DUN-specific Mobile data connection. This connection may be the   * same as {@link #TYPEMOBILE} but it may be different. This is used   * by applicaitons performing a Dial Up Networking bridge so that   * the carrier is aware of DUN traffic. It may coexist with default data   * connections.   */</span>    <span style="color:#000000;font-weight: bold;">public</span> <span style="color:#000000;font-weight: bold;">static</span> <span style="color:#000000;font-weight: bold;">final</span> <span style="color:#0660;font-weight: bold;">int</span> TYPE_MOBILE_DUN <span style="color:#339933;">=</span> <span style="color:#cc66cc;">4</span><span style="color:#339933;">;</span>

适用场合:需要使用运营商无线热点的,CMCC、ChinaNet等
5、hipri
高优先级网络,与default类似,但路由设置不同。
只有当进程访问移动DNS服务器,并明确要求使用requestRouteToHost(int, int)才会使用此连接
(这个我也不太懂,翻译的应该很有问题….)

<span style="color: rgb(8, 0, 0); font-style: italic; font-weight: bold;">/**  * A High Priority Mobile data connection. This connection is typically  * the same as {@link #TYPEMOBILE} but the routing setup is different.  * Only requesting processes will have access to the Mobile DNS servers  * and only IP's explicitly requested via {@link #requestRouteToHost}  * will route over this interface.  *{@hide}  */</span>   <span style="color: rgb(0, 0, 0); font-weight: bold;">public</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">static</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">final</span> <span style="color: rgb(0, 102, 0); font-weight: bold;">int</span> TYPE_MOBILE_HIPRI <span style="color: rgb(51, 153, 51);">=</span> <span style="color: rgb(204, 102, 204);">5</span><span style="color: rgb(51, 153, 51);">;</span> 
<span style="color:#880000;font-style: italic; font-weight: bold;">/**   * A High Priority Mobile data connection. This connection is typically   * the same as {@link #TYPEMOBILE} but the routing setup is different.   * Only requesting processes will have access to the Mobile DNS servers   * and only IP's explicitly requested via {@link #requestRouteToHost}   * will route over this interface.   *{@hide}   */</span>    <span style="color:#000000;font-weight: bold;">public</span> <span style="color:#000000;font-weight: bold;">static</span> <span style="color:#000000;font-weight: bold;">final</span> <span style="color:#0660;font-weight: bold;">int</span> TYPE_MOBILE_HIPRI <span style="color:#339933;">=</span> <span style="color:#cc



转自: http://blog.csdn.net/dy_learning/article/details/10900467

             http://www.myexception.cn/mobile/1454823.html



原创粉丝点击