Home | History | Annotate | Download | only in telephony
      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 
     17 package com.android.internal.telephony;
     18 
     19 import android.os.ResultReceiver;
     20 
     21 import java.util.regex.Pattern;
     22 
     23 /**
     24  * {@hide}
     25  */
     26 public interface MmiCode
     27 {
     28     /**
     29      * {@hide}
     30      */
     31     public enum State {
     32         PENDING,
     33         CANCELLED,
     34         COMPLETE,
     35         FAILED
     36     }
     37 
     38     /**
     39      * @return Current state of MmiCode request
     40      */
     41     public State getState();
     42 
     43     /**
     44      * @return Localized message for UI display, valid only in COMPLETE
     45      * or FAILED states. null otherwise
     46      */
     47 
     48     public CharSequence getMessage();
     49 
     50     /**
     51      * @return Phone associated with the MMI/USSD message
     52      */
     53     public Phone getPhone();
     54 
     55     /**
     56      * Cancels pending MMI request.
     57      * State becomes CANCELLED unless already COMPLETE or FAILED
     58      */
     59     public void cancel();
     60 
     61     /**
     62      * @return true if the network response is a REQUEST for more user input.
     63      */
     64     public boolean isUssdRequest();
     65 
     66     /**
     67      * @return true if an outstanding request can be canceled.
     68      */
     69     public boolean isCancelable();
     70 
     71     /**
     72      * @return true if the Service Code is PIN/PIN2/PUK/PUK2-related
     73      */
     74     public boolean isPinPukCommand();
     75 
     76     /**
     77      * Process a MMI code or short code...anything that isn't a dialing number
     78      */
     79     void processCode() throws CallStateException;
     80 
     81     /**
     82      * @return the Receiver for the Ussd Callback.
     83      */
     84     public ResultReceiver getUssdCallbackReceiver();
     85 
     86     /**
     87      * @return the dialString.
     88      */
     89     public String getDialString();
     90 
     91     Pattern sPatternCdmaMmiCodeWhileRoaming = Pattern.compile(
     92             "\\*(\\d{2})(\\+{0,1})(\\d{0,})");
     93     /*           1        2         3
     94            1 = service code
     95            2 = prefix
     96            3 = number
     97     */
     98     int MATCH_GROUP_CDMA_MMI_CODE_SERVICE_CODE = 1;
     99     int MATCH_GROUP_CDMA_MMI_CODE_NUMBER_PREFIX = 2;
    100     int MATCH_GROUP_CDMA_MMI_CODE_NUMBER = 3;
    101 }
    102