diff --git a/OAT.xml b/OAT.xml index 71bcc3b4118f73c264d08424086498be04078a3e..e215982018c0af0541042faf41c02dd834d73a10 100644 --- a/OAT.xml +++ b/OAT.xml @@ -1445,6 +1445,9 @@ Note:If the text contains special characters, please escape them according to th + + + diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/.gitignore b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/AppScope/app.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fd87f912013d994669b274ca063e8019b33e28f6 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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.netshare_case", + "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/NetShare_case/AppScope/resources/base/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..206eb26c695aadde452db6a97023698a67fb2414 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NetShare_case" + } + ] +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/AppScope/resources/base/media/app_icon.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/AppScope/resources/base/media/app_icon.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/README_zh.md b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..f9e320433661dddf9734437aa116c920cc9ca6cc --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/README_zh.md @@ -0,0 +1,82 @@ +# NetShare_case(网络共享) + +### 介绍 + +网络共享管理分享设备已有网络给其他连接设备,支持 Wi-Fi 热点共享、蓝牙共享和 USB 共享,同时提供网络共享状态、共享流量查询功能。本项目展示了一个网络共享管理的示例应用,它实现了通过按钮开启网络共享、停止网络共享以及获取默认网络的IP地址的功能,使用了[@ohos.net.sharing](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-network-kit/js-apis-net-connection.md)接口。 + +### 效果预览 + +| 程序启动 | 启动Wi-Fi共享 | 停止Wi-Fi共享 | +|-----------------------------------------| -------------------------------------------------- | ------------------------------------------------- | +| ![image](screenshots/Program_Start.jpg) | ![image](screenshots/Start_Wi-Fi_Sharing.jpg) | ![image](screenshots/Stop_Wi-Fi_Sharing.jpg) | + +使用说明 + +1. 点击“启动 Wi-Fi 共享”按钮:当点击时调用 `startWifiSharing()` 方法,启动 Wi-Fi 共享。 +2. 点击“停止 Wi-Fi 共享”按钮:当点击时调用 `stopWifiSharing()` 方法,停止 Wi-Fi 共享。 +3. 点击“获取当前共享数据”按钮:当点击时调用 `getStatsTotalBytes()` 方法,获取当前共享的数据量并更新 UI。 + +### 工程目录 + +``` +entry/src/main/ets/ +|---common +| |---Logger.ets // 日志工具 +| |---CommonConstant.ets // 字符串常量 +|---entryability +| │---EntryAbility.ets +|---entrybackupability +│ |---EntryBackupAbility.ets +|---pages +│ |---Index.ets //主页 +``` + +### 具体实现 + +1. Wi-Fi 共享状态展示 +- 在界面中显示当前 Wi-Fi 共享状态以及当前共享的数据量。 + - `sharingStatus` 用于存储当前共享的状态(如“Not Sharing”或“Sharing”),并在 UI 中进行实时更新。 +- `totalSharedBytes` 存储已共享的数据总量,单位为字节,并在 UI 中动态展示。 +2. 启动 Wi-Fi 共享 (`startWifiSharing`) + - 调用 `sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI)` 启动 Wi-Fi 共享功能。 + - 通过 `then()` 处理成功回调,更新共享状态为“Sharing”。 + - 启动共享后,立即调用 `getStatsTotalBytes()` 获取当前共享的数据量,并更新 UI。 + - 如果启动失败,使用 `catch()` 捕获错误,更新共享状态为“Not Sharing”,并通过日志输出错误信息。 +3. 停止 Wi-Fi 共享 (`stopWifiSharing`) + - 调用 `sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI)` 停止 Wi-Fi 共享功能。 + - 通过 `then()` 处理成功回调,更新共享状态为“Not Sharing”,并将已共享的数据量(`totalSharedBytes`)重置为 0。 + - 如果停止共享失败,使用 `catch()` 捕获错误,恢复共享状态为“Sharing”,并通过日志输出错误信息。 +4. 获取当前共享数据量 (`getStatsTotalBytes`) +- 调用 `sharing.getStatsTotalBytes()` 获取当前已共享的数据量。 + - 通过 `then()` 处理成功回调,将返回的数据量更新到 `totalSharedBytes`,并在 UI 中展示。 +- 如果获取数据量失败,使用 `catch()` 捕获错误,并通过日志输出错误信息。 +5. 异常处理 +- 启动共享失败:如果 `startSharing()` 调用失败,会捕获 `BusinessError` 异常并通过日志输出错误信息,UI 显示共享状态为“Not Sharing”。 + - 停止共享失败:如果 `stopSharing()` 调用失败,会捕获 `BusinessError` 异常并通过日志输出错误信息,UI 恢复共享状态为“Sharing”。 +- 获取数据量失败:如果 `getStatsTotalBytes()` 调用失败,会捕获 `BusinessError` 异常并通过日志输出错误信息。 + +### 相关权限 + +1.允许使用连接性内部权限:ohos.permission.CONNECTIVITY_INTERNAL。 + +### 依赖 + +不涉及。 + +### 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例为Stage模型,支持API14版本SDK,版本号:5.0.2.58。 +3. 本示例需要使用DevEco Studio Release(5.0.5.306)及以上版本才可编译运行。 + +### 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/build-profile.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6eb23a9a546e2abab6387dc565ef59869054268d --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/build-profile.json5 @@ -0,0 +1,51 @@ +/* + * 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" + } + ], + }, + "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/NetShare_case/entry/.gitignore b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/build-profile.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..eed6635f664fa08b992d84590bf62be7e0bb5381 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/hvigorfile.ts b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e5eb088107f8ddacfabe01e59be3359d81c700d --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/obfuscation-rules.txt b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/oh-package.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7e799ccbeebc59c1eb9b493eb137e2017f4ccde3 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/main/ets/common/CommonConstant.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/common/CommonConstant.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1859d873e8057d17a7da28bcfefdd1f9d08a21f --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/common/CommonConstant.ets @@ -0,0 +1,22 @@ +/* +* 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 { + SHARE_STATUS = 'shareStatus', + DATA_SHARE_COUNT = 'dataSharedCount', + START_WIFI_SHARING_BTN = 'startWiFiSharing', + STOP_WIFI_SHARING_BTN = 'stopWiFiSharing', + GET_CURRENT_SHARED_DATA_BTN = 'getCurrentSharedData' +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/common/Logger.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/common/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..976871bfa8f1d2444fd7a851f1019aacb4739a50 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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_NetShareCaseTest]') diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/entryability/EntryAbility.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..23935ace5aab5e4c92028e321e543ae2bfe57757 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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.error('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/NetShare_case/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d069f8feed4d34485f5793695a115b6b087867c --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/main/ets/pages/Index.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..5179927bd323cc5971d7e1906ec1fc2dda1cf5a5 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,126 @@ +/* +* 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 { sharing } from '@kit.NetworkKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import Logger from '../common/Logger'; +import { ComponentId } from '../common/CommonConstant'; + +export function resourceToString(resource: Resource): string { + return getContext().resourceManager.getStringSync(resource) +} + +@Entry +@Component +struct WifiSharingDemo { + @State sharingStatus: string = 'Not Sharing'; + @State totalSharedBytes: number = 0; + + build() { + Column() { + Text(resourceToString($r('app.string.Share_Status')) + ':' + this.sharingStatus) + .fontSize($r('app.float.size20')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.SHARE_STATUS) + + Text(resourceToString($r('app.string.Data_Share_Count')) + ':' + this.totalSharedBytes + 'bytes') + .fontSize($r('app.float.size16')) + .margin({ bottom: $r('app.float.margin20') }) + .id(ComponentId.DATA_SHARE_COUNT); + + Button($r('app.string.Start_WiFi_Sharing')) + .onClick(() => { + this.startWifiSharing(); + }) + .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.START_WIFI_SHARING_BTN); + + Button($r('app.string.Stop_WiFi_Sharing')) + .onClick(() => { + this.stopWifiSharing(); + }) + .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.STOP_WIFI_SHARING_BTN); + + Button($r('app.string.Get_Current_Shared_Data')) + .onClick(() => { + this.getStatsTotalBytes(); + }) + .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.GET_CURRENT_SHARED_DATA_BTN); + } + .width('100%') + .height('100%') + .justifyContent(FlexAlign.Center); + } + + private startWifiSharing(): void { + Logger.info('startWifiSharing enter...'); + sharing.startSharing(sharing.SharingIfaceType.SHARING_WIFI) + .then(() => { + this.sharingStatus = 'Sharing'; + Logger.info('startSharing success'); + this.getStatsTotalBytes(); + }) + .catch((error: BusinessError) => { + Logger.error(`startSharing fail: ${JSON.stringify(error)}`); + this.sharingStatus = 'Not Sharing'; + }); + } + + private stopWifiSharing(): void { + Logger.info('stopWifiSharing enter...'); + sharing.stopSharing(sharing.SharingIfaceType.SHARING_WIFI) + .then(() => { + this.sharingStatus = 'Not Sharing'; + Logger.info('stopSharing success'); + this.totalSharedBytes = 0; + }) + .catch((error: BusinessError) => { + Logger.error(`stopSharing fail: ${JSON.stringify(error)}`); + this.sharingStatus = 'Sharing'; + }); + } + + private getStatsTotalBytes(): void { + Logger.info('getStatsTotalBytes enter...'); + sharing.getStatsTotalBytes() + .then((data: number) => { + this.totalSharedBytes = data; + Logger.info(`current totalSharedBytes: ${data} bytes`); + }) + .catch((error: BusinessError) => { + Logger.error(`getStatsTotalBytes fail: ${JSON.stringify(error)}`); + }); + } +} diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/module.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e021acfc5957ef51fe00afcc37c1d9f60023bde9 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/module.json5 @@ -0,0 +1,71 @@ +/* + * 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.CONNECTIVITY_INTERNAL" + } + ] + } +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/element/color.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_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/NetShare_case/entry/src/main/resources/base/element/float.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_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/NetShare_case/entry/src/main/resources/base/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..49f56c0fa5f236f466e9ee789a97139fd67d15a5 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Start_WiFi_Sharing", + "value": "启动 Wi-Fi 共享" + }, + { + "name": "Stop_WiFi_Sharing", + "value": "停止 Wi-Fi 共享" + }, + { + "name": "Get_Current_Shared_Data", + "value": "获取当前共享数据量" + }, + { + "name": "Share_Status", + "value": "当前共享状态" + }, + { + "name": "Data_Share_Count", + "value": "共享的网络数据量" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/media/background.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/main/resources/base/media/background.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/media/foreground.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/main/resources/base/media/foreground.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/media/layered_image.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_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/NetShare_case/entry/src/main/resources/base/media/startIcon.png b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/main/resources/base/media/startIcon.png differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/base/profile/backup_config.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_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/NetShare_case/entry/src/main/resources/base/profile/main_pages.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_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/NetShare_case/entry/src/main/resources/en_US/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..827e3bfdd4426e70e12a46ea901fb123798697b4 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Start_WiFi_Sharing", + "value": "Start_Wi-Fi_Sharing" + }, + { + "name": "Stop_WiFi_Sharing", + "value": "Stop_Wi-Fi_Sharing" + }, + { + "name": "Get_Current_Shared_Data", + "value": "Get_Current_Shared_Data" + }, + { + "name": "Share_Status", + "value": "Share_Status" + }, + { + "name": "Data_Share_Count", + "value": "Data_Share_Count" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/zh_CN/element/string.json b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..05d305e7fd4f8b1794cb8a84400b6e8823a65baf --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + }, + { + "name": "Start_WiFi_Sharing", + "value": "启动 Wi-Fi 共享" + }, + { + "name": "Stop_WiFi_Sharing", + "value": "停止 Wi-Fi 共享" + }, + { + "name": "Get_Current_Shared_Data", + "value": "获取当前共享数据量" + }, + { + "name": "Share_Status", + "value": "当前共享状态" + }, + { + "name": "Data_Share_Count", + "value": "共享的网络数据量" + } + ] +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/ets/test/Ability.test.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7ac25a83559266663974d08ddd3287cea895a3f4 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,127 @@ +/* +* 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 = 'NetShare'; +const BUNDLE_NAME = 'com.samples.netshare_case'; +const ABILITY_NAME: string = 'EntryAbility'; + +let delayTime: number = 2000; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + /** + * @tc.number StartAbility_001 + * @tc.name StartAbility_001 + * @tc.desc 启动Ability + */ + it('StartAbility_001', 0, async (done: Function) => { + Logger.info('uitest: StartAbility_001 begin'); + 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(); + Logger.info("uitest: StartAbility_001 end"); + }); + + /** + * @tc.number Enable_Wi-Fi_Sharing_001 + * @tc.name Enable_Wi-Fi_Sharing_001 + * @tc.desc 测试 启动 Wi-Fi 共享 按钮 + */ + it(BUNDLE + 'Enable_Wi-Fi_Sharing_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Enable_Wi-Fi_Sharing_001 begin`); + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.START_WIFI_SHARING_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.START_WIFI_SHARING_BTN)); + await stack.click(); + await driver.delayMs(delayTime); //初始化 + await stack.click(); // 再次点击按钮 + await driver.delayMs(delayTime); + + + let resultText = await driver.findComponent(ON.id(ComponentId.SHARE_STATUS)); + let result = await resultText.getText(); + const expectedValue: string = 'Sharing'; + expect(result).assertContain(expectedValue); + Logger.info(`${BUNDLE_NAME} Enable_Wi-Fi_Sharing_001 end`); + done(); + }); + /** + * @tc.number Disable_Wi-Fi_Sharing_001 + * @tc.name Disable_Wi-Fi_Sharing_001 + * @tc.desc 测试 停止 Wi-Fi 共享 按钮 + */ + + it(BUNDLE + 'Disable_Wi-Fi_Sharing_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Disable_Wi-Fi_Sharing_001 begin`) + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.STOP_WIFI_SHARING_BTN)); + let stack = await driver.findComponent(ON.id(ComponentId.STOP_WIFI_SHARING_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + + + let resultText = await driver.findComponent(ON.id(ComponentId.SHARE_STATUS)); + let result = await resultText.getText(); + const expectedValue: string = 'Not Sharing'; + expect(result).assertContain(expectedValue); + Logger.info(`${BUNDLE_NAME} Disable_Wi-Fi_Sharing_001 end`); + done(); + }); + + /** + * @tc.number Shared_Data_Volume_001 + * @tc.name Shared_Data_Volume_001 + * @tc.desc 测试 获取当前共享数据量 按钮 + */ + + it(BUNDLE + 'Shared_Data_Volume_001', 0, async (done: Function) => { + Logger.info(`${BUNDLE_NAME} Shared_Data_Volume_001 begin`) + let driver = Driver.create(); + await driver.delayMs(delayTime); + await driver.assertComponentExist(ON.id(ComponentId.GET_CURRENT_SHARED_DATA_BTN)); + + let stack = await driver.findComponent(ON.id(ComponentId.GET_CURRENT_SHARED_DATA_BTN)); + await stack.click(); + await driver.delayMs(delayTime); + let resultText = await driver.findComponent(ON.id(ComponentId.DATA_SHARE_COUNT)); + let result = await resultText.getText(); + const expectedValue: string = 'bytes'; + expect(result).assertContain(expectedValue); + Logger.info(`${BUNDLE_NAME} Shared_Data_Volume_001 end`) + done(); + }); + }) +} \ No newline at end of file diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/ets/test/List.test.ets b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e00ce2783e3df5be75bbf984729a24f9fa582c18 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/entry/src/ohosTest/module.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/hvigor/hvigor-config.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..48c1112dfb1e74b6a5139ebbc64d1ed66b496130 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/hvigorfile.ts b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..2a5e543f190732c159beb574dfc9fa37bc94e156 --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/oh-package.json5 b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..952ab183532e81c9c50e5de1e64393704e1e48fe --- /dev/null +++ b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_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/NetShare_case/screenshots/Program_Start.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Program_Start.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2add584399fbd0192fd3a7e7d9b8ba3c2eeb0615 Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Program_Start.jpg differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Start_Wi-Fi_Sharing.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Start_Wi-Fi_Sharing.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a256748465188d5f658def236a4113a24793a75e Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Start_Wi-Fi_Sharing.jpg differ diff --git a/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Stop_Wi-Fi_Sharing.jpg b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Stop_Wi-Fi_Sharing.jpg new file mode 100644 index 0000000000000000000000000000000000000000..2add584399fbd0192fd3a7e7d9b8ba3c2eeb0615 Binary files /dev/null and b/code/DocsSample/NetWork_Kit/NetWorkKit_NetManager/NetShare_case/screenshots/Stop_Wi-Fi_Sharing.jpg differ