OSDN Git Service

am 0fbe1dfb: Merge "cherrypick from master: Change-Id: I169749dc594ca1d79a802db4c53ec...
[android-x86/frameworks-base.git] / telephony / java / com / android / internal / telephony / cdma / CDMALTEPhone.java
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.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;
28
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;
40
41 import android.util.Log;
42
43 public class CDMALTEPhone extends CDMAPhone {
44     static final String LOG_TAG = "CDMA";
45
46     private static final boolean DBG = true;
47
48     // Constructors
49     public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
50         this(context, ci, notifier, false);
51     }
52
53     public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier,
54             boolean unitTestMode) {
55         super(context, ci, notifier, false);
56     }
57
58     @Override
59     protected void initSstIcc() {
60         mSST = new CdmaLteServiceStateTracker(this);
61         mIccRecords = new CdmaLteUiccRecords(this);
62         mIccCard = new SimCard(this, LOG_TAG, DBG);
63         mIccFileHandler = new CdmaLteUiccFileHandler(this);
64     }
65
66     @Override
67     public DataState getDataConnectionState(String apnType) {
68         DataState ret = DataState.DISCONNECTED;
69
70         if (mSST == null) {
71             // Radio Technology Change is ongoning, dispose() and
72             // removeReferences() have already been called
73
74             ret = DataState.DISCONNECTED;
75         } else if (mDataConnectionTracker.isApnTypeEnabled(apnType) == false) {
76             ret = DataState.DISCONNECTED;
77         } else {
78             switch (mDataConnectionTracker.getState(apnType)) {
79                 case FAILED:
80                 case IDLE:
81                     ret = DataState.DISCONNECTED;
82                     break;
83
84                 case CONNECTED:
85                 case DISCONNECTING:
86                     if (mCT.state != Phone.State.IDLE && !mSST.isConcurrentVoiceAndDataAllowed()) {
87                         ret = DataState.SUSPENDED;
88                     } else {
89                         ret = DataState.CONNECTED;
90                     }
91                     break;
92
93                 case INITING:
94                 case CONNECTING:
95                 case SCANNING:
96                     ret = DataState.CONNECTING;
97                     break;
98             }
99         }
100
101         log("getDataConnectionState apnType=" + apnType + " ret=" + ret);
102         return ret;
103     }
104
105     public boolean updateCurrentCarrierInProvider() {
106         if (mIccRecords != null) {
107             try {
108                 Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
109                 ContentValues map = new ContentValues();
110                 map.put(Telephony.Carriers.NUMERIC, mIccRecords.getOperatorNumeric());
111                 log("updateCurrentCarrierInProvider insert uri=" + uri);
112                 mContext.getContentResolver().insert(uri, map);
113                 return true;
114             } catch (SQLException e) {
115                 Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
116             }
117         } else {
118             log("updateCurrentCarrierInProvider mIccRecords == null ret false");
119         }
120         return false;
121     }
122
123     @Override
124     public void setSystemLocale(String language, String country, boolean fromMcc) {
125         // Avoid system locale is set from MCC table if CDMALTEPhone is used.
126         // The locale will be picked up based on EFpl/EFli once CSIM records are loaded.
127         if (fromMcc) return;
128
129         super.setSystemLocale(language, country, false);
130     }
131
132     // return IMSI from USIM as subscriber ID.
133     @Override
134     public String getSubscriberId() {
135         return mIccRecords.getIMSI();
136     }
137
138     @Override
139     protected void log(String s) {
140         if (DBG)
141             Log.d(LOG_TAG, "[CDMALTEPhone] " + s);
142     }
143 }