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.javaprivate 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的内容如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          to:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

 

 

 

 

 

更多相关文章

  1. Android 的http通信(原生代码)
  2. [Android] 一份代码,两个版本
  3. Android 中解析JSON形式的数据
  4. Android应用程序组件Content Provider的共享数据更新通知机制分
  5. Android一键锁屏代码
  6. Android SQLite数据库升级的问题
  7. 使用SharedPreferences存储和读取数据
  8. Android:Content Provider数据共享

随机推荐

  1. CSS基础1:元素样式来源,选择器,权重
  2. 学习了vue中数据的挂载,vue实例的编写,数据
  3. 商品管理器实例,node基础知识(包安装、删除
  4. 如何学好素描基础?新手自学素描技巧!
  5. 闭包 访问器 js dom
  6. Android基础知识及线性布局介绍
  7. 2022年最新phpStorm激活插件,可激活2021.3
  8. 这些node开源工具你值得拥有(上)
  9. php.ini 配置文件的深入解析
  10. Oracle 9i产品文档