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 com.pax.dal.entity.ApnInfo; 020import com.pax.dal.entity.EChannelType; 021import com.pax.dal.entity.ERoute; 022import com.pax.dal.entity.EUartPort; 023import com.pax.dal.entity.EWifiSleepPolicy; 024import com.pax.dal.entity.LanParam; 025import com.pax.dal.entity.LanProxyInfo; 026import com.pax.dal.entity.MobileParam; 027import com.pax.dal.entity.ModemParam; 028import com.pax.dal.entity.UartParam; 029 030import java.util.List; 031 032public interface IDalCommManager { 033 /** 034 * <div class="zh"> 获得Ichannel </div> <div class="en"> get interface IChannel </div> 035 * 036 * @param type 037 * {@link EChannelType} 038 * @return {@link IChannel} 039 */ 040 public IChannel getChannel(EChannelType type); 041 042 /** 043 * <div class="zh"> 启用指定通讯通道,同时会禁用其他通讯通道。 </div> <div class="en"> Enable specified channel and disable others </div> 044 * 045 * 046 * @param type 047 * <div class="zh"> 只支持 {@link EChannelType#WIFI},{@link EChannelType#LAN},{@link EChannelType#MOBILE} 048 * </div> <div class="en"> {@link EChannelType} <br/> 049 * only support @{@link EChannelType#LAN}, {@link EChannelType#WIFI}, {@link EChannelType#MOBILE} </div> 050 * 051 * @param timeout 052 * <div class="zh"> 超时时间,单位秒, <=0 时不等待 </div> <div class="en"> timeout, unit seconds, <=0 will not wait 053 * </div> 054 * @return <div class="zh"> 0 - 成功 -1 - 参数错误 -2 - 打开通道失败 -3 - 超时 </div> <div class="en"> 055 * <ul> 056 * <li>0 -select success</li> 057 * <li>-1 -type error</li> 058 * <li>-2 -enable channel error</li> 059 * <li>-3 -wait for channel ready</li> 060 * </ul> 061 * </div> 062 */ 063 public int enableChannelExclusive(EChannelType type, int timeout); 064 065 /** 066 * <div class="zh"> 设置LanParam(会在调用使能数据通道的时候生效) </div> <div class="en"> set network parameters(It will take effect 067 * at the time of enableChannel) </div> 068 * 069 * @param param 070 * {@link LanParam} 071 */ 072 public void setLanParam(LanParam param); 073 074 /** 075 * <div class="zh"> 设置MobileParam(会在调用使能数据通道的时候生效) </div> <div class="en"> set the Mobile parameters(It will take 076 * effect at the time of enableChannel) </div> 077 * 078 * @param param 079 * {@link MobileParam} 080 */ 081 public void setMobileParam(MobileParam param); 082 083 /** 084 * <div class="zh"> 得到CommModem </div> <div class="en"> get Interface CommModem </div> 085 * 086 * @param param 087 * {@link ModemParam} 088 * @return {@link IComm} 089 */ 090 public IComm getModemComm(ModemParam param); 091 092 /** 093 * <div class="zh"> 得到一个共享的CommUart </div> <div class="en"> Get a shared UartComm Object</div> 094 * 095 * @param param 096 */ 097 public IComm getUartComm(UartParam param); 098 099 /** 100 * <div class="zh"> 列举出所有可用的端口编号 </div> <div class="en"> List all available port numbers </div> 101 * 102 * @return {@link EUartPort} 103 */ 104 public List<EUartPort> getUartPortList(); 105 106 /** 107 * <div class="zh"> 在系统中启用共享网络功能。 108 * <p> 109 * 传统Android只允许同时存在一种网络。 当允许共享网络时,它允许同时存在多种网络,不同的网络地址可以通过调用setRoute()来指定不同的网络连接。 110 * <br>如果移动网络断开,目的IP地址的路由会切换到默认路由,在以上情况下,会连接WIFI。 111 * <br>用户应用需要注意移动网络断开的广播,以防这些情况发生。 112 * <br>该api主要用于WIFI(以太网)以及移动网络。 113 * </p> 114 * </div> 115 * <div class= "en">Enable the shared network function in the system. 116 * <p> 117 * Traditional Android only allows one kind of network to exist at the same time. When a shared network is allowed, it allows multiple networks to exist at the same time, 118 * and different network addresses can specify different network connections by calling setRoute(). 119 * <br>If the mobile network is disconnected, the route of the destination IP address will switch to the default route. In the above cases, WIFI will be connected. 120 * <br>User applications need to be aware of mobile network disconnect broadcasts in case these situations occur. 121 * <br>This api is mainly used for WIFI (Ethernet) and mobile network. 122 * </p> 123 * </div> 124 * 125 * @return <div class="zh"> true :成功 false : 失败 </div> <div class="en"> true :success false : fail </div> 126 */ 127 public boolean enableMultiPath(); 128 129 /** 130 * <div class="zh"> 关闭网络共享 </div> <div class="en"> disable share network feature in system. </div> 131 * 132 * @return <div class="zh"> true :成功 false : 失败 </div> <div class="en"> true :success false : fail </div> 133 * @since V2.00.03 134 */ 135 public boolean disableMultiPath(); 136 137 /** 138 * <div class="zh"> 设置网络通信方式 </div> <div class="en"> set net socket type </div> 139 * 140 * @param host 141 * <div class="zh"> 目标地址 </div> <div class="en"> host address which want to socket </div> 142 * 143 * @param route 144 * {@link ERoute} 145 * @return <div class="zh"> true 设置成功。 false 设置失败 </div> <div class="en"> 146 * <ul> 147 * <li>true -- success</li> 148 * <li>false -- fail</li> 149 * </ul> 150 * </div> 151 */ 152 public boolean setRoute(String host, ERoute route); 153 154 /** 155 * <div class="zh"> 设置机器休眠时Wi-Fi休眠状态 </div> <div class="en"> set Wi-Fi sleep policy when device sleep </div> 156 * 157 * 158 * @param policy 159 * {@link EWifiSleepPolicy} 160 */ 161 public void setWifiSleepPolicy(EWifiSleepPolicy policy); 162 163 /** 164 * <div class="zh"> 检查调制解调器状态以及电话线状态;函数立即返回。 </div> <div class="en"> check modem status as well as telephone line 165 * status; function returns immediately. </div> 166 * 167 * 168 * @return <div class="zh"> 169 * <ul> 170 * <li>0x00 成功</li> 171 * <li>0x01 发送缓冲区满</li> 172 * <li>0x02 旁置电话占用</li> 173 * <li>0x03 电话线未接好或并线电话占用 [线电压不为 0,但过低]</li> 174 * <li>0x33 电话线未接[线电压为 0]</li> 175 * <li>0x83 旁置电话、并线电话均空闲(仅用于发号转人工接听方式)</li> 176 * <li>0x04 线路载波丢失(同步建链失败)</li> 177 * <li>0x05 拨号无应答</li> 178 * <li>0x06 已开始发号(仅用于发号转人工接听方式)</li> 179 * <li>0x0a 正在拨号</li> 180 * <li>0x0b 正常挂机和空闲</li> 181 * <li>0x0c 接收数据请求被拒绝(接收缓冲区为空)</li> 182 * <li>0x0d 被叫线路忙</li> 183 * <li>0xf0 (主 CPU)已无可用的通讯口(两个动态分配端口正全被其它通讯口 使用)</li> 184 * <li>0xfd CANCEL 键按下(Modem 将终止拨号操作)</li> 185 * <li>0xfe 无效的数据长度(len=0 或 len>2048)不会发送数据 其它 异常错误</li> 186 * </ul> 187 * </div> <div class="en"> 188 * <ul> 189 * <li>0x00 -- Success</li> 190 * <li>0x01 -- Sending buffer full</li> 191 * <li>0x02 -- Side telephone has been occupied</li> 192 * <li>0x03 -- Telephone line is not properly connected, or paralleled line is occupied (Line voltage is not 193 * 0, but too low)</li> 194 * <li>0x33 -- Telephone line is not connected (Line voltage is 0)</li> 195 * <li>0x83 -- Both side telephone and paralleled telephone are not busy (only for from automatically 196 * sending mode to manually receiving mode)</li> 197 * <li>0x04 -- Carrier wave of telephone lost</li> 198 * <li>0x05 -- No response for dialing</li> 199 * <li>0x06 -- Start to send numbers (only for from automatically sending mode to manually receiving mode)</li> 200 * <li>0x0a -- Dialing</li> 201 * <li>0x0b -- Normal hangup and idle</li> 202 * <li>0x0c -- Request of receiving data is denied (receiving buffer is null)</li> 203 * <li>0x0d -- Line busy</li> 204 * <li>0xf0 -- (The main CPU)There is no more communication port available (Two dynamically allocated ports 205 * are being used by other communication ports)</li> 206 * <li>0xfd -- Press CANCEL key (Modem will stop dialing)</li> 207 * <li>0xfe -- Invalid data length (len=0 or len>2048) do not send data</li> 208 * <li>others -- Abnormal errors</li> 209 * </ul> 210 * </div> 211 * 212 */ 213 public byte getModemStatus(); 214 215 /** 216 * <div class="zh"> 新建APN并设置为当前生效APN. </div> <div class="en"> Create a new APN and set it to the currently active APN. </div> 217 * 218 * @param name 219 * <div class="zh"> 设置 APN 别名 (设置界面里修改接入点的名称项)。</div> <div class="en"> set alias (modify the name of the access point in the Settings screen).</div> 220 * @param newApn 221 * <div class="zh"> 新APN名字 (设置界面里修改接入点的APN项)。</div> <div class="en"> set name (modify the APN item of the access point in the setting interface).</div> 222 * @param userName 223 * <div class="zh"> 用户名 </div> <div class="en"> user name </div> 224 * @param password 225 * <div class="zh"> 密码 </div> <div class="en"> password </div> 226 * @param authType 227 * <div class="zh"> 认证方式 (0:无 1:pap 2:chap 3:pap或chap)</div> <div class="en"> auth type(0:not have 1:pap 228 * 2:chap 3:pap or chap) </div> 229 * @return <div class="zh"> 1:成功 其他值:失败 </div> <div class="en"> 1:successful; other value:failed</div> 230 * @since V2.04.00 231 */ 232 int switchAPN(String name, String newApn, String userName, String password, int authType); 233 234 /** 235 * <div class="zh"> 关闭Wi-Fi热点并隐藏设置相关界面。需要如下权限:</br>android.permission.ACCESS_WIFI_STATE 236 * </br>android.permission.CHANGE_WIFI_STATE </br>android.permission.CHANGE_NETWORK_STATE </div> <div class="en"> 237 * disable Wi-Fi hotspot and hide Settings's UI.The following permissions are required 238 * :</br>android.permission.ACCESS_WIFI_STATE </br>android.permission.CHANGE_WIFI_STATE 239 * </br>android.permission.CHANGE_NETWORK_STATE </div> 240 */ 241 void disableWifiHotspotAndHideSettings(); 242 243 /** 244 * <div class="zh"> 显示Wi-Fi热点设置UI </div> <div class="en"> show Wi-Fi hotspot settings's UI. </div> 245 */ 246 void showWifiHotspotSettings(); 247 248 /** 249 * <div class="zh">获取以太网IP地址信息。</div> <div class="en"> Getting IP Address Information of Ethernet.</div> 250 * @return {@link LanParam} 251 * @since V3.02.00 252 */ 253 LanParam getLanConfig(); 254 255 /** 256 * <div class="zh">从XML文件新增APN。</div> 257 * <div class="en">Add APN from XML file.</div> 258 * 259 * @param data <div class="zh"> 260 * data - 从APN文件得到的数据,文件格式如下:</div> 261 * <div class="en"> </div> 262 * Data - Data from an APN file in the following format: 263 * <br/><br/> 264 * <?xml version="1.0" encoding="utf-8"?><br/> 265 * <apns version="8"><br/> 266 * <apn carrier="China Mobile"<br/> 267 * apn="cmnet"<br/> 268 * proxy=""<br/> 269 * port="80"<br/> 270 * user=""<br/> 271 * password=""<br/> 272 * server=""<br/> 273 * mmsc=""<br/> 274 * mmsproxy=""<br/> 275 * mmsport=""<br/> 276 * mcc="460"<br/> 277 * mnc="00"<br/> 278 * authtype="3"<br/> 279 * type="default"<br/> 280 * protocol="IPV4V6"<br/> 281 * roaming_protocol="IPV4V6"<br/> 282 * /><br/> 283 * <br/> 284 * <apn carrier="China MobileTTT"<br/> 285 * apn="cmnet"<br/> 286 * proxy=""<br/> 287 * port="80"<br/> 288 * user=""<br/> 289 * password=""<br/> 290 * server=""<br/> 291 * mmsc=""<br/> 292 * mmsproxy=""<br/> 293 * mmsport=""<br/> 294 * mcc="460"<br/> 295 * mnc="01"<br/> 296 * authtype="3"<br/> 297 * type="default"<br/> 298 * protocol="IPV4V6"<br/> 299 * roaming_protocol="IPV4V6"<br/> 300 * /><br/> 301 * </apns> <br/> 302 * 303 * @return <div class="zh"> true:成功 false:失败 </div> <div class="en"> true:success false:failed </div> 304 */ 305 boolean addApns(byte[] data); 306 307 /** 308 * <div class="zh"> 获取APN列表 </div> <div class="en"> get APN list </div> 309 * @return <div class="zh"> APN列表 </div> <div class="en"> APN list </div> 310 */ 311 List<ApnInfo> getApnList(); 312 313 /** 314 * <div class="zh"> 获取当前的APN </div> <div class="en"> get current APN </div> 315 * @return <div class="zh"> 当前的APN </div> <div class="en"> current APN </div> 316 */ 317 ApnInfo getCurrentApn(); 318 319 /** 320 * <div class="zh"> 删除apn </div> <div class="en"> remove APN </div> 321 * @param apnId <div class="zh"> 要删除的apnId,可通过getCurrentApn或getApnList获取 </div> <div class="en"> </div> 322 * @return <div class="zh"> true:成功 false:失败 </div> <div class="en"> true:success false:failed </div> 323 */ 324 boolean removeApn(String apnId); 325 326 /** 327 * <div class="zh">移除路由表里的对应信息</div> <div class="en">Removes the corresponding information from the routing table</div> 328 * 329 * @param host <div class="zh">主机地址</div> <div class="en">host address</div> 330 * 331 * @param route {@link ERoute} 332 * 333 * @return <div class="zh">true:成功 false:失败</div> <div class="en">true:success false:failed</div> 334 * 335 * @since V3.06.00 336 */ 337 boolean removeRoute(String host,ERoute route); 338 339 /** 340 * <div class="zh">获取路由集合</div> <div class="en">Get routing set</div> 341 * 342 * @return <div class="zh">路由集合</div> <div class="en">Routing collection</div> 343 * 344 * @since V3.06.00 345 */ 346 List<String> getRouteList(); 347 348 /** 349 * <div class="zh"> 创建一个新的CommUart </div> <div class="en"> Create a new UartComm Object</div> 350 * 351 * @param param 352 * @since V3.10.00 353 */ 354 public IComm createUartComm(UartParam param); 355 356 /** 357 * <div class="zh">获取以太网接口的状态。</div> <div class="en">Get the status of the Ethernet interface.</div> 358 * 359 * @return <div class="zh">true:开启;false: 关闭。</div> <div class="en">true: open; false: close.</div> 360 * @since V3.24.00 361 */ 362 boolean getEthernetIfaceState(); 363 364 365 /** 366 * <div class="zh"> 设置以太网网络代理。</div> <div class="en"> Set up the Ethernet proxy. </div> 367 * 368 * @param lanProxyInfo {@link LanProxyInfo} 369 * @since V3.25.00 370 */ 371 void setLanProxyInfo(LanProxyInfo lanProxyInfo); 372 373 /** 374 * <div class="zh">系统中启用共享网络功能,并设置网络优先级。</div> 375 * <div class="en">Enable the shared network function in the system and set the network priority.</div> 376 * 377 * @param preferNetwork <div class="zh">0:表示移动网络优先级大于WIFI. </div> 378 * <div class="en">0: Indicates that the mobile network priority is greater than WIFI.</div> 379 * 380 * @return <div class="zh">成功时返回true,失败时返回false。</div> 381 * <div class="en">It returns true on success, and false on failure.</div> 382 * @since V3.27.00 383 */ 384 boolean enableMultiPath(int preferNetwork); 385 386 /** 387 * <div class="zh">获取移动数据网络状态。</div> 388 * <div class="en">Get mobile data network status.</div> 389 * 390 * @return <div class="zh">打开返回true,关闭返回false。</div> 391 * <div class="en">On returns true, off returns false.</div> 392 * @since V3.33.00 393 */ 394 boolean isMobileEnabled(); 395 396 /** 397 * <div class="zh">获取共享网络开关状态。</div> 398 * <div class="en">Get shared network switch status.</div> 399 * 400 * @return <div class="zh">true 共享网络已打开,false 共享网络已禁用。</div> 401 * <div class="en">true: share network is enabled, false: share network is disabled.</div> 402 * @since V4.07.00 403 */ 404 boolean isMultiPathEnabled(); 405 406 /** 407 * <div class="zh">打开以太网开关。</div> 408 * <div class="en">open ethernet switch.</div> 409 * 410 */ 411 void ethOpen(); 412}