CDMALTEPhone.java revision bb36adde615d3d85fa0fc23935197c6bc6a799ed
1c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville/*
2c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Copyright (C) 2011 The Android Open Source Project
3c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville *
4c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Licensed under the Apache License, Version 2.0 (the "License");
5c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * you may not use this file except in compliance with the License.
6c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * You may obtain a copy of the License at
7c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville *
8c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville *      http://www.apache.org/licenses/LICENSE-2.0
9c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville *
10c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * Unless required by applicable law or agreed to in writing, software
11c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * distributed under the License is distributed on an "AS IS" BASIS,
12c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * See the License for the specific language governing permissions and
14c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville * limitations under the License.
15c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville */
16c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
17c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savillepackage com.android.internal.telephony.cdma;
18c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
19c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.content.ContentValues;
20c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.content.Context;
21c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.content.SharedPreferences;
22c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.database.SQLException;
23c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.net.Uri;
24c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.os.AsyncResult;
25c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.os.Message;
26c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.preference.PreferenceManager;
27c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.provider.Telephony;
28c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport android.util.Log;
29c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
30c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.CommandsInterface;
31c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.IccCard;
32bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenkaimport com.android.internal.telephony.IccRecords;
33c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.OperatorInfo;
34c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.Phone;
35c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.PhoneConstants;
36c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.PhoneNotifier;
37c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.PhoneProxy;
38c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.SMSDispatcher;
39c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.gsm.GsmSMSDispatcher;
40c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.gsm.SmsMessage;
41c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.ims.IsimRecords;
42c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport com.android.internal.telephony.uicc.UiccController;
43c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
44c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.io.FileDescriptor;
45c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savilleimport java.io.PrintWriter;
46c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
47c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Savillepublic class CDMALTEPhone extends CDMAPhone {
48c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    static final String LOG_TAG = "CDMA";
49c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
50c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    private static final boolean DBG = true;
51c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
52c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /** Secondary SMSDispatcher for 3GPP format messages. */
53c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    SMSDispatcher m3gppSMS;
54c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
55c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
56c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Small container class used to hold information relevant to
57c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * the carrier selection process. operatorNumeric can be ""
58c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * if we are looking for automatic selection. operatorAlphaLong is the
59c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * corresponding operator name.
60c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
61c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    private static class NetworkSelectMessage {
62c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        public Message message;
63c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        public String operatorNumeric;
64c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        public String operatorAlphaLong;
65c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
66c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
67c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    // Constructors
68c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public CDMALTEPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) {
69c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        super(context, ci, notifier, false);
70c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        m3gppSMS = new GsmSMSDispatcher(this, mSmsStorageMonitor, mSmsUsageMonitor);
71c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
72c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
73c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
74c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void handleMessage (Message msg) {
75c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        AsyncResult ar;
76c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        switch (msg.what) {
77c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            // handle the select network completion callbacks.
78c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_SET_NETWORK_MANUAL_COMPLETE:
79c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                handleSetSelectNetwork((AsyncResult) msg.obj);
80c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                break;
81c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            case EVENT_NEW_ICC_SMS:
82c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ar = (AsyncResult)msg.obj;
83c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                m3gppSMS.dispatchMessage((SmsMessage)ar.result);
84c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                break;
85c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            default:
86c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                super.handleMessage(msg);
87c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
88c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
89c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
90c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
91c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected void initSstIcc() {
92c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mSST = new CdmaLteServiceStateTracker(this);
93c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
94c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
95c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
96c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void dispose() {
97c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        synchronized(PhoneProxy.lockForRadioTechnologyChange) {
98c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            super.dispose();
99c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            m3gppSMS.dispose();
100c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
101c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
102c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
103c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
104c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void removeReferences() {
105c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        super.removeReferences();
106c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        m3gppSMS = null;
107c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
108c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
109c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
110c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public PhoneConstants.DataState getDataConnectionState(String apnType) {
111c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        PhoneConstants.DataState ret = PhoneConstants.DataState.DISCONNECTED;
112c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
113c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        if (mSST == null) {
114c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            // Radio Technology Change is ongoing, dispose() and
115c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            // removeReferences() have already been called
116c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
117c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            ret = PhoneConstants.DataState.DISCONNECTED;
118c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        } else if (mDataConnectionTracker.isApnTypeEnabled(apnType) == false) {
119c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            ret = PhoneConstants.DataState.DISCONNECTED;
120c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        } else {
121c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            switch (mDataConnectionTracker.getState(apnType)) {
122c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case FAILED:
123c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case IDLE:
124c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    ret = PhoneConstants.DataState.DISCONNECTED;
125c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
126c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
127c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case CONNECTED:
128c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case DISCONNECTING:
129c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    if (mCT.state != PhoneConstants.State.IDLE &&
130c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                            !mSST.isConcurrentVoiceAndDataAllowed()) {
131c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        ret = PhoneConstants.DataState.SUSPENDED;
132c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    } else {
133c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        ret = PhoneConstants.DataState.CONNECTED;
134c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    }
135c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
136c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
137c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case INITING:
138c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case CONNECTING:
139c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                case SCANNING:
140c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    ret = PhoneConstants.DataState.CONNECTING;
141c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                    break;
142c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            }
143c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
144c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
145c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        log("getDataConnectionState apnType=" + apnType + " ret=" + ret);
146c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        return ret;
147c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
148c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
149c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
150c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void
151c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    selectNetworkManually(OperatorInfo network,
152c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            Message response) {
153c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // wrap the response message in our own message along with
154c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // the operator's id.
155c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        NetworkSelectMessage nsm = new NetworkSelectMessage();
156c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        nsm.message = response;
157c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        nsm.operatorNumeric = network.getOperatorNumeric();
158c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        nsm.operatorAlphaLong = network.getOperatorAlphaLong();
159c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
160c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // get the message
161c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        Message msg = obtainMessage(EVENT_SET_NETWORK_MANUAL_COMPLETE, nsm);
162c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
163c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCM.setNetworkSelectionModeManual(network.getOperatorNumeric(), msg);
164c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
165c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
166c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    /**
167c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     * Used to track the settings upon completion of the network change.
168c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville     */
169c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    private void handleSetSelectNetwork(AsyncResult ar) {
170c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // look for our wrapper within the asyncresult, skip the rest if it
171c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // is null.
172c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        if (!(ar.userObj instanceof NetworkSelectMessage)) {
173c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            Log.e(LOG_TAG, "unexpected result from user object.");
174c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            return;
175c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
176c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
177c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        NetworkSelectMessage nsm = (NetworkSelectMessage) ar.userObj;
178c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
179c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // found the object, now we send off the message we had originally
180c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // attached to the request.
181c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        if (nsm.message != null) {
182c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            if (DBG) log("sending original message to recipient");
183c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            AsyncResult.forMessage(nsm.message, ar.result, ar.exception);
184c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            nsm.message.sendToTarget();
185c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
186c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
187c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // open the shared preferences editor, and write the value.
188c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // nsm.operatorNumeric is "" if we're in automatic.selection.
189c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext());
190c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        SharedPreferences.Editor editor = sp.edit();
191c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        editor.putString(NETWORK_SELECTION_KEY, nsm.operatorNumeric);
192c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        editor.putString(NETWORK_SELECTION_NAME_KEY, nsm.operatorAlphaLong);
193c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
194c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        // commit and log the result.
195c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        if (! editor.commit()) {
196c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            Log.e(LOG_TAG, "failed to commit network selection preference");
197c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
198c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
199c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
200c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
201c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
202c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public boolean updateCurrentCarrierInProvider() {
203bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
204bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        if (r != null) {
205c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            try {
206c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current");
207c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                ContentValues map = new ContentValues();
208bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka                String operatorNumeric = r.getOperatorNumeric();
209c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                map.put(Telephony.Carriers.NUMERIC, operatorNumeric);
210c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                if (DBG) log("updateCurrentCarrierInProvider from UICC: numeric=" +
211c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                        operatorNumeric);
212c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                mContext.getContentResolver().insert(uri, map);
213c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                return true;
214c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            } catch (SQLException e) {
215c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville                Log.e(LOG_TAG, "[CDMALTEPhone] Can't store current operator ret false", e);
216c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            }
217c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        } else {
218c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            if (DBG) log("updateCurrentCarrierInProvider mIccRecords == null ret false");
219c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        }
220c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        return false;
221c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
222c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
223c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    // return IMSI from USIM as subscriber ID.
224c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
225c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public String getSubscriberId() {
226bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
227bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        return (r != null) ? r.getIMSI() : "";
228c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
229c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
230c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
231c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public String getImei() {
232c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        return mImei;
233c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
234c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
235c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
236c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public String getDeviceSvn() {
237c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        return mImeiSv;
238c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
239c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
240c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
241c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public IsimRecords getIsimRecords() {
242bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
243bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        return (r != null) ? r.getIsimRecords() : null;
244c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
245c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
246c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
247c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public String getMsisdn() {
248bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
249bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        return (r != null) ? r.getMsisdnNumber() : null;
250c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
251c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
252c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
253c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void getAvailableNetworks(Message response) {
254c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCM.getAvailableNetworks(response);
255c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
256c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
257c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
258c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void requestIsimAuthentication(String nonce, Message result) {
259c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        mCM.requestIsimAuthentication(nonce, result);
260c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
261c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
262c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
263bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    protected void registerForRuimRecordEvents() {
264bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
265bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        if (r == null) {
266bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka            return;
267bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        }
268bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        r.registerForNewSms(this, EVENT_NEW_ICC_SMS, null);
269bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        super.registerForRuimRecordEvents();
270bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    }
271bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka
272bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    @Override
273bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    protected void unregisterForRuimRecordEvents() {
274bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        IccRecords r = mIccRecords.get();
275bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        if (r == null) {
276bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka            return;
277bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        }
278bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        r.unregisterForNewSms(this);
279bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka        super.unregisterForRuimRecordEvents();
280bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    }
281bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka
282bb36adde615d3d85fa0fc23935197c6bc6a799edAlex Yakavenka    @Override
283c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    protected void log(String s) {
284c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville            Log.d(LOG_TAG, "[CDMALTEPhone] " + s);
285c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
286c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville
287c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    @Override
288c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
289c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        pw.println("CDMALTEPhone extends:");
290c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        super.dump(fd, pw, args);
291c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville        pw.println(" m3gppSMS=" + m3gppSMS);
292c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville    }
293c38bb60d867c5d61d90b7179a9ed2b2d1848124fWink Saville}
294