001 /*
002 * ===========================================================================================
003 * = COPYRIGHT
004 *          PAX Computer Technology (Shenzhen) Co., Ltd. PROPRIETARY INFORMATION
005 *   This software is supplied under the terms of a license agreement or nondisclosure
006 *   agreement with PAX Computer Technology (Shenzhen) Co., Ltd. and may not be copied or
007 *   disclosed except in accordance with the terms in that agreement.
008 *     Copyright (C) 2017-2023 PAX Computer Technology (Shenzhen) Co., Ltd. All rights reserved.
009 * Description: // Detail description about the function of this module,
010 *             // interfaces with the other modules, and dependencies.
011 * Revision History:
012 * Date                         Author                        Action
013 * 2017/04/01                   PAX                     Create/Add/Modify/Delete
014 * ===========================================================================================
015 */
016 
017package com.pax.dal;
018
019import android.telephony.PhoneStateListener;
020
021import com.pax.dal.entity.OperatorInfo;
022import com.pax.dal.exceptions.PhoneDevException;
023
024import java.util.List;
025
026public interface IPhoneManager {
027
028    /**
029     * <div class="zh"> 通过卡槽获取SIM卡索引</div> <div class="en"> Obtaining SIM card index through a slot </div>
030     * 
031     * @param slotId
032     *            <div class="zh"> 0或1 </div> <div class="en"> 0 or 1 </div>
033     * @return <div class="zh"> SIM卡索引 </div> <div class="en"> SIM card index </div>
034     * @throws PhoneDevException
035     */
036    int[] getSubId(int slotId) throws PhoneDevException;
037
038    /**
039     * <div class="zh"> 通过PhoneStateListener获取SIM卡状态,必须在Activity的主线程调用 </div> <div class="en"> Obtaining the status of
040     * SIM card through PhoneStateListener must be called by the main thread of Activity. </div>
041     * 
042     * @param stateListener
043     *            <div class="zh"> {@link PhoneStateListener}</div> <div class="en"> {@link PhoneStateListener} </div>
044     * @param events
045     *            <div class="zh"> 参考{@link PhoneStateListener} </div> <div class="en"> refer to
046     *            {@link PhoneStateListener} </div>
047     * @param subId
048     *            <div class="zh"> SIM卡索引,通过getSubId获取 </div> <div class="en"> SIM card index,through call getSubId
049     *            </div>
050     * @throws PhoneDevException
051     */
052    void listenPhoneState(PhoneStateListener stateListener, int events, int subId) throws PhoneDevException;
053
054    /**
055     * <div class="zh">设置哪张卡来使用数据流量 </div> <div class="en"> set which card to use data traffic </div>
056     * 
057     * @param subId
058     *            <div class="zh"> SIM卡索引,通过getSubId获取 </div> <div class="en">SIM card index,through call getSubId
059     *            </div>
060     * @throws PhoneDevException
061     */
062    void setDefaultDataSubId(int subId) throws PhoneDevException;
063    
064    /**
065     * <div class="zh">设置网络优选模式。</div> <div class="en">Set network preferred mode.</div>
066     * 
067     * @param networkType <div class="zh">模式。<ul>
068     * <li>1:4G/3G/2G 自动选择</li>
069     * <li>2:3G/2G 自动选择</li>
070     * <li>3:2G</li>
071     * <li>4:2G(CDMA only)</li>
072     * <li>5:2G(GSM  only)</li>
073     * <li>6:4G only </li></ul>
074     * </div> <div class="en">Mode. <ul>
075     * <li>1:4G/3G/2G automatic selection</li>
076     * <li>2:3G/2G automatic selection</li>
077     * <li>3:2G</li>
078     * <li>4:2G(CDMA only)</li>
079     * <li>5:2G(GSM  only)</li>
080     * <li>6:4G only </li></ul>
081     * </div>
082     * 
083     * @return <div class="zh">设置结果。true:成功;false:失败。</div> <div class="en">Result. true:success; false:failure.</div>
084     * 
085     * @throws PhoneDevException
086     * @since V3.08.00
087     */
088    boolean setPreferredNetworkType(int networkType) throws PhoneDevException;
089    
090    /**
091     * <div class="zh">判断飞行模式是否开启。</div> <div class="en">Check whether the airplane mode is enabled.</div>
092     *
093     * @return <div class="zh">true:开启; false:关闭。</div> <div class="en">True: open; False: closed.</div>
094     * @throws PhoneDevException
095     * @since V3.17.00
096     */
097    boolean isAirplaneModeEnable() throws PhoneDevException;
098
099
100    /**
101     * <div class="zh">设置是否开启飞行模式。</div> <div class="en">Sets whether the airplane mode is enabled.</div>
102     *
103     * @param enable <div class="zh">true:开启; false:关闭。</div> <div class="en">True: open; False: closed.</div>
104     * @throws PhoneDevException
105     * @since V3.17.00
106     */
107    void enableAirplaneMode(boolean enable) throws PhoneDevException;
108    
109    /**
110     * <div class="zh">扫描当前网络并返回结果。该接口会阻塞线程,不能在主线程调用,会耗时几分钟。</div>
111     * <div class="en">Scan the current network and return the results.This interface blocks the thread and cannot be called on the main thread, 
112     * which can take several minutes. </div>
113     * 
114     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div> <div class="en">SIM card indexes. Get it by {@link #getSubId(int)}.</div>
115     * 
116     * @return {@link OperatorInfo}
117     * 
118     * @throws PhoneDevException 
119     * @since V3.20.00
120     */
121    List<OperatorInfo> getCellNetworkScanResults(int subId) throws PhoneDevException;
122    
123    /**
124     * <div class="zh">获取数据漫游状态。</div> <div class="en">Gets the data roaming state.</div>
125     * 
126     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div> <div class="en">SIM card indexes. Get it by {@link #getSubId(int)}.</div>
127     * 
128     * @return <div class="zh">true:成功 ;false:失败 。</div> <div class="en">true:Success; false:Failure.</div>
129     * 
130     * @throws PhoneDevException
131     * @since V3.20.00
132     */
133    boolean getDataRoamingEnabled(int subId) throws PhoneDevException;
134    
135    /**
136     * <div class="zh">设置数据漫游。</div> <div class="en">Set up the data roaming. </div>
137     * 
138     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div> <div class="en">SIM card indexes. Get it by {@link #getSubId(int)}.</div>
139     * 
140     * @param enable <div class="zh">true:开启 ;false:关闭 。</div> <div class="en">true:Open; false:Close.</div>
141     * 
142     * @throws PhoneDevException
143     * @since V3.20.00
144     */
145    void setDataRoamingEnabled(int subId, boolean enable) throws PhoneDevException;
146    
147    /**
148     * <div class="zh">设置网络运营商。</div> <div class="en">Set up a network operator.</div>
149     * 
150     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div> <div class="en">SIM card indexes. Get it by {@link #getSubId(int)}.</div>
151     * 
152     * @param operator {@link OperatorInfo}
153     * 
154     * @return <div class="zh">true:成功 ;false:失败 。</div> <div class="en">true:Success; false:Failure.</div>
155     * 
156     * @throws PhoneDevException
157     * @since V3.20.00
158     */
159    boolean setNetworkSelectionModeManual(int subId, OperatorInfo operator) throws PhoneDevException;
160    
161    /**
162     * <div class="zh">获取SIM卡锁的状态。</div> <div class="en">Get the status of SIM card lock.</div>
163     *
164     * @param subId <div class="zh">SIM卡索引。通过{{@link #getSubId(int)}}获取。</div>
165     *              <div class="en">SIM card index. It is obtained through {{@link #getSubId(int)}}.</div>
166     * @return <div class="zh">True:已锁;False:没有锁。</div> <div class="en">True: locked; False: no lock.</div>
167     * @throws PhoneDevException
168     * @since V3.20.00
169     */
170    boolean isSimCardLock(int subId) throws PhoneDevException;
171
172    /**
173     * <div class="zh">获取是否支持双SIM卡。</div> <div class="en">Get whether dual SIM cards are supported.</div>
174     *
175     * @return <div class="zh">True:支持;False:不支持。</div> <div class="en">True: supported; False: not supported.</div>
176     * @throws PhoneDevException
177     * @since V3.22.00
178     */
179    boolean isDualSim() throws PhoneDevException;
180
181    /**
182     * @deprecated
183     * <div class="zh">获取VSIM状态。</div> <div class="en">Get VSIM status.</div>
184     *
185     * @return <div class="zh">True:开启;False:关闭。</div> <div class="en">True: on; False: off.</div>
186     * @throws PhoneDevException
187     * @since V3.27.00
188     */
189    @Deprecated
190    boolean isVSimDataInUse() throws PhoneDevException;
191
192    /**
193     * @deprecated
194     * <div class="zh">打开VSIM。</div> <div class="en">Turn on VSIM.</div>
195     *
196     * @throws PhoneDevException
197     * @since V3.27.00
198     */
199    @Deprecated
200    void turnOnVSimData() throws PhoneDevException;
201
202    /**
203     * @deprecated
204     * <div class="zh">关闭VSIM。</div> <div class="en">Turn off VSIM.</div>
205     *
206     * @throws PhoneDevException
207     * @since V3.27.00
208     */
209    @Deprecated
210    void turnOffVSimData() throws PhoneDevException;
211
212    /**
213     * <div class="zh">获取主SIM卡相关信息。</div> <div class="en">Get primary SIM related information.</div>
214     *
215     * @return <div class="zh">simInfo[0]:DeviceId<br>simInfo[1]:IMEI<br>simInfo[2]:ICCID<br>simInfo[3]:SIM operator name<br>simInfo[4]:Network operator name</div>
216     *         <div class="en">simInfo[0]:DeviceId<br>simInfo[1]:IMEI<br>simInfo[2]:ICCID<br>simInfo[3]:SIM operator name<br>simInfo[4]:Network operator name</div>
217     * @throws PhoneDevException
218     * @since V3.29.00
219     */
220    String[] getSIMInfo() throws PhoneDevException;
221
222    /**
223     * <div class="zh">通过卡槽号获取SIM相关信息。</div> <div class="en">Get SIM information from the card slot number.</div>
224     *
225     * @param slotId <div class="zh"> 0或1 </div> <div class="en"> 0 or 1</div>
226     *
227     * @return <div class="zh">simInfo[0]:DeviceId<br>simInfo[1]:IMEI<br>simInfo[2]:ICCID<br>simInfo[3]:SIM operator name<br>simInfo[4]:Network operator name</div>
228     *         <div class="en">simInfo[0]:DeviceId<br>simInfo[1]:IMEI<br>simInfo[2]:ICCID<br>simInfo[3]:SIM operator name<br>simInfo[4]:Network operator name</div>
229     * @throws PhoneDevException
230     * @since V3.32.00
231     */
232    String[] getSIMInfoWithSlotId(int slotId) throws PhoneDevException;
233
234    /**
235     * <div class="zh">设置网络选择模式为自动。</div> <div class="en">Set the network selection mode to automatic.</div>
236     *
237     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div> <div class="en">SIM card indexes. Get it by {@link #getSubId(int)}.</div>
238     *
239     * @throws PhoneDevException
240     * @since V3.32.00
241     */
242    void setNetworkSelectionModeAutomatic(int subId) throws PhoneDevException;
243
244
245
246    /**
247     * <div class="zh">获取网络优先模式。</div> <div class="en">Get network preferred mode.</div>
248     *
249     * @return   <div class="zh">首选网络类型 </div>
250     *           <div class="en">network preferred mode</div>
251     * @throws PhoneDevException
252     * @since V3.33.00
253     */
254    int getPreferredNetworkType() throws PhoneDevException;
255
256    /**
257     * <div class="zh">更新种子卡资源文件,设置后重启生效。</div> <div class="en">Update share profile and restart to take effect.</div>
258     *
259     * @param shareProfilePath <div class="zh">文件路径,不能为空,文件必须存在。</div> <div class="en">The file path, cannot be empty. The file must exist.</div>
260     * @throws PhoneDevException
261     * @since V3.33.00
262     */
263    void updateShareProfile(String shareProfilePath) throws PhoneDevException;
264
265
266    /**
267     * <div class="zh">打开卡数据服务。</div> <div class="en">Turn on the card data service.</div>
268     *
269     * @param listener {@link IVSimAndESimListener}
270     *
271     * @throws PhoneDevException
272     * @since V3.33.00
273     */
274    void turnOnVSimAndESimService(IVSimAndESimListener listener) throws PhoneDevException;
275
276    /**
277     * <div class="zh">关闭卡数据服务。</div> <div class="en">Turn off the card data service.</div>
278     *
279     * @param listener {@link IVSimAndESimListener}
280     * @throws PhoneDevException
281     * @since V3.33.00
282     */
283    void turnOffVSimAndESimService(IVSimAndESimListener listener) throws PhoneDevException;
284
285    /**
286     * <div class="zh">获取当前使用的模式。</div> <div class="en">Get the mode currently in use.</div>
287     *
288     * @throws PhoneDevException
289     * @since V3.33.00
290     */
291    String getUiccMode() throws PhoneDevException;
292
293
294    /**
295     * <div class="zh">设置要使用的模式,重启后生效。</div> <div class="en">Set the mode to use, restart to take effect.</div>
296     *
297     * @param mode <div class="zh">
298     *             <ul><li>"ESIM"</li>
299     *             <li>"GSMA_ESIM"</li></ul></div>
300     *             <div class="en">
301     *             <ul><li>"ESIM"</li>
302     *             <li>"GSMA_ESIM"</li></ul></div>
303
304     * @throws PhoneDevException
305     * @since V3.33.00
306     */
307    void setUiccMode(String mode) throws PhoneDevException;
308
309
310
311
312    /**
313     * <div class="zh">获取卡服务状态。</div> <div class="en">Get the card service state.</div>
314     *
315     * @param listener {@link IVSimAndESimListener}
316     *
317     * @throws PhoneDevException
318     * @since V3.33.00
319     */
320    void getVSimAndESimServiceState(IVSimAndESimListener listener) throws PhoneDevException;
321
322    /**
323     * <div class="zh">打开或者关闭当前使用卡的VoLte模式。</div>
324     * <div class="en">Enable or disable the VoLte mode of the currently used card.</div>
325     *
326     * @param enable <div class="zh">true:打开VoLte false:关闭VoLte </div>
327     *               <div class="en">true: enable, false: disable</div>
328     *
329     * @throws PhoneDevException
330     * @since V3.34.00
331     */
332    void enableVoLteMode(boolean enable) throws  PhoneDevException;
333
334
335    /**
336     * <div class="zh"> VSim和ESim服务监听器 </div> <div class="en"> VSim and ESim service listener</div>
337     *
338     */
339    public interface IVSimAndESimListener {
340
341        /**
342         * <div class="zh"> 返回结果。 </div> <div class="en">Return result </div>
343         *
344         * @param code <div class="zh"><ul>
345         *             <li>0(访问成功)</li>
346         *             <li>-1(访问失败,一般是发生错误)</li>
347         *             <li>-2(无权访问,只有同uid或签名的进程可以访问)</li>
348         *             <li>1000 (服务绑定失败)</li>
349         *             <li>1001(服务未安装)</li>
350         *             <li>1002(服务初始化失败)</li>
351         *             <li>1003(服务未准备好)</li>
352         *             <li>1004 (切换码号中)</li>
353         *             <li>1005 (服务调用过于频繁)</li>
354         *             <li>1006 (操作无效)</li>
355         *             <li>1007 (输入无效)</li>
356         *             <li>1008 (没有更多的业务卡)</li>
357         *             <li>2000 (服务已打开)</li>
358         *             <li>2001 (服务已关闭)</li>
359         * </ul></div>
360         *             <div class="en"><ul>
361         *             <li>0(Access success)</li>
362         *             <li>-1(Access failed, usually an error occurred)</li>
363         *             <li>-2(Only processes with the same uid or signature have access)</li>
364         *             <li>1000 (Service binding failure)</li>
365         *             <li>1001(Service not installed)</li>
366         *             <li>1002(Service initialization failed. Procedure)</li>
367         *             <li>1003(Service initialization failed)</li>
368         *             <li>1004 (Switching code numbers)</li>
369         *             <li>1005 (Service calls are too frequent)</li>
370         *             <li>1006 (Invalid operation)</li>
371         *             <li>1007 (Invalid input)</li>
372         *             <li>1008 (No more business cards)</li>
373         *             <li>2000 (Service opened)</li>
374         *             <li>2001 (Service is closed)</li>
375         *             </ul></div>
376         *
377         */
378        public void onResult(int code);
379
380    }
381
382    /**
383     * <div class="zh">通过subId获取IMSI。</div>
384     * <div class="en">Get IMSI by subId.</div>
385     *
386     * @param subId <div class="zh">SIM卡索引。通过{@link #getSubId(int)}获取。</div>
387     *               <div class="en">SIM card index. Get it by {@link #getSubId(int)}.</div>
388     *
389     * @return <div class="zh">IMSI(International Mobile Subscriber Identity)</div> <div class="en">IMSI(International Mobile Subscriber Identity)</div>
390     * @throws PhoneDevException
391     * @since V4.07.00
392     */
393    String getSubscriberId(int subId) throws  PhoneDevException;
394
395    /**
396     * <div class="zh">获取默认数据流量卡的Subscription Id。</div>
397     * <div class="en">Gets the Subscription Id for the default data traffic card.</div>
398     *
399     * @return <div class="zh">默认数据流量卡的Subscription Id </div>
400     *          <div class="en">Subscription Id of the default data traffic card</div>
401     * @throws PhoneDevException
402     * @since V4.14.00
403     */
404    int getDefaultDataSubscriptionId() throws  PhoneDevException;
405
406
407    /**
408     * <div class="zh">获取对应卡槽是否插入SIM卡。</div>
409     * <div class="en">Obtain whether a SIM card is inserted into the corresponding slot.</div>
410     *
411     * @param slotId <div class="zh">0或1。</div>
412     *               <div class="en">0 or 1.</div>
413     *
414     * @return <div class="zh">true-存在, false-未插入 </div>
415     *          <div class="en">true- exists, false- not inserted</div>
416     * @throws PhoneDevException
417     * @since V4.14.00
418     */
419    boolean isSimPresent(int slotId) throws  PhoneDevException;
420
421    /**
422     * <div class="zh">对SIM卡进行操作:禁用plmn或者解除plmn禁用,重启生效。</div>
423     * <div class="en">Perform operations on the SIM card: Disable PLMN or enable PLMN,Reboot has taken effect.</div>
424     *
425     * @param phoneId <div class="zh">卡槽号,一般是0或者1</div>
426     *               <div class="en">The slot number is usually 0 or 1.</div>
427     *
428     * @param operation <div class="zh">只允许2个值:"1"表示禁用,"0"表示解除禁用 </div>
429     *               <div class="en">Only two values are allowed: "1" indicates disable, and "0" indicates enable.</div>
430     *
431     * @param plmn <div class="zh">想要禁用或者解除禁用的plmn,plmn长度为5位或者6位,每一位的取值范围:0~9</div>
432     *               <div class="en">To disable or re-enable a PLMN, the PLMN length should be 5 or 6 digits. Each digit's value range is from 0 to 9.</div>
433     *
434     * @throws PhoneDevException
435     * @since V4.18.00
436     */
437    void updatePlmn(int phoneId, String operation, String plmn) throws PhoneDevException;
438}