2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package com.android.internal.telephony.cdma;
19 import android.os.SystemProperties;
20 import android.content.Context;
21 import android.net.Uri;
22 import android.content.Context;
23 import android.provider.Telephony;
24 import android.content.ContentValues;
25 import android.database.SQLException;
26 import android.telephony.ServiceState;
27 import android.telephony.SignalStrength;
29 import com.android.internal.telephony.gsm.SIMRecords;
30 import com.android.internal.telephony.gsm.SimCard;
31 import com.android.internal.telephony.ServiceStateTracker;
32 import com.android.internal.telephony.DataConnectionTracker;
33 import com.android.internal.telephony.CommandsInterface;
34 import com.android.internal.telephony.Phone;
35 import com.android.internal.telephony.PhoneBase;
36 import com.android.internal.telephony.PhoneNotifier;
37 import com.android.internal.telephony.PhoneProxy;
38 import com.android.internal.telephony.IccCard;
39 import com.android.internal.telephony.gsm.GsmDataConnectionTracker;
41 import android.util.Log;
43 public class CDMALTEPhone extends CDMAPhone {
44 static final String LOG_TAG = "CDMA";
46 private static final boolean DBG = true;
49 public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
50 this(context, ci, notifier, false);
53 public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
54 boolean unitTestMode) {
55 super(context, ci, notifier, false);
59 protected void initSstIcc() {
60 mSST = new CdmaLteServiceStateTracker(this);
61 mIccRecords = new SIMRecords(this);
62 mIccCard = new SimCard(this, LOG_TAG, DBG);
66 public DataState getDataConnectionState(String apnType) {
67 // TODO: Remove instanceof if possible.
68 boolean isCdmaDataConnectionTracker = false;
69 if (mDataConnectionTracker instanceof CdmaDataConnectionTracker) {
70 log("getDataConnectionState isCdmaDataConnectionTracker");
71 isCdmaDataConnectionTracker = true;
73 log("getDataConnectionState NOT CdmaDataConnectionTracker");
75 DataState ret = DataState.DISCONNECTED;
77 if (!isCdmaDataConnectionTracker && (SystemProperties.get("adb.connected", "").length()
79 // We're connected to an ADB host and we have USB networking
80 // turned on. No matter what the radio state is,
81 // we report data connected
83 ret = DataState.CONNECTED;
84 } else if (mSST == null) {
85 // Radio Technology Change is ongoning, dispose() and
86 // removeReferences() have
87 // already been called
89 ret = DataState.DISCONNECTED;
90 } else if (mSST.getCurrentDataConnectionState() != ServiceState.STATE_IN_SERVICE) {
91 // If we're out of service, open TCP sockets may still work
92 // but no data will flow
93 ret = DataState.DISCONNECTED;
94 } else if (mDataConnectionTracker.isApnTypeEnabled(apnType) == false) {
95 ret = DataState.DISCONNECTED;
97 switch (mDataConnectionTracker.getState(apnType)) {
100 ret = DataState.DISCONNECTED;
105 if (mCT.state != Phone.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed()) {
106 ret = DataState.SUSPENDED;
108 ret = DataState.CONNECTED;
115 ret = DataState.CONNECTING;
120 log("getDataConnectionState apnType=" + apnType + " ret=" + ret);
124 public boolean updateCurrentCarrierInProvider() {
125 if (mIccRecords != null) {
127 Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
128 ContentValues map = new ContentValues();
129 map.put(Telephony.Carriers.NUMERIC, mIccRecords.getOperatorNumeric());
130 log("updateCurrentCarrierInProvider insert uri=" + uri);
131 mContext.getContentResolver().insert(uri, map);
133 } catch (SQLException e) {
134 Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
137 log("updateCurrentCarrierInProvider mIccRecords == null ret false");
143 protected void log(String s) {
145 Log.d(LOG_TAG, "[CDMALTEPhone] " + s);