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