Google provides the android2.3, only in the GSM/WCDMA case can be from the "Settings"-> "Wireless and Network"-> "mobile network"-> "Access Point Name" to select a different APN account for dial-up connection, and cdma/ EVDO does not have this function. Recently looked at the code, the simple implementation of this function.
1, the defaultThe CDMA/EVDO inside even the APN list does not show, must first dig out this.
Modify Packages/apps/phone/res/xml/cdma_options.xml
Add the following content
Copy Code code as follows:
<preferencescreen
android:key= "Button_apn_key"
android:title= "@string/apn_settings"
Android:persistent= "false" >
<intent android:action= "Android.intent.action.MAIN"
Android:targetpackage= "Com.android.settings"
android:targetclass= "Com.android.settings.ApnSettings"/>
</PreferenceScreen>
There are Development/data/etc/apns-conf.xml version value changed to the original plus 1, reason code inside find.
2, modifyThe SetupData function of Frameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnectiontracker.java
Copy Code code as follows:
Private Boolean SetupData (String reason) {
Cdmadataconnection conn = Findfreedataconnection ();
if (conn = = null) {
if (DBG) log ("Setupdata:no free cdmadataconnection found!");
return false;
}
Mactivedataconnection = conn;
String[] types;
if (Mrequestedapntype.equals (Phone.apn_type_dun)) {
types = new String[1];
Types[0] = Phone.apn_type_dun;
} else {
types = Mdefaultapntypes;
}
MACTIVEAPN = new Apnsetting (0, "", "", "", "", "", ",", "", "", "", "", "", "", "", "", "", ""
0, types, "IP", "IP");
Uri Preferred_apn_uri = Uri.parse ("CONTENT://TELEPHONY/CARRIERS/PREFERAPN");
Contentresolver cresolver = Phone.getcontext (). Getcontentresolver ();
Cursor cr = Cresolver.query (Preferred_apn_uri, NULL, NULL, NULL, NULL);
Cr.movetofirst ();
String user = cr.getstring (cr.getcolumnindex ("user"));
String pass = cr.getstring (Cr.getcolumnindex ("password"));
String APN = cr.getstring (Cr.getcolumnindex ("APN"));
LOG.E (Log_tag, "get apn:apn=" + APN + ", user=" + user + ", password=" + pass);
MACTIVEAPN = new Apnsetting (0, "", "", APN, "", "", "", "", ",", "," "," "," "
, types, "IP", "IP");
Message msg = Obtainmessage ();
Msg.what = Event_data_setup_complete;
Msg.obj = reason;
Conn.connect (msg, MACTIVEAPN);
SetState (state.initing);
Phone.notifydataconnection (reason);
return true;
}
3, modifyFrameworks/base/telephony/java/com/android/internal/telephony/cdma/cdmadataconnection.java's OnConnect function:
Copy Code code as follows:
Phone.mCM.setupDataCall (
Integer.tostring (RILCONSTANTS.SETUP_DATA_TECH_CDMA),
Integer.tostring (Dataprofile),
NULL, NULL, NULL,//original dialing parameters are empty!!!
CP.APN.APN, Cp.apn.user, Cp.apn.password,
Integer.tostring (Rilconstants.setup_data_auth_pap_chap),
RILCONSTANTS.SETUP_DATA_PROTOCOL_IP, MSG);
4, modifyframeworks/base/telephony/java/com/android/internal/telephony/gsm/ The definition of apnsetting in Apnsetting.java, which sets its member type to public