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