一、测试modem是否工作,是否可发送at命令
cat /dev/ttyUSB0 &
echo "at+cgmi" > /dev/ttyUSB0
二、APN
1、 Android的网络配置作为资源文件写入了XML(/frameworks/base/core/res/res/xml/apns.xml),这个资源文件作为Android的默认apns配置,不建议修改该文件。 因为Apn的配置是根据不同的硬件产品而不同,所以为不同的硬件产品建立各自的配置文件(system/etc/apns-conf.xml) ,而不要去改动默认的配置文件(apns.xml)。
2、TelephonyProvider.java
该类用于设置APN,如果源码提供的设置不能满足你的要求,一般可以通过修改这个类来满足。initDatabase函数主要是用来读取apns.xml(com.android.internal.R.xml.apns)和/system/etc/apns-conf.xml文件中的配置数据,用此来初始化carriers表。
以下是相对标准的APN配置,支持中国移动和中国联通的APN。
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2006, Google Inc.
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<!-- use empty string to specify no proxy or port -->
<!-- This version must agree with that in apps/common/res/apns.xml -->
<apns version="7">
<apn carrier="T-Mobile US"
mcc="310"
mnc="260"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 250"
mcc="310"
mnc="250"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 660"
mcc="310"
mnc="660"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 230"
mcc="310"
mnc="230"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 310"
mcc="310"
mnc="310"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 580"
mcc="310"
mnc="580"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 240"
mcc="310"
mnc="240"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 800"
mcc="310"
mnc="800"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 210"
mcc="310"
mnc="210"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 160"
mcc="310"
mnc="160"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 270"
mcc="310"
mnc="270"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 200"
mcc="310"
mnc="200"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 220"
mcc="310"
mnc="220"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<apn carrier="T-Mobile US 490"
mcc="310"
mnc="490"
apn="epc.tmobile.com"
user="none"
server="*"
password="none"
mmsc="http://mms.msg.eng.t-mobile.com/mms/wapenc"
/>
<!-- T-Mobile Europe -->
<apn carrier="T-Mobile UK"
mcc="234"
mnc="30"
apn="general.t-mobile.uk"
user="t-mobile"
password="tm"
server="*"
mmsproxy="149.254.201.135"
mmsport="8080"
mmsc="http://mmsc.t-mobile.co.uk:8002"
/>
<apn carrier="T-Mobile D"
mcc="262"
mnc="01"
apn="internet.t-mobile"
user="t-mobile"
password="tm"
server="*"
mmsproxy="172.028.023.131"
mmsport="8008"
mmsc="http://mms.t-mobile.de/servlets/mms"
/>
<apn carrier="T-Mobile A"
mcc="232"
mnc="03"
apn="gprsinternet"
user="t-mobile"
password="tm"
server="*"
mmsproxy="010.012.000.020"
mmsport="80"
mmsc="http://mmsc.t-mobile.at/servlets/mms"
type="default,supl"
/>
<apn carrier="T-Mobile A MMS"
mcc="232"
mnc="03"
apn="gprsmms"
user="t-mobile"
password="tm"
server="*"
mmsproxy="010.012.000.020"
mmsport="80"
mmsc="http://mmsc.t-mobile.at/servlets/mms"
type="mms"
/>
<apn carrier="T-Mobile CZ"
mcc="230"
mnc="01"
apn="internet.t-mobile.cz"
user="wap"
password="wap"
server="*"
mmsproxy="010.000.000.010"
mmsport="80"
mmsc="http://mms"
type="default,supl"
/>
<apn carrier="T-Mobile CZ MMS"
mcc="230"
mnc="01"
apn="mms.t-mobile.cz"
user="mms"
password="mms"
server="*"
mmsproxy="010.000.000.010"
mmsport="80"
mmsc="http://mms"
type="mms"
/>
<apn carrier="T-Mobile NL"
mcc="204"
mnc="16"
apn="internet"
user="*"
password="*"
server="*"
mmsproxy="010.010.010.011"
mmsport="8080"
mmsc="http://t-mobilemms"
type="default,supl"
/>
<apn carrier="T-Mobile NL MMS"
mcc="204"
mnc="16"
apn="mms"
user="tmobilemms"
password="tmobilemms"
server="*"
mmsproxy="010.010.010.011"
mmsport="8080"
mmsc="http://t-mobilemms"
type="mms"
/>
<!-- Thanks to Haykuro for the additional APNs -->
<apn carrier="3services"
apn="3services"
mmsc="mmsc.three.net.au:10021/mmsc"
mmsproxy="10.176.57.25"
mmsport="8799"
mcc="505"
mnc="06"
/>
<apn carrier="3"
apn="three.co.uk"
mmsc="http://mms.um.three.co.uk:10021/mmsc"
mmsproxy="mms.three.co.uk"
mmsport="8799"
mcc="234"
mnc="20"
/>
<apn carrier="o2 Internet"
apn="surfo2"
mmsc="http://10.81.0.7:8002"
mmsproxy="82.113.100.5"
mmsport="8080"
mcc="262"
mnc="07"
/>
<apn carrier="Airtel India"
apn="airtelgprs.com"
mmsc="airtelmms.com"
mcc="404"
mnc="90"
/>
<apn carrier="Beeline"
apn="internet.beeline.ru"
mcc="250"
mnc="99"
user="beeline"
password="beeline"
/>
<apn carrier="Megafon"
apn="internet"
mcc="250"
mnc="02"
user="gdata"
password="gdata"
/>
<apn carrier="MTS"
apn="internet.mts.ru"
mcc="250"
mnc="01"
user="mts"
password="mts"
/>
<apn carrier="中国移动因特网设置" mcc="460" mnc="00" apn="cmnet" type="default"/>
<apn carrier="中国移动WAP设置" mcc="460" mnc="00" apn="cmwap" proxy="10.0.0.172" port="80" type="default"/>
<apn carrier="中国移动彩信设置" mcc="460" mnc="00" apn="cmwap" proxy="10.0.0.172" port="80" mmsproxy="10.0.0.172" mmsport="80" mmsc="http://mmsc.monternet.com" type="mms"/>
<apn carrier="中国移动因特网设置" mcc="460" mnc="02" apn="cmnet" type="default"/>
<apn carrier="中国移动WAP设置" mcc="460" mnc="02" apn="cmwap" proxy="10.0.0.172" port="80" type="default"/>
<apn carrier="中国移动彩信设置" mcc="460" mnc="02" apn="cmwap" proxy="10.0.0.172" port="80" mmsproxy="10.0.0.172" mmsport="80" mmsc="http://mmsc.monternet.com" type="mms"/>
<apn carrier="中国移动因特网设置" mcc="460" mnc="07" apn="cmnet" type="default"/>
<apn carrier="中国移动WAP设置" mcc="460" mnc="07" apn="cmwap" proxy="10.0.0.172" port="80" type="default"/>
<apn carrier="中国移动彩信设置" mcc="460" mnc="07" apn="cmwap" proxy="10.0.0.172" port="80" mmsproxy="10.0.0.172" mmsport="80" mmsc="http://mmsc.monternet.com" type="mms"/>
<apn carrier="中国联通因特网设置" mcc="460" mnc="01" apn="uninet" type="default"/>
<apn carrier="中国联通WAP设置" mcc="460" mnc="01" apn="uniwap" proxy="10.0.0.172" port="80" type="default"/>
<apn carrier="中国联通彩信设置" mcc="460" mnc="01" apn="uniwap" proxy="10.0.0.172" port="80" mmsproxy="10.0.0.172" mmsport="80" mmsc="http://mmsc.myuni.com.cn" type="mms"/>
<apn carrier="中国联通3G因特网设置" mcc="460" mnc="01" apn="3gnet" type="default"/>
<apn carrier="中国联通3GWAP设置" mcc="460" mnc="01" apn="3gwap" proxy="10.0.0.172" port="80" type="default"/>
<apn carrier="中国联通3G彩信设置" mcc="460" mnc="01" apn="3gwap" proxy="10.0.0.172" port="80" mmsproxy="10.0.0.172" mmsport="80" mmsc="http://mmsc.myuni.com.cn" type="mms"/>
</apns>