1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * Copyright (c) 2013, The Linux Foundation. All rights reserved.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.internal.telephony;
19
20
21import android.app.ActivityManagerNative;
22import android.content.Context;
23import android.content.Intent;
24import android.net.LinkProperties;
25import android.net.NetworkCapabilities;
26import android.os.AsyncResult;
27import android.os.Bundle;
28import android.os.Handler;
29import android.os.Message;
30import android.os.PersistableBundle;
31import android.os.SystemProperties;
32import android.os.UserHandle;
33import android.telephony.CarrierConfigManager;
34import android.telephony.CellInfo;
35import android.telephony.CellLocation;
36import android.telephony.Rlog;
37import android.telephony.ServiceState;
38import android.telephony.SignalStrength;
39import android.telephony.SubscriptionManager;
40
41import com.android.internal.telephony.cdma.CDMAPhone;
42import com.android.internal.telephony.gsm.GSMPhone;
43import com.android.internal.telephony.imsphone.ImsPhone;
44import com.android.internal.telephony.test.SimulatedRadioControl;
45import com.android.internal.telephony.cdma.CDMALTEPhone;
46import com.android.internal.telephony.uicc.IccCardProxy;
47import com.android.internal.telephony.uicc.IccFileHandler;
48import com.android.internal.telephony.uicc.IsimRecords;
49import com.android.internal.telephony.uicc.UiccCard;
50import com.android.internal.telephony.uicc.UsimServiceTable;
51
52import java.io.FileDescriptor;
53import java.io.PrintWriter;
54import java.util.List;
55import java.util.Locale;
56
57import com.android.internal.telephony.dataconnection.DctController;
58
59public class PhoneProxy extends Handler implements Phone {
60    public final static Object lockForRadioTechnologyChange = new Object();
61
62    private Phone mActivePhone;
63    private CommandsInterface mCommandsInterface;
64    private IccSmsInterfaceManager mIccSmsInterfaceManager;
65    private IccPhoneBookInterfaceManagerProxy mIccPhoneBookInterfaceManagerProxy;
66    private PhoneSubInfoProxy mPhoneSubInfoProxy;
67    private IccCardProxy mIccCardProxy;
68
69    private boolean mResetModemOnRadioTechnologyChange = false;
70
71    private int mRilVersion;
72
73    private static final int EVENT_VOICE_RADIO_TECH_CHANGED = 1;
74    private static final int EVENT_RADIO_ON = 2;
75    private static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE = 3;
76    private static final int EVENT_RIL_CONNECTED = 4;
77    private static final int EVENT_UPDATE_PHONE_OBJECT = 5;
78    private static final int EVENT_SIM_RECORDS_LOADED = 6;
79
80    private int mPhoneId = 0;
81
82    private static final String LOG_TAG = "PhoneProxy";
83
84    //***** Class Methods
85    public PhoneProxy(PhoneBase phone) {
86        mActivePhone = phone;
87        mResetModemOnRadioTechnologyChange = SystemProperties.getBoolean(
88                TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false);
89        mIccPhoneBookInterfaceManagerProxy = new IccPhoneBookInterfaceManagerProxy(
90                phone.getIccPhoneBookInterfaceManager());
91        mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo());
92        mCommandsInterface = ((PhoneBase)mActivePhone).mCi;
93
94        mCommandsInterface.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
95        mCommandsInterface.registerForOn(this, EVENT_RADIO_ON, null);
96        mCommandsInterface.registerForVoiceRadioTechChanged(
97                             this, EVENT_VOICE_RADIO_TECH_CHANGED, null);
98        mPhoneId = phone.getPhoneId();
99        mIccSmsInterfaceManager =
100                new IccSmsInterfaceManager((PhoneBase)this.mActivePhone);
101        mIccCardProxy = new IccCardProxy(mActivePhone.getContext(), mCommandsInterface, mActivePhone.getPhoneId());
102
103        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
104            // For the purpose of IccCardProxy we only care about the technology family
105            mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS);
106        } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
107            mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT);
108        }
109    }
110
111    @Override
112    public void handleMessage(Message msg) {
113        AsyncResult ar = (AsyncResult) msg.obj;
114        switch(msg.what) {
115        case EVENT_RADIO_ON:
116            /* Proactively query voice radio technologies */
117            mCommandsInterface.getVoiceRadioTechnology(
118                    obtainMessage(EVENT_REQUEST_VOICE_RADIO_TECH_DONE));
119            break;
120
121        case EVENT_RIL_CONNECTED:
122            if (ar.exception == null && ar.result != null) {
123                mRilVersion = (Integer) ar.result;
124            } else {
125                logd("Unexpected exception on EVENT_RIL_CONNECTED");
126                mRilVersion = -1;
127            }
128            break;
129
130        case EVENT_VOICE_RADIO_TECH_CHANGED:
131        case EVENT_REQUEST_VOICE_RADIO_TECH_DONE:
132            String what = (msg.what == EVENT_VOICE_RADIO_TECH_CHANGED) ?
133                    "EVENT_VOICE_RADIO_TECH_CHANGED" : "EVENT_REQUEST_VOICE_RADIO_TECH_DONE";
134            if (ar.exception == null) {
135                if ((ar.result != null) && (((int[]) ar.result).length != 0)) {
136                    int newVoiceTech = ((int[]) ar.result)[0];
137                    logd(what + ": newVoiceTech=" + newVoiceTech);
138                    phoneObjectUpdater(newVoiceTech);
139                } else {
140                    loge(what + ": has no tech!");
141                }
142            } else {
143                loge(what + ": exception=" + ar.exception);
144            }
145            break;
146
147        case EVENT_UPDATE_PHONE_OBJECT:
148            phoneObjectUpdater(msg.arg1);
149            break;
150
151        case EVENT_SIM_RECORDS_LOADED:
152            // Only check for the voice radio tech if it not going to be updated by the voice
153            // registration changes.
154            if (!mActivePhone.getContext().getResources().getBoolean(
155                    com.android.internal.R.bool.config_switch_phone_on_voice_reg_state_change)) {
156                mCommandsInterface.getVoiceRadioTechnology(obtainMessage(
157                        EVENT_REQUEST_VOICE_RADIO_TECH_DONE));
158            }
159            break;
160
161        default:
162            loge("Error! This handler was not registered for this message type. Message: "
163                    + msg.what);
164            break;
165        }
166        super.handleMessage(msg);
167    }
168
169    private static void logd(String msg) {
170        Rlog.d(LOG_TAG, "[PhoneProxy] " + msg);
171    }
172
173    private void loge(String msg) {
174        Rlog.e(LOG_TAG, "[PhoneProxy] " + msg);
175    }
176
177    private void phoneObjectUpdater(int newVoiceRadioTech) {
178        logd("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech);
179
180        if (mActivePhone != null) {
181            // Check for a voice over lte replacement
182            if ((newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_LTE)
183                    || (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)) {
184                CarrierConfigManager configMgr = (CarrierConfigManager)
185                        mActivePhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
186                PersistableBundle b = configMgr.getConfigForSubId(mActivePhone.getSubId());
187                if (b != null) {
188                    int volteReplacementRat =
189                            b.getInt(CarrierConfigManager.KEY_VOLTE_REPLACEMENT_RAT_INT);
190                    logd("phoneObjectUpdater: volteReplacementRat=" + volteReplacementRat);
191                    if (volteReplacementRat != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
192                        newVoiceRadioTech = volteReplacementRat;
193                    }
194                } else {
195                    loge("phoneObjectUpdater: didn't get volteReplacementRat from carrier config");
196                }
197            }
198
199            if(mRilVersion == 6 && getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
200                /*
201                 * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone
202                 * irrespective of the voice radio tech reported.
203                 */
204                if (mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
205                    logd("phoneObjectUpdater: LTE ON CDMA property is set. Use CDMA Phone" +
206                            " newVoiceRadioTech=" + newVoiceRadioTech +
207                            " mActivePhone=" + mActivePhone.getPhoneName());
208                    return;
209                } else {
210                    logd("phoneObjectUpdater: LTE ON CDMA property is set. Switch to CDMALTEPhone" +
211                            " newVoiceRadioTech=" + newVoiceRadioTech +
212                            " mActivePhone=" + mActivePhone.getPhoneName());
213                    newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
214                }
215            } else {
216                boolean matchCdma = ServiceState.isCdma(newVoiceRadioTech);
217                boolean matchGsm = ServiceState.isGsm(newVoiceRadioTech);
218                if ((matchCdma  &&
219                        mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) ||
220                        (matchGsm &&
221                                mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)) {
222                    // Nothing changed. Keep phone as it is.
223                    logd("phoneObjectUpdater: No change ignore," +
224                            " newVoiceRadioTech=" + newVoiceRadioTech +
225                            " mActivePhone=" + mActivePhone.getPhoneName());
226                    return;
227                }
228                if (!matchCdma && !matchGsm) {
229                    loge("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech +
230                        " doesn't match either CDMA or GSM - error! No phone change");
231                    return;
232                }
233            }
234        }
235
236        if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
237            // We need some voice phone object to be active always, so never
238            // delete the phone without anything to replace it with!
239            logd("phoneObjectUpdater: Unknown rat ignore, "
240                    + " newVoiceRadioTech=Unknown. mActivePhone=" + mActivePhone.getPhoneName());
241            return;
242        }
243
244        boolean oldPowerState = false; // old power state to off
245        if (mResetModemOnRadioTechnologyChange) {
246            if (mCommandsInterface.getRadioState().isOn()) {
247                oldPowerState = true;
248                logd("phoneObjectUpdater: Setting Radio Power to Off");
249                mCommandsInterface.setRadioPower(false, null);
250            }
251        }
252
253        deleteAndCreatePhone(newVoiceRadioTech);
254
255        if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state
256            logd("phoneObjectUpdater: Resetting Radio");
257            mCommandsInterface.setRadioPower(oldPowerState, null);
258        }
259
260        // Set the new interfaces in the proxy's
261        mIccSmsInterfaceManager.updatePhoneObject((PhoneBase) mActivePhone);
262        mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager(mActivePhone
263                .getIccPhoneBookInterfaceManager());
264        mPhoneSubInfoProxy.setmPhoneSubInfo(mActivePhone.getPhoneSubInfo());
265
266        mCommandsInterface = ((PhoneBase)mActivePhone).mCi;
267        mIccCardProxy.setVoiceRadioTech(newVoiceRadioTech);
268
269        // Send an Intent to the PhoneApp that we had a radio technology change
270        Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
271        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
272        intent.putExtra(PhoneConstants.PHONE_NAME_KEY, mActivePhone.getPhoneName());
273        SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhoneId);
274        ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.USER_ALL);
275
276        DctController.getInstance().updatePhoneObject(this);
277
278    }
279
280    private void deleteAndCreatePhone(int newVoiceRadioTech) {
281
282        String outgoingPhoneName = "Unknown";
283        Phone oldPhone = mActivePhone;
284        ImsPhone imsPhone = null;
285
286        if (oldPhone != null) {
287            outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName();
288            oldPhone.unregisterForSimRecordsLoaded(this);
289        }
290
291        logd("Switching Voice Phone : " + outgoingPhoneName + " >>> "
292                + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA"));
293
294        if (ServiceState.isCdma(newVoiceRadioTech)) {
295            mActivePhone = PhoneFactory.getCdmaPhone(mPhoneId);
296        } else if (ServiceState.isGsm(newVoiceRadioTech)) {
297            mActivePhone = PhoneFactory.getGsmPhone(mPhoneId);
298        } else {
299            loge("deleteAndCreatePhone: newVoiceRadioTech=" + newVoiceRadioTech +
300                " is not CDMA or GSM (error) - aborting!");
301            return;
302        }
303
304        if (oldPhone != null) {
305            imsPhone = oldPhone.relinquishOwnershipOfImsPhone();
306        }
307
308        if(mActivePhone != null) {
309            CallManager.getInstance().registerPhone(mActivePhone);
310            if (imsPhone != null) {
311                mActivePhone.acquireOwnershipOfImsPhone(imsPhone);
312            }
313            mActivePhone.startMonitoringImsService();
314            mActivePhone.registerForSimRecordsLoaded(this, EVENT_SIM_RECORDS_LOADED, null);
315        }
316
317        if (oldPhone != null) {
318            CallManager.getInstance().unregisterPhone(oldPhone);
319            logd("Disposing old phone..");
320            oldPhone.dispose();
321            // Potential GC issues: however, callers may have references to old
322            // phone on which they perform hierarchical funcs: phone.getA().getB()
323            // HENCE: do not delete references.
324            //oldPhone.removeReferences();
325        }
326        oldPhone = null;
327    }
328
329    public IccSmsInterfaceManager getIccSmsInterfaceManager(){
330        return mIccSmsInterfaceManager;
331    }
332
333    public PhoneSubInfoProxy getPhoneSubInfoProxy(){
334        return mPhoneSubInfoProxy;
335    }
336
337    public IccPhoneBookInterfaceManagerProxy getIccPhoneBookInterfaceManagerProxy() {
338        return mIccPhoneBookInterfaceManagerProxy;
339    }
340
341    public IccFileHandler getIccFileHandler() {
342        return ((PhoneBase)mActivePhone).getIccFileHandler();
343    }
344
345    @Override
346    public boolean isVideoCallPresent() {
347        return mActivePhone.isVideoCallPresent();
348    }
349
350    @Override
351    public void updatePhoneObject(int voiceRadioTech) {
352        logd("updatePhoneObject: radioTechnology=" + voiceRadioTech);
353        sendMessage(obtainMessage(EVENT_UPDATE_PHONE_OBJECT, voiceRadioTech, 0, null));
354    }
355
356    @Override
357    public ServiceState getServiceState() {
358        return mActivePhone.getServiceState();
359    }
360
361    @Override
362    public CellLocation getCellLocation() {
363        return mActivePhone.getCellLocation();
364    }
365
366    /**
367     * @return all available cell information or null if none.
368     */
369    @Override
370    public List<CellInfo> getAllCellInfo() {
371        return mActivePhone.getAllCellInfo();
372    }
373
374    /**
375     * {@inheritDoc}
376     */
377    @Override
378    public void setCellInfoListRate(int rateInMillis) {
379        mActivePhone.setCellInfoListRate(rateInMillis);
380    }
381
382    @Override
383    public PhoneConstants.DataState getDataConnectionState() {
384        return mActivePhone.getDataConnectionState(PhoneConstants.APN_TYPE_DEFAULT);
385    }
386
387    @Override
388    public PhoneConstants.DataState getDataConnectionState(String apnType) {
389        return mActivePhone.getDataConnectionState(apnType);
390    }
391
392    @Override
393    public DataActivityState getDataActivityState() {
394        return mActivePhone.getDataActivityState();
395    }
396
397    @Override
398    public Context getContext() {
399        return mActivePhone.getContext();
400    }
401
402    @Override
403    public void disableDnsCheck(boolean b) {
404        mActivePhone.disableDnsCheck(b);
405    }
406
407    @Override
408    public boolean isDnsCheckDisabled() {
409        return mActivePhone.isDnsCheckDisabled();
410    }
411
412    @Override
413    public PhoneConstants.State getState() {
414        return mActivePhone.getState();
415    }
416
417    @Override
418    public String getPhoneName() {
419        return mActivePhone.getPhoneName();
420    }
421
422    @Override
423    public int getPhoneType() {
424        return mActivePhone.getPhoneType();
425    }
426
427    @Override
428    public String[] getActiveApnTypes() {
429        return mActivePhone.getActiveApnTypes();
430    }
431
432    @Override
433    public boolean hasMatchedTetherApnSetting() {
434        return mActivePhone.hasMatchedTetherApnSetting();
435    }
436
437    @Override
438    public String getActiveApnHost(String apnType) {
439        return mActivePhone.getActiveApnHost(apnType);
440    }
441
442    @Override
443    public LinkProperties getLinkProperties(String apnType) {
444        return mActivePhone.getLinkProperties(apnType);
445    }
446
447    @Override
448    public NetworkCapabilities getNetworkCapabilities(String apnType) {
449        return mActivePhone.getNetworkCapabilities(apnType);
450    }
451
452    @Override
453    public SignalStrength getSignalStrength() {
454        return mActivePhone.getSignalStrength();
455    }
456
457    @Override
458    public void registerForUnknownConnection(Handler h, int what, Object obj) {
459        mActivePhone.registerForUnknownConnection(h, what, obj);
460    }
461
462    @Override
463    public void unregisterForUnknownConnection(Handler h) {
464        mActivePhone.unregisterForUnknownConnection(h);
465    }
466
467    @Override
468    public void registerForHandoverStateChanged(Handler h, int what, Object obj) {
469        mActivePhone.registerForHandoverStateChanged(h, what, obj);
470    }
471
472    @Override
473    public void unregisterForHandoverStateChanged(Handler h) {
474        mActivePhone.unregisterForHandoverStateChanged(h);
475    }
476
477    @Override
478    public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) {
479        mActivePhone.registerForPreciseCallStateChanged(h, what, obj);
480    }
481
482    @Override
483    public void unregisterForPreciseCallStateChanged(Handler h) {
484        mActivePhone.unregisterForPreciseCallStateChanged(h);
485    }
486
487    @Override
488    public void registerForNewRingingConnection(Handler h, int what, Object obj) {
489        mActivePhone.registerForNewRingingConnection(h, what, obj);
490    }
491
492    @Override
493    public void unregisterForNewRingingConnection(Handler h) {
494        mActivePhone.unregisterForNewRingingConnection(h);
495    }
496
497    @Override
498    public void registerForVideoCapabilityChanged(
499            Handler h, int what, Object obj) {
500        mActivePhone.registerForVideoCapabilityChanged(h, what, obj);
501    }
502
503    @Override
504    public void unregisterForVideoCapabilityChanged(Handler h) {
505        mActivePhone.unregisterForVideoCapabilityChanged(h);
506    }
507
508    @Override
509    public void registerForIncomingRing(Handler h, int what, Object obj) {
510        mActivePhone.registerForIncomingRing(h, what, obj);
511    }
512
513    @Override
514    public void unregisterForIncomingRing(Handler h) {
515        mActivePhone.unregisterForIncomingRing(h);
516    }
517
518    @Override
519    public void registerForDisconnect(Handler h, int what, Object obj) {
520        mActivePhone.registerForDisconnect(h, what, obj);
521    }
522
523    @Override
524    public void unregisterForDisconnect(Handler h) {
525        mActivePhone.unregisterForDisconnect(h);
526    }
527
528    @Override
529    public void registerForMmiInitiate(Handler h, int what, Object obj) {
530        mActivePhone.registerForMmiInitiate(h, what, obj);
531    }
532
533    @Override
534    public void unregisterForMmiInitiate(Handler h) {
535        mActivePhone.unregisterForMmiInitiate(h);
536    }
537
538    @Override
539    public void registerForMmiComplete(Handler h, int what, Object obj) {
540        mActivePhone.registerForMmiComplete(h, what, obj);
541    }
542
543    @Override
544    public void unregisterForMmiComplete(Handler h) {
545        mActivePhone.unregisterForMmiComplete(h);
546    }
547
548    @Override
549    public List<? extends MmiCode> getPendingMmiCodes() {
550        return mActivePhone.getPendingMmiCodes();
551    }
552
553    @Override
554    public void sendUssdResponse(String ussdMessge) {
555        mActivePhone.sendUssdResponse(ussdMessge);
556    }
557
558    @Override
559    public void registerForServiceStateChanged(Handler h, int what, Object obj) {
560        mActivePhone.registerForServiceStateChanged(h, what, obj);
561    }
562
563    @Override
564    public void unregisterForServiceStateChanged(Handler h) {
565        mActivePhone.unregisterForServiceStateChanged(h);
566    }
567
568    @Override
569    public void registerForSuppServiceNotification(Handler h, int what, Object obj) {
570        mActivePhone.registerForSuppServiceNotification(h, what, obj);
571    }
572
573    @Override
574    public void unregisterForSuppServiceNotification(Handler h) {
575        mActivePhone.unregisterForSuppServiceNotification(h);
576    }
577
578    @Override
579    public void registerForSuppServiceFailed(Handler h, int what, Object obj) {
580        mActivePhone.registerForSuppServiceFailed(h, what, obj);
581    }
582
583    @Override
584    public void unregisterForSuppServiceFailed(Handler h) {
585        mActivePhone.unregisterForSuppServiceFailed(h);
586    }
587
588    @Override
589    public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){
590        mActivePhone.registerForInCallVoicePrivacyOn(h,what,obj);
591    }
592
593    @Override
594    public void unregisterForInCallVoicePrivacyOn(Handler h){
595        mActivePhone.unregisterForInCallVoicePrivacyOn(h);
596    }
597
598    @Override
599    public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){
600        mActivePhone.registerForInCallVoicePrivacyOff(h,what,obj);
601    }
602
603    @Override
604    public void unregisterForInCallVoicePrivacyOff(Handler h){
605        mActivePhone.unregisterForInCallVoicePrivacyOff(h);
606    }
607
608    @Override
609    public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj) {
610        mActivePhone.registerForCdmaOtaStatusChange(h,what,obj);
611    }
612
613    @Override
614    public void unregisterForCdmaOtaStatusChange(Handler h) {
615         mActivePhone.unregisterForCdmaOtaStatusChange(h);
616    }
617
618    @Override
619    public void registerForSubscriptionInfoReady(Handler h, int what, Object obj) {
620        mActivePhone.registerForSubscriptionInfoReady(h, what, obj);
621    }
622
623    @Override
624    public void unregisterForSubscriptionInfoReady(Handler h) {
625        mActivePhone.unregisterForSubscriptionInfoReady(h);
626    }
627
628    @Override
629    public void registerForEcmTimerReset(Handler h, int what, Object obj) {
630        mActivePhone.registerForEcmTimerReset(h,what,obj);
631    }
632
633    @Override
634    public void unregisterForEcmTimerReset(Handler h) {
635        mActivePhone.unregisterForEcmTimerReset(h);
636    }
637
638    @Override
639    public void registerForRingbackTone(Handler h, int what, Object obj) {
640        mActivePhone.registerForRingbackTone(h,what,obj);
641    }
642
643    @Override
644    public void unregisterForRingbackTone(Handler h) {
645        mActivePhone.unregisterForRingbackTone(h);
646    }
647
648    @Override
649    public void registerForOnHoldTone(Handler h, int what, Object obj) {
650        mActivePhone.registerForOnHoldTone(h,what,obj);
651    }
652
653    @Override
654    public void unregisterForOnHoldTone(Handler h) {
655        mActivePhone.unregisterForOnHoldTone(h);
656    }
657
658    @Override
659    public void registerForResendIncallMute(Handler h, int what, Object obj) {
660        mActivePhone.registerForResendIncallMute(h,what,obj);
661    }
662
663    @Override
664    public void unregisterForResendIncallMute(Handler h) {
665        mActivePhone.unregisterForResendIncallMute(h);
666    }
667
668    @Override
669    public void registerForSimRecordsLoaded(Handler h, int what, Object obj) {
670        mActivePhone.registerForSimRecordsLoaded(h,what,obj);
671    }
672
673    public void unregisterForSimRecordsLoaded(Handler h) {
674        mActivePhone.unregisterForSimRecordsLoaded(h);
675    }
676
677    @Override
678    public void registerForTtyModeReceived(Handler h, int what, Object obj) {
679        mActivePhone.registerForTtyModeReceived(h, what, obj);
680    }
681
682    @Override
683    public void unregisterForTtyModeReceived(Handler h) {
684        mActivePhone.unregisterForTtyModeReceived(h);
685    }
686
687    @Override
688    public boolean getIccRecordsLoaded() {
689        return mIccCardProxy.getIccRecordsLoaded();
690    }
691
692    @Override
693    public IccCard getIccCard() {
694        return mIccCardProxy;
695    }
696
697    @Override
698    public void acceptCall(int videoState) throws CallStateException {
699        mActivePhone.acceptCall(videoState);
700    }
701
702    @Override
703    public void rejectCall() throws CallStateException {
704        mActivePhone.rejectCall();
705    }
706
707    @Override
708    public void switchHoldingAndActive() throws CallStateException {
709        mActivePhone.switchHoldingAndActive();
710    }
711
712    @Override
713    public boolean canConference() {
714        return mActivePhone.canConference();
715    }
716
717    @Override
718    public void conference() throws CallStateException {
719        mActivePhone.conference();
720    }
721
722    @Override
723    public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) {
724        mActivePhone.enableEnhancedVoicePrivacy(enable, onComplete);
725    }
726
727    @Override
728    public void getEnhancedVoicePrivacy(Message onComplete) {
729        mActivePhone.getEnhancedVoicePrivacy(onComplete);
730    }
731
732    @Override
733    public boolean canTransfer() {
734        return mActivePhone.canTransfer();
735    }
736
737    @Override
738    public void explicitCallTransfer() throws CallStateException {
739        mActivePhone.explicitCallTransfer();
740    }
741
742    @Override
743    public void clearDisconnected() {
744        mActivePhone.clearDisconnected();
745    }
746
747    @Override
748    public Call getForegroundCall() {
749        return mActivePhone.getForegroundCall();
750    }
751
752    @Override
753    public Call getBackgroundCall() {
754        return mActivePhone.getBackgroundCall();
755    }
756
757    @Override
758    public Call getRingingCall() {
759        return mActivePhone.getRingingCall();
760    }
761
762    @Override
763    public Connection dial(String dialString, int videoState) throws CallStateException {
764        return mActivePhone.dial(dialString, videoState);
765    }
766
767    @Override
768    public Connection dial(String dialString, UUSInfo uusInfo, int videoState, Bundle intentExtras)
769            throws CallStateException {
770        return mActivePhone.dial(dialString, uusInfo, videoState, intentExtras);
771    }
772
773    @Override
774    public boolean handlePinMmi(String dialString) {
775        return mActivePhone.handlePinMmi(dialString);
776    }
777
778    @Override
779    public boolean handleInCallMmiCommands(String command) throws CallStateException {
780        return mActivePhone.handleInCallMmiCommands(command);
781    }
782
783    @Override
784    public void sendDtmf(char c) {
785        mActivePhone.sendDtmf(c);
786    }
787
788    @Override
789    public void startDtmf(char c) {
790        mActivePhone.startDtmf(c);
791    }
792
793    @Override
794    public void stopDtmf() {
795        mActivePhone.stopDtmf();
796    }
797
798    @Override
799    public void setRadioPower(boolean power) {
800        mActivePhone.setRadioPower(power);
801    }
802
803    @Override
804    public boolean getMessageWaitingIndicator() {
805        return mActivePhone.getMessageWaitingIndicator();
806    }
807
808    @Override
809    public boolean getCallForwardingIndicator() {
810        return mActivePhone.getCallForwardingIndicator();
811    }
812
813    @Override
814    public String getLine1Number() {
815        return mActivePhone.getLine1Number();
816    }
817
818    @Override
819    public String getCdmaMin() {
820        return mActivePhone.getCdmaMin();
821    }
822
823    @Override
824    public boolean isMinInfoReady() {
825        return mActivePhone.isMinInfoReady();
826    }
827
828    @Override
829    public String getCdmaPrlVersion() {
830        return mActivePhone.getCdmaPrlVersion();
831    }
832
833    @Override
834    public String getLine1AlphaTag() {
835        return mActivePhone.getLine1AlphaTag();
836    }
837
838    @Override
839    public boolean setLine1Number(String alphaTag, String number, Message onComplete) {
840        return mActivePhone.setLine1Number(alphaTag, number, onComplete);
841    }
842
843    @Override
844    public String getVoiceMailNumber() {
845        return mActivePhone.getVoiceMailNumber();
846    }
847
848     /** @hide */
849    @Override
850    public int getVoiceMessageCount(){
851        return mActivePhone.getVoiceMessageCount();
852    }
853
854    @Override
855    public String getVoiceMailAlphaTag() {
856        return mActivePhone.getVoiceMailAlphaTag();
857    }
858
859    @Override
860    public void setVoiceMailNumber(String alphaTag,String voiceMailNumber,
861            Message onComplete) {
862        mActivePhone.setVoiceMailNumber(alphaTag, voiceMailNumber, onComplete);
863    }
864
865    @Override
866    public void getCallForwardingOption(int commandInterfaceCFReason,
867            Message onComplete) {
868        mActivePhone.getCallForwardingOption(commandInterfaceCFReason,
869                onComplete);
870    }
871
872    @Override
873    public void setCallForwardingOption(int commandInterfaceCFReason,
874            int commandInterfaceCFAction, String dialingNumber,
875            int timerSeconds, Message onComplete) {
876        mActivePhone.setCallForwardingOption(commandInterfaceCFReason,
877            commandInterfaceCFAction, dialingNumber, timerSeconds, onComplete);
878    }
879
880    @Override
881    public void getOutgoingCallerIdDisplay(Message onComplete) {
882        mActivePhone.getOutgoingCallerIdDisplay(onComplete);
883    }
884
885    @Override
886    public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode,
887            Message onComplete) {
888        mActivePhone.setOutgoingCallerIdDisplay(commandInterfaceCLIRMode,
889                onComplete);
890    }
891
892    @Override
893    public void getCallWaiting(Message onComplete) {
894        mActivePhone.getCallWaiting(onComplete);
895    }
896
897    @Override
898    public void setCallWaiting(boolean enable, Message onComplete) {
899        mActivePhone.setCallWaiting(enable, onComplete);
900    }
901
902    @Override
903    public void getAvailableNetworks(Message response) {
904        mActivePhone.getAvailableNetworks(response);
905    }
906
907    @Override
908    public void setNetworkSelectionModeAutomatic(Message response) {
909        mActivePhone.setNetworkSelectionModeAutomatic(response);
910    }
911
912    @Override
913    public void getNetworkSelectionMode(Message response) {
914        mActivePhone.getNetworkSelectionMode(response);
915    }
916
917    @Override
918    public void selectNetworkManually(OperatorInfo network, Message response) {
919        mActivePhone.selectNetworkManually(network, response);
920    }
921
922    @Override
923    public void setPreferredNetworkType(int networkType, Message response) {
924        mActivePhone.setPreferredNetworkType(networkType, response);
925    }
926
927    @Override
928    public void getPreferredNetworkType(Message response) {
929        mActivePhone.getPreferredNetworkType(response);
930    }
931
932    @Override
933    public void getNeighboringCids(Message response) {
934        mActivePhone.getNeighboringCids(response);
935    }
936
937    @Override
938    public void setOnPostDialCharacter(Handler h, int what, Object obj) {
939        mActivePhone.setOnPostDialCharacter(h, what, obj);
940    }
941
942    @Override
943    public void setMute(boolean muted) {
944        mActivePhone.setMute(muted);
945    }
946
947    @Override
948    public boolean getMute() {
949        return mActivePhone.getMute();
950    }
951
952    @Override
953    public void setEchoSuppressionEnabled() {
954        mActivePhone.setEchoSuppressionEnabled();
955    }
956
957    @Override
958    public void invokeOemRilRequestRaw(byte[] data, Message response) {
959        mActivePhone.invokeOemRilRequestRaw(data, response);
960    }
961
962    @Override
963    public void invokeOemRilRequestStrings(String[] strings, Message response) {
964        mActivePhone.invokeOemRilRequestStrings(strings, response);
965    }
966
967    @Override
968    public void getDataCallList(Message response) {
969        mActivePhone.getDataCallList(response);
970    }
971
972    @Override
973    public void updateServiceLocation() {
974        mActivePhone.updateServiceLocation();
975    }
976
977    @Override
978    public void enableLocationUpdates() {
979        mActivePhone.enableLocationUpdates();
980    }
981
982    @Override
983    public void disableLocationUpdates() {
984        mActivePhone.disableLocationUpdates();
985    }
986
987    @Override
988    public void setUnitTestMode(boolean f) {
989        mActivePhone.setUnitTestMode(f);
990    }
991
992    @Override
993    public boolean getUnitTestMode() {
994        return mActivePhone.getUnitTestMode();
995    }
996
997    @Override
998    public void setBandMode(int bandMode, Message response) {
999        mActivePhone.setBandMode(bandMode, response);
1000    }
1001
1002    @Override
1003    public void queryAvailableBandMode(Message response) {
1004        mActivePhone.queryAvailableBandMode(response);
1005    }
1006
1007    @Override
1008    public boolean getDataRoamingEnabled() {
1009        return mActivePhone.getDataRoamingEnabled();
1010    }
1011
1012    @Override
1013    public void setDataRoamingEnabled(boolean enable) {
1014        mActivePhone.setDataRoamingEnabled(enable);
1015    }
1016
1017    @Override
1018    public boolean getDataEnabled() {
1019        return mActivePhone.getDataEnabled();
1020    }
1021
1022    @Override
1023    public void setDataEnabled(boolean enable) {
1024        mActivePhone.setDataEnabled(enable);
1025    }
1026
1027    @Override
1028    public void queryCdmaRoamingPreference(Message response) {
1029        mActivePhone.queryCdmaRoamingPreference(response);
1030    }
1031
1032    @Override
1033    public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) {
1034        mActivePhone.setCdmaRoamingPreference(cdmaRoamingType, response);
1035    }
1036
1037    @Override
1038    public void setCdmaSubscription(int cdmaSubscriptionType, Message response) {
1039        mActivePhone.setCdmaSubscription(cdmaSubscriptionType, response);
1040    }
1041
1042    @Override
1043    public SimulatedRadioControl getSimulatedRadioControl() {
1044        return mActivePhone.getSimulatedRadioControl();
1045    }
1046
1047    @Override
1048    public boolean isDataConnectivityPossible() {
1049        return mActivePhone.isDataConnectivityPossible(PhoneConstants.APN_TYPE_DEFAULT);
1050    }
1051
1052    @Override
1053    public boolean isDataConnectivityPossible(String apnType) {
1054        return mActivePhone.isDataConnectivityPossible(apnType);
1055    }
1056
1057    @Override
1058    public String getDeviceId() {
1059        return mActivePhone.getDeviceId();
1060    }
1061
1062    @Override
1063    public String getDeviceSvn() {
1064        return mActivePhone.getDeviceSvn();
1065    }
1066
1067    @Override
1068    public String getSubscriberId() {
1069        return mActivePhone.getSubscriberId();
1070    }
1071
1072    @Override
1073    public String getGroupIdLevel1() {
1074        return mActivePhone.getGroupIdLevel1();
1075    }
1076
1077    @Override
1078    public String getGroupIdLevel2() {
1079        return mActivePhone.getGroupIdLevel2();
1080    }
1081
1082    @Override
1083    public String getIccSerialNumber() {
1084        return mActivePhone.getIccSerialNumber();
1085    }
1086
1087    @Override
1088    public String getEsn() {
1089        return mActivePhone.getEsn();
1090    }
1091
1092    @Override
1093    public String getMeid() {
1094        return mActivePhone.getMeid();
1095    }
1096
1097    @Override
1098    public String getMsisdn() {
1099        return mActivePhone.getMsisdn();
1100    }
1101
1102    @Override
1103    public String getImei() {
1104        return mActivePhone.getImei();
1105    }
1106
1107    @Override
1108    public String getNai() {
1109        return mActivePhone.getNai();
1110    }
1111
1112    @Override
1113    public PhoneSubInfo getPhoneSubInfo(){
1114        return mActivePhone.getPhoneSubInfo();
1115    }
1116
1117    @Override
1118    public IccPhoneBookInterfaceManager getIccPhoneBookInterfaceManager(){
1119        return mActivePhone.getIccPhoneBookInterfaceManager();
1120    }
1121
1122    @Override
1123    public void setUiTTYMode(int uiTtyMode, Message onComplete) {
1124        mActivePhone.setUiTTYMode(uiTtyMode, onComplete);
1125    }
1126
1127    @Override
1128    public void setTTYMode(int ttyMode, Message onComplete) {
1129        mActivePhone.setTTYMode(ttyMode, onComplete);
1130    }
1131
1132    @Override
1133    public void queryTTYMode(Message onComplete) {
1134        mActivePhone.queryTTYMode(onComplete);
1135    }
1136
1137    @Override
1138    public void activateCellBroadcastSms(int activate, Message response) {
1139        mActivePhone.activateCellBroadcastSms(activate, response);
1140    }
1141
1142    @Override
1143    public void getCellBroadcastSmsConfig(Message response) {
1144        mActivePhone.getCellBroadcastSmsConfig(response);
1145    }
1146
1147    @Override
1148    public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response) {
1149        mActivePhone.setCellBroadcastSmsConfig(configValuesArray, response);
1150    }
1151
1152    @Override
1153    public void notifyDataActivity() {
1154         mActivePhone.notifyDataActivity();
1155    }
1156
1157    @Override
1158    public void getSmscAddress(Message result) {
1159        mActivePhone.getSmscAddress(result);
1160    }
1161
1162    @Override
1163    public void setSmscAddress(String address, Message result) {
1164        mActivePhone.setSmscAddress(address, result);
1165    }
1166
1167    @Override
1168    public int getCdmaEriIconIndex() {
1169        return mActivePhone.getCdmaEriIconIndex();
1170    }
1171
1172    @Override
1173    public String getCdmaEriText() {
1174        return mActivePhone.getCdmaEriText();
1175    }
1176
1177    @Override
1178    public int getCdmaEriIconMode() {
1179        return mActivePhone.getCdmaEriIconMode();
1180    }
1181
1182    public Phone getActivePhone() {
1183        return mActivePhone;
1184    }
1185
1186    @Override
1187    public void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete){
1188        mActivePhone.sendBurstDtmf(dtmfString, on, off, onComplete);
1189    }
1190
1191    @Override
1192    public void exitEmergencyCallbackMode(){
1193        mActivePhone.exitEmergencyCallbackMode();
1194    }
1195
1196    @Override
1197    public boolean needsOtaServiceProvisioning(){
1198        return mActivePhone.needsOtaServiceProvisioning();
1199    }
1200
1201    @Override
1202    public boolean isOtaSpNumber(String dialStr){
1203        return mActivePhone.isOtaSpNumber(dialStr);
1204    }
1205
1206    @Override
1207    public void registerForCallWaiting(Handler h, int what, Object obj){
1208        mActivePhone.registerForCallWaiting(h,what,obj);
1209    }
1210
1211    @Override
1212    public void unregisterForCallWaiting(Handler h){
1213        mActivePhone.unregisterForCallWaiting(h);
1214    }
1215
1216    @Override
1217    public void registerForSignalInfo(Handler h, int what, Object obj) {
1218        mActivePhone.registerForSignalInfo(h,what,obj);
1219    }
1220
1221    @Override
1222    public void unregisterForSignalInfo(Handler h) {
1223        mActivePhone.unregisterForSignalInfo(h);
1224    }
1225
1226    @Override
1227    public void registerForDisplayInfo(Handler h, int what, Object obj) {
1228        mActivePhone.registerForDisplayInfo(h,what,obj);
1229    }
1230
1231    @Override
1232    public void unregisterForDisplayInfo(Handler h) {
1233        mActivePhone.unregisterForDisplayInfo(h);
1234    }
1235
1236    @Override
1237    public void registerForNumberInfo(Handler h, int what, Object obj) {
1238        mActivePhone.registerForNumberInfo(h, what, obj);
1239    }
1240
1241    @Override
1242    public void unregisterForNumberInfo(Handler h) {
1243        mActivePhone.unregisterForNumberInfo(h);
1244    }
1245
1246    @Override
1247    public void registerForRedirectedNumberInfo(Handler h, int what, Object obj) {
1248        mActivePhone.registerForRedirectedNumberInfo(h, what, obj);
1249    }
1250
1251    @Override
1252    public void unregisterForRedirectedNumberInfo(Handler h) {
1253        mActivePhone.unregisterForRedirectedNumberInfo(h);
1254    }
1255
1256    @Override
1257    public void registerForLineControlInfo(Handler h, int what, Object obj) {
1258        mActivePhone.registerForLineControlInfo( h, what, obj);
1259    }
1260
1261    @Override
1262    public void unregisterForLineControlInfo(Handler h) {
1263        mActivePhone.unregisterForLineControlInfo(h);
1264    }
1265
1266    @Override
1267    public void registerFoT53ClirlInfo(Handler h, int what, Object obj) {
1268        mActivePhone.registerFoT53ClirlInfo(h, what, obj);
1269    }
1270
1271    @Override
1272    public void unregisterForT53ClirInfo(Handler h) {
1273        mActivePhone.unregisterForT53ClirInfo(h);
1274    }
1275
1276    @Override
1277    public void registerForT53AudioControlInfo(Handler h, int what, Object obj) {
1278        mActivePhone.registerForT53AudioControlInfo( h, what, obj);
1279    }
1280
1281    @Override
1282    public void unregisterForT53AudioControlInfo(Handler h) {
1283        mActivePhone.unregisterForT53AudioControlInfo(h);
1284    }
1285
1286    public void registerForRadioOffOrNotAvailable(Handler h, int what, Object obj) {
1287        mActivePhone.registerForRadioOffOrNotAvailable( h, what, obj);
1288    }
1289
1290    public void unregisterForRadioOffOrNotAvailable(Handler h) {
1291        mActivePhone.unregisterForRadioOffOrNotAvailable(h);
1292    }
1293
1294    @Override
1295    public void setOnEcbModeExitResponse(Handler h, int what, Object obj){
1296        mActivePhone.setOnEcbModeExitResponse(h,what,obj);
1297    }
1298
1299    @Override
1300    public void unsetOnEcbModeExitResponse(Handler h){
1301        mActivePhone.unsetOnEcbModeExitResponse(h);
1302    }
1303
1304    @Override
1305    public boolean isCspPlmnEnabled() {
1306        return mActivePhone.isCspPlmnEnabled();
1307    }
1308
1309    @Override
1310    public IsimRecords getIsimRecords() {
1311        return mActivePhone.getIsimRecords();
1312    }
1313
1314    /**
1315     * {@inheritDoc}
1316     */
1317    @Override
1318    public int getLteOnCdmaMode() {
1319        return mActivePhone.getLteOnCdmaMode();
1320    }
1321
1322    @Override
1323    public void setVoiceMessageWaiting(int line, int countWaiting) {
1324        mActivePhone.setVoiceMessageWaiting(line, countWaiting);
1325    }
1326
1327    @Override
1328    public UsimServiceTable getUsimServiceTable() {
1329        return mActivePhone.getUsimServiceTable();
1330    }
1331
1332    @Override
1333    public UiccCard getUiccCard() {
1334        return mActivePhone.getUiccCard();
1335    }
1336
1337    @Override
1338    public void nvReadItem(int itemID, Message response) {
1339        mActivePhone.nvReadItem(itemID, response);
1340    }
1341
1342    @Override
1343    public void nvWriteItem(int itemID, String itemValue, Message response) {
1344        mActivePhone.nvWriteItem(itemID, itemValue, response);
1345    }
1346
1347    @Override
1348    public void nvWriteCdmaPrl(byte[] preferredRoamingList, Message response) {
1349        mActivePhone.nvWriteCdmaPrl(preferredRoamingList, response);
1350    }
1351
1352    @Override
1353    public void nvResetConfig(int resetType, Message response) {
1354        mActivePhone.nvResetConfig(resetType, response);
1355    }
1356
1357    @Override
1358    public void dispose() {
1359        if (mActivePhone != null) {
1360            mActivePhone.unregisterForSimRecordsLoaded(this);
1361        }
1362        mCommandsInterface.unregisterForOn(this);
1363        mCommandsInterface.unregisterForVoiceRadioTechChanged(this);
1364        mCommandsInterface.unregisterForRilConnected(this);
1365    }
1366
1367    @Override
1368    public void removeReferences() {
1369        mActivePhone = null;
1370        mCommandsInterface = null;
1371    }
1372
1373    public boolean updateCurrentCarrierInProvider() {
1374        if (mActivePhone instanceof CDMALTEPhone) {
1375            return ((CDMALTEPhone)mActivePhone).updateCurrentCarrierInProvider();
1376        } else if (mActivePhone instanceof GSMPhone) {
1377            return ((GSMPhone)mActivePhone).updateCurrentCarrierInProvider();
1378        } else {
1379           loge("Phone object is not MultiSim. This should not hit!!!!");
1380           return false;
1381        }
1382    }
1383
1384    public void updateDataConnectionTracker() {
1385        logd("Updating Data Connection Tracker");
1386        if (mActivePhone instanceof CDMALTEPhone) {
1387            ((CDMALTEPhone)mActivePhone).updateDataConnectionTracker();
1388        } else if (mActivePhone instanceof GSMPhone) {
1389            ((GSMPhone)mActivePhone).updateDataConnectionTracker();
1390        } else {
1391           loge("Phone object is not MultiSim. This should not hit!!!!");
1392        }
1393    }
1394
1395    public void setInternalDataEnabled(boolean enable) {
1396        setInternalDataEnabled(enable, null);
1397    }
1398
1399    public boolean setInternalDataEnabledFlag(boolean enable) {
1400        boolean flag = false;
1401        if (mActivePhone instanceof CDMALTEPhone) {
1402            flag = ((CDMALTEPhone)mActivePhone).setInternalDataEnabledFlag(enable);
1403        } else if (mActivePhone instanceof GSMPhone) {
1404            flag = ((GSMPhone)mActivePhone).setInternalDataEnabledFlag(enable);
1405        } else {
1406           loge("Phone object is not MultiSim. This should not hit!!!!");
1407        }
1408        return flag;
1409    }
1410
1411    public void setInternalDataEnabled(boolean enable, Message onCompleteMsg) {
1412        if (mActivePhone instanceof CDMALTEPhone) {
1413            ((CDMALTEPhone)mActivePhone).setInternalDataEnabled(enable, onCompleteMsg);
1414        } else if (mActivePhone instanceof GSMPhone) {
1415            ((GSMPhone)mActivePhone).setInternalDataEnabled(enable, onCompleteMsg);
1416        } else {
1417           loge("Phone object is not MultiSim. This should not hit!!!!");
1418        }
1419    }
1420
1421    public void registerForAllDataDisconnected(Handler h, int what, Object obj) {
1422        if (mActivePhone instanceof CDMALTEPhone) {
1423            ((CDMALTEPhone)mActivePhone).registerForAllDataDisconnected(h, what, obj);
1424        } else if (mActivePhone instanceof GSMPhone) {
1425            ((GSMPhone)mActivePhone).registerForAllDataDisconnected(h, what, obj);
1426        } else {
1427           loge("Phone object is not MultiSim. This should not hit!!!!");
1428        }
1429    }
1430
1431    public void unregisterForAllDataDisconnected(Handler h) {
1432        if (mActivePhone instanceof CDMALTEPhone) {
1433            ((CDMALTEPhone)mActivePhone).unregisterForAllDataDisconnected(h);
1434        } else if (mActivePhone instanceof GSMPhone) {
1435            ((GSMPhone)mActivePhone).unregisterForAllDataDisconnected(h);
1436        } else {
1437           loge("Phone object is not MultiSim. This should not hit!!!!");
1438        }
1439    }
1440
1441
1442    public int getSubId() {
1443        return mActivePhone.getSubId();
1444    }
1445
1446    public int getPhoneId() {
1447        return mActivePhone.getPhoneId();
1448    }
1449
1450    @Override
1451    public String[] getPcscfAddress(String apnType) {
1452        return mActivePhone.getPcscfAddress(apnType);
1453    }
1454
1455    @Override
1456    public void setImsRegistrationState(boolean registered){
1457        logd("setImsRegistrationState - registered: " + registered);
1458
1459        mActivePhone.setImsRegistrationState(registered);
1460
1461        if ((mActivePhone.getPhoneName()).equals("GSM")) {
1462            GSMPhone GP = (GSMPhone)mActivePhone;
1463            GP.getServiceStateTracker().setImsRegistrationState(registered);
1464        } else if ((mActivePhone.getPhoneName()).equals("CDMA")) {
1465            CDMAPhone CP = (CDMAPhone)mActivePhone;
1466            CP.getServiceStateTracker().setImsRegistrationState(registered);
1467        }
1468    }
1469
1470    @Override
1471    public Phone getImsPhone() {
1472        return mActivePhone.getImsPhone();
1473    }
1474
1475    @Override
1476    public ImsPhone relinquishOwnershipOfImsPhone() { return null; }
1477
1478    @Override
1479    public void startMonitoringImsService() {}
1480
1481    @Override
1482    public void acquireOwnershipOfImsPhone(ImsPhone imsPhone) { }
1483
1484    @Override
1485    public int getVoicePhoneServiceState() {
1486        return mActivePhone.getVoicePhoneServiceState();
1487    }
1488
1489    @Override
1490    public boolean setOperatorBrandOverride(String brand) {
1491        return mActivePhone.setOperatorBrandOverride(brand);
1492    }
1493
1494    @Override
1495    public boolean setRoamingOverride(List<String> gsmRoamingList,
1496            List<String> gsmNonRoamingList, List<String> cdmaRoamingList,
1497            List<String> cdmaNonRoamingList) {
1498        return mActivePhone.setRoamingOverride(gsmRoamingList, gsmNonRoamingList,
1499                cdmaRoamingList, cdmaNonRoamingList);
1500    }
1501
1502    @Override
1503    public boolean isRadioAvailable() {
1504        return mCommandsInterface.getRadioState().isAvailable();
1505    }
1506
1507    @Override
1508    public boolean isRadioOn() {
1509        return mCommandsInterface.getRadioState().isOn();
1510    }
1511
1512    @Override
1513    public void shutdownRadio() {
1514        mActivePhone.shutdownRadio();
1515    }
1516
1517    @Override
1518    public void setRadioCapability(RadioCapability rc, Message response) {
1519        mActivePhone.setRadioCapability(rc, response);
1520    }
1521
1522    @Override
1523    public int getRadioAccessFamily() {
1524        return mActivePhone.getRadioAccessFamily();
1525    }
1526
1527    @Override
1528    public String getModemUuId() {
1529        return mActivePhone.getModemUuId();
1530    }
1531
1532    @Override
1533    public RadioCapability getRadioCapability() {
1534        return mActivePhone.getRadioCapability();
1535    }
1536
1537    @Override
1538    public void radioCapabilityUpdated(RadioCapability rc) {
1539        mActivePhone.radioCapabilityUpdated(rc);
1540    }
1541
1542    @Override
1543    public void registerForRadioCapabilityChanged(Handler h, int what, Object obj) {
1544        mActivePhone.registerForRadioCapabilityChanged(h, what, obj);
1545    }
1546
1547    @Override
1548    public void unregisterForRadioCapabilityChanged(Handler h) {
1549        mActivePhone.unregisterForRadioCapabilityChanged(h);
1550    }
1551
1552    public IccCardProxy getPhoneIccCardProxy() {
1553        return mIccCardProxy;
1554    }
1555
1556    public boolean isImsRegistered() {
1557        return mActivePhone.isImsRegistered();
1558    }
1559
1560    /**
1561     * Determines if video calling is enabled for the IMS phone.
1562     *
1563     * @return {@code true} if video calling is enabled.
1564     */
1565    @Override
1566    public boolean isVideoEnabled() {
1567        return mActivePhone.isVideoEnabled();
1568    }
1569
1570    /**
1571     * Returns the status of Link Capacity Estimation (LCE) service.
1572     */
1573    @Override
1574    public int getLceStatus() {
1575        return mActivePhone.getLceStatus();
1576    }
1577
1578    @Override
1579    public Locale getLocaleFromSimAndCarrierPrefs() {
1580        return mActivePhone.getLocaleFromSimAndCarrierPrefs();
1581    }
1582
1583    @Override
1584    public void getModemActivityInfo(Message response)  {
1585        mActivePhone.getModemActivityInfo(response);
1586    }
1587
1588    /**
1589     * @return true if we are in the emergency call back mode. This is a period where
1590     * the phone should be using as little power as possible and be ready to receive an
1591     * incoming call from the emergency operator.
1592     */
1593    @Override
1594    public boolean isInEcm() {
1595        return mActivePhone.isInEcm();
1596    }
1597
1598    public boolean isVolteEnabled() {
1599        return mActivePhone.isVolteEnabled();
1600    }
1601
1602    public boolean isWifiCallingEnabled() {
1603        return mActivePhone.isWifiCallingEnabled();
1604    }
1605
1606    public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
1607        try {
1608            ((PhoneBase)mActivePhone).dump(fd, pw, args);
1609        } catch (Exception e) {
1610            e.printStackTrace();
1611        }
1612        pw.flush();
1613        pw.println("++++++++++++++++++++++++++++++++");
1614
1615        try {
1616            mPhoneSubInfoProxy.dump(fd, pw, args);
1617        } catch (Exception e) {
1618            e.printStackTrace();
1619        }
1620        pw.flush();
1621        pw.println("++++++++++++++++++++++++++++++++");
1622
1623        try {
1624            mIccCardProxy.dump(fd, pw, args);
1625        } catch (Exception e) {
1626            e.printStackTrace();
1627        }
1628        pw.flush();
1629        pw.println("++++++++++++++++++++++++++++++++");
1630    }
1631}
1632