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