Android2.3.5 CDMA/EVDO dialing APN Solution

Source: Internet
Author: User

In android2.3 provided by google, you can select a different apn account from "Settings"> "wireless and network"> "mobile network"> "Access Point name" only in the case of GSM/WCDMA for dial-up connection., but CDMA/EVDO does not have this function. I recently read the code to implement this function.

1. DefaultIn CDMA/EVDO, the list of apn is not displayed. You need to dig this out first.
Modify packages/apps/Phone/res/xml/CDMA _options.xml
Add the following content:Copy codeThe Code is 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 is also the development/data/etc/apns-conf.xml version value to the original plus 1, The Reason code to find.
2. ModifyFrameworks/base/telephony/java/com/android/internal/telephony/cdma dataconnectiontracker. java setupData FunctionCopy codeThe Code is as follows: private boolean setupData (String reason ){
CDMA dataconnection conn = findFreeDataConnection ();
If (conn = null ){
If (DBG) log ("setupData: No free CDMA dataconnection 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 );
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, "", user, pass,
, Types, "IP", "IP ");
Message msg = obtainMessage ();
Msg. what = EVENT_DATA_SETUP_COMPLETE;
Msg. obj = reason;
Conn. connect (msg, mActiveApn );
SetState (State. INITING );
Phone. policydataconnection (reason );
Return true;
}

3. ModifyFrameworks/base/telephony/java/com/android/internal/telephony/cdma dataconnection. java onConnect function:Copy codeThe Code is as follows: phone. mCM. setupDataCall (
Integer. toString (RILConstants. SETUP_DATA_TECH_CDMA ),
Integer. toString (dataProfile ),
// Null, // The original parameters for incoming dialing 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/ApnSetting. java defines ApnSetting and sets all its member types to public.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.