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