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