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.cat; 18 19 import android.compat.annotation.UnsupportedAppUsage; 20 import android.content.ComponentName; 21 22 /** 23 * Interface for communication between STK App and CAT Telephony 24 * 25 * {@hide} 26 */ 27 public interface AppInterface { 28 29 /* 30 * Intent's actions which are broadcasted by the Telephony once a new CAT 31 * proactive command, session end, ALPHA during STK CC arrive. 32 */ 33 public static final String CAT_CMD_ACTION = 34 "com.android.internal.stk.command"; 35 public static final String CAT_SESSION_END_ACTION = 36 "com.android.internal.stk.session_end"; 37 public static final String CAT_ALPHA_NOTIFY_ACTION = 38 "com.android.internal.stk.alpha_notify"; 39 40 //This is used to send ALPHA string from card to STK App. 41 public static final String ALPHA_STRING = "alpha_string"; 42 43 // This is used to send refresh-result when MSG_ID_ICC_REFRESH is received. 44 public static final String REFRESH_RESULT = "refresh_result"; 45 //This is used to send card status from card to STK App. 46 public static final String CARD_STATUS = "card_status"; 47 //Intent's actions are broadcasted by Telephony once IccRefresh occurs. 48 public static final String CAT_ICC_STATUS_CHANGE = 49 "com.android.internal.stk.icc_status_change"; 50 51 // Permission required by STK command receiver 52 public static final String STK_PERMISSION = "android.permission.RECEIVE_STK_COMMANDS"; 53 54 // Only forwards cat broadcast to the system default stk app getDefaultSTKApplication()55 public static ComponentName getDefaultSTKApplication() { 56 return ComponentName.unflattenFromString("com.android.stk/.StkCmdReceiver"); 57 } 58 59 /* 60 * Callback function from app to telephony to pass a result code and user's 61 * input back to the ICC. 62 */ onCmdResponse(CatResponseMessage resMsg)63 void onCmdResponse(CatResponseMessage resMsg); 64 65 /** 66 * Dispose when the service is not longer needed. 67 */ dispose()68 void dispose(); 69 70 /* 71 * Enumeration for representing "Type of Command" of proactive commands. 72 * Those are the only commands which are supported by the Telephony. Any app 73 * implementation should support those. 74 * Refer to ETSI TS 102.223 section 9.4 75 */ 76 @UnsupportedAppUsage(implicitMember = 77 "values()[Lcom/android/internal/telephony/cat/AppInterface$CommandType;") 78 public static enum CommandType { 79 @UnsupportedAppUsage 80 DISPLAY_TEXT(0x21), 81 @UnsupportedAppUsage 82 GET_INKEY(0x22), 83 @UnsupportedAppUsage 84 GET_INPUT(0x23), 85 @UnsupportedAppUsage 86 LAUNCH_BROWSER(0x15), 87 @UnsupportedAppUsage 88 PLAY_TONE(0x20), 89 @UnsupportedAppUsage 90 REFRESH(0x01), 91 @UnsupportedAppUsage 92 SELECT_ITEM(0x24), 93 @UnsupportedAppUsage 94 SEND_SS(0x11), 95 @UnsupportedAppUsage 96 SEND_USSD(0x12), 97 @UnsupportedAppUsage 98 SEND_SMS(0x13), 99 RUN_AT(0x34), 100 @UnsupportedAppUsage 101 SEND_DTMF(0x14), 102 @UnsupportedAppUsage 103 SET_UP_EVENT_LIST(0x05), 104 @UnsupportedAppUsage 105 SET_UP_IDLE_MODE_TEXT(0x28), 106 @UnsupportedAppUsage 107 SET_UP_MENU(0x25), 108 @UnsupportedAppUsage 109 SET_UP_CALL(0x10), 110 @UnsupportedAppUsage 111 PROVIDE_LOCAL_INFORMATION(0x26), 112 @UnsupportedAppUsage 113 LANGUAGE_NOTIFICATION(0x35), 114 @UnsupportedAppUsage 115 OPEN_CHANNEL(0x40), 116 @UnsupportedAppUsage 117 CLOSE_CHANNEL(0x41), 118 @UnsupportedAppUsage 119 RECEIVE_DATA(0x42), 120 @UnsupportedAppUsage 121 SEND_DATA(0x43), 122 @UnsupportedAppUsage 123 GET_CHANNEL_STATUS(0x44); 124 125 private int mValue; 126 CommandType(int value)127 CommandType(int value) { 128 mValue = value; 129 } 130 value()131 public int value() { 132 return mValue; 133 } 134 135 /** 136 * Create a CommandType object. 137 * 138 * @param value Integer value to be converted to a CommandType object. 139 * @return CommandType object whose "Type of Command" value is {@code 140 * value}. If no CommandType object has that value, null is 141 * returned. 142 */ 143 @UnsupportedAppUsage fromInt(int value)144 public static CommandType fromInt(int value) { 145 for (CommandType e : CommandType.values()) { 146 if (e.mValue == value) { 147 return e; 148 } 149 } 150 return null; 151 } 152 } 153 } 154