1/*
2 * Copyright (C) 2008 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
17package com.android.internal.telephony;
18
19
20import android.app.ActivityManagerNative;
21import android.content.Context;
22import android.content.Intent;
23import android.net.LinkCapabilities;
24import android.net.LinkProperties;
25import android.os.AsyncResult;
26import android.os.Handler;
27import android.os.Message;
28import android.os.SystemProperties;
29import android.os.UserHandle;
30import android.telephony.CellInfo;
31import android.telephony.CellLocation;
32import android.telephony.ServiceState;
33import android.telephony.SignalStrength;
34import android.util.Log;
35
36import com.android.internal.telephony.cdma.CDMAPhone;
37import com.android.internal.telephony.gsm.GSMPhone;
38import com.android.internal.telephony.gsm.UsimServiceTable;
39import com.android.internal.telephony.ims.IsimRecords;
40import com.android.internal.telephony.test.SimulatedRadioControl;
41import com.android.internal.telephony.CallManager;
42
43import java.util.List;
44
45public class PhoneProxy extends Handler implements Phone {
46    public final static Object lockForRadioTechnologyChange = new Object();
47
48    private Phone mActivePhone;
49    private CommandsInterface mCommandsInterface;
50    private IccSmsInterfaceManagerProxy mIccSmsInterfaceManagerProxy;
51    private IccPhoneBookInterfaceManagerProxy mIccPhoneBookInterfaceManagerProxy;
52    private PhoneSubInfoProxy mPhoneSubInfoProxy;
53    private IccCardProxy mIccCardProxy;
54
55    private boolean mResetModemOnRadioTechnologyChange = false;
56
57    private int mRilVersion;
58
59    private static final int EVENT_VOICE_RADIO_TECH_CHANGED = 1;
60    private static final int EVENT_RADIO_ON = 2;
61    private static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE = 3;
62    private static final int EVENT_RIL_CONNECTED = 4;
63
64    private static final String LOG_TAG = "PHONE";
65
66    //***** Class Methods
67    public PhoneProxy(PhoneBase phone) {
68        mActivePhone = phone;
69        mResetModemOnRadioTechnologyChange = SystemProperties.getBoolean(
70                TelephonyProperties.PROPERTY_RESET_ON_RADIO_TECH_CHANGE, false);
71        mIccSmsInterfaceManagerProxy = new IccSmsInterfaceManagerProxy(
72                phone.getIccSmsInterfaceManager());
73        mIccPhoneBookInterfaceManagerProxy = new IccPhoneBookInterfaceManagerProxy(
74                phone.getIccPhoneBookInterfaceManager());
75        mPhoneSubInfoProxy = new PhoneSubInfoProxy(phone.getPhoneSubInfo());
76        mCommandsInterface = ((PhoneBase)mActivePhone).mCM;
77
78        mCommandsInterface.registerForRilConnected(this, EVENT_RIL_CONNECTED, null);
79        mCommandsInterface.registerForOn(this, EVENT_RADIO_ON, null);
80        mCommandsInterface.registerForVoiceRadioTechChanged(
81                             this, EVENT_VOICE_RADIO_TECH_CHANGED, null);
82        mIccCardProxy = new IccCardProxy(phone.getContext(), mCommandsInterface);
83        if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM) {
84            // For the purpose of IccCardProxy we only care about the technology family
85            mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_UMTS);
86        } else if (phone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
87            mIccCardProxy.setVoiceRadioTech(ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT);
88        }
89    }
90
91    @Override
92    public void handleMessage(Message msg) {
93        AsyncResult ar = (AsyncResult) msg.obj;
94        switch(msg.what) {
95        case EVENT_RADIO_ON:
96            /* Proactively query voice radio technologies */
97            mCommandsInterface.getVoiceRadioTechnology(
98                    this.obtainMessage(EVENT_REQUEST_VOICE_RADIO_TECH_DONE));
99            break;
100
101        case EVENT_RIL_CONNECTED:
102            if (ar.exception == null && ar.result != null) {
103                mRilVersion = (Integer) ar.result;
104            } else {
105                logd("Unexpected exception on EVENT_RIL_CONNECTED");
106                mRilVersion = -1;
107            }
108            break;
109
110        case EVENT_VOICE_RADIO_TECH_CHANGED:
111        case EVENT_REQUEST_VOICE_RADIO_TECH_DONE:
112
113            if (ar.exception == null) {
114                if ((ar.result != null) && (((int[]) ar.result).length != 0)) {
115                    int newVoiceTech = ((int[]) ar.result)[0];
116                    updatePhoneObject(newVoiceTech);
117                } else {
118                    loge("Voice Radio Technology event " + msg.what + " has no tech!");
119                }
120            } else {
121                loge("Voice Radio Technology event " + msg.what + " exception!" + ar.exception);
122            }
123            break;
124
125        default:
126            loge("Error! This handler was not registered for this message type. Message: "
127                    + msg.what);
128            break;
129        }
130        super.handleMessage(msg);
131    }
132
133    private static void logd(String msg) {
134        Log.d(LOG_TAG, "[PhoneProxy] " + msg);
135    }
136
137    private void logw(String msg) {
138        Log.w(LOG_TAG, "[PhoneProxy] " + msg);
139    }
140
141    private void loge(String msg) {
142        Log.e(LOG_TAG, "[PhoneProxy] " + msg);
143    }
144
145    private void updatePhoneObject(int newVoiceRadioTech) {
146
147        if (mActivePhone != null) {
148            if(mRilVersion == 6 && getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE) {
149                /*
150                 * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone
151                 * irrespective of the voice radio tech reported.
152                 */
153                if (mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) {
154                    logd("LTE ON CDMA property is set. Use CDMA Phone" +
155                            " newVoiceRadioTech = " + newVoiceRadioTech +
156                            " Active Phone = " + mActivePhone.getPhoneName());
157                    return;
158                } else {
159                    logd("LTE ON CDMA property is set. Switch to CDMALTEPhone" +
160                            " newVoiceRadioTech = " + newVoiceRadioTech +
161                            " Active Phone = " + mActivePhone.getPhoneName());
162                    newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
163                }
164            } else {
165                if ((ServiceState.isCdma(newVoiceRadioTech) &&
166                        mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_CDMA) ||
167                        (ServiceState.isGsm(newVoiceRadioTech) &&
168                                mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)) {
169                    // Nothing changed. Keep phone as it is.
170                    logd("Ignoring voice radio technology changed message." +
171                            " newVoiceRadioTech = " + newVoiceRadioTech +
172                            " Active Phone = " + mActivePhone.getPhoneName());
173                    return;
174                }
175            }
176        }
177
178        if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
179            // We need some voice phone object to be active always, so never
180            // delete the phone without anything to replace it with!
181            logd("Ignoring voice radio technology changed message. newVoiceRadioTech = Unknown."
182                    + " Active Phone = " + mActivePhone.getPhoneName());
183            return;
184        }
185
186        boolean oldPowerState = false; // old power state to off
187        if (mResetModemOnRadioTechnologyChange) {
188            if (mCommandsInterface.getRadioState().isOn()) {
189                oldPowerState = true;
190                logd("Setting Radio Power to Off");
191                mCommandsInterface.setRadioPower(false, null);
192            }
193        }
194
195        deleteAndCreatePhone(newVoiceRadioTech);
196
197        if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state
198            logd("Resetting Radio");
199            mCommandsInterface.setRadioPower(oldPowerState, null);
200        }
201
202        // Set the new interfaces in the proxy's
203        mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager(
204                mActivePhone.getIccSmsInterfaceManager());
205        mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager(mActivePhone
206                .getIccPhoneBookInterfaceManager());
207        mPhoneSubInfoProxy.setmPhoneSubInfo(this.mActivePhone.getPhoneSubInfo());
208
209        mCommandsInterface = ((PhoneBase)mActivePhone).mCM;
210        mIccCardProxy.setVoiceRadioTech(newVoiceRadioTech);
211
212        // Send an Intent to the PhoneApp that we had a radio technology change
213        Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
214        intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
215        intent.putExtra(PhoneConstants.PHONE_NAME_KEY, mActivePhone.getPhoneName());
216        ActivityManagerNative.broadcastStickyIntent(intent, null, UserHandle.USER_ALL);
217
218    }
219
220    private void deleteAndCreatePhone(int newVoiceRadioTech) {
221
222        String outgoingPhoneName = "Unknown";
223        Phone oldPhone = mActivePhone;
224
225        if (oldPhone != null) {
226            outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName();
227        }
228
229        logd("Switching Voice Phone : " + outgoingPhoneName + " >>> "
230                + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA"));
231
232        if (oldPhone != null) {
233            CallManager.getInstance().unregisterPhone(oldPhone);
234            logd("Disposing old phone..");
235            oldPhone.dispose();
236        }
237
238        // Give the garbage collector a hint to start the garbage collection
239        // asap NOTE this has been disabled since radio technology change could
240        // happen during e.g. a multimedia playing and could slow the system.
241        // Tests needs to be done to see the effects of the GC call here when
242        // system is busy.
243        // System.gc();
244
245        if (ServiceState.isCdma(newVoiceRadioTech)) {
246            mActivePhone = PhoneFactory.getCdmaPhone();
247        } else if (ServiceState.isGsm(newVoiceRadioTech)) {
248            mActivePhone = PhoneFactory.getGsmPhone();
249        }
250
251        if (oldPhone != null) {
252            oldPhone.removeReferences();
253        }
254
255        if(mActivePhone != null) {
256            CallManager.getInstance().registerPhone(mActivePhone);
257        }
258
259        oldPhone = null;
260    }
261
262    public ServiceState getServiceState() {
263        return mActivePhone.getServiceState();
264    }
265
266    public CellLocation getCellLocation() {
267        return mActivePhone.getCellLocation();
268    }
269
270    /**
271     * @return all available cell information or null if none.
272     */
273    @Override
274    public List<CellInfo> getAllCellInfo() {
275        return mActivePhone.getAllCellInfo();
276    }
277
278    public PhoneConstants.DataState getDataConnectionState() {
279        return mActivePhone.getDataConnectionState(PhoneConstants.APN_TYPE_DEFAULT);
280    }
281
282    public PhoneConstants.DataState getDataConnectionState(String apnType) {
283        return mActivePhone.getDataConnectionState(apnType);
284    }
285
286    public DataActivityState getDataActivityState() {
287        return mActivePhone.getDataActivityState();
288    }
289
290    public Context getContext() {
291        return mActivePhone.getContext();
292    }
293
294    public void disableDnsCheck(boolean b) {
295        mActivePhone.disableDnsCheck(b);
296    }
297
298    public boolean isDnsCheckDisabled() {
299        return mActivePhone.isDnsCheckDisabled();
300    }
301
302    public PhoneConstants.State getState() {
303        return mActivePhone.getState();
304    }
305
306    public String getPhoneName() {
307        return mActivePhone.getPhoneName();
308    }
309
310    public int getPhoneType() {
311        return mActivePhone.getPhoneType();
312    }
313
314    public String[] getActiveApnTypes() {
315        return mActivePhone.getActiveApnTypes();
316    }
317
318    public String getActiveApnHost(String apnType) {
319        return mActivePhone.getActiveApnHost(apnType);
320    }
321
322    public LinkProperties getLinkProperties(String apnType) {
323        return mActivePhone.getLinkProperties(apnType);
324    }
325
326    public LinkCapabilities getLinkCapabilities(String apnType) {
327        return mActivePhone.getLinkCapabilities(apnType);
328    }
329
330    public SignalStrength getSignalStrength() {
331        return mActivePhone.getSignalStrength();
332    }
333
334    public void registerForUnknownConnection(Handler h, int what, Object obj) {
335        mActivePhone.registerForUnknownConnection(h, what, obj);
336    }
337
338    public void unregisterForUnknownConnection(Handler h) {
339        mActivePhone.unregisterForUnknownConnection(h);
340    }
341
342    public void registerForPreciseCallStateChanged(Handler h, int what, Object obj) {
343        mActivePhone.registerForPreciseCallStateChanged(h, what, obj);
344    }
345
346    public void unregisterForPreciseCallStateChanged(Handler h) {
347        mActivePhone.unregisterForPreciseCallStateChanged(h);
348    }
349
350    public void registerForNewRingingConnection(Handler h, int what, Object obj) {
351        mActivePhone.registerForNewRingingConnection(h, what, obj);
352    }
353
354    public void unregisterForNewRingingConnection(Handler h) {
355        mActivePhone.unregisterForNewRingingConnection(h);
356    }
357
358    public void registerForIncomingRing(Handler h, int what, Object obj) {
359        mActivePhone.registerForIncomingRing(h, what, obj);
360    }
361
362    public void unregisterForIncomingRing(Handler h) {
363        mActivePhone.unregisterForIncomingRing(h);
364    }
365
366    public void registerForDisconnect(Handler h, int what, Object obj) {
367        mActivePhone.registerForDisconnect(h, what, obj);
368    }
369
370    public void unregisterForDisconnect(Handler h) {
371        mActivePhone.unregisterForDisconnect(h);
372    }
373
374    public void registerForMmiInitiate(Handler h, int what, Object obj) {
375        mActivePhone.registerForMmiInitiate(h, what, obj);
376    }
377
378    public void unregisterForMmiInitiate(Handler h) {
379        mActivePhone.unregisterForMmiInitiate(h);
380    }
381
382    public void registerForMmiComplete(Handler h, int what, Object obj) {
383        mActivePhone.registerForMmiComplete(h, what, obj);
384    }
385
386    public void unregisterForMmiComplete(Handler h) {
387        mActivePhone.unregisterForMmiComplete(h);
388    }
389
390    public List<? extends MmiCode> getPendingMmiCodes() {
391        return mActivePhone.getPendingMmiCodes();
392    }
393
394    public void sendUssdResponse(String ussdMessge) {
395        mActivePhone.sendUssdResponse(ussdMessge);
396    }
397
398    public void registerForServiceStateChanged(Handler h, int what, Object obj) {
399        mActivePhone.registerForServiceStateChanged(h, what, obj);
400    }
401
402    public void unregisterForServiceStateChanged(Handler h) {
403        mActivePhone.unregisterForServiceStateChanged(h);
404    }
405
406    public void registerForSuppServiceNotification(Handler h, int what, Object obj) {
407        mActivePhone.registerForSuppServiceNotification(h, what, obj);
408    }
409
410    public void unregisterForSuppServiceNotification(Handler h) {
411        mActivePhone.unregisterForSuppServiceNotification(h);
412    }
413
414    public void registerForSuppServiceFailed(Handler h, int what, Object obj) {
415        mActivePhone.registerForSuppServiceFailed(h, what, obj);
416    }
417
418    public void unregisterForSuppServiceFailed(Handler h) {
419        mActivePhone.unregisterForSuppServiceFailed(h);
420    }
421
422    public void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj){
423        mActivePhone.registerForInCallVoicePrivacyOn(h,what,obj);
424    }
425
426    public void unregisterForInCallVoicePrivacyOn(Handler h){
427        mActivePhone.unregisterForInCallVoicePrivacyOn(h);
428    }
429
430    public void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj){
431        mActivePhone.registerForInCallVoicePrivacyOff(h,what,obj);
432    }
433
434    public void unregisterForInCallVoicePrivacyOff(Handler h){
435        mActivePhone.unregisterForInCallVoicePrivacyOff(h);
436    }
437
438    public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj) {
439        mActivePhone.registerForCdmaOtaStatusChange(h,what,obj);
440    }
441
442    public void unregisterForCdmaOtaStatusChange(Handler h) {
443         mActivePhone.unregisterForCdmaOtaStatusChange(h);
444    }
445
446    public void registerForSubscriptionInfoReady(Handler h, int what, Object obj) {
447        mActivePhone.registerForSubscriptionInfoReady(h, what, obj);
448    }
449
450    public void unregisterForSubscriptionInfoReady(Handler h) {
451        mActivePhone.unregisterForSubscriptionInfoReady(h);
452    }
453
454    public void registerForEcmTimerReset(Handler h, int what, Object obj) {
455        mActivePhone.registerForEcmTimerReset(h,what,obj);
456    }
457
458    public void unregisterForEcmTimerReset(Handler h) {
459        mActivePhone.unregisterForEcmTimerReset(h);
460    }
461
462    public void registerForRingbackTone(Handler h, int what, Object obj) {
463        mActivePhone.registerForRingbackTone(h,what,obj);
464    }
465
466    public void unregisterForRingbackTone(Handler h) {
467        mActivePhone.unregisterForRingbackTone(h);
468    }
469
470    public void registerForResendIncallMute(Handler h, int what, Object obj) {
471        mActivePhone.registerForResendIncallMute(h,what,obj);
472    }
473
474    public void unregisterForResendIncallMute(Handler h) {
475        mActivePhone.unregisterForResendIncallMute(h);
476    }
477
478    public boolean getIccRecordsLoaded() {
479        return mIccCardProxy.getIccRecordsLoaded();
480    }
481
482    public IccCard getIccCard() {
483        return mIccCardProxy;
484    }
485
486    public void acceptCall() throws CallStateException {
487        mActivePhone.acceptCall();
488    }
489
490    public void rejectCall() throws CallStateException {
491        mActivePhone.rejectCall();
492    }
493
494    public void switchHoldingAndActive() throws CallStateException {
495        mActivePhone.switchHoldingAndActive();
496    }
497
498    public boolean canConference() {
499        return mActivePhone.canConference();
500    }
501
502    public void conference() throws CallStateException {
503        mActivePhone.conference();
504    }
505
506    public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) {
507        mActivePhone.enableEnhancedVoicePrivacy(enable, onComplete);
508    }
509
510    public void getEnhancedVoicePrivacy(Message onComplete) {
511        mActivePhone.getEnhancedVoicePrivacy(onComplete);
512    }
513
514    public boolean canTransfer() {
515        return mActivePhone.canTransfer();
516    }
517
518    public void explicitCallTransfer() throws CallStateException {
519        mActivePhone.explicitCallTransfer();
520    }
521
522    public void clearDisconnected() {
523        mActivePhone.clearDisconnected();
524    }
525
526    public Call getForegroundCall() {
527        return mActivePhone.getForegroundCall();
528    }
529
530    public Call getBackgroundCall() {
531        return mActivePhone.getBackgroundCall();
532    }
533
534    public Call getRingingCall() {
535        return mActivePhone.getRingingCall();
536    }
537
538    public Connection dial(String dialString) throws CallStateException {
539        return mActivePhone.dial(dialString);
540    }
541
542    public Connection dial(String dialString, UUSInfo uusInfo) throws CallStateException {
543        return mActivePhone.dial(dialString, uusInfo);
544    }
545
546    public boolean handlePinMmi(String dialString) {
547        return mActivePhone.handlePinMmi(dialString);
548    }
549
550    public boolean handleInCallMmiCommands(String command) throws CallStateException {
551        return mActivePhone.handleInCallMmiCommands(command);
552    }
553
554    public void sendDtmf(char c) {
555        mActivePhone.sendDtmf(c);
556    }
557
558    public void startDtmf(char c) {
559        mActivePhone.startDtmf(c);
560    }
561
562    public void stopDtmf() {
563        mActivePhone.stopDtmf();
564    }
565
566    public void setRadioPower(boolean power) {
567        mActivePhone.setRadioPower(power);
568    }
569
570    public boolean getMessageWaitingIndicator() {
571        return mActivePhone.getMessageWaitingIndicator();
572    }
573
574    public boolean getCallForwardingIndicator() {
575        return mActivePhone.getCallForwardingIndicator();
576    }
577
578    public String getLine1Number() {
579        return mActivePhone.getLine1Number();
580    }
581
582    public String getCdmaMin() {
583        return mActivePhone.getCdmaMin();
584    }
585
586    public boolean isMinInfoReady() {
587        return mActivePhone.isMinInfoReady();
588    }
589
590    public String getCdmaPrlVersion() {
591        return mActivePhone.getCdmaPrlVersion();
592    }
593
594    public String getLine1AlphaTag() {
595        return mActivePhone.getLine1AlphaTag();
596    }
597
598    public void setLine1Number(String alphaTag, String number, Message onComplete) {
599        mActivePhone.setLine1Number(alphaTag, number, onComplete);
600    }
601
602    public String getVoiceMailNumber() {
603        return mActivePhone.getVoiceMailNumber();
604    }
605
606     /** @hide */
607    public int getVoiceMessageCount(){
608        return mActivePhone.getVoiceMessageCount();
609    }
610
611    public String getVoiceMailAlphaTag() {
612        return mActivePhone.getVoiceMailAlphaTag();
613    }
614
615    public void setVoiceMailNumber(String alphaTag,String voiceMailNumber,
616            Message onComplete) {
617        mActivePhone.setVoiceMailNumber(alphaTag, voiceMailNumber, onComplete);
618    }
619
620    public void getCallForwardingOption(int commandInterfaceCFReason,
621            Message onComplete) {
622        mActivePhone.getCallForwardingOption(commandInterfaceCFReason,
623                onComplete);
624    }
625
626    public void setCallForwardingOption(int commandInterfaceCFReason,
627            int commandInterfaceCFAction, String dialingNumber,
628            int timerSeconds, Message onComplete) {
629        mActivePhone.setCallForwardingOption(commandInterfaceCFReason,
630            commandInterfaceCFAction, dialingNumber, timerSeconds, onComplete);
631    }
632
633    public void getOutgoingCallerIdDisplay(Message onComplete) {
634        mActivePhone.getOutgoingCallerIdDisplay(onComplete);
635    }
636
637    public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode,
638            Message onComplete) {
639        mActivePhone.setOutgoingCallerIdDisplay(commandInterfaceCLIRMode,
640                onComplete);
641    }
642
643    public void getCallWaiting(Message onComplete) {
644        mActivePhone.getCallWaiting(onComplete);
645    }
646
647    public void setCallWaiting(boolean enable, Message onComplete) {
648        mActivePhone.setCallWaiting(enable, onComplete);
649    }
650
651    public void getAvailableNetworks(Message response) {
652        mActivePhone.getAvailableNetworks(response);
653    }
654
655    public void setNetworkSelectionModeAutomatic(Message response) {
656        mActivePhone.setNetworkSelectionModeAutomatic(response);
657    }
658
659    public void selectNetworkManually(OperatorInfo network, Message response) {
660        mActivePhone.selectNetworkManually(network, response);
661    }
662
663    public void setPreferredNetworkType(int networkType, Message response) {
664        mActivePhone.setPreferredNetworkType(networkType, response);
665    }
666
667    public void getPreferredNetworkType(Message response) {
668        mActivePhone.getPreferredNetworkType(response);
669    }
670
671    public void getNeighboringCids(Message response) {
672        mActivePhone.getNeighboringCids(response);
673    }
674
675    public void setOnPostDialCharacter(Handler h, int what, Object obj) {
676        mActivePhone.setOnPostDialCharacter(h, what, obj);
677    }
678
679    public void setMute(boolean muted) {
680        mActivePhone.setMute(muted);
681    }
682
683    public boolean getMute() {
684        return mActivePhone.getMute();
685    }
686
687    public void setEchoSuppressionEnabled(boolean enabled) {
688        mActivePhone.setEchoSuppressionEnabled(enabled);
689    }
690
691    public void invokeOemRilRequestRaw(byte[] data, Message response) {
692        mActivePhone.invokeOemRilRequestRaw(data, response);
693    }
694
695    public void invokeOemRilRequestStrings(String[] strings, Message response) {
696        mActivePhone.invokeOemRilRequestStrings(strings, response);
697    }
698
699    public void getDataCallList(Message response) {
700        mActivePhone.getDataCallList(response);
701    }
702
703    public void updateServiceLocation() {
704        mActivePhone.updateServiceLocation();
705    }
706
707    public void enableLocationUpdates() {
708        mActivePhone.enableLocationUpdates();
709    }
710
711    public void disableLocationUpdates() {
712        mActivePhone.disableLocationUpdates();
713    }
714
715    public void setUnitTestMode(boolean f) {
716        mActivePhone.setUnitTestMode(f);
717    }
718
719    public boolean getUnitTestMode() {
720        return mActivePhone.getUnitTestMode();
721    }
722
723    public void setBandMode(int bandMode, Message response) {
724        mActivePhone.setBandMode(bandMode, response);
725    }
726
727    public void queryAvailableBandMode(Message response) {
728        mActivePhone.queryAvailableBandMode(response);
729    }
730
731    public boolean getDataRoamingEnabled() {
732        return mActivePhone.getDataRoamingEnabled();
733    }
734
735    public void setDataRoamingEnabled(boolean enable) {
736        mActivePhone.setDataRoamingEnabled(enable);
737    }
738
739    public void queryCdmaRoamingPreference(Message response) {
740        mActivePhone.queryCdmaRoamingPreference(response);
741    }
742
743    public void setCdmaRoamingPreference(int cdmaRoamingType, Message response) {
744        mActivePhone.setCdmaRoamingPreference(cdmaRoamingType, response);
745    }
746
747    public void setCdmaSubscription(int cdmaSubscriptionType, Message response) {
748        mActivePhone.setCdmaSubscription(cdmaSubscriptionType, response);
749    }
750
751    public SimulatedRadioControl getSimulatedRadioControl() {
752        return mActivePhone.getSimulatedRadioControl();
753    }
754
755    public int enableApnType(String type) {
756        return mActivePhone.enableApnType(type);
757    }
758
759    public int disableApnType(String type) {
760        return mActivePhone.disableApnType(type);
761    }
762
763    public boolean isDataConnectivityPossible() {
764        return mActivePhone.isDataConnectivityPossible(PhoneConstants.APN_TYPE_DEFAULT);
765    }
766
767    public boolean isDataConnectivityPossible(String apnType) {
768        return mActivePhone.isDataConnectivityPossible(apnType);
769    }
770
771    public String getDeviceId() {
772        return mActivePhone.getDeviceId();
773    }
774
775    public String getDeviceSvn() {
776        return mActivePhone.getDeviceSvn();
777    }
778
779    public String getSubscriberId() {
780        return mActivePhone.getSubscriberId();
781    }
782
783    public String getIccSerialNumber() {
784        return mActivePhone.getIccSerialNumber();
785    }
786
787    public String getEsn() {
788        return mActivePhone.getEsn();
789    }
790
791    public String getMeid() {
792        return mActivePhone.getMeid();
793    }
794
795    public String getMsisdn() {
796        return mActivePhone.getMsisdn();
797    }
798
799    public String getImei() {
800        return mActivePhone.getImei();
801    }
802
803    public PhoneSubInfo getPhoneSubInfo(){
804        return mActivePhone.getPhoneSubInfo();
805    }
806
807    public IccSmsInterfaceManager getIccSmsInterfaceManager(){
808        return mActivePhone.getIccSmsInterfaceManager();
809    }
810
811    public IccPhoneBookInterfaceManager getIccPhoneBookInterfaceManager(){
812        return mActivePhone.getIccPhoneBookInterfaceManager();
813    }
814
815    public void setTTYMode(int ttyMode, Message onComplete) {
816        mActivePhone.setTTYMode(ttyMode, onComplete);
817    }
818
819    public void queryTTYMode(Message onComplete) {
820        mActivePhone.queryTTYMode(onComplete);
821    }
822
823    public void activateCellBroadcastSms(int activate, Message response) {
824        mActivePhone.activateCellBroadcastSms(activate, response);
825    }
826
827    public void getCellBroadcastSmsConfig(Message response) {
828        mActivePhone.getCellBroadcastSmsConfig(response);
829    }
830
831    public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response) {
832        mActivePhone.setCellBroadcastSmsConfig(configValuesArray, response);
833    }
834
835    public void notifyDataActivity() {
836         mActivePhone.notifyDataActivity();
837    }
838
839    public void getSmscAddress(Message result) {
840        mActivePhone.getSmscAddress(result);
841    }
842
843    public void setSmscAddress(String address, Message result) {
844        mActivePhone.setSmscAddress(address, result);
845    }
846
847    public int getCdmaEriIconIndex() {
848        return mActivePhone.getCdmaEriIconIndex();
849    }
850
851    public String getCdmaEriText() {
852        return mActivePhone.getCdmaEriText();
853    }
854
855    public int getCdmaEriIconMode() {
856        return mActivePhone.getCdmaEriIconMode();
857    }
858
859    public Phone getActivePhone() {
860        return mActivePhone;
861    }
862
863    public void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete){
864        mActivePhone.sendBurstDtmf(dtmfString, on, off, onComplete);
865    }
866
867    public void exitEmergencyCallbackMode(){
868        mActivePhone.exitEmergencyCallbackMode();
869    }
870
871    public boolean needsOtaServiceProvisioning(){
872        return mActivePhone.needsOtaServiceProvisioning();
873    }
874
875    public boolean isOtaSpNumber(String dialStr){
876        return mActivePhone.isOtaSpNumber(dialStr);
877    }
878
879    public void registerForCallWaiting(Handler h, int what, Object obj){
880        mActivePhone.registerForCallWaiting(h,what,obj);
881    }
882
883    public void unregisterForCallWaiting(Handler h){
884        mActivePhone.unregisterForCallWaiting(h);
885    }
886
887    public void registerForSignalInfo(Handler h, int what, Object obj) {
888        mActivePhone.registerForSignalInfo(h,what,obj);
889    }
890
891    public void unregisterForSignalInfo(Handler h) {
892        mActivePhone.unregisterForSignalInfo(h);
893    }
894
895    public void registerForDisplayInfo(Handler h, int what, Object obj) {
896        mActivePhone.registerForDisplayInfo(h,what,obj);
897    }
898
899    public void unregisterForDisplayInfo(Handler h) {
900        mActivePhone.unregisterForDisplayInfo(h);
901    }
902
903    public void registerForNumberInfo(Handler h, int what, Object obj) {
904        mActivePhone.registerForNumberInfo(h, what, obj);
905    }
906
907    public void unregisterForNumberInfo(Handler h) {
908        mActivePhone.unregisterForNumberInfo(h);
909    }
910
911    public void registerForRedirectedNumberInfo(Handler h, int what, Object obj) {
912        mActivePhone.registerForRedirectedNumberInfo(h, what, obj);
913    }
914
915    public void unregisterForRedirectedNumberInfo(Handler h) {
916        mActivePhone.unregisterForRedirectedNumberInfo(h);
917    }
918
919    public void registerForLineControlInfo(Handler h, int what, Object obj) {
920        mActivePhone.registerForLineControlInfo( h, what, obj);
921    }
922
923    public void unregisterForLineControlInfo(Handler h) {
924        mActivePhone.unregisterForLineControlInfo(h);
925    }
926
927    public void registerFoT53ClirlInfo(Handler h, int what, Object obj) {
928        mActivePhone.registerFoT53ClirlInfo(h, what, obj);
929    }
930
931    public void unregisterForT53ClirInfo(Handler h) {
932        mActivePhone.unregisterForT53ClirInfo(h);
933    }
934
935    public void registerForT53AudioControlInfo(Handler h, int what, Object obj) {
936        mActivePhone.registerForT53AudioControlInfo( h, what, obj);
937    }
938
939    public void unregisterForT53AudioControlInfo(Handler h) {
940        mActivePhone.unregisterForT53AudioControlInfo(h);
941    }
942
943    public void setOnEcbModeExitResponse(Handler h, int what, Object obj){
944        mActivePhone.setOnEcbModeExitResponse(h,what,obj);
945    }
946
947    public void unsetOnEcbModeExitResponse(Handler h){
948        mActivePhone.unsetOnEcbModeExitResponse(h);
949    }
950
951    public boolean isCspPlmnEnabled() {
952        return mActivePhone.isCspPlmnEnabled();
953    }
954
955    public IsimRecords getIsimRecords() {
956        return mActivePhone.getIsimRecords();
957    }
958
959    public void requestIsimAuthentication(String nonce, Message response) {
960        mActivePhone.requestIsimAuthentication(nonce, response);
961    }
962
963    /**
964     * {@inheritDoc}
965     */
966    @Override
967    public int getLteOnCdmaMode() {
968        return mActivePhone.getLteOnCdmaMode();
969    }
970
971    @Override
972    public void setVoiceMessageWaiting(int line, int countWaiting) {
973        mActivePhone.setVoiceMessageWaiting(line, countWaiting);
974    }
975
976    @Override
977    public UsimServiceTable getUsimServiceTable() {
978        return mActivePhone.getUsimServiceTable();
979    }
980
981    public void dispose() {
982        mCommandsInterface.unregisterForOn(this);
983        mCommandsInterface.unregisterForVoiceRadioTechChanged(this);
984        mCommandsInterface.unregisterForRilConnected(this);
985    }
986
987    public void removeReferences() {
988        mActivePhone = null;
989        mCommandsInterface = null;
990    }
991}
992