1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package com.android.internal.telephony.cdma; 18 19import android.app.ActivityManagerNative; 20import android.content.Context; 21import android.content.ContentValues; 22import android.content.Intent; 23import android.content.res.Configuration; 24import android.content.SharedPreferences; 25import android.database.SQLException; 26import android.net.Uri; 27import android.os.AsyncResult; 28import android.os.Handler; 29import android.os.Message; 30import android.os.PowerManager; 31import android.os.PowerManager.WakeLock; 32import android.os.Registrant; 33import android.os.RegistrantList; 34import android.os.RemoteException; 35import android.os.SystemProperties; 36import android.preference.PreferenceManager; 37import android.provider.Telephony; 38import android.telephony.CellLocation; 39import android.telephony.PhoneNumberUtils; 40import android.telephony.ServiceState; 41import android.telephony.SignalStrength; 42import android.text.TextUtils; 43import android.util.Log; 44 45import com.android.internal.telephony.Call; 46import com.android.internal.telephony.CallStateException; 47import com.android.internal.telephony.CommandException; 48import com.android.internal.telephony.CommandsInterface; 49import com.android.internal.telephony.Connection; 50import com.android.internal.telephony.DataConnection; 51import com.android.internal.telephony.MccTable; 52import com.android.internal.telephony.IccCard; 53import com.android.internal.telephony.IccException; 54import com.android.internal.telephony.IccFileHandler; 55import com.android.internal.telephony.IccPhoneBookInterfaceManager; 56import com.android.internal.telephony.IccSmsInterfaceManager; 57import com.android.internal.telephony.MmiCode; 58import com.android.internal.telephony.Phone; 59import com.android.internal.telephony.PhoneBase; 60import com.android.internal.telephony.PhoneNotifier; 61import com.android.internal.telephony.PhoneProxy; 62import com.android.internal.telephony.PhoneSubInfo; 63import com.android.internal.telephony.TelephonyIntents; 64import com.android.internal.telephony.TelephonyProperties; 65 66import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA; 67import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC; 68import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY; 69 70import java.util.List; 71 72 73import java.util.regex.Matcher; 74import java.util.regex.Pattern; 75 76/** 77 * {@hide} 78 */ 79public class CDMAPhone extends PhoneBase { 80 static final String LOG_TAG = "CDMA"; 81 private static final boolean DBG = true; 82 83 // Min values used to by needsActivation 84 private static final String UNACTIVATED_MIN2_VALUE = "000000"; 85 private static final String UNACTIVATED_MIN_VALUE = "1111110111"; 86 87 // Default Emergency Callback Mode exit timer 88 private static final int DEFAULT_ECM_EXIT_TIMER_VALUE = 300000; 89 90 static final String VM_COUNT_CDMA = "vm_count_key_cdma"; 91 private static final String VM_NUMBER_CDMA = "vm_number_key_cdma"; 92 private String mVmNumber = null; 93 94 static final int RESTART_ECM_TIMER = 0; // restart Ecm timer 95 static final int CANCEL_ECM_TIMER = 1; // cancel Ecm timer 96 97 // Instance Variables 98 CdmaCallTracker mCT; 99 CdmaSMSDispatcher mSMS; 100 CdmaServiceStateTracker mSST; 101 RuimFileHandler mRuimFileHandler; 102 RuimRecords mRuimRecords; 103 RuimCard mRuimCard; 104 RuimPhoneBookInterfaceManager mRuimPhoneBookInterfaceManager; 105 RuimSmsInterfaceManager mRuimSmsInterfaceManager; 106 PhoneSubInfo mSubInfo; 107 EriManager mEriManager; 108 WakeLock mWakeLock; 109 110 111 // mNvLoadedRegistrants are informed after the EVENT_NV_READY 112 private RegistrantList mNvLoadedRegistrants = new RegistrantList(); 113 114 // mEriFileLoadedRegistrants are informed after the ERI text has been loaded 115 private RegistrantList mEriFileLoadedRegistrants = new RegistrantList(); 116 117 // mEcmTimerResetRegistrants are informed after Ecm timer is canceled or re-started 118 private RegistrantList mEcmTimerResetRegistrants = new RegistrantList(); 119 120 // mEcmExitRespRegistrant is informed after the phone has been exited 121 //the emergency callback mode 122 //keep track of if phone is in emergency callback mode 123 private boolean mIsPhoneInEcmState; 124 private Registrant mEcmExitRespRegistrant; 125 private String mEsn; 126 private String mMeid; 127 // string to define how the carrier specifies its own ota sp number 128 private String mCarrierOtaSpNumSchema; 129 130 // A runnable which is used to automatically exit from Ecm after a period of time. 131 private Runnable mExitEcmRunnable = new Runnable() { 132 public void run() { 133 exitEmergencyCallbackMode(); 134 } 135 }; 136 137 Registrant mPostDialHandler; 138 139 140 // Constructors 141 public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier) { 142 this(context,ci,notifier, false); 143 } 144 145 public CDMAPhone(Context context, CommandsInterface ci, PhoneNotifier notifier, 146 boolean unitTestMode) { 147 super(notifier, context, ci, unitTestMode); 148 149 mCM.setPhoneType(Phone.PHONE_TYPE_CDMA); 150 mCT = new CdmaCallTracker(this); 151 mSST = new CdmaServiceStateTracker (this); 152 mSMS = new CdmaSMSDispatcher(this); 153 mIccFileHandler = new RuimFileHandler(this); 154 mRuimRecords = new RuimRecords(this); 155 mDataConnection = new CdmaDataConnectionTracker (this); 156 mRuimCard = new RuimCard(this); 157 mRuimPhoneBookInterfaceManager = new RuimPhoneBookInterfaceManager(this); 158 mRuimSmsInterfaceManager = new RuimSmsInterfaceManager(this); 159 mSubInfo = new PhoneSubInfo(this); 160 mEriManager = new EriManager(this, context, EriManager.ERI_FROM_XML); 161 162 mCM.registerForAvailable(this, EVENT_RADIO_AVAILABLE, null); 163 mRuimRecords.registerForRecordsLoaded(this, EVENT_RUIM_RECORDS_LOADED, null); 164 mCM.registerForOffOrNotAvailable(this, EVENT_RADIO_OFF_OR_NOT_AVAILABLE, null); 165 mCM.registerForOn(this, EVENT_RADIO_ON, null); 166 mCM.setOnSuppServiceNotification(this, EVENT_SSN, null); 167 mSST.registerForNetworkAttach(this, EVENT_REGISTERED_TO_NETWORK, null); 168 mCM.registerForNVReady(this, EVENT_NV_READY, null); 169 mCM.setEmergencyCallbackMode(this, EVENT_EMERGENCY_CALLBACK_MODE_ENTER, null); 170 171 PowerManager pm 172 = (PowerManager) context.getSystemService(Context.POWER_SERVICE); 173 mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,LOG_TAG); 174 175 //Change the system setting 176 SystemProperties.set(TelephonyProperties.CURRENT_ACTIVE_PHONE, 177 new Integer(Phone.PHONE_TYPE_CDMA).toString()); 178 179 // This is needed to handle phone process crashes 180 String inEcm=SystemProperties.get(TelephonyProperties.PROPERTY_INECM_MODE, "false"); 181 mIsPhoneInEcmState = inEcm.equals("true"); 182 if (mIsPhoneInEcmState) { 183 // Send a message which will invoke handleExitEmergencyCallbackMode 184 mCM.exitEmergencyCallbackMode(obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE)); 185 } 186 187 // get the string that specifies the carrier OTA Sp number 188 mCarrierOtaSpNumSchema = SystemProperties.get( 189 TelephonyProperties.PROPERTY_OTASP_NUM_SCHEMA,""); 190 191 // Sets operator alpha property by retrieving from build-time system property 192 String operatorAlpha = SystemProperties.get("ro.cdma.home.operator.alpha"); 193 setSystemProperty(PROPERTY_ICC_OPERATOR_ALPHA, operatorAlpha); 194 195 // Sets operator numeric property by retrieving from build-time system property 196 String operatorNumeric = SystemProperties.get("ro.cdma.home.operator.numeric"); 197 setSystemProperty(PROPERTY_ICC_OPERATOR_NUMERIC, operatorNumeric); 198 199 // Sets iso country property by retrieving from build-time system property 200 setIsoCountryProperty(operatorNumeric); 201 202 // Sets current entry in the telephony carrier table 203 updateCurrentCarrierInProvider(operatorNumeric); 204 205 // Notify voicemails. 206 notifier.notifyMessageWaitingChanged(this); 207 } 208 209 public void dispose() { 210 synchronized(PhoneProxy.lockForRadioTechnologyChange) { 211 super.dispose(); 212 213 //Unregister from all former registered events 214 mRuimRecords.unregisterForRecordsLoaded(this); //EVENT_RUIM_RECORDS_LOADED 215 mCM.unregisterForAvailable(this); //EVENT_RADIO_AVAILABLE 216 mCM.unregisterForOffOrNotAvailable(this); //EVENT_RADIO_OFF_OR_NOT_AVAILABLE 217 mCM.unregisterForOn(this); //EVENT_RADIO_ON 218 mCM.unregisterForNVReady(this); //EVENT_NV_READY 219 mSST.unregisterForNetworkAttach(this); //EVENT_REGISTERED_TO_NETWORK 220 mCM.unSetOnSuppServiceNotification(this); 221 222 //Force all referenced classes to unregister their former registered events 223 mCT.dispose(); 224 mDataConnection.dispose(); 225 mSST.dispose(); 226 mSMS.dispose(); 227 mIccFileHandler.dispose(); // instance of RuimFileHandler 228 mRuimRecords.dispose(); 229 mRuimCard.dispose(); 230 mRuimPhoneBookInterfaceManager.dispose(); 231 mRuimSmsInterfaceManager.dispose(); 232 mSubInfo.dispose(); 233 mEriManager.dispose(); 234 } 235 } 236 237 public void removeReferences() { 238 this.mRuimPhoneBookInterfaceManager = null; 239 this.mRuimSmsInterfaceManager = null; 240 this.mSMS = null; 241 this.mSubInfo = null; 242 this.mRuimRecords = null; 243 this.mIccFileHandler = null; 244 this.mRuimCard = null; 245 this.mDataConnection = null; 246 this.mCT = null; 247 this.mSST = null; 248 this.mEriManager = null; 249 } 250 251 protected void finalize() { 252 if(DBG) Log.d(LOG_TAG, "CDMAPhone finalized"); 253 if (mWakeLock.isHeld()) { 254 Log.e(LOG_TAG, "UNEXPECTED; mWakeLock is held when finalizing."); 255 mWakeLock.release(); 256 } 257 } 258 259 public ServiceState getServiceState() { 260 return mSST.ss; 261 } 262 263 public Phone.State getState() { 264 return mCT.state; 265 } 266 267 public String getPhoneName() { 268 return "CDMA"; 269 } 270 271 public int getPhoneType() { 272 return Phone.PHONE_TYPE_CDMA; 273 } 274 275 public boolean canTransfer() { 276 Log.e(LOG_TAG, "canTransfer: not possible in CDMA"); 277 return false; 278 } 279 280 public CdmaCall getRingingCall() { 281 return mCT.ringingCall; 282 } 283 284 public void setMute(boolean muted) { 285 mCT.setMute(muted); 286 } 287 288 public boolean getMute() { 289 return mCT.getMute(); 290 } 291 292 public void conference() throws CallStateException { 293 // three way calls in CDMA will be handled by feature codes 294 Log.e(LOG_TAG, "conference: not possible in CDMA"); 295 } 296 297 public void enableEnhancedVoicePrivacy(boolean enable, Message onComplete) { 298 this.mCM.setPreferredVoicePrivacy(enable, onComplete); 299 } 300 301 public void getEnhancedVoicePrivacy(Message onComplete) { 302 this.mCM.getPreferredVoicePrivacy(onComplete); 303 } 304 305 public void clearDisconnected() { 306 mCT.clearDisconnected(); 307 } 308 309 public DataActivityState getDataActivityState() { 310 DataActivityState ret = DataActivityState.NONE; 311 312 if (mSST.getCurrentCdmaDataConnectionState() == ServiceState.STATE_IN_SERVICE) { 313 314 switch (mDataConnection.getActivity()) { 315 case DATAIN: 316 ret = DataActivityState.DATAIN; 317 break; 318 319 case DATAOUT: 320 ret = DataActivityState.DATAOUT; 321 break; 322 323 case DATAINANDOUT: 324 ret = DataActivityState.DATAINANDOUT; 325 break; 326 327 case DORMANT: 328 ret = DataActivityState.DORMANT; 329 break; 330 } 331 } 332 return ret; 333 } 334 335 /*package*/ void 336 notifySignalStrength() { 337 mNotifier.notifySignalStrength(this); 338 } 339 340 public Connection 341 dial (String dialString) throws CallStateException { 342 // Need to make sure dialString gets parsed properly 343 String newDialString = PhoneNumberUtils.stripSeparators(dialString); 344 return mCT.dial(newDialString); 345 } 346 347 public SignalStrength getSignalStrength() { 348 return mSST.mSignalStrength; 349 } 350 351 public boolean 352 getMessageWaitingIndicator() { 353 return (getVoiceMessageCount() > 0); 354 } 355 356 public List<? extends MmiCode> 357 getPendingMmiCodes() { 358 Log.e(LOG_TAG, "method getPendingMmiCodes is NOT supported in CDMA!"); 359 return null; 360 } 361 362 public void registerForSuppServiceNotification( 363 Handler h, int what, Object obj) { 364 Log.e(LOG_TAG, "method registerForSuppServiceNotification is NOT supported in CDMA!"); 365 } 366 367 public CdmaCall getBackgroundCall() { 368 return mCT.backgroundCall; 369 } 370 371 public boolean handleInCallMmiCommands(String dialString) { 372 Log.e(LOG_TAG, "method handleInCallMmiCommands is NOT supported in CDMA!"); 373 return false; 374 } 375 376 public void 377 setNetworkSelectionModeAutomatic(Message response) { 378 Log.e(LOG_TAG, "method setNetworkSelectionModeAutomatic is NOT supported in CDMA!"); 379 } 380 381 public void unregisterForSuppServiceNotification(Handler h) { 382 Log.e(LOG_TAG, "method unregisterForSuppServiceNotification is NOT supported in CDMA!"); 383 } 384 385 public void 386 acceptCall() throws CallStateException { 387 mCT.acceptCall(); 388 } 389 390 public void 391 rejectCall() throws CallStateException { 392 mCT.rejectCall(); 393 } 394 395 public void 396 switchHoldingAndActive() throws CallStateException { 397 mCT.switchWaitingOrHoldingAndActive(); 398 } 399 400 public String getLine1Number() { 401 return mSST.getMdnNumber(); 402 } 403 404 public String getCdmaPrlVersion(){ 405 return mSST.getPrlVersion(); 406 } 407 408 public String getCdmaMin() { 409 return mSST.getCdmaMin(); 410 } 411 412 public boolean isMinInfoReady() { 413 return mSST.isMinInfoReady(); 414 } 415 416 public void getCallWaiting(Message onComplete) { 417 mCM.queryCallWaiting(CommandsInterface.SERVICE_CLASS_VOICE, onComplete); 418 } 419 420 public void 421 setRadioPower(boolean power) { 422 mSST.setRadioPower(power); 423 } 424 425 public String getEsn() { 426 return mEsn; 427 } 428 429 public String getMeid() { 430 return mMeid; 431 } 432 433 //returns MEID or ESN in CDMA 434 public String getDeviceId() { 435 String id = getMeid(); 436 if ((id == null) || id.matches("^0*$")) { 437 Log.d(LOG_TAG, "getDeviceId(): MEID is not initialized use ESN"); 438 id = getEsn(); 439 } 440 return id; 441 } 442 443 public String getDeviceSvn() { 444 Log.d(LOG_TAG, "getDeviceSvn(): return 0"); 445 return "0"; 446 } 447 448 public String getSubscriberId() { 449 return mSST.getImsi(); 450 } 451 452 public boolean canConference() { 453 Log.e(LOG_TAG, "canConference: not possible in CDMA"); 454 return false; 455 } 456 457 public CellLocation getCellLocation() { 458 return mSST.cellLoc; 459 } 460 461 public boolean disableDataConnectivity() { 462 return mDataConnection.setDataEnabled(false); 463 } 464 465 public CdmaCall getForegroundCall() { 466 return mCT.foregroundCall; 467 } 468 469 public void 470 selectNetworkManually(com.android.internal.telephony.gsm.NetworkInfo network, 471 Message response) { 472 Log.e(LOG_TAG, "selectNetworkManually: not possible in CDMA"); 473 } 474 475 public void setOnPostDialCharacter(Handler h, int what, Object obj) { 476 mPostDialHandler = new Registrant(h, what, obj); 477 } 478 479 public boolean handlePinMmi(String dialString) { 480 Log.e(LOG_TAG, "method handlePinMmi is NOT supported in CDMA!"); 481 return false; 482 } 483 484 public boolean isDataConnectivityPossible() { 485 boolean noData = mDataConnection.getDataEnabled() && 486 getDataConnectionState() == DataState.DISCONNECTED; 487 return !noData && getIccCard().getState() == IccCard.State.READY && 488 getServiceState().getState() == ServiceState.STATE_IN_SERVICE && 489 (mDataConnection.getDataOnRoamingEnabled() || !getServiceState().getRoaming()); 490 } 491 492 public void setLine1Number(String alphaTag, String number, Message onComplete) { 493 Log.e(LOG_TAG, "setLine1Number: not possible in CDMA"); 494 } 495 496 public IccCard getIccCard() { 497 return mRuimCard; 498 } 499 500 public String getIccSerialNumber() { 501 return mRuimRecords.iccid; 502 } 503 504 public void setCallWaiting(boolean enable, Message onComplete) { 505 Log.e(LOG_TAG, "method setCallWaiting is NOT supported in CDMA!"); 506 } 507 508 public void updateServiceLocation() { 509 mSST.enableSingleLocationUpdate(); 510 } 511 512 public void setDataRoamingEnabled(boolean enable) { 513 mDataConnection.setDataOnRoamingEnabled(enable); 514 } 515 516 public void registerForCdmaOtaStatusChange(Handler h, int what, Object obj) { 517 mCM.registerForCdmaOtaProvision(h, what, obj); 518 } 519 520 public void unregisterForCdmaOtaStatusChange(Handler h) { 521 mCM.unregisterForCdmaOtaProvision(h); 522 } 523 524 public void registerForSubscriptionInfoReady(Handler h, int what, Object obj) { 525 mSST.registerForSubscriptionInfoReady(h, what, obj); 526 } 527 528 public void unregisterForSubscriptionInfoReady(Handler h) { 529 mSST.unregisterForSubscriptionInfoReady(h); 530 } 531 532 public void setOnEcbModeExitResponse(Handler h, int what, Object obj) { 533 mEcmExitRespRegistrant = new Registrant (h, what, obj); 534 } 535 536 public void unsetOnEcbModeExitResponse(Handler h) { 537 mEcmExitRespRegistrant.clear(); 538 } 539 540 public void registerForCallWaiting(Handler h, int what, Object obj) { 541 mCT.registerForCallWaiting(h, what, obj); 542 } 543 544 public void unregisterForCallWaiting(Handler h) { 545 mCT.unregisterForCallWaiting(h); 546 } 547 548 public void 549 getNeighboringCids(Message response) { 550 /* 551 * This is currently not implemented. At least as of June 552 * 2009, there is no neighbor cell information available for 553 * CDMA because some party is resisting making this 554 * information readily available. Consequently, calling this 555 * function can have no useful effect. This situation may 556 * (and hopefully will) change in the future. 557 */ 558 if (response != null) { 559 CommandException ce = new CommandException( 560 CommandException.Error.REQUEST_NOT_SUPPORTED); 561 AsyncResult.forMessage(response).exception = ce; 562 response.sendToTarget(); 563 } 564 } 565 566 public DataState getDataConnectionState() { 567 DataState ret = DataState.DISCONNECTED; 568 569 if (mSST == null) { 570 // Radio Technology Change is ongoning, dispose() and removeReferences() have 571 // already been called 572 573 ret = DataState.DISCONNECTED; 574 } else if (mSST.getCurrentCdmaDataConnectionState() != ServiceState.STATE_IN_SERVICE) { 575 // If we're out of service, open TCP sockets may still work 576 // but no data will flow 577 ret = DataState.DISCONNECTED; 578 } else { 579 switch (mDataConnection.getState()) { 580 case FAILED: 581 case IDLE: 582 ret = DataState.DISCONNECTED; 583 break; 584 585 case CONNECTED: 586 case DISCONNECTING: 587 if ( mCT.state != Phone.State.IDLE 588 && !mSST.isConcurrentVoiceAndData()) { 589 ret = DataState.SUSPENDED; 590 } else { 591 ret = DataState.CONNECTED; 592 } 593 break; 594 595 case INITING: 596 case CONNECTING: 597 case SCANNING: 598 ret = DataState.CONNECTING; 599 break; 600 } 601 } 602 603 return ret; 604 } 605 606 public void sendUssdResponse(String ussdMessge) { 607 Log.e(LOG_TAG, "sendUssdResponse: not possible in CDMA"); 608 } 609 610 public void sendDtmf(char c) { 611 if (!PhoneNumberUtils.is12Key(c)) { 612 Log.e(LOG_TAG, 613 "sendDtmf called with invalid character '" + c + "'"); 614 } else { 615 if (mCT.state == Phone.State.OFFHOOK) { 616 mCM.sendDtmf(c, null); 617 } 618 } 619 } 620 621 public void startDtmf(char c) { 622 if (!PhoneNumberUtils.is12Key(c)) { 623 Log.e(LOG_TAG, 624 "startDtmf called with invalid character '" + c + "'"); 625 } else { 626 mCM.startDtmf(c, null); 627 } 628 } 629 630 public void stopDtmf() { 631 mCM.stopDtmf(null); 632 } 633 634 public void sendBurstDtmf(String dtmfString, int on, int off, Message onComplete) { 635 boolean check = true; 636 for (int itr = 0;itr < dtmfString.length(); itr++) { 637 if (!PhoneNumberUtils.is12Key(dtmfString.charAt(itr))) { 638 Log.e(LOG_TAG, 639 "sendDtmf called with invalid character '" + dtmfString.charAt(itr)+ "'"); 640 check = false; 641 break; 642 } 643 } 644 if ((mCT.state == Phone.State.OFFHOOK)&&(check)) { 645 mCM.sendBurstDtmf(dtmfString, on, off, onComplete); 646 } 647 } 648 649 public void getAvailableNetworks(Message response) { 650 Log.e(LOG_TAG, "getAvailableNetworks: not possible in CDMA"); 651 } 652 653 public void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete) { 654 Log.e(LOG_TAG, "setOutgoingCallerIdDisplay: not possible in CDMA"); 655 } 656 657 public void enableLocationUpdates() { 658 mSST.enableLocationUpdates(); 659 } 660 661 public void disableLocationUpdates() { 662 mSST.disableLocationUpdates(); 663 } 664 665 public void getDataCallList(Message response) { 666 mCM.getDataCallList(response); 667 } 668 669 public boolean getDataRoamingEnabled() { 670 return mDataConnection.getDataOnRoamingEnabled(); 671 } 672 673 public List<DataConnection> getCurrentDataConnectionList () { 674 return mDataConnection.getAllDataConnections(); 675 } 676 677 public void setVoiceMailNumber(String alphaTag, 678 String voiceMailNumber, 679 Message onComplete) { 680 Message resp; 681 mVmNumber = voiceMailNumber; 682 resp = obtainMessage(EVENT_SET_VM_NUMBER_DONE, 0, 0, onComplete); 683 mRuimRecords.setVoiceMailNumber(alphaTag, mVmNumber, resp); 684 } 685 686 public String getVoiceMailNumber() { 687 String number = null; 688 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 689 // TODO: The default value of voicemail number should be read from a system property 690 number = sp.getString(VM_NUMBER_CDMA, "*86"); 691 return number; 692 } 693 694 /* Returns Number of Voicemails 695 * @hide 696 */ 697 public int getVoiceMessageCount() { 698 int voicemailCount = mRuimRecords.getVoiceMessageCount(); 699 // If mRuimRecords.getVoiceMessageCount returns zero, then there is possibility 700 // that phone was power cycled and would have lost the voicemail count. 701 // So get the count from preferences. 702 if (voicemailCount == 0) { 703 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 704 voicemailCount = sp.getInt(VM_COUNT_CDMA, 0); 705 } 706 return voicemailCount; 707 } 708 709 public String getVoiceMailAlphaTag() { 710 // TODO: Where can we get this value has to be clarified with QC. 711 String ret = "";//TODO: Remove = "", if we know where to get this value. 712 713 //ret = mSIMRecords.getVoiceMailAlphaTag(); 714 715 if (ret == null || ret.length() == 0) { 716 return mContext.getText( 717 com.android.internal.R.string.defaultVoiceMailAlphaTag).toString(); 718 } 719 720 return ret; 721 } 722 723 public boolean enableDataConnectivity() { 724 725 // block data activities when phone is in emergency callback mode 726 if (mIsPhoneInEcmState) { 727 Intent intent = new Intent(TelephonyIntents.ACTION_SHOW_NOTICE_ECM_BLOCK_OTHERS); 728 ActivityManagerNative.broadcastStickyIntent(intent, null); 729 return false; 730 } else if ((mCT.state == Phone.State.OFFHOOK) && mCT.isInEmergencyCall()) { 731 // Do not allow data call to be enabled when emergency call is going on 732 return false; 733 } else { 734 return mDataConnection.setDataEnabled(true); 735 } 736 } 737 738 public boolean getIccRecordsLoaded() { 739 return mRuimRecords.getRecordsLoaded(); 740 } 741 742 public void getCallForwardingOption(int commandInterfaceCFReason, Message onComplete) { 743 Log.e(LOG_TAG, "getCallForwardingOption: not possible in CDMA"); 744 } 745 746 public void setCallForwardingOption(int commandInterfaceCFAction, 747 int commandInterfaceCFReason, 748 String dialingNumber, 749 int timerSeconds, 750 Message onComplete) { 751 Log.e(LOG_TAG, "setCallForwardingOption: not possible in CDMA"); 752 } 753 754 public void 755 getOutgoingCallerIdDisplay(Message onComplete) { 756 Log.e(LOG_TAG, "getOutgoingCallerIdDisplay: not possible in CDMA"); 757 } 758 759 public boolean 760 getCallForwardingIndicator() { 761 Log.e(LOG_TAG, "getCallForwardingIndicator: not possible in CDMA"); 762 return false; 763 } 764 765 public void explicitCallTransfer() { 766 Log.e(LOG_TAG, "explicitCallTransfer: not possible in CDMA"); 767 } 768 769 public String getLine1AlphaTag() { 770 Log.e(LOG_TAG, "getLine1AlphaTag: not possible in CDMA"); 771 return null; 772 } 773 774 /** 775 * Notify any interested party of a Phone state change {@link Phone.State} 776 */ 777 /*package*/ void notifyPhoneStateChanged() { 778 mNotifier.notifyPhoneState(this); 779 } 780 781 /** 782 * Notify registrants of a change in the call state. This notifies changes in {@link Call.State} 783 * Use this when changes in the precise call state are needed, else use notifyPhoneStateChanged. 784 */ 785 /*package*/ void notifyPreciseCallStateChanged() { 786 /* we'd love it if this was package-scoped*/ 787 super.notifyPreciseCallStateChangedP(); 788 } 789 790 void notifyServiceStateChanged(ServiceState ss) { 791 super.notifyServiceStateChangedP(ss); 792 } 793 794 void notifyLocationChanged() { 795 mNotifier.notifyCellLocation(this); 796 } 797 798 /*package*/ void notifyNewRingingConnection(Connection c) { 799 /* we'd love it if this was package-scoped*/ 800 super.notifyNewRingingConnectionP(c); 801 } 802 803 /*package*/ void notifyDisconnect(Connection cn) { 804 mDisconnectRegistrants.notifyResult(cn); 805 } 806 807 void notifyUnknownConnection() { 808 mUnknownConnectionRegistrants.notifyResult(this); 809 } 810 811 void sendEmergencyCallbackModeChange(){ 812 //Send an Intent 813 Intent intent = new Intent(TelephonyIntents.ACTION_EMERGENCY_CALLBACK_MODE_CHANGED); 814 intent.putExtra(PHONE_IN_ECM_STATE, mIsPhoneInEcmState); 815 ActivityManagerNative.broadcastStickyIntent(intent,null); 816 if (DBG) Log.d(LOG_TAG, "sendEmergencyCallbackModeChange"); 817 } 818 819 /*package*/ void 820 updateMessageWaitingIndicator(boolean mwi) { 821 // this also calls notifyMessageWaitingIndicator() 822 mRuimRecords.setVoiceMessageWaiting(1, mwi ? -1 : 0); 823 } 824 825 /* This function is overloaded to send number of voicemails instead of sending true/false */ 826 /*package*/ void 827 updateMessageWaitingIndicator(int mwi) { 828 mRuimRecords.setVoiceMessageWaiting(1, mwi); 829 } 830 831 /** 832 * Returns true if CDMA OTA Service Provisioning needs to be performed. 833 */ 834 /* package */ boolean 835 needsOtaServiceProvisioning() { 836 String cdmaMin = getCdmaMin(); 837 boolean needsProvisioning; 838 if (cdmaMin == null || (cdmaMin.length() < 6)) { 839 if (DBG) Log.d(LOG_TAG, "needsOtaServiceProvisioning: illegal cdmaMin='" 840 + cdmaMin + "' assume provisioning needed."); 841 needsProvisioning = true; 842 } else { 843 needsProvisioning = (cdmaMin.equals(UNACTIVATED_MIN_VALUE) 844 || cdmaMin.substring(0,6).equals(UNACTIVATED_MIN2_VALUE)) 845 || SystemProperties.getBoolean("test_cdma_setup", false); 846 } 847 if (DBG) Log.d(LOG_TAG, "needsOtaServiceProvisioning: ret=" + needsProvisioning); 848 return needsProvisioning; 849 } 850 851 @Override 852 public void exitEmergencyCallbackMode() { 853 if (mWakeLock.isHeld()) { 854 mWakeLock.release(); 855 } 856 // Send a message which will invoke handleExitEmergencyCallbackMode 857 mCM.exitEmergencyCallbackMode(obtainMessage(EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE)); 858 } 859 860 private void handleEnterEmergencyCallbackMode(Message msg) { 861 if (DBG) { 862 Log.d(LOG_TAG, "handleEnterEmergencyCallbackMode,mIsPhoneInEcmState= " 863 + mIsPhoneInEcmState); 864 } 865 // if phone is not in Ecm mode, and it's changed to Ecm mode 866 if (mIsPhoneInEcmState == false) { 867 mIsPhoneInEcmState = true; 868 // notify change 869 sendEmergencyCallbackModeChange(); 870 setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE, "true"); 871 872 // Post this runnable so we will automatically exit 873 // if no one invokes exitEmergencyCallbackMode() directly. 874 long delayInMillis = SystemProperties.getLong( 875 TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); 876 postDelayed(mExitEcmRunnable, delayInMillis); 877 // We don't want to go to sleep while in Ecm 878 mWakeLock.acquire(); 879 } 880 } 881 882 private void handleExitEmergencyCallbackMode(Message msg) { 883 AsyncResult ar = (AsyncResult)msg.obj; 884 if (DBG) { 885 Log.d(LOG_TAG, "handleExitEmergencyCallbackMode,ar.exception , mIsPhoneInEcmState " 886 + ar.exception + mIsPhoneInEcmState); 887 } 888 // Remove pending exit Ecm runnable, if any 889 removeCallbacks(mExitEcmRunnable); 890 891 if (mEcmExitRespRegistrant != null) { 892 mEcmExitRespRegistrant.notifyRegistrant(ar); 893 } 894 // if exiting ecm success 895 if (ar.exception == null) { 896 if (mIsPhoneInEcmState) { 897 mIsPhoneInEcmState = false; 898 setSystemProperty(TelephonyProperties.PROPERTY_INECM_MODE, "false"); 899 } 900 // send an Intent 901 sendEmergencyCallbackModeChange(); 902 // Re-initiate data connection 903 mDataConnection.setDataEnabled(true); 904 } 905 } 906 907 /** 908 * Handle to cancel or restart Ecm timer in emergency call back mode 909 * if action is CANCEL_ECM_TIMER, cancel Ecm timer and notify apps the timer is canceled; 910 * otherwise, restart Ecm timer and notify apps the timer is restarted. 911 */ 912 void handleTimerInEmergencyCallbackMode(int action) { 913 switch(action) { 914 case CANCEL_ECM_TIMER: 915 removeCallbacks(mExitEcmRunnable); 916 mEcmTimerResetRegistrants.notifyResult(new Boolean(true)); 917 break; 918 case RESTART_ECM_TIMER: 919 long delayInMillis = SystemProperties.getLong( 920 TelephonyProperties.PROPERTY_ECM_EXIT_TIMER, DEFAULT_ECM_EXIT_TIMER_VALUE); 921 postDelayed(mExitEcmRunnable, delayInMillis); 922 mEcmTimerResetRegistrants.notifyResult(new Boolean(false)); 923 break; 924 default: 925 Log.e(LOG_TAG, "handleTimerInEmergencyCallbackMode, unsupported action " + action); 926 } 927 } 928 929 /** 930 * Registration point for Ecm timer reset 931 * @param h handler to notify 932 * @param what User-defined message code 933 * @param obj placed in Message.obj 934 */ 935 public void registerForEcmTimerReset(Handler h, int what, Object obj) { 936 mEcmTimerResetRegistrants.addUnique(h, what, obj); 937 } 938 939 public void unregisterForEcmTimerReset(Handler h) { 940 mEcmTimerResetRegistrants.remove(h); 941 } 942 943 @Override 944 public void handleMessage(Message msg) { 945 AsyncResult ar; 946 Message onComplete; 947 948 switch(msg.what) { 949 case EVENT_RADIO_AVAILABLE: { 950 mCM.getBasebandVersion(obtainMessage(EVENT_GET_BASEBAND_VERSION_DONE)); 951 952 mCM.getDeviceIdentity(obtainMessage(EVENT_GET_DEVICE_IDENTITY_DONE)); 953 } 954 break; 955 956 case EVENT_GET_BASEBAND_VERSION_DONE:{ 957 ar = (AsyncResult)msg.obj; 958 959 if (ar.exception != null) { 960 break; 961 } 962 963 if (DBG) Log.d(LOG_TAG, "Baseband version: " + ar.result); 964 setSystemProperty(TelephonyProperties.PROPERTY_BASEBAND_VERSION, (String)ar.result); 965 } 966 break; 967 968 case EVENT_GET_DEVICE_IDENTITY_DONE:{ 969 ar = (AsyncResult)msg.obj; 970 971 if (ar.exception != null) { 972 break; 973 } 974 String[] respId = (String[])ar.result; 975 mEsn = respId[2]; 976 mMeid = respId[3]; 977 } 978 break; 979 980 case EVENT_EMERGENCY_CALLBACK_MODE_ENTER:{ 981 handleEnterEmergencyCallbackMode(msg); 982 } 983 break; 984 985 case EVENT_EXIT_EMERGENCY_CALLBACK_RESPONSE:{ 986 handleExitEmergencyCallbackMode(msg); 987 } 988 break; 989 990 case EVENT_RUIM_RECORDS_LOADED:{ 991 Log.d(LOG_TAG, "Event EVENT_RUIM_RECORDS_LOADED Received"); 992 } 993 break; 994 995 case EVENT_RADIO_OFF_OR_NOT_AVAILABLE:{ 996 Log.d(LOG_TAG, "Event EVENT_RADIO_OFF_OR_NOT_AVAILABLE Received"); 997 } 998 break; 999 1000 case EVENT_RADIO_ON:{ 1001 Log.d(LOG_TAG, "Event EVENT_RADIO_ON Received"); 1002 } 1003 break; 1004 1005 case EVENT_SSN:{ 1006 Log.d(LOG_TAG, "Event EVENT_SSN Received"); 1007 } 1008 break; 1009 1010 case EVENT_REGISTERED_TO_NETWORK:{ 1011 Log.d(LOG_TAG, "Event EVENT_REGISTERED_TO_NETWORK Received"); 1012 } 1013 break; 1014 1015 case EVENT_NV_READY:{ 1016 Log.d(LOG_TAG, "Event EVENT_NV_READY Received"); 1017 //Inform the Service State Tracker 1018 mEriManager.loadEriFile(); 1019 mNvLoadedRegistrants.notifyRegistrants(); 1020 if(mEriManager.isEriFileLoaded()) { 1021 // when the ERI file is loaded 1022 Log.d(LOG_TAG, "ERI read, notify registrants"); 1023 mEriFileLoadedRegistrants.notifyRegistrants(); 1024 } 1025 } 1026 break; 1027 1028 case EVENT_SET_VM_NUMBER_DONE:{ 1029 ar = (AsyncResult)msg.obj; 1030 if (IccException.class.isInstance(ar.exception)) { 1031 storeVoiceMailNumber(mVmNumber); 1032 ar.exception = null; 1033 } 1034 onComplete = (Message) ar.userObj; 1035 if (onComplete != null) { 1036 AsyncResult.forMessage(onComplete, ar.result, ar.exception); 1037 onComplete.sendToTarget(); 1038 } 1039 } 1040 break; 1041 1042 default:{ 1043 super.handleMessage(msg); 1044 } 1045 } 1046 } 1047 1048 /** 1049 * Retrieves the PhoneSubInfo of the CDMAPhone 1050 */ 1051 public PhoneSubInfo getPhoneSubInfo() { 1052 return mSubInfo; 1053 } 1054 1055 /** 1056 * Retrieves the IccSmsInterfaceManager of the CDMAPhone 1057 */ 1058 public IccSmsInterfaceManager getIccSmsInterfaceManager() { 1059 return mRuimSmsInterfaceManager; 1060 } 1061 1062 /** 1063 * Retrieves the IccPhoneBookInterfaceManager of the CDMAPhone 1064 */ 1065 public IccPhoneBookInterfaceManager getIccPhoneBookInterfaceManager() { 1066 return mRuimPhoneBookInterfaceManager; 1067 } 1068 1069 public void registerForNvLoaded(Handler h, int what, Object obj) { 1070 Registrant r = new Registrant (h, what, obj); 1071 mNvLoadedRegistrants.add(r); 1072 } 1073 1074 public void unregisterForNvLoaded(Handler h) { 1075 mNvLoadedRegistrants.remove(h); 1076 } 1077 1078 public void registerForEriFileLoaded(Handler h, int what, Object obj) { 1079 Registrant r = new Registrant (h, what, obj); 1080 mEriFileLoadedRegistrants.add(r); 1081 } 1082 1083 public void unregisterForEriFileLoaded(Handler h) { 1084 mEriFileLoadedRegistrants.remove(h); 1085 } 1086 1087 // override for allowing access from other classes of this package 1088 /** 1089 * {@inheritDoc} 1090 */ 1091 public final void setSystemProperty(String property, String value) { 1092 super.setSystemProperty(property, value); 1093 } 1094 1095 /** 1096 * {@inheritDoc} 1097 */ 1098 public IccFileHandler getIccFileHandler() { 1099 return this.mIccFileHandler; 1100 } 1101 1102 /** 1103 * Set the TTY mode of the CDMAPhone 1104 */ 1105 public void setTTYMode(int ttyMode, Message onComplete) { 1106 this.mCM.setTTYMode(ttyMode, onComplete); 1107 } 1108 1109 /** 1110 * Queries the TTY mode of the CDMAPhone 1111 */ 1112 public void queryTTYMode(Message onComplete) { 1113 this.mCM.queryTTYMode(onComplete); 1114 } 1115 1116 /** 1117 * Activate or deactivate cell broadcast SMS. 1118 * 1119 * @param activate 0 = activate, 1 = deactivate 1120 * @param response Callback message is empty on completion 1121 */ 1122 public void activateCellBroadcastSms(int activate, Message response) { 1123 mSMS.activateCellBroadcastSms(activate, response); 1124 } 1125 1126 /** 1127 * Query the current configuration of cdma cell broadcast SMS. 1128 * 1129 * @param response Callback message is empty on completion 1130 */ 1131 public void getCellBroadcastSmsConfig(Message response) { 1132 mSMS.getCellBroadcastSmsConfig(response); 1133 } 1134 1135 /** 1136 * Configure cdma cell broadcast SMS. 1137 * 1138 * @param response Callback message is empty on completion 1139 */ 1140 public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response) { 1141 mSMS.setCellBroadcastConfig(configValuesArray, response); 1142 } 1143 1144 private static final String IS683A_FEATURE_CODE = "*228"; 1145 private static final int IS683A_FEATURE_CODE_NUM_DIGITS = 4; 1146 private static final int IS683A_SYS_SEL_CODE_NUM_DIGITS = 2; 1147 private static final int IS683A_SYS_SEL_CODE_OFFSET = 4; 1148 1149 private static final int IS683_CONST_800MHZ_A_BAND = 0; 1150 private static final int IS683_CONST_800MHZ_B_BAND = 1; 1151 private static final int IS683_CONST_1900MHZ_A_BLOCK = 2; 1152 private static final int IS683_CONST_1900MHZ_B_BLOCK = 3; 1153 private static final int IS683_CONST_1900MHZ_C_BLOCK = 4; 1154 private static final int IS683_CONST_1900MHZ_D_BLOCK = 5; 1155 private static final int IS683_CONST_1900MHZ_E_BLOCK = 6; 1156 private static final int IS683_CONST_1900MHZ_F_BLOCK = 7; 1157 private static final int INVALID_SYSTEM_SELECTION_CODE = -1; 1158 1159 private boolean isIs683OtaSpDialStr(String dialStr) { 1160 int sysSelCodeInt; 1161 boolean isOtaspDialString = false; 1162 int dialStrLen = dialStr.length(); 1163 1164 if (dialStrLen == IS683A_FEATURE_CODE_NUM_DIGITS) { 1165 if (dialStr.equals(IS683A_FEATURE_CODE)) { 1166 isOtaspDialString = true; 1167 } 1168 } else { 1169 sysSelCodeInt = extractSelCodeFromOtaSpNum(dialStr); 1170 switch (sysSelCodeInt) { 1171 case IS683_CONST_800MHZ_A_BAND: 1172 case IS683_CONST_800MHZ_B_BAND: 1173 case IS683_CONST_1900MHZ_A_BLOCK: 1174 case IS683_CONST_1900MHZ_B_BLOCK: 1175 case IS683_CONST_1900MHZ_C_BLOCK: 1176 case IS683_CONST_1900MHZ_D_BLOCK: 1177 case IS683_CONST_1900MHZ_E_BLOCK: 1178 case IS683_CONST_1900MHZ_F_BLOCK: 1179 isOtaspDialString = true; 1180 break; 1181 default: 1182 break; 1183 } 1184 } 1185 return isOtaspDialString; 1186 } 1187 /** 1188 * This function extracts the system selection code from the dial string. 1189 */ 1190 private int extractSelCodeFromOtaSpNum(String dialStr) { 1191 int dialStrLen = dialStr.length(); 1192 int sysSelCodeInt = INVALID_SYSTEM_SELECTION_CODE; 1193 1194 if ((dialStr.regionMatches(0, IS683A_FEATURE_CODE, 1195 0, IS683A_FEATURE_CODE_NUM_DIGITS)) && 1196 (dialStrLen >= (IS683A_FEATURE_CODE_NUM_DIGITS + 1197 IS683A_SYS_SEL_CODE_NUM_DIGITS))) { 1198 // Since we checked the condition above, the system selection code 1199 // extracted from dialStr will not cause any exception 1200 sysSelCodeInt = Integer.parseInt ( 1201 dialStr.substring (IS683A_FEATURE_CODE_NUM_DIGITS, 1202 IS683A_FEATURE_CODE_NUM_DIGITS + IS683A_SYS_SEL_CODE_NUM_DIGITS)); 1203 } 1204 if (DBG) Log.d(LOG_TAG, "extractSelCodeFromOtaSpNum " + sysSelCodeInt); 1205 return sysSelCodeInt; 1206 } 1207 1208 /** 1209 * This function checks if the system selection code extracted from 1210 * the dial string "sysSelCodeInt' is the system selection code specified 1211 * in the carrier ota sp number schema "sch". 1212 */ 1213 private boolean 1214 checkOtaSpNumBasedOnSysSelCode (int sysSelCodeInt, String sch[]) { 1215 boolean isOtaSpNum = false; 1216 try { 1217 // Get how many number of system selection code ranges 1218 int selRc = Integer.parseInt((String)sch[1]); 1219 for (int i = 0; i < selRc; i++) { 1220 if (!TextUtils.isEmpty(sch[i+2]) && !TextUtils.isEmpty(sch[i+3])) { 1221 int selMin = Integer.parseInt((String)sch[i+2]); 1222 int selMax = Integer.parseInt((String)sch[i+3]); 1223 // Check if the selection code extracted from the dial string falls 1224 // within any of the range pairs specified in the schema. 1225 if ((sysSelCodeInt >= selMin) && (sysSelCodeInt <= selMax)) { 1226 isOtaSpNum = true; 1227 break; 1228 } 1229 } 1230 } 1231 } catch (NumberFormatException ex) { 1232 // If the carrier ota sp number schema is not correct, we still allow dial 1233 // and only log the error: 1234 Log.e(LOG_TAG, "checkOtaSpNumBasedOnSysSelCode, error", ex); 1235 } 1236 return isOtaSpNum; 1237 } 1238 1239 // Define the pattern/format for carrier specified OTASP number schema. 1240 // It separates by comma and/or whitespace. 1241 private static Pattern pOtaSpNumSchema = Pattern.compile("[,\\s]+"); 1242 1243 /** 1244 * The following function checks if a dial string is a carrier specified 1245 * OTASP number or not by checking against the OTASP number schema stored 1246 * in PROPERTY_OTASP_NUM_SCHEMA. 1247 * 1248 * Currently, there are 2 schemas for carriers to specify the OTASP number: 1249 * 1) Use system selection code: 1250 * The schema is: 1251 * SELC,the # of code pairs,min1,max1,min2,max2,... 1252 * e.g "SELC,3,10,20,30,40,60,70" indicates that there are 3 pairs of 1253 * selection codes, and they are {10,20}, {30,40} and {60,70} respectively. 1254 * 1255 * 2) Use feature code: 1256 * The schema is: 1257 * "FC,length of feature code,feature code". 1258 * e.g "FC,2,*2" indicates that the length of the feature code is 2, 1259 * and the code itself is "*2". 1260 */ 1261 private boolean isCarrierOtaSpNum(String dialStr) { 1262 boolean isOtaSpNum = false; 1263 int sysSelCodeInt = extractSelCodeFromOtaSpNum(dialStr); 1264 if (sysSelCodeInt == INVALID_SYSTEM_SELECTION_CODE) { 1265 return isOtaSpNum; 1266 } 1267 // mCarrierOtaSpNumSchema is retrieved from PROPERTY_OTASP_NUM_SCHEMA: 1268 if (!TextUtils.isEmpty(mCarrierOtaSpNumSchema)) { 1269 Matcher m = pOtaSpNumSchema.matcher(mCarrierOtaSpNumSchema); 1270 if (DBG) { 1271 Log.d(LOG_TAG, "isCarrierOtaSpNum,schema" + mCarrierOtaSpNumSchema); 1272 } 1273 1274 if (m.find()) { 1275 String sch[] = pOtaSpNumSchema.split(mCarrierOtaSpNumSchema); 1276 // If carrier uses system selection code mechanism 1277 if (!TextUtils.isEmpty(sch[0]) && sch[0].equals("SELC")) { 1278 if (sysSelCodeInt!=INVALID_SYSTEM_SELECTION_CODE) { 1279 isOtaSpNum=checkOtaSpNumBasedOnSysSelCode(sysSelCodeInt,sch); 1280 } else { 1281 if (DBG) { 1282 Log.d(LOG_TAG, "isCarrierOtaSpNum,sysSelCodeInt is invalid"); 1283 } 1284 } 1285 } else if (!TextUtils.isEmpty(sch[0]) && sch[0].equals("FC")) { 1286 int fcLen = Integer.parseInt((String)sch[1]); 1287 String fc = (String)sch[2]; 1288 if (dialStr.regionMatches(0,fc,0,fcLen)) { 1289 isOtaSpNum = true; 1290 } else { 1291 if (DBG) Log.d(LOG_TAG, "isCarrierOtaSpNum,not otasp number"); 1292 } 1293 } else { 1294 if (DBG) { 1295 Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema not supported" + sch[0]); 1296 } 1297 } 1298 } else { 1299 if (DBG) { 1300 Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern not right" + 1301 mCarrierOtaSpNumSchema); 1302 } 1303 } 1304 } else { 1305 if (DBG) Log.d(LOG_TAG, "isCarrierOtaSpNum,ota schema pattern empty"); 1306 } 1307 return isOtaSpNum; 1308 } 1309 1310 /** 1311 * isOTASPNumber: checks a given number against the IS-683A OTASP dial string and carrier 1312 * OTASP dial string. 1313 * 1314 * @param dialStr the number to look up. 1315 * @return true if the number is in IS-683A OTASP dial string or carrier OTASP dial string 1316 */ 1317 @Override 1318 public boolean isOtaSpNumber(String dialStr){ 1319 boolean isOtaSpNum = false; 1320 String dialableStr = PhoneNumberUtils.extractNetworkPortionAlt(dialStr); 1321 if (dialableStr != null) { 1322 isOtaSpNum = isIs683OtaSpDialStr(dialableStr); 1323 if (isOtaSpNum == false) { 1324 isOtaSpNum = isCarrierOtaSpNum(dialableStr); 1325 } 1326 } 1327 if (DBG) Log.d(LOG_TAG, "isOtaSpNumber " + isOtaSpNum); 1328 return isOtaSpNum; 1329 } 1330 1331 @Override 1332 public int getCdmaEriIconIndex() { 1333 return getServiceState().getCdmaEriIconIndex(); 1334 } 1335 1336 /** 1337 * Returns the CDMA ERI icon mode, 1338 * 0 - ON 1339 * 1 - FLASHING 1340 */ 1341 @Override 1342 public int getCdmaEriIconMode() { 1343 return getServiceState().getCdmaEriIconMode(); 1344 } 1345 1346 /** 1347 * Returns the CDMA ERI text, 1348 */ 1349 @Override 1350 public String getCdmaEriText() { 1351 int roamInd = getServiceState().getCdmaRoamingIndicator(); 1352 int defRoamInd = getServiceState().getCdmaDefaultRoamingIndicator(); 1353 return mEriManager.getCdmaEriText(roamInd, defRoamInd); 1354 } 1355 1356 /** 1357 * Store the voicemail number in preferences 1358 */ 1359 private void storeVoiceMailNumber(String number) { 1360 // Update the preference value of voicemail number 1361 SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); 1362 SharedPreferences.Editor editor = sp.edit(); 1363 editor.putString(VM_NUMBER_CDMA, number); 1364 editor.commit(); 1365 } 1366 1367 /** 1368 * Sets PROPERTY_ICC_OPERATOR_ISO_COUNTRY property 1369 * 1370 */ 1371 private void setIsoCountryProperty(String operatorNumeric) { 1372 if (TextUtils.isEmpty(operatorNumeric)) { 1373 setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, ""); 1374 } else { 1375 String iso = ""; 1376 try { 1377 iso = MccTable.countryCodeForMcc(Integer.parseInt( 1378 operatorNumeric.substring(0,3))); 1379 } catch (NumberFormatException ex) { 1380 Log.w(LOG_TAG, "countryCodeForMcc error" + ex); 1381 } catch (StringIndexOutOfBoundsException ex) { 1382 Log.w(LOG_TAG, "countryCodeForMcc error" + ex); 1383 } 1384 1385 setSystemProperty(PROPERTY_ICC_OPERATOR_ISO_COUNTRY, iso); 1386 } 1387 } 1388 1389 /** 1390 * Sets the "current" field in the telephony provider according to the 1391 * build-time operator numeric property 1392 * 1393 * @return true for success; false otherwise. 1394 */ 1395 boolean updateCurrentCarrierInProvider(String operatorNumeric) { 1396 if (!TextUtils.isEmpty(operatorNumeric)) { 1397 try { 1398 Uri uri = Uri.withAppendedPath(Telephony.Carriers.CONTENT_URI, "current"); 1399 ContentValues map = new ContentValues(); 1400 map.put(Telephony.Carriers.NUMERIC, operatorNumeric); 1401 getContext().getContentResolver().insert(uri, map); 1402 1403 // Updates MCC MNC device configuration information 1404 MccTable.updateMccMncConfiguration(this, operatorNumeric); 1405 1406 return true; 1407 } catch (SQLException e) { 1408 Log.e(LOG_TAG, "Can't store current operator", e); 1409 } 1410 } 1411 return false; 1412 } 1413 1414} 1415