1 /* 2 * Copyright (C) 2022 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 android.telephony.mockmodem; 18 19 import android.hardware.radio.modem.ImeiInfo; 20 import android.hardware.radio.voice.CdmaSignalInfoRecord; 21 import android.hardware.radio.voice.LastCallFailCauseInfo; 22 import android.hardware.radio.voice.UusInfo; 23 import android.os.Handler; 24 import android.telephony.Annotation; 25 26 public interface MockModemConfigInterface { 27 28 // ***** Constants 29 int MAX_NUM_OF_SIM_SLOT = 3; // Change this needs to add more SIM SLOT NVs. 30 int MAX_NUM_OF_LOGICAL_MODEM = 2; // Change this needs to add more MODEM NVs. 31 int RADIO_STATE_UNAVAILABLE = 0; 32 int RADIO_STATE_OFF = 1; 33 int RADIO_STATE_ON = 2; 34 35 // Default config value 36 String DEFAULT_BASEBAND_VERSION = "mock-modem-service-1.0"; 37 // PHONE1 38 String DEFAULT_PHONE1_IMEI = "123456789012345"; 39 String DEFAULT_PHONE1_IMEISV = "01"; 40 String DEFAULT_PHONE1_ESN = "123456789"; 41 String DEFAULT_PHONE1_MEID = "123456789012345"; 42 int DEFAULT_PHONE1_IMEITYPE = ImeiInfo.ImeiType.PRIMARY; 43 // PHONE2 44 String DEFAULT_PHONE2_IMEI = "987654321543210"; 45 String DEFAULT_PHONE2_IMEISV = "02"; 46 String DEFAULT_PHONE2_ESN = "987654321"; 47 String DEFAULT_PHONE2_MEID = "987654321543210"; 48 int DEFAULT_PHONE2_IMEITYPE = ImeiInfo.ImeiType.SECONDARY; 49 50 int DEFAULT_RADIO_STATE = RADIO_STATE_UNAVAILABLE; 51 int DEFAULT_NUM_OF_LIVE_MODEM = 1; // Should <= MAX_NUM_OF_MODEM 52 int DEFAULT_MAX_ACTIVE_DATA = 2; 53 int DEFAULT_MAX_ACTIVE_INTERNAL_DATA = 1; 54 boolean DEFAULT_IS_INTERNAL_LINGERING_SUPPORTED = false; 55 int DEFAULT_LOGICAL_MODEM1_ID = 0; 56 int DEFAULT_LOGICAL_MODEM2_ID = 1; 57 58 // ***** Methods destroy()59 void destroy(); 60 getMockModemConfigHandler(int logicalSlotId)61 Handler getMockModemConfigHandler(int logicalSlotId); 62 63 /** Broadcast all notifications */ notifyAllRegistrantNotifications()64 void notifyAllRegistrantNotifications(); 65 66 // ***** IRadioConfig 67 /** Register/unregister notification handler for number of modem changed */ registerForNumOfLiveModemChanged(int logicalSlotId, Handler h, int what, Object obj)68 void registerForNumOfLiveModemChanged(int logicalSlotId, Handler h, int what, Object obj); 69 unregisterForNumOfLiveModemChanged(int logicalSlotId, Handler h)70 void unregisterForNumOfLiveModemChanged(int logicalSlotId, Handler h); 71 72 /** Register/unregister notification handler for sim slot status changed */ registerForPhoneCapabilityChanged(int logicalSlotId, Handler h, int what, Object obj)73 void registerForPhoneCapabilityChanged(int logicalSlotId, Handler h, int what, Object obj); 74 unregisterForPhoneCapabilityChanged(int logicalSlotId, Handler h)75 void unregisterForPhoneCapabilityChanged(int logicalSlotId, Handler h); 76 77 /** Register/unregister notification handler for sim slot status changed */ registerForSimSlotStatusChanged(int logicalSlotId, Handler h, int what, Object obj)78 void registerForSimSlotStatusChanged(int logicalSlotId, Handler h, int what, Object obj); 79 unregisterForSimSlotStatusChanged(int logicalSlotId, Handler h)80 void unregisterForSimSlotStatusChanged(int logicalSlotId, Handler h); 81 82 // ***** IRadioModem 83 /** Register/unregister notification handler for baseband version changed */ registerForBasebandVersionChanged(int logicalSlotId, Handler h, int what, Object obj)84 void registerForBasebandVersionChanged(int logicalSlotId, Handler h, int what, Object obj); 85 unregisterForBasebandVersionChanged(int logicalSlotId, Handler h)86 void unregisterForBasebandVersionChanged(int logicalSlotId, Handler h); 87 88 /** Register/unregister notification handler for device identity changed */ registerForDeviceIdentityChanged(int logicalSlotId, Handler h, int what, Object obj)89 void registerForDeviceIdentityChanged(int logicalSlotId, Handler h, int what, Object obj); 90 91 /** Register/unregister notification handler for device ImeiInfo changed */ registerForDeviceImeiInfoChanged(int logicalSlotId, Handler h, int what, Object obj)92 void registerForDeviceImeiInfoChanged(int logicalSlotId, Handler h, int what, Object obj); 93 unregisterForDeviceIdentityChanged(int logicalSlotId, Handler h)94 void unregisterForDeviceIdentityChanged(int logicalSlotId, Handler h); 95 96 /** Register/unregister notification handler for radio state changed */ registerForRadioStateChanged(int logicalSlotId, Handler h, int what, Object obj)97 void registerForRadioStateChanged(int logicalSlotId, Handler h, int what, Object obj); 98 unregisterForRadioStateChanged(int logicalSlotId, Handler h)99 void unregisterForRadioStateChanged(int logicalSlotId, Handler h); 100 101 /** 102 * Sets the latest radio power state of modem 103 * 104 * @param logicalSlotId the Id of logical sim slot. 105 * @param state 0 means "unavailable", 1 means "off", 2 means "on". 106 * @param client for tracking calling client 107 */ setRadioState(int logicalSlotId, int state, String client)108 void setRadioState(int logicalSlotId, int state, String client); 109 110 // ***** IRadioSim 111 /** Register/unregister notification handler for card status changed */ registerForCardStatusChanged(int logicalSlotId, Handler h, int what, Object obj)112 void registerForCardStatusChanged(int logicalSlotId, Handler h, int what, Object obj); 113 unregisterForCardStatusChanged(int logicalSlotId, Handler h)114 void unregisterForCardStatusChanged(int logicalSlotId, Handler h); 115 116 /** Register/unregister notification handler for sim app data changed */ registerForSimAppDataChanged(int logicalSlotId, Handler h, int what, Object obj)117 void registerForSimAppDataChanged(int logicalSlotId, Handler h, int what, Object obj); 118 unregisterForSimAppDataChanged(int logicalSlotId, Handler h)119 void unregisterForSimAppDataChanged(int logicalSlotId, Handler h); 120 121 /** Register/unregister notification handler for sim info changed */ registerForSimInfoChanged(int logicalSlotId, Handler h, int what, Object obj)122 void registerForSimInfoChanged(int logicalSlotId, Handler h, int what, Object obj); 123 unregisterForSimInfoChanged(int logicalSlotId, Handler h)124 void unregisterForSimInfoChanged(int logicalSlotId, Handler h); 125 126 // ***** IRadioNetwork 127 /** Register/unregister notification handler for service status changed */ registerForServiceStateChanged(int logicalSlotId, Handler h, int what, Object obj)128 void registerForServiceStateChanged(int logicalSlotId, Handler h, int what, Object obj); 129 unregisterForServiceStateChanged(int logicalSlotId, Handler h)130 void unregisterForServiceStateChanged(int logicalSlotId, Handler h); 131 132 // ***** IRadioVoice 133 /** Register/unregister notification handler for call state changed */ registerForCallStateChanged(int logicalSlotId, Handler h, int what, Object obj)134 void registerForCallStateChanged(int logicalSlotId, Handler h, int what, Object obj); 135 unregisterForCallStateChanged(int logicalSlotId, Handler h)136 void unregisterForCallStateChanged(int logicalSlotId, Handler h); 137 138 /** Register/unregister notification handler for current calls response */ registerForCurrentCallsResponse(int logicalSlotId, Handler h, int what, Object obj)139 void registerForCurrentCallsResponse(int logicalSlotId, Handler h, int what, Object obj); 140 unregisterForCurrentCallsResponse(int logicalSlotId, Handler h)141 void unregisterForCurrentCallsResponse(int logicalSlotId, Handler h); 142 143 /** Register/unregister notification handler for incoming call */ registerForCallIncoming(int logicalSlotId, Handler h, int what, Object obj)144 void registerForCallIncoming(int logicalSlotId, Handler h, int what, Object obj); 145 unregisterForCallIncoming(int logicalSlotId, Handler h)146 void unregisterForCallIncoming(int logicalSlotId, Handler h); 147 148 /** Register/unregister notification handler for ringback tone */ registerRingbackTone(int logicalSlotId, Handler h, int what, Object obj)149 void registerRingbackTone(int logicalSlotId, Handler h, int what, Object obj); 150 unregisterRingbackTone(int logicalSlotId, Handler h)151 void unregisterRingbackTone(int logicalSlotId, Handler h); 152 153 /** 154 * Request to get current calls. 155 * 156 * @param logicalSlotId the Id of logical sim slot. 157 * @param client for tracking calling client 158 * @return boolean true if the operation succeeds, otherwise false. 159 */ getCurrentCalls(int logicalSlotId, String client)160 boolean getCurrentCalls(int logicalSlotId, String client); 161 162 /** 163 * Request to dial a voice call. 164 * 165 * @param logicalSlotId the Id of logical sim slot. 166 * @param address the phone number to dial. 167 * @param clir CLIR mode. 168 * @param uusInfo user to user signaling information. 169 * @param client for tracking calling client 170 * @return boolean true if the operation succeeds, otherwise false. 171 */ dialVoiceCall( int logicalSlotId, String address, int clir, UusInfo[] uusInfo, String client)172 boolean dialVoiceCall( 173 int logicalSlotId, String address, int clir, UusInfo[] uusInfo, String client); 174 175 /** 176 * Request to dial a voice call with a call control info. 177 * 178 * @param logicalSlotId the Id of logical sim slot. 179 * @param address the phone number to dial. 180 * @param clir CLIR mode. 181 * @param uusInfo user to user signaling information. 182 * @param callControlInfo call control configuration 183 * @param client for tracking calling client 184 * @return boolean true if the operation succeeds, otherwise false. 185 */ dialVoiceCall( int logicalSlotId, String address, int clir, UusInfo[] uusInfo, MockCallControlInfo callControlInfo, String client)186 boolean dialVoiceCall( 187 int logicalSlotId, 188 String address, 189 int clir, 190 UusInfo[] uusInfo, 191 MockCallControlInfo callControlInfo, 192 String client); 193 194 /** 195 * Request to dial an emergency voice call. 196 * 197 * @param logicalSlotId the Id of logical sim slot. 198 * @param address the phone number to dial. 199 * @param categories the Emergency Service Category(s) of the call. 200 * @param urns the emergency Uniform Resource Names (URN). 201 * @param routing EmergencyCallRouting the emergency call routing information. 202 * @param client for tracking calling client. 203 * @return boolean true if the operation succeeds, otherwise false. 204 */ dialEccVoiceCall(int logicalSlotId, String address, int categories, String[] urns, int routing, String client)205 boolean dialEccVoiceCall(int logicalSlotId, String address, 206 int categories, String[] urns, int routing, String client); 207 208 /** 209 * Request to dial an emergency voice call with call control info. 210 * 211 * @param logicalSlotId the Id of logical sim slot. 212 * @param address the phone number to dial. 213 * @param categories the Emergency Service Category(s) of the call. 214 * @param urns the emergency Uniform Resource Names (URN). 215 * @param routing EmergencyCallRouting the emergency call routing information. 216 * @param callControlInfo call control configuration. 217 * @param client for tracking calling client. 218 * @return boolean true if the operation succeeds, otherwise false. 219 */ dialEccVoiceCall(int logicalSlotId, String address, int categories, String[] urns, int routing, MockCallControlInfo callControlInfo, String client)220 boolean dialEccVoiceCall(int logicalSlotId, String address, 221 int categories, String[] urns, int routing, 222 MockCallControlInfo callControlInfo, String client); 223 224 /** 225 * Request to hangup a voice call. 226 * 227 * @param logicalSlotId the Id of logical sim slot. 228 * @param index call identify to hangup. 229 * @param client for tracking calling client 230 * @return boolean true if the operation succeeds, otherwise false. 231 */ hangupVoiceCall(int logicalSlotId, int index, String client)232 boolean hangupVoiceCall(int logicalSlotId, int index, String client); 233 234 /** 235 * Request to reject an incoming voice call. 236 * 237 * @param logicalSlotId the Id of logical sim slot. 238 * @param client for tracking calling client 239 * @return boolean true if the operation succeeds, otherwise false. 240 */ rejectVoiceCall(int logicalSlotId, String client)241 boolean rejectVoiceCall(int logicalSlotId, String client); 242 243 /** 244 * Request to accept an incoming voice call. 245 * 246 * @param logicalSlotId the Id of logical sim slot. 247 * @param client for tracking calling client 248 * @return boolean true if the operation succeeds, otherwise false. 249 */ acceptVoiceCall(int logicalSlotId, String client)250 boolean acceptVoiceCall(int logicalSlotId, String client); 251 252 /** 253 * Get last call fail cause. 254 * 255 * @param logicalSlotId the Id of logical sim slot. 256 * @param client for tracking calling client 257 * @return LastCallFailCauseInfo last cause code and vendor cause info. 258 */ getLastCallFailCause(int logicalSlotId, String client)259 LastCallFailCauseInfo getLastCallFailCause(int logicalSlotId, String client); 260 261 /** 262 * Sets the last call fail cause. 263 * 264 * @param logicalSlotId the Id of logical sim slot. 265 * @param client for tracking calling client. 266 * @param cause the disconnect cause code. 267 */ setLastCallFailCause(int logicalSlotId, @Annotation.DisconnectCauses int cause, String client)268 void setLastCallFailCause(int logicalSlotId, 269 @Annotation.DisconnectCauses int cause, String client); 270 271 /** 272 * Clears all calls. 273 * 274 * @param logicalSlotId the Id of logical sim slot. 275 * @param client for tracking calling client. 276 * @param cause the disconnect cause code. 277 */ clearAllCalls(int logicalSlotId, @Annotation.DisconnectCauses int cause, String client)278 void clearAllCalls(int logicalSlotId, 279 @Annotation.DisconnectCauses int cause, String client); 280 281 /** 282 * Get voice mute mode. 283 * 284 * @param logicalSlotId the Id of logical sim slot. 285 * @param client for tracking calling client 286 * @return boolean true if voice is mute, otherwise false. 287 */ getVoiceMuteMode(int logicalSlotId, String client)288 boolean getVoiceMuteMode(int logicalSlotId, String client); 289 290 /** 291 * Set voice mute mode. 292 * 293 * @param logicalSlotId the Id of logical sim slot. 294 * @param muteMode mute mode for voice call. 295 * @param client for tracking calling client 296 * @return boolean true if the operation succeeds, otherwise false. 297 */ setVoiceMuteMode(int logicalSlotId, boolean muteMode, String client)298 boolean setVoiceMuteMode(int logicalSlotId, boolean muteMode, String client); 299 300 // ***** Utility methods 301 /** 302 * Query whether any SIM cards are present or not. 303 * 304 * @param logicalSlotId the Id of logical sim slot. 305 * @param client for tracking calling client 306 * @return boolean true if any sim card inserted, otherwise false. 307 */ isSimCardPresent(int logicalSlotId, String client)308 boolean isSimCardPresent(int logicalSlotId, String client); 309 310 /** 311 * Change SIM profile 312 * 313 * @param logicalSlotId the Id of logical sim slot. 314 * @param simProfileId The target profile to be switched. 315 * @param client for tracking calling client 316 * @return boolean true if the operation succeeds. 317 */ changeSimProfile(int logicalSlotId, int simProfileId, String client)318 boolean changeSimProfile(int logicalSlotId, int simProfileId, String client); 319 320 /** 321 * Modify SIM info of the SIM such as MCC/MNC, IMSI, etc. 322 * 323 * @param logicalSlotId the Id of logical sim slot. 324 * @param type the type of SIM info to modify. 325 * @param data to modify for the type of SIM info. 326 * @param client for tracking calling client 327 */ setSimInfo(int logicalSlotId, int type, String[] data, String client)328 void setSimInfo(int logicalSlotId, int type, String[] data, String client); 329 330 /** 331 * Get SIM info of the SIM slot, e.g. MCC/MNC, IMSI. 332 * 333 * @param logicalSlotId the Id of logical sim slot. 334 * @param type the type of SIM info. 335 * @param client for tracking calling client 336 * @return String the SIM info of the queried type. 337 */ getSimInfo(int logicalSlotId, int type, String client)338 String getSimInfo(int logicalSlotId, int type, String client); 339 340 /** 341 * Request to set call control configuration. 342 * 343 * @param logicalSlotId the Id of logical sim slot. 344 * @param callControlInfo the configuration of call control. 345 * @param client for tracking calling client 346 * @return boolean true if the operation succeeds, otherwise false. 347 */ setCallControlInfo( int logicalSlotId, MockCallControlInfo callControlInfo, String client)348 boolean setCallControlInfo( 349 int logicalSlotId, MockCallControlInfo callControlInfo, String client); 350 351 /** 352 * Request to get call control configuration. 353 * 354 * @param logicalSlotId the Id of logical sim slot. 355 * @param client for tracking calling client 356 * @return MockCallControlInfo which was set before. 357 */ getCallControlInfo(int logicalSlotId, String client)358 MockCallControlInfo getCallControlInfo(int logicalSlotId, String client); 359 360 /** 361 * Request to trigger an incoming voice call with a call control info. 362 * 363 * @param logicalSlotId the Id of logical sim slot. 364 * @param address the phone number to dial. 365 * @param uusInfo user to user signaling information. 366 * @param cdmaSignalInfoRecord CDMA Signal Information Record as defined in C.S0005 section 367 * 3.7.5.5, null for GSM case. 368 * @param callControlInfo call control configuration 369 * @param client for tracking calling client 370 * @return boolean true if the operation succeeds, otherwise false. 371 */ triggerIncomingVoiceCall( int logicalSlotId, String address, UusInfo[] uusInfo, CdmaSignalInfoRecord cdmaSignalInfoRecord, MockCallControlInfo callControlInfo, String client)372 boolean triggerIncomingVoiceCall( 373 int logicalSlotId, 374 String address, 375 UusInfo[] uusInfo, 376 CdmaSignalInfoRecord cdmaSignalInfoRecord, 377 MockCallControlInfo callControlInfo, 378 String client); 379 380 /** 381 * Get number of voice calls. 382 * 383 * @param logicalSlotId the Id of logical sim slot. 384 * @param client for tracking calling client 385 * @return int number of ongoing calls 386 */ getNumberOfCalls(int logicalSlotId, String client)387 int getNumberOfCalls(int logicalSlotId, String client); 388 } 389