TelephonyManager.java revision 767a662ecde33c3979bf02b793d392aca0403162
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 android.telephony; 18 19import com.android.internal.telephony.*; 20 21import java.util.ArrayList; 22import java.util.List; 23 24import android.annotation.SdkConstant.SdkConstantType; 25import android.annotation.SdkConstant; 26import android.content.Context; 27import android.os.Bundle; 28import android.os.RemoteException; 29import android.os.ServiceManager; 30import android.os.SystemProperties; 31import android.telephony.CellLocation; 32 33import com.android.internal.telephony.IPhoneSubInfo; 34import com.android.internal.telephony.ITelephony; 35import com.android.internal.telephony.ITelephonyRegistry; 36import com.android.internal.telephony.RILConstants; 37import com.android.internal.telephony.TelephonyProperties; 38 39/** 40 * Provides access to information about the telephony services on 41 * the device. Applications can use the methods in this class to 42 * determine telephony services and states, as well as to access some 43 * types of subscriber information. Applications can also register 44 * a listener to receive notification of telephony state changes. 45 * <p> 46 * You do not instantiate this class directly; instead, you retrieve 47 * a reference to an instance through 48 * {@link android.content.Context#getSystemService 49 * Context.getSystemService(Context.TELEPHONY_SERVICE)}. 50 * <p> 51 * Note that acess to some telephony information is 52 * permission-protected. Your application cannot access the protected 53 * information unless it has the appropriate permissions declared in 54 * its manifest file. Where permissions apply, they are noted in the 55 * the methods through which you access the protected information. 56 */ 57public class TelephonyManager { 58 private static final String TAG = "TelephonyManager"; 59 60 private Context mContext; 61 private ITelephonyRegistry mRegistry; 62 63 /** @hide */ 64 public TelephonyManager(Context context) { 65 mContext = context; 66 mRegistry = ITelephonyRegistry.Stub.asInterface(ServiceManager.getService( 67 "telephony.registry")); 68 } 69 70 /** @hide */ 71 private TelephonyManager() { 72 } 73 74 private static TelephonyManager sInstance = new TelephonyManager(); 75 76 /** @hide */ 77 public static TelephonyManager getDefault() { 78 return sInstance; 79 } 80 81 82 // 83 // Broadcast Intent actions 84 // 85 86 /** 87 * Broadcast intent action indicating that the call state (cellular) 88 * on the device has changed. 89 * 90 * <p> 91 * The {@link #EXTRA_STATE} extra indicates the new call state. 92 * If the new state is RINGING, a second extra 93 * {@link #EXTRA_INCOMING_NUMBER} provides the incoming phone number as 94 * a String. 95 * 96 * <p class="note"> 97 * Requires the READ_PHONE_STATE permission. 98 * 99 * <p class="note"> 100 * This was a {@link android.content.Context#sendStickyBroadcast sticky} 101 * broadcast in version 1.0, but it is no longer sticky. 102 * Instead, use {@link #getCallState} to synchronously query the current call state. 103 * 104 * @see #EXTRA_STATE 105 * @see #EXTRA_INCOMING_NUMBER 106 * @see #getCallState 107 * 108 * @hide pending API Council approval 109 */ 110 @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) 111 public static final String ACTION_PHONE_STATE_CHANGED = 112 "android.intent.action.PHONE_STATE"; 113 114 /** 115 * The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast 116 * for a String containing the new call state. 117 * 118 * @see #EXTRA_STATE_IDLE 119 * @see #EXTRA_STATE_RINGING 120 * @see #EXTRA_STATE_OFFHOOK 121 * 122 * <p class="note"> 123 * Retrieve with 124 * {@link android.content.Intent#getStringExtra(String)}. 125 * 126 * @hide pending API Council approval 127 */ 128 public static final String EXTRA_STATE = Phone.STATE_KEY; 129 130 /** 131 * Value used with {@link #EXTRA_STATE} corresponding to 132 * {@link #CALL_STATE_IDLE}. 133 * 134 * @hide pending API Council approval 135 */ 136 public static final String EXTRA_STATE_IDLE = Phone.State.IDLE.toString(); 137 138 /** 139 * Value used with {@link #EXTRA_STATE} corresponding to 140 * {@link #CALL_STATE_RINGING}. 141 * 142 * @hide pending API Council approval 143 */ 144 public static final String EXTRA_STATE_RINGING = Phone.State.RINGING.toString(); 145 146 /** 147 * Value used with {@link #EXTRA_STATE} corresponding to 148 * {@link #CALL_STATE_OFFHOOK}. 149 * 150 * @hide pending API Council approval 151 */ 152 public static final String EXTRA_STATE_OFFHOOK = Phone.State.OFFHOOK.toString(); 153 154 /** 155 * The lookup key used with the {@link #ACTION_PHONE_STATE_CHANGED} broadcast 156 * for a String containing the incoming phone number. 157 * Only valid when the new call state is RINGING. 158 * 159 * <p class="note"> 160 * Retrieve with 161 * {@link android.content.Intent#getStringExtra(String)}. 162 * 163 * @hide pending API Council approval 164 */ 165 public static final String EXTRA_INCOMING_NUMBER = "incoming_number"; 166 167 168 // 169 // 170 // Device Info 171 // 172 // 173 174 /** 175 * Returns the software version number for the device, for example, 176 * the IMEI/SV for GSM phones. 177 * 178 * <p>Requires Permission: 179 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 180 */ 181 public String getDeviceSoftwareVersion() { 182 try { 183 return getSubscriberInfo().getDeviceSvn(); 184 } catch (RemoteException ex) { 185 } 186 return null; 187 } 188 189 /** 190 * Returns the unique device ID, for example, the IMEI for GSM and the MEID for CDMA 191 * phones. 192 * 193 * <p>Requires Permission: 194 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 195 */ 196 public String getDeviceId() { 197 try { 198 return getSubscriberInfo().getDeviceId(); 199 } catch (RemoteException ex) { 200 } 201 return null; 202 } 203 204 /** 205 * Returns the current location of the device. 206 * 207 * <p>Requires Permission: {@link android.Manifest.permission#ACCESS_COARSE_LOCATION 208 * ACCESS_COARSE_LOCATION}. 209 */ 210 public CellLocation getCellLocation() { 211 try { 212 Bundle bundle = getITelephony().getCellLocation(); 213 return CellLocation.newFromBundle(bundle); 214 } catch (RemoteException ex) { 215 } 216 return null; 217 } 218 219 /** 220 * Enables location update notifications. {@link PhoneStateListener#onCellLocationChanged 221 * PhoneStateListener.onCellLocationChanged} will be called on location updates. 222 * 223 * <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES 224 * CONTROL_LOCATION_UPDATES} 225 * 226 * @hide 227 */ 228 public void enableLocationUpdates() { 229 try { 230 getITelephony().enableLocationUpdates(); 231 } catch (RemoteException ex) { 232 } 233 } 234 235 /** 236 * Disables location update notifications. {@link PhoneStateListener#onCellLocationChanged 237 * PhoneStateListener.onCellLocationChanged} will be called on location updates. 238 * 239 * <p>Requires Permission: {@link android.Manifest.permission#CONTROL_LOCATION_UPDATES 240 * CONTROL_LOCATION_UPDATES} 241 * 242 * @hide 243 */ 244 public void disableLocationUpdates() { 245 try { 246 getITelephony().disableLocationUpdates(); 247 } catch (RemoteException ex) { 248 } 249 } 250 251 /** 252 * Returns the neighboring cell information of the device. 253 * 254 * @return List of NeighboringCellInfo or null if info unavailable. 255 * 256 * <p>Requires Permission: 257 * (@link android.Manifest.permission#ACCESS_COARSE_UPDATES} 258 */ 259 public List<NeighboringCellInfo> getNeighboringCellInfo() { 260 try { 261 return getITelephony().getNeighboringCellInfo(); 262 } catch (RemoteException ex) { 263 } 264 return null; 265 266 } 267 268 /** 269 * No phone module 270 */ 271 public static final int PHONE_TYPE_NONE = 0; 272 273 /** 274 * GSM phone 275 */ 276 public static final int PHONE_TYPE_GSM = 1; 277 278 /** 279 * CDMA phone 280 * @hide 281 */ 282 public static final int PHONE_TYPE_CDMA = 2; 283 284 /** 285 * Returns a constant indicating the device phone type. 286 * 287 * @see #PHONE_TYPE_NONE 288 * @see #PHONE_TYPE_GSM 289 * @see #PHONE_TYPE_CDMA 290 */ 291 public int getPhoneType() { 292 try{ 293 if(getITelephony().getActivePhoneType() == RILConstants.CDMA_PHONE) { 294 return PHONE_TYPE_CDMA; 295 } else { 296 return PHONE_TYPE_GSM; 297 } 298 }catch(RemoteException ex){ 299 return PHONE_TYPE_NONE; 300 } 301 } 302 303 // 304 // 305 // Current Network 306 // 307 // 308 309 /** 310 * Returns the alphabetic name of current registered operator. 311 * <p> 312 * Availability: Only when user is registered to a network 313 */ 314 public String getNetworkOperatorName() { 315 return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ALPHA); 316 } 317 318 /** 319 * Returns the numeric name (MCC+MNC) of current registered operator. 320 * <p> 321 * Availability: Only when user is registered to a network 322 */ 323 public String getNetworkOperator() { 324 return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_NUMERIC); 325 } 326 327 /** 328 * Returns true if the device is considered roaming on the current 329 * network, for GSM purposes. 330 * <p> 331 * Availability: Only when user registered to a network 332 */ 333 public boolean isNetworkRoaming() { 334 return "true".equals(SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISROAMING)); 335 } 336 337 /** 338 * Returns the ISO country code equivilent of the current registered 339 * operator's MCC (Mobile Country Code). 340 * <p> 341 * Availability: Only when user is registered to a network 342 */ 343 public String getNetworkCountryIso() { 344 return SystemProperties.get(TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY); 345 } 346 347 /** Network type is unknown */ 348 public static final int NETWORK_TYPE_UNKNOWN = 0; 349 /** Current network is GPRS */ 350 public static final int NETWORK_TYPE_GPRS = 1; 351 /** Current network is EDGE */ 352 public static final int NETWORK_TYPE_EDGE = 2; 353 /** Current network is UMTS */ 354 public static final int NETWORK_TYPE_UMTS = 3; 355 /** Current network is CDMA: Either IS95A or IS95B*/ 356 /** @hide */ 357 public static final int NETWORK_TYPE_CDMA = 4; 358 /** Current network is EVDO revision 0 or revision A*/ 359 /** @hide */ 360 public static final int NETWORK_TYPE_EVDO_0 = 5; 361 /** @hide */ 362 public static final int NETWORK_TYPE_EVDO_A = 6; 363 /** Current network is 1xRTT*/ 364 /** @hide */ 365 public static final int NETWORK_TYPE_1xRTT = 7; 366 367 /** 368 * Returns a constant indicating the radio technology (network type) 369 * currently in use on the device. 370 * @return the network type 371 * 372 * @see #NETWORK_TYPE_UNKNOWN 373 * @see #NETWORK_TYPE_GPRS 374 * @see #NETWORK_TYPE_EDGE 375 * @see #NETWORK_TYPE_UMTS 376 * @see #NETWORK_TYPE_CDMA 377 * @see #NETWORK_TYPE_EVDO_0 378 * @see #NETWORK_TYPE_EVDO_A 379 * @see #NETWORK_TYPE_1xRTT 380 */ 381 public int getNetworkType() { 382 String prop = SystemProperties.get(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE); 383 if ("GPRS".equals(prop)) { 384 return NETWORK_TYPE_GPRS; 385 } 386 else if ("EDGE".equals(prop)) { 387 return NETWORK_TYPE_EDGE; 388 } 389 else if ("UMTS".equals(prop)) { 390 return NETWORK_TYPE_UMTS; 391 } 392 else if ("CDMA".equals(prop)) { 393 return NETWORK_TYPE_CDMA; 394 } 395 else if ("CDMA - EvDo rev. 0".equals(prop)) { 396 return NETWORK_TYPE_EVDO_0; 397 } 398 else if ("CDMA - EvDo rev. A".equals(prop)) { 399 return NETWORK_TYPE_EVDO_A; 400 } 401 else if ("CDMA - 1xRTT".equals(prop)) { 402 return NETWORK_TYPE_1xRTT; 403 } 404 else { 405 return NETWORK_TYPE_UNKNOWN; 406 } 407 } 408 409 /** 410 * Returns a string representation of the radio technology (network type) 411 * currently in use on the device. 412 * @return the name of the radio technology 413 * 414 * @hide pending API council review 415 */ 416 public String getNetworkTypeName() { 417 switch (getNetworkType()) { 418 case NETWORK_TYPE_GPRS: 419 return "GPRS"; 420 case NETWORK_TYPE_EDGE: 421 return "EDGE"; 422 case NETWORK_TYPE_UMTS: 423 return "UMTS"; 424 case NETWORK_TYPE_CDMA: 425 return "CDMA"; 426 case NETWORK_TYPE_EVDO_0: 427 return "CDMA - EvDo rev. 0"; 428 case NETWORK_TYPE_EVDO_A: 429 return "CDMA - EvDo rev. A"; 430 case NETWORK_TYPE_1xRTT: 431 return "CDMA - 1xRTT"; 432 default: 433 return "UNKNOWN"; 434 } 435 } 436 437 // 438 // 439 // SIM Card 440 // 441 // 442 443 /** SIM card state: Unknown. Signifies that the SIM is in transition 444 * between states. For example, when the user inputs the SIM pin 445 * under PIN_REQUIRED state, a query for sim status returns 446 * this state before turning to SIM_STATE_READY. */ 447 public static final int SIM_STATE_UNKNOWN = 0; 448 /** SIM card state: no SIM card is available in the device */ 449 public static final int SIM_STATE_ABSENT = 1; 450 /** SIM card state: Locked: requires the user's SIM PIN to unlock */ 451 public static final int SIM_STATE_PIN_REQUIRED = 2; 452 /** SIM card state: Locked: requires the user's SIM PUK to unlock */ 453 public static final int SIM_STATE_PUK_REQUIRED = 3; 454 /** SIM card state: Locked: requries a network PIN to unlock */ 455 public static final int SIM_STATE_NETWORK_LOCKED = 4; 456 /** SIM card state: Ready */ 457 public static final int SIM_STATE_READY = 5; 458 459 /** 460 * Returns a constant indicating the state of the 461 * device SIM card. 462 * 463 * @see #SIM_STATE_UNKNOWN 464 * @see #SIM_STATE_ABSENT 465 * @see #SIM_STATE_PIN_REQUIRED 466 * @see #SIM_STATE_PUK_REQUIRED 467 * @see #SIM_STATE_NETWORK_LOCKED 468 * @see #SIM_STATE_READY 469 */ 470 public int getSimState() { 471 String prop = SystemProperties.get(TelephonyProperties.PROPERTY_SIM_STATE); 472 if ("ABSENT".equals(prop)) { 473 return SIM_STATE_ABSENT; 474 } 475 else if ("PIN_REQUIRED".equals(prop)) { 476 return SIM_STATE_PIN_REQUIRED; 477 } 478 else if ("PUK_REQUIRED".equals(prop)) { 479 return SIM_STATE_PUK_REQUIRED; 480 } 481 else if ("NETWORK_LOCKED".equals(prop)) { 482 return SIM_STATE_NETWORK_LOCKED; 483 } 484 else if ("READY".equals(prop)) { 485 return SIM_STATE_READY; 486 } 487 else { 488 return SIM_STATE_UNKNOWN; 489 } 490 } 491 492 /** 493 * Returns the MCC+MNC (mobile country code + mobile network code) of the 494 * provider of the SIM. 5 or 6 decimal digits. 495 * <p> 496 * Availability: SIM state must be {@link #SIM_STATE_READY} 497 * 498 * @see #getSimState 499 */ 500 public String getSimOperator() { 501 return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_NUMERIC); 502 } 503 504 /** 505 * Returns the Service Provider Name (SPN). 506 * <p> 507 * Availability: SIM state must be {@link #SIM_STATE_READY} 508 * 509 * @see #getSimState 510 */ 511 public String getSimOperatorName() { 512 return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ALPHA); 513 } 514 515 /** 516 * Returns the ISO country code equivalent for the SIM provider's country code. 517 */ 518 public String getSimCountryIso() { 519 return SystemProperties.get(TelephonyProperties.PROPERTY_ICC_OPERATOR_ISO_COUNTRY); 520 } 521 522 /** 523 * Returns the serial number of the SIM, if applicable. 524 * <p> 525 * Requires Permission: 526 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 527 */ 528 public String getSimSerialNumber() { 529 try { 530 return getSubscriberInfo().getIccSerialNumber(); 531 } catch (RemoteException ex) { 532 } 533 return null; 534 } 535 536 // 537 // 538 // Subscriber Info 539 // 540 // 541 542 /** 543 * Returns the unique subscriber ID, for example, the IMSI for a GSM phone. 544 * <p> 545 * Requires Permission: 546 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 547 */ 548 public String getSubscriberId() { 549 try { 550 return getSubscriberInfo().getSubscriberId(); 551 } catch (RemoteException ex) { 552 } 553 return null; 554 } 555 556 /** 557 * Returns the phone number string for line 1, for example, the MSISDN 558 * for a GSM phone. 559 * <p> 560 * Requires Permission: 561 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 562 */ 563 public String getLine1Number() { 564 try { 565 return getSubscriberInfo().getLine1Number(); 566 } catch (RemoteException ex) { 567 } 568 return null; 569 } 570 571 /** 572 * Returns the alphabetic identifier associated with the line 1 number. 573 * <p> 574 * Requires Permission: 575 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 576 * @hide 577 * nobody seems to call this. 578 */ 579 public String getLine1AlphaTag() { 580 try { 581 return getSubscriberInfo().getLine1AlphaTag(); 582 } catch (RemoteException ex) { 583 } 584 return null; 585 } 586 587 /** 588 * Returns the voice mail number. 589 * <p> 590 * Requires Permission: 591 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 592 */ 593 public String getVoiceMailNumber() { 594 try { 595 return getSubscriberInfo().getVoiceMailNumber(); 596 } catch (RemoteException ex) { 597 } 598 return null; 599 } 600 601 /** 602 * Retrieves the alphabetic identifier associated with the voice 603 * mail number. 604 * <p> 605 * Requires Permission: 606 * {@link android.Manifest.permission#READ_PHONE_STATE READ_PHONE_STATE} 607 */ 608 public String getVoiceMailAlphaTag() { 609 try { 610 return getSubscriberInfo().getVoiceMailAlphaTag(); 611 } catch (RemoteException ex) { 612 } 613 return null; 614 } 615 616 private IPhoneSubInfo getSubscriberInfo() { 617 // get it each time because that process crashes a lot 618 return IPhoneSubInfo.Stub.asInterface(ServiceManager.getService("iphonesubinfo")); 619 } 620 621 622 /** Device call state: No activity. */ 623 public static final int CALL_STATE_IDLE = 0; 624 /** Device call state: Ringing. A new call arrived and is 625 * ringing or waiting. In the latter case, another call is 626 * already active. */ 627 public static final int CALL_STATE_RINGING = 1; 628 /** Device call state: Off-hook. At least one call exists 629 * that is dialing, active, or on hold, and no calls are ringing 630 * or waiting. */ 631 public static final int CALL_STATE_OFFHOOK = 2; 632 633 /** 634 * Returns a constant indicating the call state (cellular) on the device. 635 */ 636 public int getCallState() { 637 try { 638 return getITelephony().getCallState(); 639 } catch (RemoteException ex) { 640 // the phone process is restarting. 641 return CALL_STATE_IDLE; 642 } 643 } 644 645 /** Data connection activity: No traffic. */ 646 public static final int DATA_ACTIVITY_NONE = 0x00000000; 647 /** Data connection activity: Currently receiving IP PPP traffic. */ 648 public static final int DATA_ACTIVITY_IN = 0x00000001; 649 /** Data connection activity: Currently sending IP PPP traffic. */ 650 public static final int DATA_ACTIVITY_OUT = 0x00000002; 651 /** Data connection activity: Currently both sending and receiving 652 * IP PPP traffic. */ 653 public static final int DATA_ACTIVITY_INOUT = DATA_ACTIVITY_IN | DATA_ACTIVITY_OUT; 654 655 /** 656 * Returns a constant indicating the type of activity on a data connection 657 * (cellular). 658 * 659 * @see #DATA_ACTIVITY_NONE 660 * @see #DATA_ACTIVITY_IN 661 * @see #DATA_ACTIVITY_OUT 662 * @see #DATA_ACTIVITY_INOUT 663 */ 664 public int getDataActivity() { 665 try { 666 return getITelephony().getDataActivity(); 667 } catch (RemoteException ex) { 668 // the phone process is restarting. 669 return DATA_ACTIVITY_NONE; 670 } 671 } 672 673 /** Data connection state: Disconnected. IP traffic not available. */ 674 public static final int DATA_DISCONNECTED = 0; 675 /** Data connection state: Currently setting up a data connection. */ 676 public static final int DATA_CONNECTING = 1; 677 /** Data connection state: Connected. IP traffic should be available. */ 678 public static final int DATA_CONNECTED = 2; 679 /** Data connection state: Suspended. The connection is up, but IP 680 * traffic is temporarily unavailable. For example, in a 2G network, 681 * data activity may be suspended when a voice call arrives. */ 682 public static final int DATA_SUSPENDED = 3; 683 684 /** 685 * Returns a constant indicating the current data connection state 686 * (cellular). 687 * 688 * @see #DATA_DISCONNECTED 689 * @see #DATA_CONNECTING 690 * @see #DATA_CONNECTED 691 * @see #DATA_SUSPENDED 692 */ 693 public int getDataState() { 694 try { 695 return getITelephony().getDataState(); 696 } catch (RemoteException ex) { 697 // the phone process is restarting. 698 return DATA_DISCONNECTED; 699 } 700 } 701 702 private ITelephony getITelephony() { 703 return ITelephony.Stub.asInterface(ServiceManager.getService(Context.TELEPHONY_SERVICE)); 704 } 705 706 // 707 // 708 // PhoneStateListener 709 // 710 // 711 712 /** 713 * Registers a listener object to receive notification of changes 714 * in specified telephony states. 715 * <p> 716 * To register a listener, pass a {@link PhoneStateListener} 717 * and specify at least one telephony state of interest in 718 * the events argument. 719 * 720 * At registration, and when a specified telephony state 721 * changes, the telephony manager invokes the appropriate 722 * callback method on the listener object and passes the 723 * current (udpated) values. 724 * <p> 725 * To unregister a listener, pass the listener object and set the 726 * events argument to 727 * {@link PhoneStateListener#LISTEN_NONE LISTEN_NONE} (0). 728 * 729 * @param listener The {@link PhoneStateListener} object to register 730 * (or unregister) 731 * @param events The telephony state(s) of interest to the listener, 732 * as a bitwise-OR combination of {@link PhoneStateListener} 733 * LISTEN_ flags. 734 */ 735 public void listen(PhoneStateListener listener, int events) { 736 String pkgForDebug = mContext != null ? mContext.getPackageName() : "<unknown>"; 737 try { 738 Boolean notifyNow = (getITelephony() != null); 739 mRegistry.listen(pkgForDebug, listener.callback, events, notifyNow); 740 } catch (RemoteException ex) { 741 // system process dead 742 } 743 } 744} 745