• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = "123456789012347";
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 = "987654321543218";
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 = "987654321012347";
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     // For SIM-IO on AIDs through logical channel
141     /** Register to receive notification when SIM IO data has changed */
registerForSimIoDataChanged(int logicalSlotId, Handler h, int what, Object obj)142     void registerForSimIoDataChanged(int logicalSlotId, Handler h, int what, Object obj);
143     /** Unregister to receive notification when SIM IO data has changed */
unregisterForSimIoDataChanged(int logicalSlotId, Handler h)144     void unregisterForSimIoDataChanged(int logicalSlotId, Handler h);
145 
146     // ***** IRadioNetwork
147     /** Register/unregister notification handler for service status changed */
registerForServiceStateChanged(int logicalSlotId, Handler h, int what, Object obj)148     void registerForServiceStateChanged(int logicalSlotId, Handler h, int what, Object obj);
149 
unregisterForServiceStateChanged(int logicalSlotId, Handler h)150     void unregisterForServiceStateChanged(int logicalSlotId, Handler h);
151 
152     // ***** IRadioVoice
153     /** Register/unregister notification handler for call state changed */
registerForCallStateChanged(int logicalSlotId, Handler h, int what, Object obj)154     void registerForCallStateChanged(int logicalSlotId, Handler h, int what, Object obj);
155 
unregisterForCallStateChanged(int logicalSlotId, Handler h)156     void unregisterForCallStateChanged(int logicalSlotId, Handler h);
157 
158     /** Register/unregister notification handler for current calls response */
registerForCurrentCallsResponse(int logicalSlotId, Handler h, int what, Object obj)159     void registerForCurrentCallsResponse(int logicalSlotId, Handler h, int what, Object obj);
160 
unregisterForCurrentCallsResponse(int logicalSlotId, Handler h)161     void unregisterForCurrentCallsResponse(int logicalSlotId, Handler h);
162 
163     /** Register/unregister notification handler for incoming call */
registerForCallIncoming(int logicalSlotId, Handler h, int what, Object obj)164     void registerForCallIncoming(int logicalSlotId, Handler h, int what, Object obj);
165 
unregisterForCallIncoming(int logicalSlotId, Handler h)166     void unregisterForCallIncoming(int logicalSlotId, Handler h);
167 
168     /** Register/unregister notification handler for ringback tone */
registerRingbackTone(int logicalSlotId, Handler h, int what, Object obj)169     void registerRingbackTone(int logicalSlotId, Handler h, int what, Object obj);
170 
unregisterRingbackTone(int logicalSlotId, Handler h)171     void unregisterRingbackTone(int logicalSlotId, Handler h);
172 
173     /**
174      * Request to get current calls.
175      *
176      * @param logicalSlotId the Id of logical sim slot.
177      * @param client for tracking calling client
178      * @return boolean true if the operation succeeds, otherwise false.
179      */
getCurrentCalls(int logicalSlotId, String client)180     boolean getCurrentCalls(int logicalSlotId, String client);
181 
182     /**
183      * Request to dial a voice call.
184      *
185      * @param logicalSlotId the Id of logical sim slot.
186      * @param address the phone number to dial.
187      * @param clir CLIR mode.
188      * @param uusInfo user to user signaling information.
189      * @param client for tracking calling client
190      * @return boolean true if the operation succeeds, otherwise false.
191      */
dialVoiceCall( int logicalSlotId, String address, int clir, UusInfo[] uusInfo, String client)192     boolean dialVoiceCall(
193             int logicalSlotId, String address, int clir, UusInfo[] uusInfo, String client);
194 
195     /**
196      * Request to dial a voice call with a call control info.
197      *
198      * @param logicalSlotId the Id of logical sim slot.
199      * @param address the phone number to dial.
200      * @param clir CLIR mode.
201      * @param uusInfo user to user signaling information.
202      * @param callControlInfo call control configuration
203      * @param client for tracking calling client
204      * @return boolean true if the operation succeeds, otherwise false.
205      */
dialVoiceCall( int logicalSlotId, String address, int clir, UusInfo[] uusInfo, MockCallControlInfo callControlInfo, String client)206     boolean dialVoiceCall(
207             int logicalSlotId,
208             String address,
209             int clir,
210             UusInfo[] uusInfo,
211             MockCallControlInfo callControlInfo,
212             String client);
213 
214     /**
215      * Request to dial an emergency voice call.
216      *
217      * @param logicalSlotId the Id of logical sim slot.
218      * @param address the phone number to dial.
219      * @param categories the Emergency Service Category(s) of the call.
220      * @param urns the emergency Uniform Resource Names (URN).
221      * @param routing EmergencyCallRouting the emergency call routing information.
222      * @param client for tracking calling client.
223      * @return boolean true if the operation succeeds, otherwise false.
224      */
dialEccVoiceCall(int logicalSlotId, String address, int categories, String[] urns, int routing, String client)225     boolean dialEccVoiceCall(int logicalSlotId, String address,
226             int categories, String[] urns, int routing, String client);
227 
228     /**
229      * Request to dial an emergency voice call with call control info.
230      *
231      * @param logicalSlotId the Id of logical sim slot.
232      * @param address the phone number to dial.
233      * @param categories the Emergency Service Category(s) of the call.
234      * @param urns the emergency Uniform Resource Names (URN).
235      * @param routing EmergencyCallRouting the emergency call routing information.
236      * @param callControlInfo call control configuration.
237      * @param client for tracking calling client.
238      * @return boolean true if the operation succeeds, otherwise false.
239      */
dialEccVoiceCall(int logicalSlotId, String address, int categories, String[] urns, int routing, MockCallControlInfo callControlInfo, String client)240     boolean dialEccVoiceCall(int logicalSlotId, String address,
241             int categories, String[] urns, int routing,
242             MockCallControlInfo callControlInfo, String client);
243 
244     /**
245      * Request to hangup a voice call.
246      *
247      * @param logicalSlotId the Id of logical sim slot.
248      * @param index call identify to hangup.
249      * @param client for tracking calling client
250      * @return boolean true if the operation succeeds, otherwise false.
251      */
hangupVoiceCall(int logicalSlotId, int index, String client)252     boolean hangupVoiceCall(int logicalSlotId, int index, String client);
253 
254     /**
255      * Request to reject an incoming voice call.
256      *
257      * @param logicalSlotId the Id of logical sim slot.
258      * @param client for tracking calling client
259      * @return boolean true if the operation succeeds, otherwise false.
260      */
rejectVoiceCall(int logicalSlotId, String client)261     boolean rejectVoiceCall(int logicalSlotId, String client);
262 
263     /**
264      * Request to accept an incoming voice call.
265      *
266      * @param logicalSlotId the Id of logical sim slot.
267      * @param client for tracking calling client
268      * @return boolean true if the operation succeeds, otherwise false.
269      */
acceptVoiceCall(int logicalSlotId, String client)270     boolean acceptVoiceCall(int logicalSlotId, String client);
271 
272     /**
273      * Get last call fail cause.
274      *
275      * @param logicalSlotId the Id of logical sim slot.
276      * @param client for tracking calling client
277      * @return LastCallFailCauseInfo last cause code and vendor cause info.
278      */
getLastCallFailCause(int logicalSlotId, String client)279     LastCallFailCauseInfo getLastCallFailCause(int logicalSlotId, String client);
280 
281     /**
282      * Sets the last call fail cause.
283      *
284      * @param logicalSlotId the Id of logical sim slot.
285      * @param client for tracking calling client.
286      * @param cause the disconnect cause code.
287      */
setLastCallFailCause(int logicalSlotId, @Annotation.DisconnectCauses int cause, String client)288     void setLastCallFailCause(int logicalSlotId,
289             @Annotation.DisconnectCauses int cause, String client);
290 
291     /**
292      * Clears all calls.
293      *
294      * @param logicalSlotId the Id of logical sim slot.
295      * @param client for tracking calling client.
296      * @param cause the disconnect cause code.
297      */
clearAllCalls(int logicalSlotId, @Annotation.DisconnectCauses int cause, String client)298     void clearAllCalls(int logicalSlotId,
299             @Annotation.DisconnectCauses int cause, String client);
300 
301     /**
302      * Get voice mute mode.
303      *
304      * @param logicalSlotId the Id of logical sim slot.
305      * @param client for tracking calling client
306      * @return boolean true if voice is mute, otherwise false.
307      */
getVoiceMuteMode(int logicalSlotId, String client)308     boolean getVoiceMuteMode(int logicalSlotId, String client);
309 
310     /**
311      * Set voice mute mode.
312      *
313      * @param logicalSlotId the Id of logical sim slot.
314      * @param muteMode mute mode for voice call.
315      * @param client for tracking calling client
316      * @return boolean true if the operation succeeds, otherwise false.
317      */
setVoiceMuteMode(int logicalSlotId, boolean muteMode, String client)318     boolean setVoiceMuteMode(int logicalSlotId, boolean muteMode, String client);
319 
320     // ***** Utility methods
321     /**
322      * Query whether any SIM cards are present or not.
323      *
324      * @param logicalSlotId the Id of logical sim slot.
325      * @param client for tracking calling client
326      * @return boolean true if any sim card inserted, otherwise false.
327      */
isSimCardPresent(int logicalSlotId, String client)328     boolean isSimCardPresent(int logicalSlotId, String client);
329 
330     /**
331      * Change SIM profile
332      *
333      * @param logicalSlotId the Id of logical sim slot.
334      * @param simProfileId The target profile to be switched.
335      * @param client for tracking calling client
336      * @return boolean true if the operation succeeds.
337      */
changeSimProfile(int logicalSlotId, int simProfileId, String client)338     boolean changeSimProfile(int logicalSlotId, int simProfileId, String client);
339 
340     /**
341      * Sets the logical slots enabled for simultaneous calling for the provided logical slotId
342      *
343      * @param logicalSlotId the Id of logical sim slot.
344      * @param enabledLogicalSlots the phone slot Id's that support simultaneous cellular calling.
345      * @param client for tracking calling client.
346      */
setSimulCallingEnabledLogicalSlots(int logicalSlotId, int[] enabledLogicalSlots, String client)347     void setSimulCallingEnabledLogicalSlots(int logicalSlotId, int[] enabledLogicalSlots,
348             String client);
349 
350     /**
351      * Modify SIM info of the SIM such as MCC/MNC, IMSI, etc.
352      *
353      * @param logicalSlotId the Id of logical sim slot.
354      * @param type the type of SIM info to modify.
355      * @param data to modify for the type of SIM info.
356      * @param client for tracking calling client
357      */
setSimInfo(int logicalSlotId, int type, String[] data, String client)358     void setSimInfo(int logicalSlotId, int type, String[] data, String client);
359 
360     /**
361      * Get SIM info of the SIM slot, e.g. MCC/MNC, IMSI.
362      *
363      * @param logicalSlotId the Id of logical sim slot.
364      * @param type the type of SIM info.
365      * @param client for tracking calling client
366      * @return String the SIM info of the queried type.
367      */
getSimInfo(int logicalSlotId, int type, String client)368     String getSimInfo(int logicalSlotId, int type, String client);
369 
370     /**
371      * Request to set call control configuration.
372      *
373      * @param logicalSlotId the Id of logical sim slot.
374      * @param callControlInfo the configuration of call control.
375      * @param client for tracking calling client
376      * @return boolean true if the operation succeeds, otherwise false.
377      */
setCallControlInfo( int logicalSlotId, MockCallControlInfo callControlInfo, String client)378     boolean setCallControlInfo(
379             int logicalSlotId, MockCallControlInfo callControlInfo, String client);
380 
381     /**
382      * Request to get call control configuration.
383      *
384      * @param logicalSlotId the Id of logical sim slot.
385      * @param client for tracking calling client
386      * @return MockCallControlInfo which was set before.
387      */
getCallControlInfo(int logicalSlotId, String client)388     MockCallControlInfo getCallControlInfo(int logicalSlotId, String client);
389 
390     /**
391      * Request to trigger an incoming voice call with a call control info.
392      *
393      * @param logicalSlotId the Id of logical sim slot.
394      * @param address the phone number to dial.
395      * @param uusInfo user to user signaling information.
396      * @param cdmaSignalInfoRecord CDMA Signal Information Record as defined in C.S0005 section
397      *     3.7.5.5, null for GSM case.
398      * @param callControlInfo call control configuration
399      * @param client for tracking calling client
400      * @return boolean true if the operation succeeds, otherwise false.
401      */
triggerIncomingVoiceCall( int logicalSlotId, String address, UusInfo[] uusInfo, CdmaSignalInfoRecord cdmaSignalInfoRecord, MockCallControlInfo callControlInfo, String client)402     boolean triggerIncomingVoiceCall(
403             int logicalSlotId,
404             String address,
405             UusInfo[] uusInfo,
406             CdmaSignalInfoRecord cdmaSignalInfoRecord,
407             MockCallControlInfo callControlInfo,
408             String client);
409 
410     /**
411      * Get number of voice calls.
412      *
413      * @param logicalSlotId the Id of logical sim slot.
414      * @param client for tracking calling client
415      * @return int number of ongoing calls
416      */
getNumberOfCalls(int logicalSlotId, String client)417     int getNumberOfCalls(int logicalSlotId, String client);
418 }
419