1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.internal.telephony;
18
19import com.android.internal.telephony.gsm.SmsBroadcastConfigInfo;
20
21import android.os.Message;
22import android.os.Handler;
23
24
25/**
26 * {@hide}
27 */
28public interface CommandsInterface {
29    enum RadioState {
30        RADIO_OFF,         /* Radio explictly powered off (eg CFUN=0) */
31        RADIO_UNAVAILABLE, /* Radio unavailable (eg, resetting or not booted) */
32        SIM_NOT_READY,     /* Radio is on, but the SIM interface is not ready */
33        SIM_LOCKED_OR_ABSENT,  /* SIM PIN locked, PUK required, network
34                               personalization, or SIM absent */
35        SIM_READY,         /* Radio is on and SIM interface is available */
36        RUIM_NOT_READY,    /* Radio is on, but the RUIM interface is not ready */
37        RUIM_READY,        /* Radio is on and the RUIM interface is available */
38        RUIM_LOCKED_OR_ABSENT, /* RUIM PIN locked, PUK required, network
39                                  personalization locked, or RUIM absent */
40        NV_NOT_READY,      /* Radio is on, but the NV interface is not available */
41        NV_READY;          /* Radio is on and the NV interface is available */
42
43        public boolean isOn() /* and available...*/ {
44            return this == SIM_NOT_READY
45                    || this == SIM_LOCKED_OR_ABSENT
46                    || this == SIM_READY
47                    || this == RUIM_NOT_READY
48                    || this == RUIM_READY
49                    || this == RUIM_LOCKED_OR_ABSENT
50                    || this == NV_NOT_READY
51                    || this == NV_READY;
52        }
53
54        public boolean isAvailable() {
55            return this != RADIO_UNAVAILABLE;
56        }
57
58        public boolean isSIMReady() {
59            return this == SIM_READY;
60        }
61
62        public boolean isRUIMReady() {
63            return this == RUIM_READY;
64        }
65
66        public boolean isNVReady() {
67            return this == NV_READY;
68        }
69
70        public boolean isGsm() {
71            return this == SIM_NOT_READY
72                    || this == SIM_LOCKED_OR_ABSENT
73                    || this == SIM_READY;
74        }
75
76        public boolean isCdma() {
77            return this ==  RUIM_NOT_READY
78                    || this == RUIM_READY
79                    || this == RUIM_LOCKED_OR_ABSENT
80                    || this == NV_NOT_READY
81                    || this == NV_READY;
82        }
83    }
84
85    //***** Constants
86
87    // Used as parameter to dial() and setCLIR() below
88    static final int CLIR_DEFAULT = 0;      // "use subscription default value"
89    static final int CLIR_INVOCATION = 1;   // (restrict CLI presentation)
90    static final int CLIR_SUPPRESSION = 2;  // (allow CLI presentation)
91
92
93    // Used as parameters for call forward methods below
94    static final int CF_ACTION_DISABLE          = 0;
95    static final int CF_ACTION_ENABLE           = 1;
96//  static final int CF_ACTION_UNUSED           = 2;
97    static final int CF_ACTION_REGISTRATION     = 3;
98    static final int CF_ACTION_ERASURE          = 4;
99
100    static final int CF_REASON_UNCONDITIONAL    = 0;
101    static final int CF_REASON_BUSY             = 1;
102    static final int CF_REASON_NO_REPLY         = 2;
103    static final int CF_REASON_NOT_REACHABLE    = 3;
104    static final int CF_REASON_ALL              = 4;
105    static final int CF_REASON_ALL_CONDITIONAL  = 5;
106
107    // Used for call barring methods below
108    static final String CB_FACILITY_BAOC         = "AO";
109    static final String CB_FACILITY_BAOIC        = "OI";
110    static final String CB_FACILITY_BAOICxH      = "OX";
111    static final String CB_FACILITY_BAIC         = "AI";
112    static final String CB_FACILITY_BAICr        = "IR";
113    static final String CB_FACILITY_BA_ALL       = "AB";
114    static final String CB_FACILITY_BA_MO        = "AG";
115    static final String CB_FACILITY_BA_MT        = "AC";
116    static final String CB_FACILITY_BA_SIM       = "SC";
117    static final String CB_FACILITY_BA_FD        = "FD";
118
119
120    // Used for various supp services apis
121    // See 27.007 +CCFC or +CLCK
122    static final int SERVICE_CLASS_NONE     = 0; // no user input
123    static final int SERVICE_CLASS_VOICE    = (1 << 0);
124    static final int SERVICE_CLASS_DATA     = (1 << 1); //synoym for 16+32+64+128
125    static final int SERVICE_CLASS_FAX      = (1 << 2);
126    static final int SERVICE_CLASS_SMS      = (1 << 3);
127    static final int SERVICE_CLASS_DATA_SYNC = (1 << 4);
128    static final int SERVICE_CLASS_DATA_ASYNC = (1 << 5);
129    static final int SERVICE_CLASS_PACKET   = (1 << 6);
130    static final int SERVICE_CLASS_PAD      = (1 << 7);
131    static final int SERVICE_CLASS_MAX      = (1 << 7); // Max SERVICE_CLASS value
132
133    // Numeric representation of string values returned
134    // by messages sent to setOnUSSD handler
135    static final int USSD_MODE_NOTIFY       = 0;
136    static final int USSD_MODE_REQUEST      = 1;
137
138    // SIM Refresh results, passed up from RIL.
139    static final int SIM_REFRESH_FILE_UPDATED   = 0;  // Single file updated
140    static final int SIM_REFRESH_INIT           = 1;  // SIM initialized; reload all
141    static final int SIM_REFRESH_RESET          = 2;  // SIM reset; may be locked
142
143    // GSM SMS fail cause for acknowledgeLastIncomingSMS. From TS 23.040, 9.2.3.22.
144    static final int GSM_SMS_FAIL_CAUSE_MEMORY_CAPACITY_EXCEEDED    = 0xD3;
145    static final int GSM_SMS_FAIL_CAUSE_UNSPECIFIED_ERROR           = 0xFF;
146
147    // CDMA SMS fail cause for acknowledgeLastIncomingCdmaSms.  From TS N.S0005, 6.5.2.125.
148    static final int CDMA_SMS_FAIL_CAUSE_INVALID_TELESERVICE_ID     = 4;
149    static final int CDMA_SMS_FAIL_CAUSE_RESOURCE_SHORTAGE          = 35;
150    static final int CDMA_SMS_FAIL_CAUSE_OTHER_TERMINAL_PROBLEM     = 39;
151    static final int CDMA_SMS_FAIL_CAUSE_ENCODING_PROBLEM           = 96;
152
153    //***** Methods
154
155    RadioState getRadioState();
156
157    /**
158     * Fires on any RadioState transition
159     * Always fires immediately as well
160     *
161     * do not attempt to calculate transitions by storing getRadioState() values
162     * on previous invocations of this notification. Instead, use the other
163     * registration methods
164     */
165    void registerForRadioStateChanged(Handler h, int what, Object obj);
166    void unregisterForRadioStateChanged(Handler h);
167
168    /**
169     * Fires on any transition into RadioState.isOn()
170     * Fires immediately if currently in that state
171     * In general, actions should be idempotent. State may change
172     * before event is received.
173     */
174    void registerForOn(Handler h, int what, Object obj);
175    void unregisterForOn(Handler h);
176
177    /**
178     * Fires on any transition out of RadioState.isAvailable()
179     * Fires immediately if currently in that state
180     * In general, actions should be idempotent. State may change
181     * before event is received.
182     */
183    void registerForAvailable(Handler h, int what, Object obj);
184    void unregisterForAvailable(Handler h);
185
186    /**
187     * Fires on any transition into !RadioState.isAvailable()
188     * Fires immediately if currently in that state
189     * In general, actions should be idempotent. State may change
190     * before event is received.
191     */
192    void registerForNotAvailable(Handler h, int what, Object obj);
193    void unregisterForNotAvailable(Handler h);
194
195    /**
196     * Fires on any transition into RADIO_OFF or !RadioState.isAvailable()
197     * Fires immediately if currently in that state
198     * In general, actions should be idempotent. State may change
199     * before event is received.
200     */
201    void registerForOffOrNotAvailable(Handler h, int what, Object obj);
202    void unregisterForOffOrNotAvailable(Handler h);
203
204    /**
205     * Fires on any transition into SIM_READY
206     * Fires immediately if if currently in that state
207     * In general, actions should be idempotent. State may change
208     * before event is received.
209     */
210    void registerForSIMReady(Handler h, int what, Object obj);
211    void unregisterForSIMReady(Handler h);
212
213    /** Any transition into SIM_LOCKED_OR_ABSENT */
214    void registerForSIMLockedOrAbsent(Handler h, int what, Object obj);
215    void unregisterForSIMLockedOrAbsent(Handler h);
216
217    void registerForCallStateChanged(Handler h, int what, Object obj);
218    void unregisterForCallStateChanged(Handler h);
219    void registerForNetworkStateChanged(Handler h, int what, Object obj);
220    void unregisterForNetworkStateChanged(Handler h);
221    void registerForDataStateChanged(Handler h, int what, Object obj);
222    void unregisterForDataStateChanged(Handler h);
223
224    void registerForRadioTechnologyChanged(Handler h, int what, Object obj);
225    void unregisterForRadioTechnologyChanged(Handler h);
226    void registerForNVReady(Handler h, int what, Object obj);
227    void unregisterForNVReady(Handler h);
228    void registerForRUIMLockedOrAbsent(Handler h, int what, Object obj);
229    void unregisterForRUIMLockedOrAbsent(Handler h);
230
231    /** InCall voice privacy notifications */
232    void registerForInCallVoicePrivacyOn(Handler h, int what, Object obj);
233    void unregisterForInCallVoicePrivacyOn(Handler h);
234    void registerForInCallVoicePrivacyOff(Handler h, int what, Object obj);
235    void unregisterForInCallVoicePrivacyOff(Handler h);
236
237    /**
238     * Fires on any transition into RUIM_READY
239     * Fires immediately if if currently in that state
240     * In general, actions should be idempotent. State may change
241     * before event is received.
242     */
243    void registerForRUIMReady(Handler h, int what, Object obj);
244    void unregisterForRUIMReady(Handler h);
245
246    /**
247     * unlike the register* methods, there's only one new SMS handler
248     * if you need to unregister, you should also tell the radio to stop
249     * sending SMS's to you (via AT+CNMI)
250     *
251     * AsyncResult.result is a String containing the SMS PDU
252     */
253    void setOnNewSMS(Handler h, int what, Object obj);
254    void unSetOnNewSMS(Handler h);
255
256   /**
257     * Register for NEW_SMS_ON_SIM unsolicited message
258     *
259     * AsyncResult.result is an int array containing the index of new SMS
260     */
261    void setOnSmsOnSim(Handler h, int what, Object obj);
262    void unSetOnSmsOnSim(Handler h);
263
264    /**
265     * Register for NEW_SMS_STATUS_REPORT unsolicited message
266     *
267     * AsyncResult.result is a String containing the status report PDU
268     */
269    void setOnSmsStatus(Handler h, int what, Object obj);
270    void unSetOnSmsStatus(Handler h);
271
272    /**
273     * unlike the register* methods, there's only one NITZ time handler
274     *
275     * AsyncResult.result is an Object[]
276     * ((Object[])AsyncResult.result)[0] is a String containing the NITZ time string
277     * ((Object[])AsyncResult.result)[1] is a Long containing the milliseconds since boot as
278     *                                   returned by elapsedRealtime() when this NITZ time
279     *                                   was posted.
280     *
281     * Please note that the delivery of this message may be delayed several
282     * seconds on system startup
283     */
284    void setOnNITZTime(Handler h, int what, Object obj);
285    void unSetOnNITZTime(Handler h);
286
287    /**
288     * unlike the register* methods, there's only one USSD notify handler
289     *
290     * Represents the arrival of a USSD "notify" message, which may
291     * or may not have been triggered by a previous USSD send
292     *
293     * AsyncResult.result is a String[]
294     * ((String[])(AsyncResult.result))[0] contains status code
295     *      "0"   USSD-Notify -- text in ((const char **)data)[1]
296     *      "1"   USSD-Request -- text in ((const char **)data)[1]
297     *      "2"   Session terminated by network
298     *      "3"   other local client (eg, SIM Toolkit) has responded
299     *      "4"   Operation not supported
300     *      "5"   Network timeout
301     *
302     * ((String[])(AsyncResult.result))[1] contains the USSD message
303     * The numeric representations of these are in USSD_MODE_*
304     */
305
306    void setOnUSSD(Handler h, int what, Object obj);
307    void unSetOnUSSD(Handler h);
308
309    /**
310     * unlike the register* methods, there's only one signal strength handler
311     * AsyncResult.result is an int[2]
312     * response.obj.result[0] is received signal strength (0-31, 99)
313     * response.obj.result[1] is  bit error rate (0-7, 99)
314     * as defined in TS 27.007 8.5
315     */
316
317    void setOnSignalStrengthUpdate(Handler h, int what, Object obj);
318    void unSetOnSignalStrengthUpdate(Handler h);
319
320    /**
321     * Sets the handler for SIM/RUIM SMS storage full unsolicited message.
322     * Unlike the register* methods, there's only one notification handler
323     *
324     * @param h Handler for notification message.
325     * @param what User-defined message code.
326     * @param obj User object.
327     */
328    void setOnIccSmsFull(Handler h, int what, Object obj);
329    void unSetOnIccSmsFull(Handler h);
330
331    /**
332     * Sets the handler for SIM Refresh notifications.
333     * Unlike the register* methods, there's only one notification handler
334     *
335     * @param h Handler for notification message.
336     * @param what User-defined message code.
337     * @param obj User object.
338     */
339    void setOnIccRefresh(Handler h, int what, Object obj);
340    void unSetOnIccRefresh(Handler h);
341
342    /**
343     * Sets the handler for RING notifications.
344     * Unlike the register* methods, there's only one notification handler
345     *
346     * @param h Handler for notification message.
347     * @param what User-defined message code.
348     * @param obj User object.
349     */
350    void setOnCallRing(Handler h, int what, Object obj);
351    void unSetOnCallRing(Handler h);
352
353    /**
354     * Sets the handler for RESTRICTED_STATE changed notification,
355     * eg, for Domain Specific Access Control
356     * unlike the register* methods, there's only one signal strength handler
357     *
358     * AsyncResult.result is an int[1]
359     * response.obj.result[0] is a bitmask of RIL_RESTRICTED_STATE_* values
360     */
361
362    void setOnRestrictedStateChanged(Handler h, int what, Object obj);
363    void unSetOnRestrictedStateChanged(Handler h);
364
365    /**
366     * Sets the handler for Supplementary Service Notifications.
367     * Unlike the register* methods, there's only one notification handler
368     *
369     * @param h Handler for notification message.
370     * @param what User-defined message code.
371     * @param obj User object.
372     */
373    void setOnSuppServiceNotification(Handler h, int what, Object obj);
374    void unSetOnSuppServiceNotification(Handler h);
375
376    /**
377     * Sets the handler for Session End Notifications for STK.
378     * Unlike the register* methods, there's only one notification handler
379     *
380     * @param h Handler for notification message.
381     * @param what User-defined message code.
382     * @param obj User object.
383     */
384    void setOnStkSessionEnd(Handler h, int what, Object obj);
385    void unSetOnStkSessionEnd(Handler h);
386
387    /**
388     * Sets the handler for Proactive Commands for STK.
389     * Unlike the register* methods, there's only one notification handler
390     *
391     * @param h Handler for notification message.
392     * @param what User-defined message code.
393     * @param obj User object.
394     */
395    void setOnStkProactiveCmd(Handler h, int what, Object obj);
396    void unSetOnStkProactiveCmd(Handler h);
397
398    /**
399     * Sets the handler for Event Notifications for STK.
400     * Unlike the register* methods, there's only one notification handler
401     *
402     * @param h Handler for notification message.
403     * @param what User-defined message code.
404     * @param obj User object.
405     */
406    void setOnStkEvent(Handler h, int what, Object obj);
407    void unSetOnStkEvent(Handler h);
408
409    /**
410     * Sets the handler for Call Set Up Notifications for STK.
411     * Unlike the register* methods, there's only one notification handler
412     *
413     * @param h Handler for notification message.
414     * @param what User-defined message code.
415     * @param obj User object.
416     */
417    void setOnStkCallSetUp(Handler h, int what, Object obj);
418    void unSetOnStkCallSetUp(Handler h);
419
420    /**
421     * Enables/disbables supplementary service related notifications from
422     * the network.
423     *
424     * @param enable true to enable notifications, false to disable.
425     * @param result Message to be posted when command completes.
426     */
427    void setSuppServiceNotifications(boolean enable, Message result);
428    //void unSetSuppServiceNotifications(Handler h);
429
430    /**
431     * Sets the handler for Event Notifications for CDMA Display Info.
432     * Unlike the register* methods, there's only one notification handler
433     *
434     * @param h Handler for notification message.
435     * @param what User-defined message code.
436     * @param obj User object.
437     */
438    void registerForDisplayInfo(Handler h, int what, Object obj);
439    void unregisterForDisplayInfo(Handler h);
440
441    /**
442     * Sets the handler for Event Notifications for CallWaiting Info.
443     * Unlike the register* methods, there's only one notification handler
444     *
445     * @param h Handler for notification message.
446     * @param what User-defined message code.
447     * @param obj User object.
448     */
449    void registerForCallWaitingInfo(Handler h, int what, Object obj);
450    void unregisterForCallWaitingInfo(Handler h);
451
452    /**
453     * Sets the handler for Event Notifications for Signal Info.
454     * Unlike the register* methods, there's only one notification handler
455     *
456     * @param h Handler for notification message.
457     * @param what User-defined message code.
458     * @param obj User object.
459     */
460    void registerForSignalInfo(Handler h, int what, Object obj);
461    void unregisterForSignalInfo(Handler h);
462
463    /**
464     * Registers the handler for CDMA number information record
465     * Unlike the register* methods, there's only one notification handler
466     *
467     * @param h Handler for notification message.
468     * @param what User-defined message code.
469     * @param obj User object.
470     */
471    void registerForNumberInfo(Handler h, int what, Object obj);
472    void unregisterForNumberInfo(Handler h);
473
474    /**
475     * Registers the handler for CDMA redirected number Information record
476     * Unlike the register* methods, there's only one notification handler
477     *
478     * @param h Handler for notification message.
479     * @param what User-defined message code.
480     * @param obj User object.
481     */
482    void registerForRedirectedNumberInfo(Handler h, int what, Object obj);
483    void unregisterForRedirectedNumberInfo(Handler h);
484
485    /**
486     * Registers the handler for CDMA line control information record
487     * Unlike the register* methods, there's only one notification handler
488     *
489     * @param h Handler for notification message.
490     * @param what User-defined message code.
491     * @param obj User object.
492     */
493    void registerForLineControlInfo(Handler h, int what, Object obj);
494    void unregisterForLineControlInfo(Handler h);
495
496    /**
497     * Registers the handler for CDMA T53 CLIR information record
498     * Unlike the register* methods, there's only one notification handler
499     *
500     * @param h Handler for notification message.
501     * @param what User-defined message code.
502     * @param obj User object.
503     */
504    void registerFoT53ClirlInfo(Handler h, int what, Object obj);
505    void unregisterForT53ClirInfo(Handler h);
506
507    /**
508     * Registers the handler for CDMA T53 audio control information record
509     * Unlike the register* methods, there's only one notification handler
510     *
511     * @param h Handler for notification message.
512     * @param what User-defined message code.
513     * @param obj User object.
514     */
515    void registerForT53AudioControlInfo(Handler h, int what, Object obj);
516    void unregisterForT53AudioControlInfo(Handler h);
517
518    /**
519     * Fires on if Modem enters Emergency Callback mode
520     */
521    void setEmergencyCallbackMode(Handler h, int what, Object obj);
522
523     /**
524      * Fires on any CDMA OTA provision status change
525      */
526     void registerForCdmaOtaProvision(Handler h,int what, Object obj);
527     void unregisterForCdmaOtaProvision(Handler h);
528
529     /**
530      * Registers the handler when out-band ringback tone is needed.<p>
531      *
532      *  Messages received from this:
533      *  Message.obj will be an AsyncResult
534      *  AsyncResult.userObj = obj
535      *  AsyncResult.result = boolean. <p>
536      */
537     void registerForRingbackTone(Handler h, int what, Object obj);
538     void unregisterForRingbackTone(Handler h);
539
540     /**
541      * Registers the handler when mute/unmute need to be resent to get
542      * uplink audio during a call.<p>
543      *
544      * @param h Handler for notification message.
545      * @param what User-defined message code.
546      * @param obj User object.
547      *
548      */
549     void registerForResendIncallMute(Handler h, int what, Object obj);
550     void unregisterForResendIncallMute(Handler h);
551
552    /**
553     * Supply the ICC PIN to the ICC card
554     *
555     *  returned message
556     *  retMsg.obj = AsyncResult ar
557     *  ar.exception carries exception on failure
558     *  This exception is CommandException with an error of PASSWORD_INCORRECT
559     *  if the password is incorrect
560     *
561     * ar.exception and ar.result are null on success
562     */
563
564    void supplyIccPin(String pin, Message result);
565
566    /**
567     * Supply the ICC PUK to the ICC card
568     *
569     *  returned message
570     *  retMsg.obj = AsyncResult ar
571     *  ar.exception carries exception on failure
572     *  This exception is CommandException with an error of PASSWORD_INCORRECT
573     *  if the password is incorrect
574     *
575     * ar.exception and ar.result are null on success
576     */
577
578    void supplyIccPuk(String puk, String newPin, Message result);
579
580    /**
581     * Supply the ICC PIN2 to the ICC card
582     * Only called following operation where ICC_PIN2 was
583     * returned as a a failure from a previous operation
584     *
585     *  returned message
586     *  retMsg.obj = AsyncResult ar
587     *  ar.exception carries exception on failure
588     *  This exception is CommandException with an error of PASSWORD_INCORRECT
589     *  if the password is incorrect
590     *
591     * ar.exception and ar.result are null on success
592     */
593
594    void supplyIccPin2(String pin2, Message result);
595
596    /**
597     * Supply the SIM PUK2 to the SIM card
598     * Only called following operation where SIM_PUK2 was
599     * returned as a a failure from a previous operation
600     *
601     *  returned message
602     *  retMsg.obj = AsyncResult ar
603     *  ar.exception carries exception on failure
604     *  This exception is CommandException with an error of PASSWORD_INCORRECT
605     *  if the password is incorrect
606     *
607     * ar.exception and ar.result are null on success
608     */
609
610    void supplyIccPuk2(String puk2, String newPin2, Message result);
611
612    void changeIccPin(String oldPin, String newPin, Message result);
613    void changeIccPin2(String oldPin2, String newPin2, Message result);
614
615    void changeBarringPassword(String facility, String oldPwd, String newPwd, Message result);
616
617    void supplyNetworkDepersonalization(String netpin, Message result);
618
619    /**
620     *  returned message
621     *  retMsg.obj = AsyncResult ar
622     *  ar.exception carries exception on failure
623     *  ar.userObject contains the orignal value of result.obj
624     *  ar.result contains a List of DriverCall
625     *      The ar.result List is sorted by DriverCall.index
626     */
627    void getCurrentCalls (Message result);
628
629    /**
630     *  returned message
631     *  retMsg.obj = AsyncResult ar
632     *  ar.exception carries exception on failure
633     *  ar.userObject contains the orignal value of result.obj
634     *  ar.result contains a List of DataCallState
635     *  @deprecated Do not use.
636     */
637    @Deprecated
638    void getPDPContextList(Message result);
639
640    /**
641     *  returned message
642     *  retMsg.obj = AsyncResult ar
643     *  ar.exception carries exception on failure
644     *  ar.userObject contains the orignal value of result.obj
645     *  ar.result contains a List of DataCallState
646     */
647    void getDataCallList(Message result);
648
649    /**
650     *  returned message
651     *  retMsg.obj = AsyncResult ar
652     *  ar.exception carries exception on failure
653     *  ar.userObject contains the orignal value of result.obj
654     *  ar.result is null on success and failure
655     *
656     * CLIR_DEFAULT     == on "use subscription default value"
657     * CLIR_SUPPRESSION == on "CLIR suppression" (allow CLI presentation)
658     * CLIR_INVOCATION  == on "CLIR invocation" (restrict CLI presentation)
659     */
660    void dial (String address, int clirMode, Message result);
661
662    /**
663     *  returned message
664     *  retMsg.obj = AsyncResult ar
665     *  ar.exception carries exception on failure
666     *  ar.userObject contains the orignal value of result.obj
667     *  ar.result is String containing IMSI on success
668     */
669    void getIMSI(Message result);
670
671    /**
672     *  returned message
673     *  retMsg.obj = AsyncResult ar
674     *  ar.exception carries exception on failure
675     *  ar.userObject contains the orignal value of result.obj
676     *  ar.result is String containing IMEI on success
677     */
678    void getIMEI(Message result);
679
680    /**
681     *  returned message
682     *  retMsg.obj = AsyncResult ar
683     *  ar.exception carries exception on failure
684     *  ar.userObject contains the orignal value of result.obj
685     *  ar.result is String containing IMEISV on success
686     */
687    void getIMEISV(Message result);
688
689    /**
690     * Hang up one individual connection.
691     *  returned message
692     *  retMsg.obj = AsyncResult ar
693     *  ar.exception carries exception on failure
694     *  ar.userObject contains the orignal value of result.obj
695     *  ar.result is null on success and failure
696     *
697     *  3GPP 22.030 6.5.5
698     *  "Releases a specific active call X"
699     */
700    void hangupConnection (int gsmIndex, Message result);
701
702    /**
703     * 3GPP 22.030 6.5.5
704     *  "Releases all held calls or sets User Determined User Busy (UDUB)
705     *   for a waiting call."
706     *  ar.exception carries exception on failure
707     *  ar.userObject contains the orignal value of result.obj
708     *  ar.result is null on success and failure
709     */
710    void hangupWaitingOrBackground (Message result);
711
712    /**
713     * 3GPP 22.030 6.5.5
714     * "Releases all active calls (if any exist) and accepts
715     *  the other (held or waiting) call."
716     *
717     *  ar.exception carries exception on failure
718     *  ar.userObject contains the orignal value of result.obj
719     *  ar.result is null on success and failure
720     */
721    void hangupForegroundResumeBackground (Message result);
722
723    /**
724     * 3GPP 22.030 6.5.5
725     * "Places all active calls (if any exist) on hold and accepts
726     *  the other (held or waiting) call."
727     *
728     *  ar.exception carries exception on failure
729     *  ar.userObject contains the orignal value of result.obj
730     *  ar.result is null on success and failure
731     */
732    void switchWaitingOrHoldingAndActive (Message result);
733
734    /**
735     * 3GPP 22.030 6.5.5
736     * "Adds a held call to the conversation"
737     *
738     *  ar.exception carries exception on failure
739     *  ar.userObject contains the orignal value of result.obj
740     *  ar.result is null on success and failure
741     */
742    void conference (Message result);
743
744    /**
745     * Set preferred Voice Privacy (VP).
746     *
747     * @param enable true is enhanced and false is normal VP
748     * @param result is a callback message
749     */
750    void setPreferredVoicePrivacy(boolean enable, Message result);
751
752    /**
753     * Get currently set preferred Voice Privacy (VP) mode.
754     *
755     * @param result is a callback message
756     */
757    void getPreferredVoicePrivacy(Message result);
758
759    /**
760     * 3GPP 22.030 6.5.5
761     * "Places all active calls on hold except call X with which
762     *  communication shall be supported."
763     */
764    void separateConnection (int gsmIndex, Message result);
765
766    /**
767     *
768     *  ar.exception carries exception on failure
769     *  ar.userObject contains the orignal value of result.obj
770     *  ar.result is null on success and failure
771     */
772    void acceptCall (Message result);
773
774    /**
775     *  also known as UDUB
776     *  ar.exception carries exception on failure
777     *  ar.userObject contains the orignal value of result.obj
778     *  ar.result is null on success and failure
779     */
780    void rejectCall (Message result);
781
782    /**
783     * 3GPP 22.030 6.5.5
784     * "Connects the two calls and disconnects the subscriber from both calls"
785     *
786     *  ar.exception carries exception on failure
787     *  ar.userObject contains the orignal value of result.obj
788     *  ar.result is null on success and failure
789     */
790    void explicitCallTransfer (Message result);
791
792    /**
793     * cause code returned as int[0] in Message.obj.response
794     * Returns integer cause code defined in TS 24.008
795     * Annex H or closest approximation.
796     * Most significant codes:
797     * - Any defined in 22.001 F.4 (for generating busy/congestion)
798     * - Cause 68: ACM >= ACMMax
799     */
800    void getLastCallFailCause (Message result);
801
802
803    /**
804     * Reason for last PDP context deactivate or failure to activate
805     * cause code returned as int[0] in Message.obj.response
806     * returns an integer cause code defined in TS 24.008
807     * section 6.1.3.1.3 or close approximation
808     * @deprecated Do not use.
809     */
810    @Deprecated
811    void getLastPdpFailCause (Message result);
812
813    /**
814     * The preferred new alternative to getLastPdpFailCause
815     * that is also CDMA-compatible.
816     */
817    void getLastDataCallFailCause (Message result);
818
819    void setMute (boolean enableMute, Message response);
820
821    void getMute (Message response);
822
823    /**
824     * response.obj is an AsyncResult
825     * response.obj.result is an int[2]
826     * response.obj.result[0] is received signal strength (0-31, 99)
827     * response.obj.result[1] is  bit error rate (0-7, 99)
828     * as defined in TS 27.007 8.5
829     */
830    void getSignalStrength (Message response);
831
832
833    /**
834     * response.obj.result is an int[3]
835     * response.obj.result[0] is registration state 0-5 from TS 27.007 7.2
836     * response.obj.result[1] is LAC if registered or -1 if not
837     * response.obj.result[2] is CID if registered or -1 if not
838     * valid LAC and CIDs are 0x0000 - 0xffff
839     *
840     * Please note that registration state 4 ("unknown") is treated
841     * as "out of service" above
842     */
843    void getRegistrationState (Message response);
844
845    /**
846     * response.obj.result is an int[3]
847     * response.obj.result[0] is registration state 0-5 from TS 27.007 7.2
848     * response.obj.result[1] is LAC if registered or -1 if not
849     * response.obj.result[2] is CID if registered or -1 if not
850     * valid LAC and CIDs are 0x0000 - 0xffff
851     *
852     * Please note that registration state 4 ("unknown") is treated
853     * as "out of service" above
854     */
855    void getGPRSRegistrationState (Message response);
856
857    /**
858     * response.obj.result is a String[3]
859     * response.obj.result[0] is long alpha or null if unregistered
860     * response.obj.result[1] is short alpha or null if unregistered
861     * response.obj.result[2] is numeric or null if unregistered
862     */
863    void getOperator(Message response);
864
865    /**
866     *  ar.exception carries exception on failure
867     *  ar.userObject contains the orignal value of result.obj
868     *  ar.result is null on success and failure
869     */
870    void sendDtmf(char c, Message result);
871
872
873    /**
874     *  ar.exception carries exception on failure
875     *  ar.userObject contains the orignal value of result.obj
876     *  ar.result is null on success and failure
877     */
878    void startDtmf(char c, Message result);
879
880    /**
881     *  ar.exception carries exception on failure
882     *  ar.userObject contains the orignal value of result.obj
883     *  ar.result is null on success and failure
884     */
885    void stopDtmf(Message result);
886
887    /**
888     *  ar.exception carries exception on failure
889     *  ar.userObject contains the orignal value of result.obj
890     *  ar.result is null on success and failure
891     */
892    void sendBurstDtmf(String dtmfString, int on, int off, Message result);
893
894    /**
895     * smscPDU is smsc address in PDU form GSM BCD format prefixed
896     *      by a length byte (as expected by TS 27.005) or NULL for default SMSC
897     * pdu is SMS in PDU format as an ASCII hex string
898     *      less the SMSC address
899     */
900    void sendSMS (String smscPDU, String pdu, Message response);
901
902    /**
903     * @param pdu is CDMA-SMS in internal pseudo-PDU format
904     * @param response sent when operation completes
905     */
906    void sendCdmaSms(byte[] pdu, Message response);
907
908    /**
909     * Deletes the specified SMS record from SIM memory (EF_SMS).
910     *
911     * @param index index of the SMS record to delete
912     * @param response sent when operation completes
913     */
914    void deleteSmsOnSim(int index, Message response);
915
916    /**
917     * Deletes the specified SMS record from RUIM memory (EF_SMS in DF_CDMA).
918     *
919     * @param index index of the SMS record to delete
920     * @param response sent when operation completes
921     */
922    void deleteSmsOnRuim(int index, Message response);
923
924    /**
925     * Writes an SMS message to SIM memory (EF_SMS).
926     *
927     * @param status status of message on SIM.  One of:
928     *                  SmsManger.STATUS_ON_ICC_READ
929     *                  SmsManger.STATUS_ON_ICC_UNREAD
930     *                  SmsManger.STATUS_ON_ICC_SENT
931     *                  SmsManger.STATUS_ON_ICC_UNSENT
932     * @param pdu message PDU, as hex string
933     * @param response sent when operation completes.
934     *                  response.obj will be an AsyncResult, and will indicate
935     *                  any error that may have occurred (eg, out of memory).
936     */
937    void writeSmsToSim(int status, String smsc, String pdu, Message response);
938
939    void writeSmsToRuim(int status, String pdu, Message response);
940
941    /**
942     * @deprecated
943     * @param apn
944     * @param user
945     * @param password
946     * @param response
947     */
948    void setupDefaultPDP(String apn, String user, String password, Message response);
949
950    /**
951     * @deprecated
952     * @param cid
953     * @param response
954     */
955    void deactivateDefaultPDP(int cid, Message response);
956
957    void setRadioPower(boolean on, Message response);
958
959    void acknowledgeLastIncomingGsmSms(boolean success, int cause, Message response);
960
961    void acknowledgeLastIncomingCdmaSms(boolean success, int cause, Message response);
962
963    /**
964     * parameters equivilient to 27.007 AT+CRSM command
965     * response.obj will be an AsyncResult
966     * response.obj.userObj will be a IccIoResult on success
967     */
968    void iccIO (int command, int fileid, String path, int p1, int p2, int p3,
969            String data, String pin2, Message response);
970
971    /**
972     * (AsyncResult)response.obj).result is an int[] with element [0] set to
973     * 1 for "CLIP is provisioned", and 0 for "CLIP is not provisioned".
974     *
975     * @param response is callback message
976     */
977
978    void queryCLIP(Message response);
979
980    /**
981     * response.obj will be a an int[2]
982     *
983     * response.obj[0] will be TS 27.007 +CLIR parameter 'n'
984     *  0 presentation indicator is used according to the subscription of the CLIR service
985     *  1 CLIR invocation
986     *  2 CLIR suppression
987     *
988     * response.obj[1] will be TS 27.007 +CLIR parameter 'm'
989     *  0 CLIR not provisioned
990     *  1 CLIR provisioned in permanent mode
991     *  2 unknown (e.g. no network, etc.)
992     *  3 CLIR temporary mode presentation restricted
993     *  4 CLIR temporary mode presentation allowed
994     */
995
996    void getCLIR(Message response);
997
998    /**
999     * clirMode is one of the CLIR_* constants above
1000     *
1001     * response.obj is null
1002     */
1003
1004    void setCLIR(int clirMode, Message response);
1005
1006    /**
1007     * (AsyncResult)response.obj).result is an int[] with element [0] set to
1008     * 0 for disabled, 1 for enabled.
1009     *
1010     * @param serviceClass is a sum of SERVICE_CLASS_*
1011     * @param response is callback message
1012     */
1013
1014    void queryCallWaiting(int serviceClass, Message response);
1015
1016    /**
1017     * @param enable is true to enable, false to disable
1018     * @param serviceClass is a sum of SERVICE_CLASS_*
1019     * @param response is callback message
1020     */
1021
1022    void setCallWaiting(boolean enable, int serviceClass, Message response);
1023
1024    /**
1025     * @param action is one of CF_ACTION_*
1026     * @param cfReason is one of CF_REASON_*
1027     * @param serviceClass is a sum of SERVICE_CLASSS_*
1028     */
1029    void setCallForward(int action, int cfReason, int serviceClass,
1030                String number, int timeSeconds, Message response);
1031
1032    /**
1033     * cfReason is one of CF_REASON_*
1034     *
1035     * ((AsyncResult)response.obj).result will be an array of
1036     * CallForwardInfo's
1037     *
1038     * An array of length 0 means "disabled for all codes"
1039     */
1040    void queryCallForwardStatus(int cfReason, int serviceClass,
1041            String number, Message response);
1042
1043    void setNetworkSelectionModeAutomatic(Message response);
1044
1045    void setNetworkSelectionModeManual(String operatorNumeric, Message response);
1046
1047    /**
1048     * Queries whether the current network selection mode is automatic
1049     * or manual
1050     *
1051     * ((AsyncResult)response.obj).result  is an int[] with element [0] being
1052     * a 0 for automatic selection and a 1 for manual selection
1053     */
1054
1055    void getNetworkSelectionMode(Message response);
1056
1057    /**
1058     * Queries the currently available networks
1059     *
1060     * ((AsyncResult)response.obj).result  is a List of NetworkInfo objects
1061     */
1062    void getAvailableNetworks(Message response);
1063
1064    void getBasebandVersion (Message response);
1065
1066
1067    /**
1068     * (AsyncResult)response.obj).result will be an Integer representing
1069     * the sum of enabled serivice classes (sum of SERVICE_CLASS_*)
1070     *
1071     * @param facility one of CB_FACILTY_*
1072     * @param password password or "" if not required
1073     * @param serviceClass is a sum of SERVICE_CLASS_*
1074     * @param response is callback message
1075     */
1076
1077    void queryFacilityLock (String facility, String password, int serviceClass,
1078        Message response);
1079
1080    /**
1081     * @param facility one of CB_FACILTY_*
1082     * @param lockState true means lock, false means unlock
1083     * @param password password or "" if not required
1084     * @param serviceClass is a sum of SERVICE_CLASS_*
1085     * @param response is callback message
1086     */
1087    void setFacilityLock (String facility, boolean lockState, String password,
1088        int serviceClass, Message response);
1089
1090
1091    void sendUSSD (String ussdString, Message response);
1092
1093    /**
1094     * Cancels a pending USSD session if one exists.
1095     * @param response callback message
1096     */
1097    void cancelPendingUssd (Message response);
1098
1099    void resetRadio(Message result);
1100
1101    /**
1102     * Assign a specified band for RF configuration.
1103     *
1104     * @param bandMode one of BM_*_BAND
1105     * @param response is callback message
1106     */
1107    void setBandMode (int bandMode, Message response);
1108
1109    /**
1110     * Query the list of band mode supported by RF.
1111     *
1112     * @param response is callback message
1113     *        ((AsyncResult)response.obj).result  is an int[] with every
1114     *        element representing one avialable BM_*_BAND
1115     */
1116    void queryAvailableBandMode (Message response);
1117
1118    /**
1119     *  Requests to set the preferred network type for searching and registering
1120     * (CS/PS domain, RAT, and operation mode)
1121     * @param networkType one of  NT_*_TYPE
1122     * @param response is callback message
1123     */
1124    void setPreferredNetworkType(int networkType , Message response);
1125
1126     /**
1127     *  Query the preferred network type setting
1128     *
1129     * @param response is callback message to report one of  NT_*_TYPE
1130     */
1131    void getPreferredNetworkType(Message response);
1132
1133    /**
1134     * Query neighboring cell ids
1135     *
1136     * @param response s callback message to cell ids
1137     */
1138    void getNeighboringCids(Message response);
1139
1140    /**
1141     * Request to enable/disable network state change notifications when
1142     * location informateion (lac and/or cid) has changed.
1143     *
1144     * @param enable true to enable, false to disable
1145     * @param response callback message
1146     */
1147    void setLocationUpdates(boolean enable, Message response);
1148
1149    /**
1150     * Gets the default SMSC address.
1151     *
1152     * @param result Callback message contains the SMSC address.
1153     */
1154    void getSmscAddress(Message result);
1155
1156    /**
1157     * Sets the default SMSC address.
1158     *
1159     * @param address new SMSC address
1160     * @param result Callback message is empty on completion
1161     */
1162    void setSmscAddress(String address, Message result);
1163
1164    /**
1165     * Indicates whether there is storage available for new SMS messages.
1166     * @param available true if storage is available
1167     * @param result callback message
1168     */
1169    void reportSmsMemoryStatus(boolean available, Message result);
1170
1171    /**
1172     * Indicates to the vendor ril that StkService is running
1173     * rand is eady to receive RIL_UNSOL_STK_XXXX commands.
1174     *
1175     * @param result callback message
1176     */
1177    void reportStkServiceIsRunning(Message result);
1178
1179    void invokeOemRilRequestRaw(byte[] data, Message response);
1180
1181    void invokeOemRilRequestStrings(String[] strings, Message response);
1182
1183
1184    /**
1185     * Send TERMINAL RESPONSE to the SIM, after processing a proactive command
1186     * sent by the SIM.
1187     *
1188     * @param contents  String containing SAT/USAT response in hexadecimal
1189     *                  format starting with first byte of response data. See
1190     *                  TS 102 223 for details.
1191     * @param response  Callback message
1192     */
1193    public void sendTerminalResponse(String contents, Message response);
1194
1195    /**
1196     * Send ENVELOPE to the SIM, after processing a proactive command sent by
1197     * the SIM.
1198     *
1199     * @param contents  String containing SAT/USAT response in hexadecimal
1200     *                  format starting with command tag. See TS 102 223 for
1201     *                  details.
1202     * @param response  Callback message
1203     */
1204    public void sendEnvelope(String contents, Message response);
1205
1206    /**
1207     * Accept or reject the call setup request from SIM.
1208     *
1209     * @param accept   true if the call is to be accepted, false otherwise.
1210     * @param response Callback message
1211     */
1212    public void handleCallSetupRequestFromSim(boolean accept, Message response);
1213
1214    /**
1215     * Activate or deactivate cell broadcast SMS for GSM.
1216     *
1217     * @param activate
1218     *            true = activate, false = deactivate
1219     * @param result Callback message is empty on completion
1220     */
1221    public void setGsmBroadcastActivation(boolean activate, Message result);
1222
1223    /**
1224     * Configure cell broadcast SMS for GSM.
1225     *
1226     * @param response Callback message is empty on completion
1227     */
1228    public void setGsmBroadcastConfig(SmsBroadcastConfigInfo[] config, Message response);
1229
1230    /**
1231     * Query the current configuration of cell broadcast SMS of GSM.
1232     *
1233     * @param response
1234     *        Callback message contains the configuration from the modem
1235     *        on completion
1236     */
1237    public void getGsmBroadcastConfig(Message response);
1238
1239    //***** new Methods for CDMA support
1240
1241    /**
1242     * Request the device ESN / MEID / IMEI / IMEISV.
1243     * "response" is const char **
1244     *   [0] is IMEI if GSM subscription is available
1245     *   [1] is IMEISV if GSM subscription is available
1246     *   [2] is ESN if CDMA subscription is available
1247     *   [3] is MEID if CDMA subscription is available
1248     */
1249    public void getDeviceIdentity(Message response);
1250
1251    /**
1252     * Request the device MDN / H_SID / H_NID / MIN.
1253     * "response" is const char **
1254     *   [0] is MDN if CDMA subscription is available
1255     *   [1] is a comma separated list of H_SID (Home SID) in decimal format
1256     *       if CDMA subscription is available
1257     *   [2] is a comma separated list of H_NID (Home NID) in decimal format
1258     *       if CDMA subscription is available
1259     *   [3] is MIN (10 digits, MIN2+MIN1) if CDMA subscription is available
1260     */
1261    public void getCDMASubscription(Message response);
1262
1263    /**
1264     * Send Flash Code.
1265     * "response" is is NULL
1266     *   [0] is a FLASH string
1267     */
1268    public void sendCDMAFeatureCode(String FeatureCode, Message response);
1269
1270    /** Set the Phone type created */
1271    void setPhoneType(int phoneType);
1272
1273    /**
1274     *  Query the CDMA roaming preference setting
1275     *
1276     * @param response is callback message to report one of  CDMA_RM_*
1277     */
1278    void queryCdmaRoamingPreference(Message response);
1279
1280    /**
1281     *  Requests to set the CDMA roaming preference
1282     * @param cdmaRoamingType one of  CDMA_RM_*
1283     * @param response is callback message
1284     */
1285    void setCdmaRoamingPreference(int cdmaRoamingType, Message response);
1286
1287    /**
1288     *  Requests to set the CDMA subscription mode
1289     * @param cdmaSubscriptionType one of  CDMA_SUBSCRIPTION_*
1290     * @param response is callback message
1291     */
1292    void setCdmaSubscription(int cdmaSubscriptionType, Message response);
1293
1294    /**
1295     *  Set the TTY mode for the CDMA phone
1296     *
1297     * @param enable is true to enable, false to disable
1298     * @param response is callback message
1299     */
1300    void setTTYMode(int ttyMode, Message response);
1301
1302    /**
1303     *  Query the TTY mode for the CDMA phone
1304     * (AsyncResult)response.obj).result is an int[] with element [0] set to
1305     * 0 for disabled, 1 for enabled.
1306     *
1307     * @param response is callback message
1308     */
1309    void queryTTYMode(Message response);
1310
1311    /**
1312     * Setup a packet data connection On successful completion, the result
1313     * message will return the following: [0] indicating PDP CID, which is
1314     * generated by RIL. This Connection ID is used in both GSM/UMTS and CDMA
1315     * modes [1] indicating the network interface name for GSM/UMTS or CDMA [2]
1316     * indicating the IP address for this interface for GSM/UMTS and NULL in the
1317     * case of CDMA
1318     *
1319     * @param radioTechnology
1320     *            indicates whether to setup connection on radio technology CDMA
1321     *            (0) or GSM/UMTS (1)
1322     * @param profile
1323     *            Profile Number or NULL to indicate default profile
1324     * @param apn
1325     *            the APN to connect to if radio technology is GSM/UMTS.
1326     *            Otherwise null for CDMA.
1327     * @param user
1328     *            the username for APN, or NULL
1329     * @param password
1330     *            the password for APN, or NULL
1331     * @param authType
1332     *            the PAP / CHAP auth type. Values is one of SETUP_DATA_AUTH_*
1333     * @param result
1334     *            Callback message
1335     */
1336    public void setupDataCall(String radioTechnology, String profile, String apn,
1337            String user, String password, String authType, Message result);
1338
1339    /**
1340     * Deactivate packet data connection
1341     *
1342     * @param cid
1343     *            The connection ID
1344     * @param result
1345     *            Callback message is empty on completion
1346     */
1347    public void deactivateDataCall(int cid, Message result);
1348
1349    /**
1350     * Activate or deactivate cell broadcast SMS for CDMA.
1351     *
1352     * @param activate
1353     *            true = activate, false = deactivate
1354     * @param result
1355     *            Callback message is empty on completion
1356     */
1357    public void setCdmaBroadcastActivation(boolean activate, Message result);
1358
1359    /**
1360     * Configure cdma cell broadcast SMS.
1361     *
1362     * @param result
1363     *            Callback message is empty on completion
1364     */
1365    // TODO: Change the configValuesArray to a RIL_BroadcastSMSConfig
1366    public void setCdmaBroadcastConfig(int[] configValuesArray, Message result);
1367
1368    /**
1369     * Query the current configuration of cdma cell broadcast SMS.
1370     *
1371     * @param result
1372     *            Callback message contains the configuration from the modem on completion
1373     */
1374    public void getCdmaBroadcastConfig(Message result);
1375
1376    /**
1377     *  Requests the radio's system selection module to exit emergency callback mode.
1378     *  This function should only be called from CDMAPHone.java.
1379     *
1380     * @param response callback message
1381     */
1382    public void exitEmergencyCallbackMode(Message response);
1383
1384    /**
1385     * Request the status of the ICC and UICC cards.
1386     *
1387     * @param response
1388     *          Callback message containing {@link IccCardStatus} structure for the card.
1389     */
1390    public void getIccCardStatus(Message result);
1391}
1392