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