Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhangbo1_wd
2024-05-18 15:22:41 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7bd5fa6fb2290213801cfd78b86fb54092fe786b
7bd5fa6f
1 parent
12cfe2f9
修改网络获取,无网络判断
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
1 deletions
sight_harmony/commons/wdKit/src/main/ets/network/NetworkManager.ets
sight_harmony/commons/wdKit/src/main/ets/utils/NetworkUtil.ets
sight_harmony/commons/wdKit/src/main/ets/network/NetworkManager.ets
View file @
7bd5fa6
...
...
@@ -133,10 +133,15 @@ export class NetworkManager {
* 同步获取网络类型,耗时
*/
public getNetTypeSync(): NetworkType {
try {
let netHandle = connection.getDefaultNetSync();
let netCapabilities = connection.getNetCapabilitiesSync(netHandle)
this.reset(netCapabilities.bearerTypes)
return this.networkType;
} catch (e) {
Logger.error(TAG, 'getNetTypeSync e: ' + JSON.stringify(e))
}
return NetworkType.TYPE_UNKNOWN
}
private parseData(data: connection.NetCapabilityInfo) {
...
...
sight_harmony/commons/wdKit/src/main/ets/utils/NetworkUtil.ets
View file @
7bd5fa6
...
...
@@ -43,7 +43,7 @@ export class NetworkUtil {
*/
static isNetConnected(): boolean {
let type = NetworkManager.getInstance().getNetType()
if (type == NetworkType.TYPE_NONE) {
if (type == NetworkType.TYPE_
UNKNOWN || type == NetworkType.TYPE_
NONE) {
return false
}
return true
...
...
Please
register
or
login
to post a comment