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.compat.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 the request was initiated USSD by the network. 74 */ isNetworkInitiatedUssd()75 boolean isNetworkInitiatedUssd(); 76 77 /** 78 * @return true if an outstanding request can be canceled. 79 */ isCancelable()80 public boolean isCancelable(); 81 82 /** 83 * @return true if the Service Code is PIN/PIN2/PUK/PUK2-related 84 */ isPinPukCommand()85 public boolean isPinPukCommand(); 86 87 /** 88 * Process a MMI code or short code...anything that isn't a dialing number 89 */ processCode()90 void processCode() throws CallStateException; 91 92 /** 93 * @return the Receiver for the Ussd Callback. 94 */ getUssdCallbackReceiver()95 public ResultReceiver getUssdCallbackReceiver(); 96 97 /** 98 * @return the dialString. 99 */ getDialString()100 public String getDialString(); 101 102 Pattern sPatternCdmaMmiCodeWhileRoaming = Pattern.compile( 103 "\\*(\\d{2})(\\+{0,1})(\\d{0,})"); 104 /* 1 2 3 105 1 = service code 106 2 = prefix 107 3 = number 108 */ 109 int MATCH_GROUP_CDMA_MMI_CODE_SERVICE_CODE = 1; 110 int MATCH_GROUP_CDMA_MMI_CODE_NUMBER_PREFIX = 2; 111 int MATCH_GROUP_CDMA_MMI_CODE_NUMBER = 3; 112 } 113