1 /* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.internal.telephony.cdma; 18 19 import android.os.Message; 20 import android.util.Log; 21 22 import com.android.internal.telephony.DataConnection; 23 import com.android.internal.telephony.Phone; 24 import com.android.internal.telephony.RILConstants; 25 import com.android.internal.telephony.RetryManager; 26 27 /** 28 * {@hide} 29 */ 30 public class CdmaDataConnection extends DataConnection { 31 32 private static final String LOG_TAG = "CDMA"; 33 34 // ***** Constructor 35 private CdmaDataConnection(CDMAPhone phone, String name, int id, RetryManager rm) { 36 super(phone, name, id, rm); 37 } 38 39 /** 40 * Create the connection object 41 * 42 * @param phone the Phone 43 * @param id the connection id 44 * @param rm the RetryManager 45 * @return CdmaDataConnection that was created. 46 */ 47 static CdmaDataConnection makeDataConnection(CDMAPhone phone, int id, RetryManager rm) { 48 synchronized (mCountLock) { 49 mCount += 1; 50 } 51 CdmaDataConnection cdmaDc = new CdmaDataConnection(phone, "CdmaDC-" + mCount, 52 id, rm); 53 cdmaDc.start(); 54 if (DBG) cdmaDc.log("Made " + cdmaDc.getName()); 55 return cdmaDc; 56 } 57 58 /** 59 * Begin setting up a data connection, calls setupDataCall 60 * and the ConnectionParams will be returned with the 61 * EVENT_SETUP_DATA_CONNECTION_DONE AsyncResul.userObj. 62 * 63 * @param cp is the connection parameters 64 */ 65 @Override 66 protected void onConnect(ConnectionParams cp) { 67 if (DBG) log("CdmaDataConnection Connecting..."); 68 69 mApn = cp.apn; 70 createTime = -1; 71 lastFailTime = -1; 72 lastFailCause = FailCause.NONE; 73 int dataProfile; 74 if ((cp.apn != null) && (cp.apn.types.length > 0) && (cp.apn.types[0] != null) && 75 (cp.apn.types[0].equals(Phone.APN_TYPE_DUN))) { 76 if (DBG) log("CdmaDataConnection using DUN"); 77 dataProfile = RILConstants.DATA_PROFILE_TETHERED; 78 } else { 79 dataProfile = RILConstants.DATA_PROFILE_DEFAULT; 80 } 81 82 // msg.obj will be returned in AsyncResult.userObj; 83 Message msg = obtainMessage(EVENT_SETUP_DATA_CONNECTION_DONE, cp); 84 msg.obj = cp; 85 phone.mCM.setupDataCall( 86 Integer.toString(getRadioTechnology(RILConstants.SETUP_DATA_TECH_CDMA)), 87 Integer.toString(dataProfile), 88 null, null, null, 89 Integer.toString(RILConstants.SETUP_DATA_AUTH_PAP_CHAP), 90 RILConstants.SETUP_DATA_PROTOCOL_IP, msg); 91 } 92 93 @Override 94 public String toString() { 95 return "State=" + getCurrentState().getName() + " create=" + createTime + " lastFail=" 96 + lastFailTime + " lastFasilCause=" + lastFailCause; 97 } 98 99 @Override 100 protected boolean isDnsOk(String[] domainNameServers) { 101 if (NULL_IP.equals(domainNameServers[0]) 102 && NULL_IP.equals(domainNameServers[1]) 103 && !phone.isDnsCheckDisabled()) { 104 return false; 105 } else { 106 return true; 107 } 108 } 109 110 @Override 111 protected void log(String s) { 112 Log.d(LOG_TAG, "[" + getName() + "] " + s); 113 } 114 } 115