Fortunately, Android is an open-source platform. I can find the answer for myself. I checked out the source code of platform/packages/apps/Settings.git in Android source tree and dug into ApnSettings.java.
Now, I am wondering if changing APN names will do the tricks? Let's find out!
Two content URIs defined as constants in the file,
public static final String RESTORE_CARRIERS_URI = "content://telephony/carriers/restore"; public static final String PREFERRED_APN_URI = "content://telephony/carriers/preferapn";and the "content://telephony/carriers" is hinting me that it should store all carriers your phone predefined or has searched. I wrote a small piece of code to dump the contents of this URI.
private ListgetApnInfoList(Context context) { List retList = new ArrayList (); ContentResolver contentResolver = context.getContentResolver(); Cursor apnCursor = contentResolver.query(CARRIERS_URI, new String[]{COLUMN_NAME_ID, COLUMN_NAME_APN, COLUMN_NAME_TYPES}, null, null, null); if (apnCursor.moveToFirst()) { do { ApnInfo apnInfo = new ApnInfo(); apnInfo.id = apnCursor.getInt(COLUMN_INDEX_ID); apnInfo.apn = apnCursor.getString(COLUMN_INDEX_APN); apnInfo.types = apnCursor.getString(COLUMN_INDEX_TYPES); retList.add(apnInfo); } while (apnCursor.moveToNext()); } apnCursor.close(); return retList; }
This function gave me a list of carriers and their types in the emulator.
| Id | APN | Types |
| 1 | epc.tmobile.com | null |
| 2 | epc.tmobile.com | null |
| 3 | epc.tmobile.com | null |
| 4 | epc.tmobile.com | null |
| 5 | epc.tmobile.com | null |
| 6 | epc.tmobile.com | null |
| 7 | epc.tmobile.com | null |
| 8 | epc.tmobile.com | null |
| 9 | epc.tmobile.com | null |
| 10 | epc.tmobile.com | null |
| 11 | epc.tmobile.com | null |
| 12 | epc.tmobile.com | null |
| 13 | epc.tmobile.com | null |
| 14 | epc.tmobile.com | null |
| 15 | general.t-mobile.uk | null |
| 16 | internet.t-mobile | null |
| 17 | gprsinternet | default |
| 18 | gprsmms | mms |
| 19 | internet.t-mobile.cz | default |
| 20 | mms.t-mobile.cz | mms |
| 21 | internet | default |
| 22 | mms | mms |
| 23 | wap.cingular | null |
| 24 | wap.cingular | null |
| 25 | proxy | null |
| 26 | internet.com | null |
| 27 | internet | null |
| 28 | internet | null |
| 29 | internet | null |
| 30 | internet | null |
| 31 | portalnmms | null |
| 32 | wapsfr | default |
| 33 | mmssfr | mms |
| 34 | orange | default |
| 35 | orange.acte | mms |
| 36 | mmsbouygtel.com | null |
| 37 | internet | null |
| 38 | internet | null |
| 39 | internetg | null |
| 40 | internet | null |
| 41 | internet | null |
| 42 | gprs.swisscom.ch | null |
| 43 | erainternet | null |
| 44 | cmwap | null |
| 45 | internet | null |
| 46 | internet | null |
| 47 | internet | default |
| 48 | mms | mms |
| 49 | internet | null |
Now, it's time to see whether or not changing APN of a carrier will do the trick. I appended all the APNs with a fixed suffix. For example, orange becomes "orange haha". Guess what, the logcat shows these messages to make me think I am doing the right thing.
D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: epc.tmobile.com reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged D/TelephonyProvider( 620): Setting numeric '310260' to be the current operator D/dalvikvm( 577): GREF has increased to 301 D/GpsLocationProvider( 577): state: DISCONNECTED apnName: null reason: apnChanged ...And I went to open a URL link in Browser and it can't receive any data from internet.
Next, I'm gonna to test it on my Magic. :)