diff --git a/OAT.xml b/OAT.xml index 71bcc3b4118f73c264d08424086498be04078a3e..17ae958a1ef0b294d60042bf9e9798fec08345c7 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1506,6 +1506,10 @@ Note:If the text contains special characters, please escape them according to th + + + + diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/.gitignore b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/app.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a51a7f5ba36d7ecaf39da131615d5c28f545fb9 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "bundleName": "com.samples.connect_control", + "vendor": "samples", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0a74d1be9b48198dbf8ddcd835ef21ba34875a66 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Connect_Control" + } + ] +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/media/app_icon.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/README_zh.md b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..3b09e8da1687e514de53a9f8c55ab38139a6408d --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/README_zh.md @@ -0,0 +1,155 @@ +# 以太网连接(仅对系统应用开放) + +### 介绍 + +以太网连接的功能是提供支持设备通过硬件接口,以插入网线的形式访问互联网的能力。 设备接入网线后,可以获取动态分配的IP地址,子网掩码,Gateway,DNS等一系列网络属性;通过静态模式,手动配置与获取设备的网络属性。本项目展示了一个网络共享管理的示例应用,它实现了通过按钮实现以太网连接-DHCP模式、以太网连接-静态模式以及监听网络设备接口状态变化的功能,使用了[@ohos.net.ethernet](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-network-kit/js-apis-net-connection.md)接口。 + +### 效果预览 + +| 获取网卡名称 | 获取接口状态 | 获取接口配置 | 获取配置状态 | +| ------------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | -------------------------------------------------- | +| ![image](screenshots/Get_Configuration_Status.jpg) | ![image](screenshots/Get_Interface_Configuration.jpg) | ![image](screenshots/Get_Interface_Configuration.jpg) | ![image](screenshots/Get_Configuration_Status.jpg) | + +使用说明 + +1. 点击“获取所有活动接口”按钮,显示当前所有处于活动状态的接口。 +2. 点击“检查接口状态”按钮,检查 `eth0` 接口是否激活。 +3. 点击“获取接口配置”按钮,获取 `eth0` 接口的网络配置信息。 +4. 点击“设置接口配置”按钮,设置 `eth0` 接口为静态 IP 模式。 +5. 点击“订阅接口状态变化”按钮,实时监听接口状态的变化。 +6. 点击“取消接口状态变化订阅”按钮,停止监听接口状态变化。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---common +| |---Logger.ets // 日志工具 +| |---CommonCOnstant.ets // 字符串常量 +|---entryability +| │---EntryAbility.ets +|---entrybackupability +│ |---EntryBackupAbility.ets +|---pages +│ |---Index.ets //主页 +``` + +### 具体实现 + +1. 获取所有活动的网络接口 + + - 调用 `ethernet.getAllActiveIfaces()` 方法获取当前设备中所有处于活动状态的网络接口。 + + - 返回值为一个包含接口名称的字符串数组。 + + - 将结果转换为字符串显示在界面中: + + ``` + this.activeIfaces = ` ${data.join(', ')}`; + ``` + + - 如果发生错误,捕获异常并在界面显示“获取失败”,同时通过日志输出错误信息。 + +2. 检查指定接口状态 + + - 调用 `ethernet.isIfaceActive("eth0")` 方法检查接口 `eth0` 是否处于激活状态。 + + - 结果为一个布尔值,`1` 表示激活,`0` 表示未激活。 + + - 根据返回值更新 UI 状态为“已激活”或“未激活”: + + ``` + this.ifaceStatus = data === 1 ? "已激活" : "未激活"; + ``` + + - 如果检查失败,捕获异常并在界面显示“检查失败”,同时通过日志输出错误信息。 + +3. 获取指定接口的网络配置 + + - 调用 `ethernet.getIfaceConfig("eth0")` 方法获取接口 `eth0` 的配置信息。 + + - 返回值包含以下配置信息: + + - IP 地址(`ipAddr`) + - 路由(`route`) + - 网关(`gateway`) + - 子网掩码(`netMask`) + - DNS 服务器(`dnsServers`) + + - 将这些信息格式化为字符串并显示在界面: + + ``` + this.ifaceConfig = `IP地址: ${data.ipAddr}, 路由: ${data.route}, 网关: ${data.gateway}, 子网掩码: ${data.netMask}, DNS: ${data.dnsServers}`; + ``` + + - 如果获取失败,捕获异常并在界面显示“获取失败”,同时通过日志输出错误信息。 + +4. 设置指定接口的网络配置 + + - 调用 `ethernet.setIfaceConfig("eth0", config)` 方法为 `eth0` 接口设置静态 IP 配置。 + - 配置参数如下: + - IP 地址(`ipAddr`):`192.168.147.226` + - 路由(`route`):`192.168.147.0` + - 网关(`gateway`):`192.168.147.1` + - 子网掩码(`netMask`):`255.255.255.0` + - DNS 服务器(`dnsServers`):`8.8.8.8` + +5. 订阅接口状态变化 + + - 调用 `ethernet.on("interfaceStateChange", callback)` 方法订阅接口状态变化事件。 + + - 在事件回调函数中,获取状态变化的接口名称(`iface`)及其状态(`active`)。 + + - 将事件记录到日志区域并更新 UI: + + ``` + this.eventLog = `接口: ${data.iface}, 状态: ${data.active ? '已激活' : '未激活'}`; + ``` + + - 如果已经订阅,不重复订阅,并输出提示日志。 + + - 如果订阅失败,捕获异常并输出错误日志。 + +6. 取消接口状态变化订阅 + + - 调用 `ethernet.off("interfaceStateChange")` 方法取消订阅接口状态变化事件。 + + - 取消订阅成功后,将日志区域更新为“接口状态变化订阅已取消”,并通过日志记录取消成功信息: + + ``` + this.eventLog = '接口状态变化订阅已取消'; + ``` + + - 如果未订阅,直接输出提示信息,不执行操作。 + + - 如果取消失败,捕获异常并输出错误日志。 + + + +### 相关权限 + +1.使用连接性内部权限:ohos.permission.CONNECTIVITY_INTERNAL。 +2.获取网络信息的权限:ohos.permission.GET_NETWORK_INFO。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.58。 +3. 本示例需要使用DevEco Studio Release(5.0.5.306)及以上版本才可编译运行。 +4. 本示例要求设备插入有效的网线,否则部分功能(如获取活动网络接口、检查接口状态等)可能无法正常运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/ > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/build-profile.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..177f3078c26894b3db5bf58cf36541bfc05c3455 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/build-profile.json5 @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "app": { + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "targetSdkVersion": 14, + "compatibleSdkVersion": 14, + "runtimeOS": "OpenHarmony" + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ], + "signingConfigs": [ + { + "name": "default", + "material": { + "certpath": "C:/Users/Administrator/.ohos/config/openharmony/default_Connect_Control_case_CMEdrmJnhhnch3mK1Ron5pIH5VA60Ha0T9F9OpTPam8=.cer", + "storePassword": "0000001B31C79A8574704507018C7E9B082BB34B125C324F4A161D542F91ACE1729639AEB5346F6D41DB23", + "keyAlias": "debugKey", + "keyPassword": "0000001B7B1540D653D0DE50D638E152B00018D08C2ED3C4B2D449E7762BD4D435F957563B802AD3355CE6", + "profile": "C:/Users/Administrator/.ohos/config/openharmony/default_Connect_Control_case_CMEdrmJnhhnch3mK1Ron5pIH5VA60Ha0T9F9OpTPam8=.p7b", + "signAlg": "SHA256withECDSA", + "storeFile": "C:/Users/Administrator/.ohos/config/openharmony/default_Connect_Control_case_CMEdrmJnhhnch3mK1Ron5pIH5VA60Ha0T9F9OpTPam8=.p12" + } + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/.gitignore b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/build-profile.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..eed6635f664fa08b992d84590bf62be7e0bb5381 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/hvigorfile.ts b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..e4f43d54667f8327c367c8096bd08bb8c75aff54 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/obfuscation-rules.txt b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/oh-package.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/CommonConstant.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/CommonConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..2eeb398d795e1761a943bed2b003c1a61f5d726f --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/CommonConstant.ets @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export enum ComponentId { + ACTIVE_INTERFACE = 'activeIfaces', + IFACE_STATUS = 'ifaceStatus', + IFACE_CONFIG = 'ifaceConfig', + CONFIG_STATUS = 'configStatus', + EVENT_LOG = 'eventLog', + GET_ALL_ACTIVE_INTERFACE_BTN = 'GetAllActiveInterfaces', + CHECK_ETH0_ACTIVE_BTN = 'checkEth0Activation', + Eth0_CONFIG_GET_BTN = 'getEth0InterfaceConfiguration', + Eth0_CONFIG_SET_BTN = 'setEth0InterfaceConfiguration', + IFACE_STATUS_CHANGE_SUB_BTN = 'subscribeInterfaceStatusChanges', + IFACE_STATUS_CHANGE_UNSUB_BTN = 'unsubscribeInterfaceStatusChanges' +} + +export enum IFaceStatus { + ACTIVE = 1, + INACTIVE = 0 +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/Logger.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..c6ce8d4fffeb65d20d829360b7bb6e099d828147 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/common/Logger.ets @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; + +class Logger { + private domain: number + private prefix: string + private format: string = '%{public}s' + + constructor(prefix: string) { + this.prefix = prefix + this.domain = 0x0001 + } + + debug(...args: string[]) { + hilog.debug(this.domain, this.prefix, this.format, args) + } + + info(...args: string[]) { + hilog.info(this.domain, this.prefix, this.format, args) + } + + warn(...args: string[]) { + hilog.warn(this.domain, this.prefix, this.format, args) + } + + error(...args: string[]) { + hilog.error(this.domain, this.prefix, this.format, args) + } + + fatal(...args: string[]) { + hilog.fatal(this.domain, this.prefix, this.format, args) + } + + isLoggable(level: number) { + hilog.isLoggable(this.domain, this.prefix, level) + } +} + +export default new Logger('[Sample_ConnectControl]') diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..27fe8ebfc701efcd8d20fa272d4a3017d5229897 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import Logger from '../common/Logger'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + Logger.info('Ability onCreate'); + } + + onDestroy(): void { + Logger.info('Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + Logger.info('Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + Logger.error(`Failed to load the content. ${JSON.stringify(err)}`); + return; + } + Logger.info('Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + Logger.info('Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + Logger.info('Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + Logger.info('Ability onBackground'); + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..f1047bd4d077992ee5ef3098291ecd3ada054198 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; +import Logger from '../common/Logger'; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + Logger.info('onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + Logger.info(`onRestore ok ${JSON.stringify(bundleVersion)}`); + } +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/pages/Index.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..57b68a98c08ce7fe313cf2d7384b6ca916a41c80 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ethernet } from '@kit.NetworkKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import Logger from '../common/Logger'; +import { ComponentId, IFaceStatus } from '../common/CommonConstant'; + +// 订阅和取消事件相关的数据类型定义 +class EthernetData { + iface: string = ""; + active: boolean = false; +} + +const IFACE_NAME: string = 'eth0'; + +export function resourceToString(resource: Resource): string { + return getContext().resourceManager.getStringSync(resource.id) +} + +@Entry +@Component +struct EthernetInfoDemo { + @State activeIfaces: string = ''; + @State ifaceStatus: string = ''; + @State ifaceConfig: string = ''; + @State configStatus: string = ''; + @State eventLog: string = ''; + @State isSubscribed: boolean = false; + + build() { + Column() { + // 显示活动接口信息 + Text(resourceToString($r('app.string.Active_Interfaces')) + ':' + this.activeIfaces) + .fontSize($r('app.float.size20')) + .fontColor(Color.Black) + .margin({ top: $r('app.float.margin10') }) + .id(ComponentId.ACTIVE_INTERFACE); + // 显示接口状态,通过绑定状态值实时更新显示内容 + Text(resourceToString($r('app.string.ifaceStatus')) + ':' + this.ifaceStatus) + .fontSize($r('app.float.size20')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.IFACE_STATUS); + // 显示接口配置,通过绑定状态值实时更新显示内容 + Text(resourceToString($r('app.string.ifaceConfig')) + ':' + this.ifaceConfig) + .fontSize($r('app.float.size16')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.IFACE_CONFIG); + + // 显示接口配置设置状态,通过绑定状态值实时更新显示内容 + Text(resourceToString($r('app.string.configStatus')) + ':' + this.configStatus) + .fontSize($r('app.float.size20')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.CONFIG_STATUS); + + // 显示接口状态变化日志,通过绑定状态值实时更新显示内容 + Text(resourceToString($r('app.string.eventLog')) + ':' + this.eventLog) + .fontSize($r('app.float.size20')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.EVENT_LOG); + + // 按钮: 获取所有活动接口 + Button($r('app.string.Get_All_Active_Interfaces')) + .onClick(() => { + this.getAllActiveIfaces(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .backgroundColor(Color.Blue) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.GET_ALL_ACTIVE_INTERFACE_BTN) + + // 按钮: 获取指定接口的状态 + Button($r('app.string.Check_eth0_Activation')) + .onClick(() => { + this.checkIfaceStatus(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .backgroundColor(Color.Green) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.CHECK_ETH0_ACTIVE_BTN) + + // 按钮: 获取接口配置 + Button($r('app.string.Get_eth0_Interface_Configuration')) + .onClick(() => { + this.getIfaceConfig(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .backgroundColor(Color.Red) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.Eth0_CONFIG_GET_BTN); + + // 按钮: 设置接口配置 + Button($r('app.string.Set_eth0_Interface_Configuration')) + .onClick(() => { + this.setIfaceConfig(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .backgroundColor(Color.Orange) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.Eth0_CONFIG_SET_BTN) + + // 按钮: 订阅接口状态变化 + Button($r('app.string.Subscribe_Interface_Status_Changes')) + .onClick(() => { + this.subscribeInterfaceStateChange(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.IFACE_STATUS_CHANGE_SUB_BTN) + + // 按钮: 取消接口状态变化事件订阅 + Button($r('app.string.Unsubscribe_Interface_Status_Changes')) + .onClick(() => { + this.unsubscribeInterfaceStateChange(); + }) + .width('80%') + .height($r('app.float.height50')) + .margin({ top: $r('app.float.margin20') }) + .backgroundColor(Color.Gray) + .fontColor(Color.White) + .fontSize($r('app.float.size20')) + .borderRadius($r('app.float.borderRadius')) + .id(ComponentId.IFACE_STATUS_CHANGE_UNSUB_BTN) + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center); + } + + // 获取所有活动的网络接口 + private getAllActiveIfaces(): void { + ethernet.getAllActiveIfaces().then((data: string[]) => { + Logger.info(`activeIfaces: ${JSON.stringify(data)}`); + this.activeIfaces = ` ${data.join(', ')}`; + }).catch((error: BusinessError) => { + Logger.error(`getAllActiveFail: ${JSON.stringify(error)}`); + this.activeIfaces = resourceToString($r('app.string.getFail')); + }); + } + + // 检查 eth0 接口是否已激活 + private checkIfaceStatus(): void { + ethernet.isIfaceActive(IFACE_NAME).then((data: number) => { + Logger.info('eth0 status: ', JSON.stringify(data)); + this.ifaceStatus = data === IFaceStatus.ACTIVE ? resourceToString($r('app.string.active')) : + resourceToString($r('app.string.inactive')); + }).catch((error: BusinessError) => { + Logger.error(`check ifaceActive fail: ${JSON.stringify(error)}`); + this.ifaceStatus = resourceToString($r('app.string.checkFail')); + }); + } + + // 获取 eth0 接口配置 + private getIfaceConfig(): void { + ethernet.getIfaceConfig(IFACE_NAME).then((data: ethernet.InterfaceConfiguration) => { + Logger.info(`eth0 ifaceConfiguration:${JSON.stringify(data)}`); + this.ifaceConfig = + resourceToString($r('app.string.ipAddr')) + data.ipAddr; + resourceToString($r('app.string.route')) + data.route; + resourceToString($r('app.string.gateway')) + data.gateway; + resourceToString($r('app.string.netMask')) + data.netMask; + resourceToString($r('app.string.dnsServers')) + data.dnsServers; + }).catch((error: BusinessError) => { + Logger.error(`getIfaceConfig fail: ${JSON.stringify(error)}`,); + this.ifaceConfig = resourceToString($r('app.string.getFail')); + }); + } + + // 设置 eth0 接口配置 + private setIfaceConfig(): void { + let config: ethernet.InterfaceConfiguration = { + mode: 0, + ipAddr: "192.168.147.226", + route: "192.168.147.0", + gateway: "192.168.147.1", + netMask: "255.255.255.0", + dnsServers: "8.8.8.8" + }; + + ethernet.setIfaceConfig(IFACE_NAME, config).then(() => { + Logger.info('setIfaceConfig promise ok'); + this.configStatus = resourceToString($r('app.string.setSuccess')); + }).catch((error: BusinessError) => { + Logger.error(`setIfaceConfig promise error: ${JSON.stringify(error)}`); + this.configStatus = resourceToString($r('app.string.setFail')); + }); + } + + // 订阅接口状态变化 + private subscribeInterfaceStateChange(): void { + try { + if (!this.isSubscribed) { + ethernet.on('interfaceStateChange', (data: EthernetData) => { + Logger.info(`subscribeInterfaceStateChange success: ${JSON.stringify(data)} `); + this.eventLog = resourceToString($r('app.string.iface')) + data.iface; + this.eventLog = + resourceToString($r('app.string.status')) + data.active ? resourceToString($r('app.string.active')) : + resourceToString($r('app.string.inactive')); + }); + this.isSubscribed = true; + // 当成功订阅时,更新事件日志的显示内容 + this.eventLog = resourceToString($r('app.string.subSuccess')); + Logger.info('subscribeInterfaceStateChange success'); + } else { + Logger.info('InterfaceState has subscribed, not require subscribe'); + } + } catch (error) { + Logger.error(`subscribeInterfaceStateChange: ${JSON.stringify(error)}`); + } + } + + // 取消接口状态变化订阅 + private unsubscribeInterfaceStateChange(): void { + try { + if (this.isSubscribed) { + ethernet.off('interfaceStateChange'); + this.isSubscribed = false; + this.eventLog = resourceToString($r('app.string.cancelSubscribe')); + Logger.info('unsubscribeInterfaceStateChange success'); + } else { + Logger.info('no InterfaceState is subscribed, not require cancel '); + } + } catch (error) { + Logger.error(`unsubscribeInterfaceStateChange fail: ${JSON.stringify(error)}`); + } + } +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/module.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b110d3845f14b04270c845c902da607af135939b --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/module.json5 @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:app_name", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name":"ohos.permission.GET_NETWORK_INFO" + }, + { + "name":"ohos.permission.CONNECTIVITY_INTERNAL" + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/color.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/float.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..358118fda5c16e481b25149e9dff1eda453c9f47 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/float.json @@ -0,0 +1,36 @@ +{ + "float": [ + { + "name": "margin20", + "value": "20" + }, + { + "name": "margin18", + "value": "18" + }, + { + "name": "margin10", + "value": "10" + }, + { + "name": "size16", + "value": "16" + }, + { + "name": "size18", + "value": "18" + }, + { + "name": "size20", + "value": "20" + }, + { + "name": "height50", + "value": "50" + }, + { + "name": "borderRadius", + "value": "5" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f0b1d00fc87ff37596a829fbe8d48edd3b083bed --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Get_All_Active_Interfaces", + "value": "Get_All_Active_Interfaces" + }, + { + "name": "Check_eth0_Activation", + "value": "Check_eth0_Activation" + }, + { + "name": "Get_eth0_Interface_Configuration", + "value": "Get_eth0_Interface_Configuration" + }, + { + "name": "Set_eth0_Interface_Configuration", + "value": "Set_eth0_Interface_Configuration" + }, + { + "name": "Subscribe_Interface_Status_Changes", + "value": "Subscribe_Interface_Status_Changes" + }, + { + "name": "Unsubscribe_Interface_Status_Changes", + "value": "Unsubscribe_Interface_Status_Changes" + }, + { + "name": "getFail", + "value": "getActiveInterfaceFail" + }, + { + "name": "active", + "value": "active" + }, + { + "name": "inactive", + "value": "inactive" + }, + { + "name": "checkFail", + "value": "check fail" + }, + { + "name": "setSuccess", + "value": "set success" + }, + { + "name": "setFail", + "value": "set fail" + }, + { + "name": "subSuccess", + "value": "subscribe success" + }, + { + "name": "cancelSubscribe", + "value": "cancel subscribe" + }, + { + "name": "Active_Interfaces", + "value": "活动网络接口" + }, + { + "name": "ifaceStatus", + "value": "接口状态" + }, + { + "name": "ifaceConfig", + "value": "接口配置" + }, + { + "name": "configStatus", + "value": "配置状态" + }, + { + "name": "eventLog", + "value": "接口状态变化日志" + }, + { + "name": "ipAddr", + "value": "IP地址" + }, + { + "name": "route", + "value": "路由" + }, + { + "name": "gateway", + "value": "网关" + }, + { + "name": "netMask", + "value": "子网掩码" + }, + { + "name": "dnsServers", + "value": "DNS" + }, + { + "name": "iface", + "value": "接口" + }, + { + "name": "acquisition_failed", + "value": "获取失败" + }, + { + "name": "Success", + "value": "成功" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "status", + "value": "状态" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/background.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d1de09c1f19f7b54fd61c9ccf32f1ffd36fa62b4 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Get_All_Active_Interfaces", + "value": "Get_All_Active_Interfaces" + }, + { + "name": "Check_eth0_Activation", + "value": "Check_eth0_Activation" + }, + { + "name": "Get_eth0_Interface_Configuration", + "value": "Get_eth0_Interface_Configuration" + }, + { + "name": "Set_eth0_Interface_Configuration", + "value": "Set_eth0_Interface_Configuration" + }, + { + "name": "Subscribe_Interface_Status_Changes", + "value": "Subscribe_Interface_Status_Changes" + }, + { + "name": "Unsubscribe_Interface_Status_Changes", + "value": "Unsubscribe_Interface_Status_Changes" + }, + { + "name": "getFail", + "value": "getActiveInterfaceFail" + }, + { + "name": "active", + "value": "active" + }, + { + "name": "inactive", + "value": "inactive" + }, + { + "name": "checkFail", + "value": "check fail" + }, + { + "name": "setSuccess", + "value": "set success" + }, + { + "name": "setFail", + "value": "set fail" + }, + { + "name": "subSuccess", + "value": "subscribe success" + }, + { + "name": "cancelSubscribe", + "value": "cancel subscribe " + }, + { + "name": "Active_Interfaces", + "value": "Active_Interfaces" + }, + { + "name": "ifaceStatus", + "value": "ifaceStatus" + }, + { + "name": "ifaceConfig", + "value": "ifaceConfig" + }, + { + "name": "configStatus", + "value": "configStatus" + }, + { + "name": "eventLog", + "value": "eventLog" + }, + { + "name": "ipAddr", + "value": "ipAddr" + }, + { + "name": "route", + "value": "route" + }, + { + "name": "gateway", + "value": "gateway" + }, + { + "name": "netMask", + "value": "netMask" + }, + { + "name": "dnsServers", + "value": "dnsServers" + }, + { + "name": "iface", + "value": "iface" + }, + { + "name": "acquisition_failed", + "value": "acquisition_failed" + }, + { + "name": "Success", + "value": "Success" + }, + { + "name": "cancel", + "value": "cancel" + }, + { + "name": "status", + "value": "status" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4360857f3ff62396d117784f4e0dd90b862e28c0 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,132 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Get_All_Active_Interfaces", + "value": "获取所有活动接口" + }, + { + "name": "Check_eth0_Activation", + "value": "检查 eth0 是否激活" + }, + { + "name": "Get_eth0_Interface_Configuration", + "value": "获取 eth0 接口配置" + }, + { + "name": "Set_eth0_Interface_Configuration", + "value": "设置 eth0 接口配置" + }, + { + "name": "Subscribe_Interface_Status_Changes", + "value": "订阅接口状态变化" + }, + { + "name": "Unsubscribe_Interface_Status_Changes", + "value": "取消接口状态变化订阅" + }, + { + "name": "getFail", + "value": "获取失败" + }, + { + "name": "active", + "value": "激活" + }, + { + "name": "inactive", + "value": "未激活" + }, + { + "name": "checkFail", + "value": "检查失败" + }, + { + "name": "setSuccess", + "value": "设置成功" + }, + { + "name": "setFail", + "value": "设置失败" + }, + { + "name": "subSuccess", + "value": "订阅接口状态变化成功" + }, + { + "name": "cancelSubscribe", + "value": "接口状态变化订阅已取消 " + }, + { + "name": "Active_Interfaces", + "value": "活动网络接口" + }, + { + "name": "ifaceStatus", + "value": "接口状态" + }, + { + "name": "ifaceConfig", + "value": "接口配置" + }, + { + "name": "configStatus", + "value": "配置状态" + }, + { + "name": "eventLog", + "value": "接口状态变化日志" + }, + { + "name": "ipAddr", + "value": "IP地址" + }, + { + "name": "route", + "value": "路由" + }, + { + "name": "gateway", + "value": "网关" + }, + { + "name": "netMask", + "value": "子网掩码" + }, + { + "name": "dnsServers", + "value": "DNS" + }, + { + "name": "iface", + "value": "接口" + }, + { + "name": "acquisition_failed", + "value": "获取失败" + }, + { + "name": "Success", + "value": "成功" + }, + { + "name": "cancel", + "value": "取消" + }, + { + "name": "status", + "value": "状态" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dd873c4ffc2afabad9b149da0c3b1507fb3c01d2 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; +import Logger from '../../../main/ets/common/Logger'; +import { ComponentId } from '../../../main/ets/common/CommonConstant'; + +const delegator = abilityDelegatorRegistry.getAbilityDelegator(); + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +const BUNDLE_NAME = 'com.samples.connect_control'; +const ABILITY_NAME: string = 'EntryAbility'; + +let delayTime: number = 2000; + +function getResourceString(resource: Resource): string { + let manage = delegator.getAppContext().resourceManager; + let text = manage.getStringSync(resource); + return text; +} + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * @tc.number StartAbility_001 + * @tc.name StartAbility_001 + * @tc.desc 启动Ability + */ + it('StartAbility_001', 0, async (done: Function) => { + const want: Want = { + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME, + }; + await delegator.startAbility(want); + await sleep(delayTime); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + expect(ability.context.abilityInfo.name).assertEqual(ABILITY_NAME); + done(); + }); + + /** + * @tc.number Acquire_Interface_001 + * @tc.name Acquire_Interface_001 + * @tc.desc 测试连接网络按钮 + */ + it('Acquire_Interface_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME}Acquire_Interface_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.GET_ALL_ACTIVE_INTERFACE_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.GET_ALL_ACTIVE_INTERFACE_BTN)); + await stack.click(); // 点击按钮 + await driver.delayMs(delayTime); // 等待点击后的状态更新 + + // 验证界面上是否显示了"未连接"或"已连接" + let resultText = await driver.findComponent(ON.id(ComponentId.ACTIVE_INTERFACE)); + let result = await resultText.getText(); + const expectedValue: string = 'eth0'; + expect(result).assertContain(expectedValue); + Logger.info(`${BUNDLE_NAME}Acquire_Interface_001 end`); + done(); + }); + /** + * @tc.number Check_Activation_001 + * @tc.name Check_Activation_001 + * @tc.desc 测试 检查 eth0 是否激活 按钮 + */ + + it('Check_Activation_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Check_Activation_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.CHECK_ETH0_ACTIVE_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.CHECK_ETH0_ACTIVE_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + let resultText = await driver.findComponent(ON.id(ComponentId.IFACE_STATUS)); + let result = await resultText.getText(); + const expectedValue: string = getResourceString($r('app.string.active')); + expect(result).assertContain(expectedValue); + + Logger.info(`${BUNDLE_NAME}Check_Activation_001 end`); + done(); + }); + + /** + * @tc.number Acquire_Interface_Configuration_001 + * @tc.name Interface_Configuration_001 + * @tc.desc 测试 获取 eth0 接口配置 按钮 + */ + it('Acquire_Interface_Configuration_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Acquire_Interface_Configuration_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.Eth0_CONFIG_GET_BTN)); + let stack = await driver.findComponent(ON.id(ComponentId.Eth0_CONFIG_GET_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + let resultText = await driver.findComponent(ON.id(ComponentId.IFACE_CONFIG)); + let result = await resultText.getText(); + const expectedValue: string = getResourceString($r('app.string.acquisition_failed')); + expect(result).not().assertEqual(expectedValue); + Logger.info(`${BUNDLE_NAME} Acquire_Interface_Configuration_001 end`); + done(); + }); + + /** + * @tc.number Set_Interface_Configuration_001 + * @tc.name Set_Interface_Configuration_001 + * @tc.desc 测试 获取默认网络 按钮 + */ + + it('Set_Interface_Configuration_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Set_Interface_Configuration_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.Eth0_CONFIG_SET_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.Eth0_CONFIG_SET_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + let resultText = await driver.findComponent(ON.id(ComponentId.CONFIG_STATUS)); + let result = await resultText.getText(); + const expectedValue: string = getResourceString($r('app.string.Success')); + expect(result).assertContain(expectedValue); + Logger.info(`${BUNDLE_NAME} Set_Interface_Configuration_001 end`); + done(); + }); + + /** + * @tc.number Subscription_Interface_Status_001 + * @tc.name Subscription_Interface_Status_001 + * @tc.desc 测试 订阅接口状态变化 按钮 + */ + + it('Subscription_Interface_Status_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Subscription_Interface_Status_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.IFACE_STATUS_CHANGE_SUB_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.IFACE_STATUS_CHANGE_SUB_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + + // 验证界面上是否显示了"通过"或"失败" + let resultText = await driver.findComponent(ON.id(ComponentId.EVENT_LOG)); + let result = await resultText.getText(); + const expectedValue: string = getResourceString($r('app.string.Success')); + expect(result).assertContain(expectedValue); // 如果有 "通过" 或 "失败" 字段,说明测试成功 + + Logger.info(`${BUNDLE_NAME} Subscription_Interface_Status_001 end`); + done(); + }); + + /** + * @tc.number Unsubscription_Interface_Status_001 + * @tc.name Unsubscription_Interface_Status_001 + * @tc.desc 测试 订阅接口状态变化 按钮 + */ + it('Unsubscription_Interface_Status_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Unsubscription_Interface_Status_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.IFACE_STATUS_CHANGE_UNSUB_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.IFACE_STATUS_CHANGE_UNSUB_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + + // 验证界面上是否显示了"通过"或"失败" + let resultText = await driver.findComponent(ON.id(ComponentId.EVENT_LOG)); + let result = await resultText.getText(); + result = result.trim().normalize(); + const expectedValue: string = getResourceString($r('app.string.cancel')); + expect(result).assertContain(expectedValue); + + Logger.info(`${BUNDLE_NAME} Unsubscription_Interface_Status_001 end`); + done(); + }); + }) +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..44890b3f5cde292e15201232393d4c5cb546c8c6 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test' + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/module.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigor/hvigor-config.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigorfile.ts b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/hvigorfile.ts @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/oh-package.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..952ab183532e81c9c50e5de1e64393704e1e48fe --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.18", + "@ohos/hamock": "1.0.0" + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Configuration_Status.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Configuration_Status.jpg new file mode 100644 index 0000000000000000000000000000000000000000..821034907a1d27ded9e0cd46db9ff7eb854314ac Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Configuration_Status.jpg differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Configuration.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Configuration.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d7e7c6becfec28b4de3f44a030b1f637832c47bd Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Configuration.jpg differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Status.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Status.jpg new file mode 100644 index 0000000000000000000000000000000000000000..217ac48407072a846851ad46de85040d5e82e67f Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Interface_Status.jpg differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Network_Interface_Name.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Network_Interface_Name.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d25ac848abf9a7dcb0addc752876eb343bf06cf5 Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/Connect_Control_case/screenshots/Get_Network_Interface_Name.jpg differ