Settings > More > Mobile networks > Access Point Names
在此选项中, 我手中的平台,目前是没有任何选项显示的.
代码:
packages/apps/Settings/src/com/android/settings/ApnSettings.java
//以下代码用于构建一个列表, 从数据库中读取数据并填充到表中.
//注意下面的代码有一些过滤条件
private void fillList() {
String where = "numeric=\""
+ android.os.SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC, "")
+ "\"";
String operatorDongle = SystemProperties.get("gsm.dongle.operator");
Log.d(TAG,"fillList:operatorDongle:"+operatorDongle);
if(operatorDongle != null) {
if(!operatorDongle.equals("llll") && false)
where = "numeric=\""+operatorDongle+"\"";
}
//从数据库获取, 下面代码会说明数据库是如何创建及始化的.
Cursor cursor = getContentResolver().query(Telephony.Carriers.CONTENT_URI, new String[] {
"_id", "name", "apn", "type"}, null, null,
Telephony.Carriers.DEFAULT_SORT_ORDER);
PreferenceGroup apnList = (PreferenceGroup) findPreference("apn_list");
apnList.removeAll();
ArrayList mmsApnList = new ArrayList();
mSelectedKey = getSelectedApnKey();
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String name = cursor.getString(NAME_INDEX);
String apn = cursor.getString(APN_INDEX);
String key = cursor.getString(ID_INDEX);
String type = cursor.getString(TYPES_INDEX);
ApnPreference pref = new ApnPreference(this);
pref.setKey(key);
pref.setTitle(name);
pref.setSummary(apn);
pref.setPersistent(false);
pref.setOnPreferenceChangeListener(this);
boolean selectable = ((type == null) || !type.equals("mms"));
pref.setSelectable(selectable);
if (selectable) {
if ((mSelectedKey != null) && mSelectedKey.equals(key)) {
pref.setChecked();
}
apnList.addPreference(pref);
} else {
mmsApnList.add(pref);
}
cursor.moveToNext();
}
cursor.close();
for (Preference preference : mmsApnList) {
apnList.addPreference(preference);
}
}
数据库创建:
packages/providers/TelephonyProvider/src/com/android/providers/telephony/TelephonyProvider.java
private static class DatabaseHelper extends SQLiteOpenHelper {
// Context to access resources with
private Context mContext;
/**
* DatabaseHelper helper class for loading apns into a database.
*
* @param context of the user.
*/
public DatabaseHelper(Context context) {
super(context, DATABASE_NAME, null, getVersion(context));
mContext = context;
}
private static int getVersion(Context context) {
// Get the database version, combining a static schema version and the XML version
Resources r = context.getResources();
XmlResourceParser parser = r.getXml(com.android.internal.R.xml.apns);
try {
XmlUtils.beginDocument(parser, "apns");
int publicversion = Integer.parseInt(parser.getAttributeValue(null, "version"));
return DATABASE_VERSION | publicversion;
} catch (Exception e) {
Log.e(TAG, "Can't get version of APN database", e);
return DATABASE_VERSION;
} finally {
parser.close();
}
}
@Override
public void onCreate(SQLiteDatabase db) {
// Set up the database schema
db.execSQL("CREATE TABLE " + CARRIERS_TABLE +
"(_id INTEGER PRIMARY KEY," +
"name TEXT," +
"numeric TEXT," +
"mcc TEXT," +
"mnc TEXT," +
"apn TEXT," +
"user TEXT," +
"server TEXT," +
"password TEXT," +
"proxy TEXT," +
"port TEXT," +
"mmsproxy TEXT," +
"mmsport TEXT," +
"mmsc TEXT," +
"authtype INTEGER," +
"type TEXT," +
"current INTEGER," +
"protocol TEXT," +
"roaming_protocol TEXT," +
"carrier_enabled BOOLEAN," +
"bearer INTEGER);");
initDatabase(db);//创建后,初始数据
}
private void initDatabase(SQLiteDatabase db) {
// Read internal APNS data
Resources r = mContext.getResources();
XmlResourceParser parser = r.getXml(com.android.internal.R.xml.apns);//从frameworks/base/core/res/中获取XML并添加到数据库中.
int publicversion = -1;
try {
XmlUtils.beginDocument(parser, "apns");
publicversion = Integer.parseInt(parser.getAttributeValue(null, "version"));
loadApns(db, parser);
} catch (Exception e) {
Log.e(TAG, "Got exception while loading APN database.", e);
} finally {
parser.close();
}
// Read external APNS data (partner-provided)
XmlPullParser confparser = null;
// Environment.getRootDirectory() is a fancy way of saying ANDROID_ROOT or "/system".
File confFile = new File(Environment.getRootDirectory(), PARTNER_APNS_PATH);//从/etc/apns-conf.xml中获取并添加到数据库中.
FileReader confreader = null;
try {
confreader = new FileReader(confFile);
confparser = Xml.newPullParser();
confparser.setInput(confreader);
XmlUtils.beginDocument(confparser, "apns");
// Sanity check. Force internal version and confidential versions to agree
int confversion = Integer.parseInt(confparser.getAttributeValue(null, "version"));
if (publicversion != confversion) {
throw new IllegalStateException("Internal APNS file version doesn't match "
+ confFile.getAbsolutePath());
}
loadApns(db, confparser);
} catch (FileNotFoundException e) {
// It's ok if the file isn't found. It means there isn't a confidential file
// Log.e(TAG, "File not found: '" + confFile.getAbsolutePath() + "'");
} catch (Exception e) {
Log.e(TAG, "Exception while parsing '" + confFile.getAbsolutePath() + "'", e);
} finally {
try { if (confreader != null) confreader.close(); } catch (IOException e) { }
}
}
所以, 一般默认的APN有两个地方可添加:
1. frameworks/base/core/res/res/xml/apns.xml
2. RK平台中,采用此路径:
device/rockchip/common/phone/etc/apns-full-conf.xml
XML的内容如下:
to:
mcc="240"
mnc="08"
apn="sp-services"
proxy="172.030.253.241"
port="8799"
mmsc="http://mms"
mmsproxy="172.30.253.241"
mmsport="8799"
type="default" />
mcc="293"
mnc="64"
apn="internet.t-2.net"
type="default,supl" />
mcc="293"
mnc="64"
apn="mms.t-2.net"
mmsc="http://www.mms.t-2.net:8002/"
mmsproxy="172.20.18.137"
mmsport="8080"
type="mms" />
mcc="218"
mnc="03"
apn="mms.eronet.ba"
user=""
server=""
password=""
mmsc="http://mms.gprs.eronet.ba/mms/wapenc"
mmsproxy="010.012.003.011"
mmsport="8080"
type="mms"/>
mcc="425"
mnc="01"
apn="internet"
type="default" />
mcc="425"
mnc="01"
apn="wap.orange.co.il"
mmsc="http://192.168.220.15/servlets/mms"
mmsport="8080"
type="mms" />
mcc="425"
mnc="01"
apn="Internet"
username="Internet"
password="Internet"
type="default" />
mcc="502"
mnc="19"
apn="celcom3g"
type="default,supl" />
mcc="502"
mnc="19"
apn="celcom3g"
user="mms"
password="mms"
mmsc="http://mms.celcom.net.my"
mmsproxy="10.128.1.242"
mmsport="8080"
type="mms" />
mcc="226"
mnc="03"
apn="wnw"
user="wnw"
password="wnw"
proxy="10.252.1.62"
port="8080"
type="default,supl" />
mcc="525"
mnc="03"
apn="miworld"
user="65"
password="user123"
mmsc="http://mmsgw:8002"
mmsproxy="172.16.14.10"
mmsport="8080"
authenticationtype="PAP"
type="mms" />
mcc="525"
mnc="03"
apn="sunsurf"
type="default,supl,mms" />
mcc="734"
mnc="02"
apn="gprsweb.digitel.ve"
mmsc="http://expresate.digitel.ve"
mmsproxy="213.026.205.001"
mmsport="8080"
type="default,supl,mms" />
mcc="262"
mnc="03"
apn="internet.eplus.de"
user="eplus"
password="gprs"
type="default,supl" />
mcc="262"
mnc="03"
apn="mms.eplus.de"
user="blau"
password="blau"
mmsc="http://mms/eplus"
mmsproxy="212.23.97.153"
mmsport="5080" type="mms" />
mcc="220"
mnc="03"
apn="gprswap"
user="mts"
password="064"
proxy="172.017.088.198"
port="8080"
type="default" />
mcc="220"
mnc="03"
apn="mms"
user="mts"
password="064"
mmsc="http://mms.mts064.telekom.rs/mms/wapenc"
mmsproxy="172.017.085.131"
mmsport="8080"
type="mms" />
mcc="234"
mnc="01"
apn="prepay.tesco-mobile.com"
user="tescowap"
password="password"
server="http://wap.tesco-mobile.com/"
proxy="193.113.200.195"
port="9201"
type="default,supl,mms" />
mcc="502"
mnc="13"
apn="celcom"
type="default,supl" />
mcc="502"
mnc="13"
apn="celcom3g"
user="mms"
password="mms"
mmsc="http://mms.celcom.net.my"
mmsproxy="10.128.1.242"
mmsport="8080"
type="mms" />
mcc="310"
mnc="450"
apn="internet.vedge.com"
user=""
password=""
server=""
proxy="10.168.3.23"
port="9401"
type="default" />
mcc="310"
mnc="450"
apn="mms"
user=""
password=""
server=""
mmsc="http://mms.viaero.com"
mmsproxy="10.168.3.23"
port="9401"
typ="mms" />
mcc="502"
mnc="13"
apn="celcom"
type="default,supl" />
mcc="502"
mnc="13"
apn="celcom3g"
user="mms"
password="mms"
mmsc="http://mms.celcom.net.my"
mmsproxy="10.128.1.242"
mmsport="8080"
type="mms" />
mcc="714"
mnc="01"
apn="apn02.cwpanama.com.pa"
mmsc="http://mms.zonamovil.com.pa:80/i.bin"
mmsproxy="172.25.3.5"
port="8080"
type="mms" />
mcc="234"
mnc="15"
apn="uk.lebara.mobi"
user="web"
password="web"
type="default,supl" />
mcc="234"
mnc="15"
apn="uk.lebara.mobi"
user="web"
password="web"
server="*"
mmsc="http://mms.lebara.co.uk/servlets/mms"
mmsproxy="212.183.137.012"
mmsport="8799"
type="default,supl,mms" />
mcc="238"
mnc="02"
apn="internet.sp.dk"
user=""
server=""
password=""
proxy="212.088.064.008"
port="" mmsproxy="212.088.064.008"
mmsport="8080"
mmsprotocol="null"
mmsc="http://mms.telenor.dk"
type="" />
mcc="238"
mnc="02"
apn="internet.sp.dk"
user="" server=""
password=""
proxy="212.088.064.008"
port=""
mmsproxy="212.088.064.008"
mmsport="8080"
mmsprotocol="null"
mmsc="http://mms.telenor.dk"
type="" />
mcc="238"
mnc="02"
apn="telenor"
user=""
server=""
password=""
proxy=""
port=""
mmsproxy="212.088.064.008"
mmsport="8080"
mmsprotocol="null"
mmsc="http://mms.telenor.dk"
type="mms" />
mcc="238"
mnc="02"
apn="telenor"
user=""
server=""
password=""
proxy=""
port=""
mmsproxy="212.088.064.008"
mmsport="8080"
mmsprotocol="null"
mmsc="http://mms.telenor.dk"
type="mms" />
mcc="240"
mnc="02"
apn="data.tre.se"
type="default,supl" />
mcc="426"
mnc="01"
apn="mms.batelco.com"
user="wap"
password="wap"
mmsc="http://192.168.36.10/servlets/mms"
mmsport="80"
type="mms" />
mcc="208"
mnc="15"
apn="free"
type="default,supl" />
mcc="724"
mnc="05"
apn="java.claro.com.br"
user="claro"
password="claro"
type="default,supl" />
mcc="302"
mnc="220"
apn="isp.telus.com"
mmsc="http://aliasredirect.net/proxy/mmsc"
mmsproxy="74.49.0.18"
mmsport="80"
type="default,supl,mms" />
mcc="208"
mnc="10"
apn="fnetnrj"
type="default,supl" />
mcc="208"
mnc="10"
apn="mmsnrj"
mmsproxy="010.143.156.005"
mmsport="8080"
mmsc="http://mmsnrj"
type="mms" />