1 /*
2  * Copyright (C) 2007 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 
17 package com.android.internal.telephony;
18 
19 import android.annotation.NonNull;
20 import android.compat.annotation.UnsupportedAppUsage;
21 import android.os.Bundle;
22 import android.os.Handler;
23 import android.os.Message;
24 import android.os.ResultReceiver;
25 import android.telecom.VideoProfile;
26 import android.telephony.ImsiEncryptionInfo;
27 import android.telephony.NetworkScanRequest;
28 import android.telephony.PreciseDataConnectionState;
29 import android.telephony.ServiceState;
30 import android.telephony.TelephonyManager;
31 
32 import com.android.internal.telephony.PhoneConstants.DataState;
33 
34 import java.util.List;
35 
36 /**
37  * Internal interface used to control the phone; SDK developers cannot
38  * obtain this interface.
39  *
40  * {@hide}
41  *
42  */
43 public interface PhoneInternalInterface {
44 
45     /** used to enable additional debug messages */
46     static final boolean DEBUG_PHONE = true;
47 
48     public enum DataActivityState {
49         /**
50          * The state of a data activity.
51          * <ul>
52          * <li>NONE = No traffic</li>
53          * <li>DATAIN = Receiving IP ppp traffic</li>
54          * <li>DATAOUT = Sending IP ppp traffic</li>
55          * <li>DATAINANDOUT = Both receiving and sending IP ppp traffic</li>
56          * <li>DORMANT = The data connection is still active,
57                                      but physical link is down</li>
58          * </ul>
59          */
60         @UnsupportedAppUsage
61         NONE, DATAIN, DATAOUT, DATAINANDOUT, DORMANT;
62     }
63 
64     enum SuppService {
65       UNKNOWN, SWITCH, SEPARATE, TRANSFER, CONFERENCE, REJECT, HANGUP, RESUME, HOLD;
66     }
67 
68     /**
69      * Arguments that control behavior of dialing a call.
70      */
71     public static class DialArgs {
72         public static class Builder<T extends Builder<T>> {
73             protected UUSInfo mUusInfo;
74             protected int mVideoState = VideoProfile.STATE_AUDIO_ONLY;
75             protected Bundle mIntentExtras;
76 
setUusInfo(UUSInfo uusInfo)77             public T setUusInfo(UUSInfo uusInfo) {
78                 mUusInfo = uusInfo;
79                 return (T) this;
80             }
81 
setVideoState(int videoState)82             public T setVideoState(int videoState) {
83                 mVideoState = videoState;
84                 return (T) this;
85             }
86 
setIntentExtras(Bundle intentExtras)87             public T setIntentExtras(Bundle intentExtras) {
88                 this.mIntentExtras = intentExtras;
89                 return (T) this;
90             }
91 
build()92             public PhoneInternalInterface.DialArgs build() {
93                 return new DialArgs(this);
94             }
95         }
96 
97         /** The UUSInfo */
98         public final UUSInfo uusInfo;
99 
100         /** The desired video state for the connection. */
101         public final int videoState;
102 
103         /** The extras from the original CALL intent. */
104         public final Bundle intentExtras;
105 
DialArgs(Builder b)106         protected DialArgs(Builder b) {
107             this.uusInfo = b.mUusInfo;
108             this.videoState = b.mVideoState;
109             this.intentExtras = b.mIntentExtras;
110         }
111     }
112 
113     // "Features" accessible through the connectivity manager
114     static final String FEATURE_ENABLE_MMS = "enableMMS";
115     static final String FEATURE_ENABLE_SUPL = "enableSUPL";
116     static final String FEATURE_ENABLE_DUN = "enableDUN";
117     static final String FEATURE_ENABLE_HIPRI = "enableHIPRI";
118     static final String FEATURE_ENABLE_DUN_ALWAYS = "enableDUNAlways";
119     static final String FEATURE_ENABLE_FOTA = "enableFOTA";
120     static final String FEATURE_ENABLE_IMS = "enableIMS";
121     static final String FEATURE_ENABLE_CBS = "enableCBS";
122     static final String FEATURE_ENABLE_EMERGENCY = "enableEmergency";
123 
124     /**
125      * Optional reasons for disconnect and connect
126      */
127     static final String REASON_ROAMING_ON = "roamingOn";
128     static final String REASON_ROAMING_OFF = "roamingOff";
129     static final String REASON_DATA_DISABLED_INTERNAL = "dataDisabledInternal";
130     static final String REASON_DATA_ENABLED = "dataEnabled";
131     static final String REASON_DATA_ATTACHED = "dataAttached";
132     static final String REASON_DATA_DETACHED = "dataDetached";
133     static final String REASON_CDMA_DATA_ATTACHED = "cdmaDataAttached";
134     static final String REASON_CDMA_DATA_DETACHED = "cdmaDataDetached";
135     static final String REASON_APN_CHANGED = "apnChanged";
136     static final String REASON_APN_SWITCHED = "apnSwitched";
137     static final String REASON_APN_FAILED = "apnFailed";
138     static final String REASON_RESTORE_DEFAULT_APN = "restoreDefaultApn";
139     static final String REASON_RADIO_TURNED_OFF = "radioTurnedOff";
140     static final String REASON_PDP_RESET = "pdpReset";
141     static final String REASON_VOICE_CALL_ENDED = "2GVoiceCallEnded";
142     static final String REASON_VOICE_CALL_STARTED = "2GVoiceCallStarted";
143     static final String REASON_PS_RESTRICT_ENABLED = "psRestrictEnabled";
144     static final String REASON_PS_RESTRICT_DISABLED = "psRestrictDisabled";
145     static final String REASON_SIM_LOADED = "simLoaded";
146     static final String REASON_NW_TYPE_CHANGED = "nwTypeChanged";
147     static final String REASON_DATA_DEPENDENCY_MET = "dependencyMet";
148     static final String REASON_DATA_DEPENDENCY_UNMET = "dependencyUnmet";
149     static final String REASON_LOST_DATA_CONNECTION = "lostDataConnection";
150     static final String REASON_CONNECTED = "connected";
151     static final String REASON_SINGLE_PDN_ARBITRATION = "SinglePdnArbitration";
152     static final String REASON_DATA_SPECIFIC_DISABLED = "specificDisabled";
153     static final String REASON_SIM_NOT_READY = "simNotReady";
154     static final String REASON_IWLAN_AVAILABLE = "iwlanAvailable";
155     static final String REASON_CARRIER_CHANGE = "carrierChange";
156     static final String REASON_CARRIER_ACTION_DISABLE_METERED_APN =
157             "carrierActionDisableMeteredApn";
158     static final String REASON_CSS_INDICATOR_CHANGED = "cssIndicatorChanged";
159     static final String REASON_RELEASED_BY_CONNECTIVITY_SERVICE = "releasedByConnectivityService";
160     static final String REASON_DATA_ENABLED_OVERRIDE = "dataEnabledOverride";
161 
162     // Used for band mode selection methods
163     static final int BM_UNSPECIFIED = RILConstants.BAND_MODE_UNSPECIFIED; // automatic
164     static final int BM_EURO_BAND   = RILConstants.BAND_MODE_EURO;
165     static final int BM_US_BAND     = RILConstants.BAND_MODE_USA;
166     static final int BM_JPN_BAND    = RILConstants.BAND_MODE_JPN;
167     static final int BM_AUS_BAND    = RILConstants.BAND_MODE_AUS;
168     static final int BM_AUS2_BAND   = RILConstants.BAND_MODE_AUS_2;
169     static final int BM_CELL_800    = RILConstants.BAND_MODE_CELL_800;
170     static final int BM_PCS         = RILConstants.BAND_MODE_PCS;
171     static final int BM_JTACS       = RILConstants.BAND_MODE_JTACS;
172     static final int BM_KOREA_PCS   = RILConstants.BAND_MODE_KOREA_PCS;
173     static final int BM_4_450M      = RILConstants.BAND_MODE_5_450M;
174     static final int BM_IMT2000     = RILConstants.BAND_MODE_IMT2000;
175     static final int BM_7_700M2     = RILConstants.BAND_MODE_7_700M_2;
176     static final int BM_8_1800M     = RILConstants.BAND_MODE_8_1800M;
177     static final int BM_9_900M      = RILConstants.BAND_MODE_9_900M;
178     static final int BM_10_800M_2   = RILConstants.BAND_MODE_10_800M_2;
179     static final int BM_EURO_PAMR   = RILConstants.BAND_MODE_EURO_PAMR_400M;
180     static final int BM_AWS         = RILConstants.BAND_MODE_AWS;
181     static final int BM_US_2500M    = RILConstants.BAND_MODE_USA_2500M;
182     static final int BM_NUM_BAND_MODES = 19; //Total number of band modes
183 
184     @UnsupportedAppUsage
185     int PREFERRED_NT_MODE                = RILConstants.PREFERRED_NETWORK_MODE;
186 
187     // Used for CDMA roaming mode
188     // Home Networks only, as defined in PRL
189     int CDMA_RM_HOME        = TelephonyManager.CDMA_ROAMING_MODE_HOME;
190     // Roaming an Affiliated networks, as defined in PRL
191     int CDMA_RM_AFFILIATED  = TelephonyManager.CDMA_ROAMING_MODE_AFFILIATED;
192     // Roaming on Any Network, as defined in PRL
193     int CDMA_RM_ANY         = TelephonyManager.CDMA_ROAMING_MODE_ANY;
194 
195     // Used for CDMA subscription mode
196     // Unknown
197     static final int CDMA_SUBSCRIPTION_UNKNOWN  = TelephonyManager.CDMA_SUBSCRIPTION_UNKNOWN;
198     // RUIM/SIM (default)
199     static final int CDMA_SUBSCRIPTION_RUIM_SIM = TelephonyManager.CDMA_SUBSCRIPTION_RUIM_SIM;
200     // NV -> non-volatile memory
201     static final int CDMA_SUBSCRIPTION_NV       = TelephonyManager.CDMA_SUBSCRIPTION_NV;
202 
203     static final int PREFERRED_CDMA_SUBSCRIPTION = CDMA_SUBSCRIPTION_RUIM_SIM;
204 
205     static final int TTY_MODE_OFF = 0;
206     static final int TTY_MODE_FULL = 1;
207     static final int TTY_MODE_HCO = 2;
208     static final int TTY_MODE_VCO = 3;
209 
210      /**
211      * CDMA OTA PROVISION STATUS, the same as RIL_CDMA_OTA_Status in ril.h
212      */
213 
214     public static final int CDMA_OTA_PROVISION_STATUS_SPL_UNLOCKED = 0;
215     public static final int CDMA_OTA_PROVISION_STATUS_SPC_RETRIES_EXCEEDED = 1;
216     public static final int CDMA_OTA_PROVISION_STATUS_A_KEY_EXCHANGED = 2;
217     public static final int CDMA_OTA_PROVISION_STATUS_SSD_UPDATED = 3;
218     public static final int CDMA_OTA_PROVISION_STATUS_NAM_DOWNLOADED = 4;
219     public static final int CDMA_OTA_PROVISION_STATUS_MDN_DOWNLOADED = 5;
220     public static final int CDMA_OTA_PROVISION_STATUS_IMSI_DOWNLOADED = 6;
221     public static final int CDMA_OTA_PROVISION_STATUS_PRL_DOWNLOADED = 7;
222     public static final int CDMA_OTA_PROVISION_STATUS_COMMITTED = 8;
223     public static final int CDMA_OTA_PROVISION_STATUS_OTAPA_STARTED = 9;
224     public static final int CDMA_OTA_PROVISION_STATUS_OTAPA_STOPPED = 10;
225     public static final int CDMA_OTA_PROVISION_STATUS_OTAPA_ABORTED = 11;
226 
227 
228     /**
229      * Get the current ServiceState. Use
230      * <code>registerForServiceStateChanged</code> to be informed of
231      * updates.
232      */
getServiceState()233     ServiceState getServiceState();
234 
235     /**
236      * Get the current DataState. No change notification exists at this
237      * interface -- use
238      * {@link android.telephony.PhoneStateListener} instead.
239      * @param apnType specify for which apn to get connection state info.
240      */
getDataConnectionState(String apnType)241     DataState getDataConnectionState(String apnType);
242 
243     /**
244      * Get the current Precise DataState. No change notification exists at this
245      * interface -- use
246      * {@link android.telephony.PhoneStateListener} instead.
247      *
248      * @param apnType specify for which apn to get connection state info.
249      * @return the PreciseDataConnectionState for the data connection supporting apnType
250      */
getPreciseDataConnectionState(String apnType)251     PreciseDataConnectionState getPreciseDataConnectionState(String apnType);
252 
253     /**
254      * Get the current DataActivityState. No change notification exists at this
255      * interface -- use
256      * {@link android.telephony.TelephonyManager} instead.
257      */
getDataActivityState()258     DataActivityState getDataActivityState();
259 
260     /**
261      * Returns a list of MMI codes that are pending. (They have initiated
262      * but have not yet completed).
263      * Presently there is only ever one.
264      * Use <code>registerForMmiInitiate</code>
265      * and <code>registerForMmiComplete</code> for change notification.
266      */
getPendingMmiCodes()267     public List<? extends MmiCode> getPendingMmiCodes();
268 
269     /**
270      * Sends user response to a USSD REQUEST message.  An MmiCode instance
271      * representing this response is sent to handlers registered with
272      * registerForMmiInitiate.
273      *
274      * @param ussdMessge    Message to send in the response.
275      */
sendUssdResponse(String ussdMessge)276     public void sendUssdResponse(String ussdMessge);
277 
278     /**
279      * Register for Supplementary Service notifications from the network.
280      * Message.obj will contain an AsyncResult.
281      * AsyncResult.result will be a SuppServiceNotification instance.
282      *
283      * @param h Handler that receives the notification message.
284      * @param what User-defined message code.
285      * @param obj User object.
286      */
registerForSuppServiceNotification(Handler h, int what, Object obj)287     void registerForSuppServiceNotification(Handler h, int what, Object obj);
288 
289     /**
290      * Unregisters for Supplementary Service notifications.
291      * Extraneous calls are tolerated silently
292      *
293      * @param h Handler to be removed from the registrant list.
294      */
unregisterForSuppServiceNotification(Handler h)295     void unregisterForSuppServiceNotification(Handler h);
296 
297     /**
298      * Answers a ringing or waiting call. Active calls, if any, go on hold.
299      * Answering occurs asynchronously, and final notification occurs via
300      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
301      * java.lang.Object) registerForPreciseCallStateChanged()}.
302      *
303      * @param videoState The video state in which to answer the call.
304      * @exception CallStateException when no call is ringing or waiting
305      */
acceptCall(int videoState)306     void acceptCall(int videoState) throws CallStateException;
307 
308     /**
309      * Reject (ignore) a ringing call. In GSM, this means UDUB
310      * (User Determined User Busy). Reject occurs asynchronously,
311      * and final notification occurs via
312      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
313      * java.lang.Object) registerForPreciseCallStateChanged()}.
314      *
315      * @exception CallStateException when no call is ringing or waiting
316      */
rejectCall()317     void rejectCall() throws CallStateException;
318 
319     /**
320      * Places any active calls on hold, and makes any held calls
321      *  active. Switch occurs asynchronously and may fail.
322      * Final notification occurs via
323      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
324      * java.lang.Object) registerForPreciseCallStateChanged()}.
325      *
326      * @exception CallStateException if a call is ringing, waiting, or
327      * dialing/alerting. In these cases, this operation may not be performed.
328      */
switchHoldingAndActive()329     void switchHoldingAndActive() throws CallStateException;
330 
331     /**
332      * Whether or not the phone can conference in the current phone
333      * state--that is, one call holding and one call active.
334      * @return true if the phone can conference; false otherwise.
335      */
canConference()336     boolean canConference();
337 
338     /**
339      * Conferences holding and active. Conference occurs asynchronously
340      * and may fail. Final notification occurs via
341      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
342      * java.lang.Object) registerForPreciseCallStateChanged()}.
343      *
344      * @exception CallStateException if canConference() would return false.
345      * In these cases, this operation may not be performed.
346      */
conference()347     void conference() throws CallStateException;
348 
349     /**
350      * Whether or not the phone can do explicit call transfer in the current
351      * phone state--that is, one call holding and one call active.
352      * @return true if the phone can do explicit call transfer; false otherwise.
353      */
canTransfer()354     boolean canTransfer();
355 
356     /**
357      * Connects the two calls and disconnects the subscriber from both calls
358      * Explicit Call Transfer occurs asynchronously
359      * and may fail. Final notification occurs via
360      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
361      * java.lang.Object) registerForPreciseCallStateChanged()}.
362      *
363      * @exception CallStateException if canTransfer() would return false.
364      * In these cases, this operation may not be performed.
365      */
explicitCallTransfer()366     void explicitCallTransfer() throws CallStateException;
367 
368     /**
369      * Clears all DISCONNECTED connections from Call connection lists.
370      * Calls that were in the DISCONNECTED state become idle. This occurs
371      * synchronously.
372      */
clearDisconnected()373     void clearDisconnected();
374 
375     /**
376      * Gets the foreground call object, which represents all connections that
377      * are dialing or active (all connections
378      * that have their audio path connected).<p>
379      *
380      * The foreground call is a singleton object. It is constant for the life
381      * of this phone. It is never null.<p>
382      *
383      * The foreground call will only ever be in one of these states:
384      * IDLE, ACTIVE, DIALING, ALERTING, or DISCONNECTED.
385      *
386      * State change notification is available via
387      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
388      * java.lang.Object) registerForPreciseCallStateChanged()}.
389      */
getForegroundCall()390     Call getForegroundCall();
391 
392     /**
393      * Gets the background call object, which represents all connections that
394      * are holding (all connections that have been accepted or connected, but
395      * do not have their audio path connected). <p>
396      *
397      * The background call is a singleton object. It is constant for the life
398      * of this phone object . It is never null.<p>
399      *
400      * The background call will only ever be in one of these states:
401      * IDLE, HOLDING or DISCONNECTED.
402      *
403      * State change notification is available via
404      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
405      * java.lang.Object) registerForPreciseCallStateChanged()}.
406      */
getBackgroundCall()407     Call getBackgroundCall();
408 
409     /**
410      * Gets the ringing call object, which represents an incoming
411      * connection (if present) that is pending answer/accept. (This connection
412      * may be RINGING or WAITING, and there may be only one.)<p>
413 
414      * The ringing call is a singleton object. It is constant for the life
415      * of this phone. It is never null.<p>
416      *
417      * The ringing call will only ever be in one of these states:
418      * IDLE, INCOMING, WAITING or DISCONNECTED.
419      *
420      * State change notification is available via
421      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
422      * java.lang.Object) registerForPreciseCallStateChanged()}.
423      */
getRingingCall()424     Call getRingingCall();
425 
426     /**
427      * Initiate a new voice connection. This happens asynchronously, so you
428      * cannot assume the audio path is connected (or a call index has been
429      * assigned) until PhoneStateChanged notification has occurred.
430      *
431      * @param dialString The dial string.
432      * @param dialArgs Parameters to perform the dial with.
433      * @exception CallStateException if a new outgoing call is not currently
434      *                possible because no more call slots exist or a call exists
435      *                that is dialing, alerting, ringing, or waiting. Other
436      *                errors are handled asynchronously.
437      */
dial(String dialString, @NonNull DialArgs dialArgs)438     Connection dial(String dialString, @NonNull DialArgs dialArgs) throws CallStateException;
439 
440     /**
441      * Initiate a new conference connection. This happens asynchronously, so you
442      * cannot assume the audio path is connected (or a call index has been
443      * assigned) until PhoneStateChanged notification has occurred.
444      *
445      * @param participantsToDial The participants to dial.
446      * @param dialArgs Parameters to perform the start conference with.
447      * @exception CallStateException if a new outgoing call is not currently
448      *                possible because no more call slots exist or a call exists
449      *                that is dialing, alerting, ringing, or waiting. Other
450      *                errors are handled asynchronously.
451      */
startConference(String[] participantsToDial, @NonNull DialArgs dialArgs)452     Connection startConference(String[] participantsToDial, @NonNull DialArgs dialArgs)
453             throws CallStateException;
454 
455     /**
456      * Handles PIN MMI commands (PIN/PIN2/PUK/PUK2), which are initiated
457      * without SEND (so <code>dial</code> is not appropriate).
458      *
459      * @param dialString the MMI command to be executed.
460      * @return true if MMI command is executed.
461      */
handlePinMmi(String dialString)462     boolean handlePinMmi(String dialString);
463 
464     /**
465      * Handles USSD commands
466      *
467      * @param ussdRequest the USSD command to be executed.
468      * @param wrappedCallback receives the callback result.
469      */
handleUssdRequest(String ussdRequest, ResultReceiver wrappedCallback)470     boolean handleUssdRequest(String ussdRequest, ResultReceiver wrappedCallback)
471             throws CallStateException;
472 
473     /**
474      * Handles in-call MMI commands. While in a call, or while receiving a
475      * call, use this to execute MMI commands.
476      * see 3GPP 20.030, section 6.5.5.1 for specs on the allowed MMI commands.
477      *
478      * @param command the MMI command to be executed.
479      * @return true if the MMI command is executed.
480      * @throws CallStateException
481      */
handleInCallMmiCommands(String command)482     boolean handleInCallMmiCommands(String command) throws CallStateException;
483 
484     /**
485      * Play a DTMF tone on the active call. Ignored if there is no active call.
486      * @param c should be one of 0-9, '*' or '#'. Other values will be
487      * silently ignored.
488      */
sendDtmf(char c)489     void sendDtmf(char c);
490 
491     /**
492      * Start to paly a DTMF tone on the active call. Ignored if there is no active call
493      * or there is a playing DTMF tone.
494      * @param c should be one of 0-9, '*' or '#'. Other values will be
495      * silently ignored.
496      */
startDtmf(char c)497     void startDtmf(char c);
498 
499     /**
500      * Stop the playing DTMF tone. Ignored if there is no playing DTMF
501      * tone or no active call.
502      */
stopDtmf()503     void stopDtmf();
504 
505     /**
506      * Sets the radio power on/off state (off is sometimes
507      * called "airplane mode"). Current state can be gotten via
508      * {@link #getServiceState()}.{@link
509      * android.telephony.ServiceState#getState() getState()}.
510      * <strong>Note: </strong>This request is asynchronous.
511      * getServiceState().getState() will not change immediately after this call.
512      * registerForServiceStateChanged() to find out when the
513      * request is complete.
514      *
515      * @param power true means "on", false means "off".
516      */
setRadioPower(boolean power)517     default void setRadioPower(boolean power) {
518         setRadioPower(power, false, false, false);
519     }
520 
521     /**
522      * Sets the radio power on/off state with option to specify whether it's for emergency call
523      * (off is sometimes called "airplane mode"). Current state can be gotten via
524      * {@link #getServiceState()}.{@link
525      * android.telephony.ServiceState#getState() getState()}.
526      * <strong>Note: </strong>This request is asynchronous.
527      * getServiceState().getState() will not change immediately after this call.
528      * registerForServiceStateChanged() to find out when the
529      * request is complete.
530      *
531      * @param power true means "on", false means "off".
532      * @param forEmergencyCall true means the purpose of turning radio power on is for emergency
533      *                         call. No effect if power is set false.
534      * @param isSelectedPhoneForEmergencyCall true means this phone / modem is selected to place
535      *                                  emergency call after turning power on. No effect if power
536      *                                  or forEmergency is set false.
537      * @param forceApply true means always call setRadioPower HAL API without checking against
538      *                   current radio power state. It's needed when: radio was powered on into
539      *                   emergency call mode, to exit from that mode, we set radio
540      *                   power on again with forEmergencyCall being false.
541      */
setRadioPower(boolean power, boolean forEmergencyCall, boolean isSelectedPhoneForEmergencyCall, boolean forceApply)542     default void setRadioPower(boolean power, boolean forEmergencyCall,
543             boolean isSelectedPhoneForEmergencyCall, boolean forceApply) {}
544 
545     /**
546      * Get the line 1 phone number (MSISDN). For CDMA phones, the MDN is returned
547      * and {@link #getMsisdn()} will return the MSISDN on CDMA/LTE phones.<p>
548      *
549      * @return phone number. May return null if not
550      * available or the SIM is not ready
551      */
getLine1Number()552     String getLine1Number();
553 
554     /**
555      * Returns the alpha tag associated with the msisdn number.
556      * If there is no alpha tag associated or the record is not yet available,
557      * returns a default localized string. <p>
558      */
getLine1AlphaTag()559     String getLine1AlphaTag();
560 
561     /**
562      * Sets the MSISDN phone number in the SIM card.
563      *
564      * @param alphaTag the alpha tag associated with the MSISDN phone number
565      *        (see getMsisdnAlphaTag)
566      * @param number the new MSISDN phone number to be set on the SIM.
567      * @param onComplete a callback message when the action is completed.
568      *
569      * @return true if req is sent, false otherwise. If req is not sent there will be no response,
570      * that is, onComplete will never be sent.
571      */
setLine1Number(String alphaTag, String number, Message onComplete)572     boolean setLine1Number(String alphaTag, String number, Message onComplete);
573 
574     /**
575      * Get the voice mail access phone number. Typically dialed when the
576      * user holds the "1" key in the phone app. May return null if not
577      * available or the SIM is not ready.<p>
578      */
getVoiceMailNumber()579     String getVoiceMailNumber();
580 
581     /**
582      * Returns the alpha tag associated with the voice mail number.
583      * If there is no alpha tag associated or the record is not yet available,
584      * returns a default localized string. <p>
585      *
586      * Please use this value instead of some other localized string when
587      * showing a name for this number in the UI. For example, call log
588      * entries should show this alpha tag. <p>
589      *
590      * Usage of this alpha tag in the UI is a common carrier requirement.
591      */
getVoiceMailAlphaTag()592     String getVoiceMailAlphaTag();
593 
594     /**
595      * setVoiceMailNumber
596      * sets the voicemail number in the SIM card.
597      *
598      * @param alphaTag the alpha tag associated with the voice mail number
599      *        (see getVoiceMailAlphaTag)
600      * @param voiceMailNumber the new voicemail number to be set on the SIM.
601      * @param onComplete a callback message when the action is completed.
602      */
setVoiceMailNumber(String alphaTag, String voiceMailNumber, Message onComplete)603     void setVoiceMailNumber(String alphaTag,
604                             String voiceMailNumber,
605                             Message onComplete);
606 
607     /**
608      * getCallForwardingOptions
609      * gets a call forwarding option for SERVICE_CLASS_VOICE. The return value of
610      * ((AsyncResult)onComplete.obj) is an array of CallForwardInfo.
611      *
612      * @param commandInterfaceCFReason is one of the valid call forwarding
613      *        CF_REASONS, as defined in
614      *        <code>com.android.internal.telephony.CommandsInterface.</code>
615      * @param onComplete a callback message when the action is completed.
616      *        @see com.android.internal.telephony.CallForwardInfo for details.
617      */
getCallForwardingOption(int commandInterfaceCFReason, Message onComplete)618     void getCallForwardingOption(int commandInterfaceCFReason,
619                                   Message onComplete);
620 
621     /**
622      * getCallForwardingOptions
623      * gets a call forwarding option. The return value of
624      * ((AsyncResult)onComplete.obj) is an array of CallForwardInfo.
625      *
626      * @param commandInterfaceCFReason is one of the valid call forwarding
627      *        CF_REASONS, as defined in
628      *        <code>com.android.internal.telephony.CommandsInterface.</code>
629      * @param serviceClass is a sum of SERVICE_CLASS_* as defined in
630      *        <code>com.android.internal.telephony.CommandsInterface.</code>
631      * @param onComplete a callback message when the action is completed.
632      *        @see com.android.internal.telephony.CallForwardInfo for details.
633      */
getCallForwardingOption(int commandInterfaceCFReason, int serviceClass, Message onComplete)634     void getCallForwardingOption(int commandInterfaceCFReason, int serviceClass,
635                                   Message onComplete);
636 
637     /**
638      * setCallForwardingOptions
639      * sets a call forwarding option for SERVICE_CLASS_VOICE.
640      *
641      * @param commandInterfaceCFAction is one of the valid call forwarding
642      *        CF_ACTIONS, as defined in
643      *        <code>com.android.internal.telephony.CommandsInterface.</code>
644      * @param commandInterfaceCFReason is one of the valid call forwarding
645      *        CF_REASONS, as defined in
646      *        <code>com.android.internal.telephony.CommandsInterface.</code>
647      * @param dialingNumber is the target phone number to forward calls to
648      * @param timerSeconds is used by CFNRy to indicate the timeout before
649      *        forwarding is attempted.
650      * @param onComplete a callback message when the action is completed.
651      */
setCallForwardingOption(int commandInterfaceCFAction, int commandInterfaceCFReason, String dialingNumber, int timerSeconds, Message onComplete)652     void setCallForwardingOption(int commandInterfaceCFAction,
653                                  int commandInterfaceCFReason,
654                                  String dialingNumber,
655                                  int timerSeconds,
656                                  Message onComplete);
657 
658     /**
659      * setCallForwardingOptions
660      * sets a call forwarding option.
661      *
662      * @param commandInterfaceCFAction is one of the valid call forwarding
663      *        CF_ACTIONS, as defined in
664      *        <code>com.android.internal.telephony.CommandsInterface.</code>
665      * @param commandInterfaceCFReason is one of the valid call forwarding
666      *        CF_REASONS, as defined in
667      *        <code>com.android.internal.telephony.CommandsInterface.</code>
668      * @param dialingNumber is the target phone number to forward calls to
669      * @param serviceClass is a sum of SERVICE_CLASS_* as defined in
670      *        <code>com.android.internal.telephony.CommandsInterface.</code>
671      * @param timerSeconds is used by CFNRy to indicate the timeout before
672      *        forwarding is attempted.
673      * @param onComplete a callback message when the action is completed.
674      */
setCallForwardingOption(int commandInterfaceCFAction, int commandInterfaceCFReason, String dialingNumber, int serviceClass, int timerSeconds, Message onComplete)675     void setCallForwardingOption(int commandInterfaceCFAction,
676                                  int commandInterfaceCFReason,
677                                  String dialingNumber,
678                                  int serviceClass,
679                                  int timerSeconds,
680                                  Message onComplete);
681 
682     /**
683      * Gets a call barring option. The return value of ((AsyncResult) onComplete.obj) will be an
684      * Integer representing the sum of enabled serivice classes (sum of SERVICE_CLASS_*)
685      *
686      * @param facility is one of CB_FACILTY_*
687      * @param password is password or "" if not required
688      * @param serviceClass is a sum of SERVICE_CLASS_*
689      * @param onComplete is callback message when the action is completed.
690      */
getCallBarring(String facility, String password, Message onComplete, int serviceClass)691     public void getCallBarring(String facility,
692             String password,
693             Message onComplete,
694             int serviceClass);
695 
696     /**
697      * Sets a call barring option.
698      *
699      * @param facility is one of CB_FACILTY_*
700      * @param lockState is true means lock, false means unlock
701      * @param password is password or "" if not required
702      * @param serviceClass is a sum of SERVICE_CLASS_*
703      * @param onComplete is callback message when the action is completed.
704      */
setCallBarring(String facility, boolean lockState, String password, Message onComplete, int serviceClass)705     public void setCallBarring(String facility,
706             boolean lockState,
707             String password,
708             Message onComplete,
709             int serviceClass);
710 
711     /**
712      * getOutgoingCallerIdDisplay
713      * gets outgoing caller id display. The return value of
714      * ((AsyncResult)onComplete.obj) is an array of int, with a length of 2.
715      *
716      * @param onComplete a callback message when the action is completed.
717      *        @see com.android.internal.telephony.CommandsInterface#getCLIR for details.
718      */
getOutgoingCallerIdDisplay(Message onComplete)719     void getOutgoingCallerIdDisplay(Message onComplete);
720 
721     /**
722      * setOutgoingCallerIdDisplay
723      * sets a call forwarding option.
724      *
725      * @param commandInterfaceCLIRMode is one of the valid call CLIR
726      *        modes, as defined in
727      *        <code>com.android.internal.telephony.CommandsInterface./code>
728      * @param onComplete a callback message when the action is completed.
729      */
setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode, Message onComplete)730     void setOutgoingCallerIdDisplay(int commandInterfaceCLIRMode,
731                                     Message onComplete);
732 
733     /**
734      * getCallWaiting
735      * gets call waiting activation state. The return value of
736      * ((AsyncResult)onComplete.obj) is an array of int, with a length of 1.
737      *
738      * @param onComplete a callback message when the action is completed.
739      *        @see com.android.internal.telephony.CommandsInterface#queryCallWaiting for details.
740      */
getCallWaiting(Message onComplete)741     void getCallWaiting(Message onComplete);
742 
743     /**
744      * setCallWaiting
745      * sets a call forwarding option.
746      *
747      * @param enable is a boolean representing the state that you are
748      *        requesting, true for enabled, false for disabled.
749      * @param onComplete a callback message when the action is completed.
750      */
setCallWaiting(boolean enable, Message onComplete)751     void setCallWaiting(boolean enable, Message onComplete);
752 
753     /**
754      * Scan available networks. This method is asynchronous; .
755      * On completion, <code>response.obj</code> is set to an AsyncResult with
756      * one of the following members:.<p>
757      *<ul>
758      * <li><code>response.obj.result</code> will be a <code>List</code> of
759      * <code>OperatorInfo</code> objects, or</li>
760      * <li><code>response.obj.exception</code> will be set with an exception
761      * on failure.</li>
762      * </ul>
763      */
getAvailableNetworks(Message response)764     void getAvailableNetworks(Message response);
765 
766     /**
767      * Start a network scan. This method is asynchronous; .
768      * On completion, <code>response.obj</code> is set to an AsyncResult with
769      * one of the following members:.<p>
770      * <ul>
771      * <li><code>response.obj.result</code> will be a <code>NetworkScanResult</code> object, or</li>
772      * <li><code>response.obj.exception</code> will be set with an exception
773      * on failure.</li>
774      * </ul>
775      */
startNetworkScan(NetworkScanRequest nsr, Message response)776     void startNetworkScan(NetworkScanRequest nsr, Message response);
777 
778     /**
779      * Stop ongoing network scan. This method is asynchronous; .
780      * On completion, <code>response.obj</code> is set to an AsyncResult with
781      * one of the following members:.<p>
782      * <ul>
783      * <li><code>response.obj.result</code> will be a <code>NetworkScanResult</code> object, or</li>
784      * <li><code>response.obj.exception</code> will be set with an exception
785      * on failure.</li>
786      * </ul>
787      */
stopNetworkScan(Message response)788     void stopNetworkScan(Message response);
789 
790     /**
791      * Mutes or unmutes the microphone for the active call. The microphone
792      * is automatically unmuted if a call is answered, dialed, or resumed
793      * from a holding state.
794      *
795      * @param muted true to mute the microphone,
796      * false to activate the microphone.
797      */
798 
setMute(boolean muted)799     void setMute(boolean muted);
800 
801     /**
802      * Gets current mute status. Use
803      * {@link #registerForPreciseCallStateChanged(android.os.Handler, int,
804      * java.lang.Object) registerForPreciseCallStateChanged()}
805      * as a change notifcation, although presently phone state changed is not
806      * fired when setMute() is called.
807      *
808      * @return true is muting, false is unmuting
809      */
getMute()810     boolean getMute();
811 
812     /**
813      * Update the ServiceState CellLocation for current network registration.
814      */
updateServiceLocation()815     void updateServiceLocation();
816 
817     /**
818      * Enable location update notifications.
819      */
enableLocationUpdates()820     void enableLocationUpdates();
821 
822     /**
823      * Disable location update notifications.
824      */
disableLocationUpdates()825     void disableLocationUpdates();
826 
827     /**
828      * @return true if enable data connection on roaming
829      */
getDataRoamingEnabled()830     boolean getDataRoamingEnabled();
831 
832     /**
833      * @param enable set true if enable data connection on roaming
834      */
setDataRoamingEnabled(boolean enable)835     void setDataRoamingEnabled(boolean enable);
836 
837     /**
838      * @return true if user has enabled data
839      */
isUserDataEnabled()840     boolean isUserDataEnabled();
841 
842     /**
843      * Retrieves the unique device ID, e.g., IMEI for GSM phones and MEID for CDMA phones.
844      */
getDeviceId()845     String getDeviceId();
846 
847     /**
848      * Retrieves the software version number for the device, e.g., IMEI/SV
849      * for GSM phones.
850      */
getDeviceSvn()851     String getDeviceSvn();
852 
853     /**
854      * Retrieves the unique subscriber ID, e.g., IMSI for GSM phones.
855      */
getSubscriberId()856     String getSubscriberId();
857 
858     /**
859      * Retrieves the Group Identifier Level1 for GSM phones.
860      */
getGroupIdLevel1()861     String getGroupIdLevel1();
862 
863     /**
864      * Retrieves the Group Identifier Level2 for phones.
865      */
getGroupIdLevel2()866     String getGroupIdLevel2();
867 
868     /* CDMA support methods */
869 
870     /**
871      * Retrieves the ESN for CDMA phones.
872      */
getEsn()873     String getEsn();
874 
875     /**
876      * Retrieves MEID for CDMA phones.
877      */
getMeid()878     String getMeid();
879 
880     /**
881      * Retrieves IMEI for phones. Returns null if IMEI is not set.
882      */
getImei()883     String getImei();
884 
885     /**
886      * Retrieves the IccPhoneBookInterfaceManager of the Phone
887      */
getIccPhoneBookInterfaceManager()888     public IccPhoneBookInterfaceManager getIccPhoneBookInterfaceManager();
889 
890     /**
891      * Activate or deactivate cell broadcast SMS.
892      *
893      * @param activate
894      *            0 = activate, 1 = deactivate
895      * @param response
896      *            Callback message is empty on completion
897      */
activateCellBroadcastSms(int activate, Message response)898     void activateCellBroadcastSms(int activate, Message response);
899 
900     /**
901      * Query the current configuration of cdma cell broadcast SMS.
902      *
903      * @param response
904      *            Callback message is empty on completion
905      */
getCellBroadcastSmsConfig(Message response)906     void getCellBroadcastSmsConfig(Message response);
907 
908     /**
909      * Configure cell broadcast SMS.
910      *
911      * TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig
912      *
913      * @param response
914      *            Callback message is empty on completion
915      */
setCellBroadcastSmsConfig(int[] configValuesArray, Message response)916     public void setCellBroadcastSmsConfig(int[] configValuesArray, Message response);
917 
918     /*
919     * Sets the carrier information needed to encrypt the IMSI and IMPI.
920     * @param imsiEncryptionInfo Carrier specific information that will be used to encrypt the
921     *        IMSI and IMPI. This includes the Key type, the Public key
922     *        {@link java.security.PublicKey} and the Key identifier.
923     */
setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo)924     public void setCarrierInfoForImsiEncryption(ImsiEncryptionInfo imsiEncryptionInfo);
925 
926     /**
927      * Returns Carrier specific information that will be used to encrypt the IMSI and IMPI.
928      * @param keyType whether the key is being used for WLAN or ePDG.
929      * @return ImsiEncryptionInfo which includes the Key Type, the Public Key
930      *        {@link java.security.PublicKey} and the Key Identifier.
931      *        The keyIdentifier This is used by the server to help it locate the private key to
932      *        decrypt the permanent identity.
933      */
getCarrierInfoForImsiEncryption(int keyType)934     public ImsiEncryptionInfo getCarrierInfoForImsiEncryption(int keyType);
935 
936     /**
937      * Resets the Carrier Keys, by deleting them from the database and sending a download intent.
938      */
resetCarrierKeysForImsiEncryption()939     public void resetCarrierKeysForImsiEncryption();
940 }
941