diff --git a/README.md b/README.md
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5 b/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5
index 151a5d2ac9a4d845b96d8d47bfd4aa7d019c859b..0a2e1b209ca5ffa5e78f7c325090f5fc2c8e832b 100644
--- a/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2023 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.abilityFeature",
- "vendor": "samples",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * Copyright (c) 2023 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.abilityFeature",
+ "vendor": "samples",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json
index 7f9e90ebc7812d334e0423f3c46fa1899f325550..3c15b21f5a08edb9efae62d0937dff7c257fb14f 100644
--- a/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/Ability/AbilityFeature/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "AbilityFeature"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AbilityFeature"
+ }
+ ]
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/README_zh.md b/code/BasicFeature/Ability/AbilityFeature/README_zh.md
index 42a50d6eebcfb331542fd3e9d26d1402c225ec63..bc3e4ff2fc6499916dd2a3efe0d3d0ff3a05428d 100644
--- a/code/BasicFeature/Ability/AbilityFeature/README_zh.md
+++ b/code/BasicFeature/Ability/AbilityFeature/README_zh.md
@@ -1,98 +1,98 @@
-# 基础能力增强
-
-### 介绍
-
-本示例使用 [ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) ,[ohos.ability.wantConstant](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-wantConstant.md) ,[ohos.app.ability.StartOptions](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-startOptions.md)等接口实现了以下功能:
-
-1. 支持应用定制系统环境参数;
-
-5. 支持隐式启动个数为0时才触发提示弹框--增加了一个flag;
-
-6. 支持应用清理自己的数据;
-
-7. Ability启动参数支持传递初始位置/初始大小/是否携带动效;
-
-### 效果预览
-
-| 主页面 | 隐式启动弹窗 | 英文切换页 | 深色模式切换页 |
-| :----------------------------------------------------------: | :----------------------------------------------------------: | :--------------------------------------------------: | :--------------------------------------------------: |
-|
|
|  |  |
-
-使用说明
-
-1.应用切换语言的能力;
-
-点击'切换英文语言'的ListItem,当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced'
-,点击'切换中文语言'的ListItem,当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强';
-
-2.应用切换颜色模式的能力
-
-点击'切换深色模式'的ListItem,当前页面颜色切换为深色,弹出Toast提示'切换成功',点击'切换浅色模式'
-的ListItem,当前页面颜色切换为浅色,弹出Toast提示'切换成功';
-
-3.应用隐式启动个数为0时,才触发提示弹框的特性
-
-点击'隐式启动弹窗'的ListItem,弹出弹窗,弹窗标题为'未找到文件',点击'隐式启动不弹窗'
-的ListItem,弹出Toast提示'隐式启动不弹窗',且无弹窗(仅支持rk);
-
-4.应用清理自己的数据的能力
-
-点击'创建数据'的ListItem,弹出Toast提示创建'缓存文件成功',点击'检查数据'的ListItem,弹出Toast提示创建'查询到缓存文件'
-,点击'清除数据'的ListItem,应用清理缓存文件后自动退出。手动重新启动应用后,点击'检查数据'的ListItem,弹出Toast提示创建'未找到缓存文件';
-
-5.应用可以设置启动参数启动Ability能力
-
-点击'StartOptions配置'的ListItem,应用启动NewAbility。返回主界面后,点击'启动动画'的Toggle,再点击'
-StartOptions配置'的ListItem,应用启动NewAbility;
-
-### 工程目录
-
-```
-entry/src/main/ets/
-|---characteroperation
-| |---CharacterOperation.ets // 调用applicationContext方法的工具类
-|---entryability
-| |---EntryAbility.ets // 首页的Ability
-|---pages
-| |---Index.ets // 首页
-| |---New.ets // 被启动UIAbility的展示页
-|---newability
-| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用)
-|---utils // 工具
-| |---Logger.ets // 日志工具
-```
-
-### 具体实现
-
-- 应用切换语言的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setLanguage(language: string): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
-- 应用切换颜色模式的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setColorMode(colorMode: ConfigurationConstant.ColorMode): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
-- 应用清理自己的数据的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用clearUpApplicationData(callback: AsyncCallback): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
-- 应用隐式启动个数为0时不触发提示弹框的特性,通过给Want的flags设置为FLAG_START_WITHOUT_TIPS,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets)
-- 应用可以设置启动参数启动Ability能力,通过给startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void;方法传递新增参数StartOptions来设置启动位置,大小以及是否包含动画,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets)
-
-### 相关权限
-
-无
-
-### 依赖
-
-无
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568;
-
-2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1;
-
-3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行;
-
-### 下载
-
-```shell
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Ability/AbilityFeature/ > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
-
+# 基础能力增强
+
+### 介绍
+
+本示例使用 [ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) ,[ohos.ability.wantConstant](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-wantConstant.md) ,[ohos.app.ability.StartOptions](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-startOptions.md)等接口实现了以下功能:
+
+1. 支持应用定制系统环境参数;
+
+5. 支持隐式启动个数为0时才触发提示弹框--增加了一个flag;
+
+6. 支持应用清理自己的数据;
+
+7. Ability启动参数支持传递初始位置/初始大小/是否携带动效;
+
+### 效果预览
+
+| 主页面 | 隐式启动弹窗 | 英文切换页 | 深色模式切换页 |
+| :----------------------------------------------------------: | :----------------------------------------------------------: | :--------------------------------------------------: | :--------------------------------------------------: |
+|
|
|  |  |
+
+使用说明
+
+1.应用切换语言的能力;
+
+点击'切换英文语言'的ListItem,当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced'
+,点击'切换中文语言'的ListItem,当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强';
+
+2.应用切换颜色模式的能力
+
+点击'切换深色模式'的ListItem,当前页面颜色切换为深色,弹出Toast提示'切换成功',点击'切换浅色模式'
+的ListItem,当前页面颜色切换为浅色,弹出Toast提示'切换成功';
+
+3.应用隐式启动个数为0时,才触发提示弹框的特性
+
+点击'隐式启动弹窗'的ListItem,弹出弹窗,弹窗标题为'未找到文件',点击'隐式启动不弹窗'
+的ListItem,弹出Toast提示'隐式启动不弹窗',且无弹窗(仅支持rk);
+
+4.应用清理自己的数据的能力
+
+点击'创建数据'的ListItem,弹出Toast提示创建'缓存文件成功',点击'检查数据'的ListItem,弹出Toast提示创建'查询到缓存文件'
+,点击'清除数据'的ListItem,应用清理缓存文件后自动退出。手动重新启动应用后,点击'检查数据'的ListItem,弹出Toast提示创建'未找到缓存文件';
+
+5.应用可以设置启动参数启动Ability能力
+
+点击'StartOptions配置'的ListItem,应用启动NewAbility。返回主界面后,点击'启动动画'的Toggle,再点击'
+StartOptions配置'的ListItem,应用启动NewAbility;
+
+### 工程目录
+
+```
+entry/src/main/ets/
+|---characteroperation
+| |---CharacterOperation.ets // 调用applicationContext方法的工具类
+|---entryability
+| |---EntryAbility.ets // 首页的Ability
+|---pages
+| |---Index.ets // 首页
+| |---New.ets // 被启动UIAbility的展示页
+|---newability
+| |---NewAbility.ets // 被启动的UIAbility(验证新接口启动使用)
+|---utils // 工具
+| |---Logger.ets // 日志工具
+```
+
+### 具体实现
+
+- 应用切换语言的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setLanguage(language: string): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
+- 应用切换颜色模式的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用setColorMode(colorMode: ConfigurationConstant.ColorMode): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
+- 应用清理自己的数据的功能接口封装在CharacterOperation,使用[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md) 调用clearUpApplicationData(callback: AsyncCallback): void方法实现,源码参考:[CharacterOperation.ets](entry/src/main/ets/characteroperation/CharacterOperation.ets)
+- 应用隐式启动个数为0时不触发提示弹框的特性,通过给Want的flags设置为FLAG_START_WITHOUT_TIPS,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets)
+- 应用可以设置启动参数启动Ability能力,通过给startAbility(want: Want, options: StartOptions, callback: AsyncCallback): void;方法传递新增参数StartOptions来设置启动位置,大小以及是否包含动画,源码参考:[Index.ets](entry/src/main/ets/pages/Index.ets)
+
+### 相关权限
+
+无
+
+### 依赖
+
+无
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568;
+
+2.本示例为Stage模型,支持API11版本SDK,版本号:4.1.5.1;
+
+3.本示例需要使用DevEco Studio 3.1.1 Release (Build Version: 3.1.0.501, built on June 20, 2023)才可编译运行;
+
+### 下载
+
+```shell
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Ability/AbilityFeature/ > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
+
diff --git a/code/BasicFeature/Ability/AbilityFeature/build-profile.json5 b/code/BasicFeature/Ability/AbilityFeature/build-profile.json5
index 6e4824ee32c74ed2c8150843557de85a879e7c39..51d43b29fefc5fa4622edbb868c588525238f272 100644
--- a/code/BasicFeature/Ability/AbilityFeature/build-profile.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/build-profile.json5
@@ -1,44 +1,44 @@
-/*
- * Copyright (c) 2023 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": {
- "signingConfigs": [
- ],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compileSdkVersion": 11,
- "compatibleSdkVersion": 11,
- "runtimeOS": "OpenHarmony"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ "signingConfigs": [
+ ],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compileSdkVersion": 11,
+ "compatibleSdkVersion": 11,
+ "runtimeOS": "OpenHarmony"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5
index 0c8525dfdde040a6d029cd2dc7bbddc5a5ee5353..910cc991f5e6483bbaebf92e26274ddd43db6f82 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/build-profile.json5
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2023 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": {
- },
- "targets": [
- {
- "name": "default",
- "runtimeOS": "OpenHarmony"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ },
+ "targets": [
+ {
+ "name": "default",
+ "runtimeOS": "OpenHarmony"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5
index 60744fdbc79d1e21f9e40bd00955aa195ba84e22..225946cb11a2c405c8dc81eea89c22f923556638 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/oh-package.json5
@@ -1,10 +1,10 @@
-{
- "license": "",
- "devDependencies": {},
- "author": "",
- "name": "entry",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+{
+ "license": "",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets
index 9a5778e9e502d9e5483102b942edd79cdc0aa4f4..290786979084f19a17ecf37ff3116a6a2a492eef 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/characteroperation/CharacterOperation.ets
@@ -1,146 +1,146 @@
-/*
- * Copyright (c) 2023 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 ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
-import fs from '@ohos.file.fs';
-import prompt from '@ohos.promptAction';
-import { logger } from '../util/Logger';
-
-const TAG: string = 'EntryAbility';
-const TIME: number = 3000;
-
-export default class CharacterOperation {
- private context: Context;
-
- constructor(context: Context) {
- this.context = context;
- }
- // 设置中文
- setZHCNLanguage = () => {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.setLanguage('zh-cn');
- logger.info(`${TAG} Chinese success`);
- }
- // 设置英文
- setENUSLanguage = () => {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.setLanguage('en-us');
- logger.info(`${TAG} English success`);
- }
- // 设置深色模式
- setDarKColorMode = () => {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_DARK);
- prompt.showToast({
- message: $r('app.string.switchDarkSuccess'), duration: TIME
- });
- }
- // 设置浅色模式
- setLightColorMode = () => {
- let applicationContext = this.context.getApplicationContext();
- applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT);
- prompt.showToast({
- message: $r('app.string.switchLightSuccess'), duration: TIME
- });
- }
- // 获取缓存路径
- generateStorageFiles = () => {
- let context = this.context;
- let filePathName = '/test.txt';
- let cacheDirPath = context.cacheDir + filePathName;
- let filesDirPath = context.filesDir + filePathName;
- let preferencesDirPath = context.preferencesDir + filePathName;
- let tempDirPath = context.tempDir + filePathName;
- let databaseDirPath = context.databaseDir + filePathName;
-
- return [cacheDirPath, filesDirPath, preferencesDirPath, tempDirPath, databaseDirPath];
- }
- // 创建存储数据
- createStorageData = () => {
- let context = this.context;
- let filePathName = '/test.txt';
- let cacheDirPath = context.cacheDir + filePathName;
- let filesDirPath = context.filesDir + filePathName;
- let preferencesDirPath = context.preferencesDir + filePathName;
- let tempDirPath = context.tempDir + filePathName;
- let databaseDirPath = context.databaseDir + filePathName;
- try {
- let file1 = fs.openSync(cacheDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
- let file2 = fs.openSync(filesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
- let file3 = fs.openSync(preferencesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
- let file4 = fs.openSync(tempDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
- let file5 = fs.openSync(databaseDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
-
- fs.closeSync(file1);
- fs.closeSync(file2);
- fs.closeSync(file3);
- fs.closeSync(file4);
- fs.closeSync(file5);
-
- if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath)
- && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath)
- && fs.accessSync(databaseDirPath)) {
- prompt.showToast({
- message: $r('app.string.create_File_Success'), duration: TIME
- });
- }
- } catch (error) {
- }
- }
- // 检查文件
- checkStorageData = () => {
- let context = this.context;
- let filePathName = '/test.txt';
- let cacheDirPath = context.cacheDir + filePathName;
- let filesDirPath = context.filesDir + filePathName;
- let preferencesDirPath = context.preferencesDir + filePathName;
- let tempDirPath = context.tempDir + filePathName;
- let databaseDirPath = context.databaseDir + filePathName;
- if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath)
- && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) {
- prompt.showToast({
- message: $r('app.string.search_File_Success'), duration: TIME
- });
- } else {
- prompt.showToast({
- message: $r('app.string.search_File_Failed'), duration: TIME
- });
- }
- }
- // 清理存储数据
- clearStorageData = () => {
- let context = this.context;
- let filePathName = '/test.txt';
- let cacheDirPath = context.cacheDir + filePathName;
- let filesDirPath = context.filesDir + filePathName;
- let preferencesDirPath = context.preferencesDir + filePathName;
- let tempDirPath = context.tempDir + filePathName;
- let databaseDirPath = context.databaseDir + filePathName;
- if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) && fs.accessSync(preferencesDirPath)
- && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) {
- context.getApplicationContext().clearUpApplicationData((err) => {
- logger.info(`clearUpApplicationData err:${JSON.stringify(err)}}`);
- prompt.showToast({
- message: $r('app.string.clean_Data_Success'), duration: TIME
- });
- });
- } else {
- // 清理存储数据失败
- prompt.showToast({
- message: $r('app.string.clean_Data_Failed'), duration: TIME
- });
- }
- }
-}
+/*
+ * Copyright (c) 2023 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 ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant';
+import fs from '@ohos.file.fs';
+import prompt from '@ohos.promptAction';
+import { logger } from '../util/Logger';
+
+const TAG: string = 'EntryAbility';
+const TIME: number = 3000;
+
+export default class CharacterOperation {
+ private context: Context;
+
+ constructor(context: Context) {
+ this.context = context;
+ }
+ // 设置中文
+ setZHCNLanguage = () => {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.setLanguage('zh-cn');
+ logger.info(`${TAG} Chinese success`);
+ }
+ // 设置英文
+ setENUSLanguage = () => {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.setLanguage('en-us');
+ logger.info(`${TAG} English success`);
+ }
+ // 设置深色模式
+ setDarKColorMode = () => {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_DARK);
+ prompt.showToast({
+ message: $r('app.string.switchDarkSuccess'), duration: TIME
+ });
+ }
+ // 设置浅色模式
+ setLightColorMode = () => {
+ let applicationContext = this.context.getApplicationContext();
+ applicationContext.setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT);
+ prompt.showToast({
+ message: $r('app.string.switchLightSuccess'), duration: TIME
+ });
+ }
+ // 获取缓存路径
+ generateStorageFiles = () => {
+ let context = this.context;
+ let filePathName = '/test.txt';
+ let cacheDirPath = context.cacheDir + filePathName;
+ let filesDirPath = context.filesDir + filePathName;
+ let preferencesDirPath = context.preferencesDir + filePathName;
+ let tempDirPath = context.tempDir + filePathName;
+ let databaseDirPath = context.databaseDir + filePathName;
+
+ return [cacheDirPath, filesDirPath, preferencesDirPath, tempDirPath, databaseDirPath];
+ }
+ // 创建存储数据
+ createStorageData = () => {
+ let context = this.context;
+ let filePathName = '/test.txt';
+ let cacheDirPath = context.cacheDir + filePathName;
+ let filesDirPath = context.filesDir + filePathName;
+ let preferencesDirPath = context.preferencesDir + filePathName;
+ let tempDirPath = context.tempDir + filePathName;
+ let databaseDirPath = context.databaseDir + filePathName;
+ try {
+ let file1 = fs.openSync(cacheDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+ let file2 = fs.openSync(filesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+ let file3 = fs.openSync(preferencesDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+ let file4 = fs.openSync(tempDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+ let file5 = fs.openSync(databaseDirPath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE);
+
+ fs.closeSync(file1);
+ fs.closeSync(file2);
+ fs.closeSync(file3);
+ fs.closeSync(file4);
+ fs.closeSync(file5);
+
+ if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath)
+ && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath)
+ && fs.accessSync(databaseDirPath)) {
+ prompt.showToast({
+ message: $r('app.string.create_File_Success'), duration: TIME
+ });
+ }
+ } catch (error) {
+ }
+ }
+ // 检查文件
+ checkStorageData = () => {
+ let context = this.context;
+ let filePathName = '/test.txt';
+ let cacheDirPath = context.cacheDir + filePathName;
+ let filesDirPath = context.filesDir + filePathName;
+ let preferencesDirPath = context.preferencesDir + filePathName;
+ let tempDirPath = context.tempDir + filePathName;
+ let databaseDirPath = context.databaseDir + filePathName;
+ if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath)
+ && fs.accessSync(preferencesDirPath) && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) {
+ prompt.showToast({
+ message: $r('app.string.search_File_Success'), duration: TIME
+ });
+ } else {
+ prompt.showToast({
+ message: $r('app.string.search_File_Failed'), duration: TIME
+ });
+ }
+ }
+ // 清理存储数据
+ clearStorageData = () => {
+ let context = this.context;
+ let filePathName = '/test.txt';
+ let cacheDirPath = context.cacheDir + filePathName;
+ let filesDirPath = context.filesDir + filePathName;
+ let preferencesDirPath = context.preferencesDir + filePathName;
+ let tempDirPath = context.tempDir + filePathName;
+ let databaseDirPath = context.databaseDir + filePathName;
+ if (fs.accessSync(cacheDirPath) && fs.accessSync(filesDirPath) && fs.accessSync(preferencesDirPath)
+ && fs.accessSync(tempDirPath) && fs.accessSync(databaseDirPath)) {
+ context.getApplicationContext().clearUpApplicationData((err) => {
+ logger.info(`clearUpApplicationData err:${JSON.stringify(err)}}`);
+ prompt.showToast({
+ message: $r('app.string.clean_Data_Success'), duration: TIME
+ });
+ });
+ } else {
+ // 清理存储数据失败
+ prompt.showToast({
+ message: $r('app.string.clean_Data_Failed'), duration: TIME
+ });
+ }
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets
index f640336e76d40da47dc2cfe81cb8bf326a3e8efc..d759f4f0a6333fc2ba066566399d9decaf3cef4e 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,61 +1,61 @@
-/*
- * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import window from '@ohos.window';
-import Want from '@ohos.app.ability.Want';
-import { BusinessError } from '@ohos.base';
-import { logger } from '../util/Logger';
-
-export default class EntryAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- windowStage.loadContent('pages/Index', (err: BusinessError) => {
- });
- windowStage.getMainWindow((err, windowClass) => {
- if (err.code) {
- return;
- }
- windowClass.setWindowLayoutFullScreen(true);
- })
- logger.info(`EntryAbility onWindowStageCreate`);
- }
-
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
- AppStorage.setOrCreate('want', want);
- AppStorage.setOrCreate('launchParam', launchParam);
- logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`);
- }
-
- onDestroy() {
- logger.info(`EntryAbility onDestroy`);
- }
-
- onWindowStageDestroy() {
- logger.info(`EntryAbility onWindowStageDestroy`);
- // Main window is destroyed, release UI related resources
- }
-
- onForeground() {
- logger.info(`EntryAbility onForeground`);
- // Ability has brought to foreground
- }
-
- onBackground() {
- logger.info(`EntryAbility onBackground`);
- // Ability has back to background
- }
-}
+/*
+ * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import window from '@ohos.window';
+import Want from '@ohos.app.ability.Want';
+import { BusinessError } from '@ohos.base';
+import { logger } from '../util/Logger';
+
+export default class EntryAbility extends UIAbility {
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ windowStage.loadContent('pages/Index', (err: BusinessError) => {
+ });
+ windowStage.getMainWindow((err, windowClass) => {
+ if (err.code) {
+ return;
+ }
+ windowClass.setWindowLayoutFullScreen(true);
+ })
+ logger.info(`EntryAbility onWindowStageCreate`);
+ }
+
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ AppStorage.setOrCreate('want', want);
+ AppStorage.setOrCreate('launchParam', launchParam);
+ logger.info(`EntryAbility onCreate ${want.bundleName},${launchParam.launchReason}`);
+ }
+
+ onDestroy() {
+ logger.info(`EntryAbility onDestroy`);
+ }
+
+ onWindowStageDestroy() {
+ logger.info(`EntryAbility onWindowStageDestroy`);
+ // Main window is destroyed, release UI related resources
+ }
+
+ onForeground() {
+ logger.info(`EntryAbility onForeground`);
+ // Ability has brought to foreground
+ }
+
+ onBackground() {
+ logger.info(`EntryAbility onBackground`);
+ // Ability has back to background
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets
index b9acfd827cba61cc2599d55a6276c0a9c86f2146..f74c81a86dd1897ce35bdcdbb86ecfdabed384ef 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/newability/NewAbility.ets
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import window from '@ohos.window';
-import Want from '@ohos.app.ability.Want';
-import { logger } from '../util/Logger';
-
-export default class NewAbility extends UIAbility {
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- windowStage.loadContent('pages/New', () => {
- });
- windowStage.getMainWindow((err, windowClass) => {
- if (err.code) {
- return;
- }
- windowClass.setWindowLayoutFullScreen(true);
- })
- }
-
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
- AppStorage.setOrCreate('want', want);
- AppStorage.setOrCreate('launchParam', launchParam);
- logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`);
- }
-
- onDestroy() {
- logger.info(`NewAbility onDestroy`);
- }
-
- onWindowStageDestroy() {
- logger.info(`NewAbility onWindowStageDestroy`);
- // Main window is destroyed, release UI related resources
- }
-
- onForeground() {
- logger.info(`NewAbility onForeground`);
- // Ability has brought to foreground
- }
-
- onBackground() {
- logger.info(`NewAbility onBackground`);
- // Ability has back to background
- }
-}
+/*
+ * Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import window from '@ohos.window';
+import Want from '@ohos.app.ability.Want';
+import { logger } from '../util/Logger';
+
+export default class NewAbility extends UIAbility {
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ windowStage.loadContent('pages/New', () => {
+ });
+ windowStage.getMainWindow((err, windowClass) => {
+ if (err.code) {
+ return;
+ }
+ windowClass.setWindowLayoutFullScreen(true);
+ })
+ }
+
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ AppStorage.setOrCreate('want', want);
+ AppStorage.setOrCreate('launchParam', launchParam);
+ logger.info(`NewAbility onCreate ${want.bundleName},${launchParam.launchReason}`);
+ }
+
+ onDestroy() {
+ logger.info(`NewAbility onDestroy`);
+ }
+
+ onWindowStageDestroy() {
+ logger.info(`NewAbility onWindowStageDestroy`);
+ // Main window is destroyed, release UI related resources
+ }
+
+ onForeground() {
+ logger.info(`NewAbility onForeground`);
+ // Ability has brought to foreground
+ }
+
+ onBackground() {
+ logger.info(`NewAbility onBackground`);
+ // Ability has back to background
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets
index 93bec9d38dd07ad771841d2cc56da4073508c586..e7eb83d5d253e08d483651767fb70d986183b1af 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/pages/New.ets
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
-import { logger } from '../util/Logger';
-
-const TAG: string = 'NewAbility';
-
-@Entry
-@Component
-struct New {
- private context = getContext(this) as common.UIAbilityContext;
-
- build() {
- Column() {
- Row() {
- Image($r('app.media.ic_back'))
- .size({ width: 20, height: 18 })
- .margin({ right: 18 })
- .onClick(() => {
- this.context.terminateSelf((err, data) => {
- logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`);
- })
- })
- Text($r('app.string.NewAbility_label'))
- .fontSize(20)
- .fontWeight(FontWeight.Bold)
- }.height(56)
- .padding({ left: 26, right: 26 })
- .width('100%')
-
- Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) {
- Column() {
- Image($r('app.media.pic_empty')).width('33%')
- Text($r('app.string.empty'))
- .fontSize(14)
- }
- }.width('100%')
- .height('90%')
- }
- .width('100%')
- .height('100%')
- .padding({ top: 36, bottom: 0 })
- .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
- }
+/*
+ * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
+import { logger } from '../util/Logger';
+
+const TAG: string = 'NewAbility';
+
+@Entry
+@Component
+struct New {
+ private context = getContext(this) as common.UIAbilityContext;
+
+ build() {
+ Column() {
+ Row() {
+ Image($r('app.media.ic_back'))
+ .size({ width: 20, height: 18 })
+ .margin({ right: 18 })
+ .onClick(() => {
+ this.context.terminateSelf((err, data) => {
+ logger.info(`${TAG} terminateSelf err:${JSON.stringify(err)},data:${JSON.stringify(data)}`);
+ })
+ })
+ Text($r('app.string.NewAbility_label'))
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }.height(56)
+ .padding({ left: 26, right: 26 })
+ .width('100%')
+
+ Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) {
+ Column() {
+ Image($r('app.media.pic_empty')).width('33%')
+ Text($r('app.string.empty'))
+ .fontSize(14)
+ }
+ }.width('100%')
+ .height('90%')
+ }
+ .width('100%')
+ .height('100%')
+ .padding({ top: 36, bottom: 0 })
+ .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets
index dbbf08e5292486204cef219969154b1b20c21178..69eaf0c33edd29ce360ff25dcb87a4cbf66c3119 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/ets/util/Logger.ets
@@ -1,49 +1,49 @@
-/*
- * Copyright (c) 2023 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 '@ohos.hilog'
-
-class Logger {
- private domain: number;
- private prefix: string;
- private format: string = '%{public}s, %{public}s';
-
- constructor(prefix: string) {
- this.prefix = prefix;
- this.domain = 0xFF00;
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR);
- }
-
- 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);
- }
-}
-
+/*
+ * Copyright (c) 2023 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 '@ohos.hilog'
+
+class Logger {
+ private domain: number;
+ private prefix: string;
+ private format: string = '%{public}s, %{public}s';
+
+ constructor(prefix: string) {
+ this.prefix = prefix;
+ this.domain = 0xFF00;
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR);
+ }
+
+ 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);
+ }
+}
+
export let logger = new Logger('[Basic capabilities are enhanced]');
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5
index 420b8c1ce3f861db27530fd7fb3c9fcf9b05496c..1658c2f6e809945ae4f0b6866dc53d8e3f5961a1 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/module.json5
@@ -1,62 +1,62 @@
-/*
- * Copyright (c) 2023 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"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:main_pages",
- "abilities": [
- {
- "name": "EntryAbility",
- "srcEntry": "./ets/entryability/EntryAbility.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- },
- {
- "name": "NewAbility",
- "srcEntry": "./ets/newability/NewAbility.ets",
- "description": "$string:NewAbility_desc",
- "icon": "$media:icon",
- "label": "$string:NewAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background"
- },
- ],
- "extensionAbilities": [
- ]
- }
+/*
+ * Copyright (c) 2023 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"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "NewAbility",
+ "srcEntry": "./ets/newability/NewAbility.ets",
+ "description": "$string:NewAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:NewAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background"
+ },
+ ],
+ "extensionAbilities": [
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json
index a55608bdfd4b80e04025510c67c65dd138310caf..01dee5176177a542d94efac26fae560c5c19a30a 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/color.json
@@ -1,24 +1,24 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "background",
- "value": "#FAFAFA"
- },
- {
- "name": "line_color",
- "value": "#182431"
- },
- {
- "name": "text_color",
- "value": "#182431"
- },
- {
- "name": "button_color",
- "value": "#182431"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "background",
+ "value": "#FAFAFA"
+ },
+ {
+ "name": "line_color",
+ "value": "#182431"
+ },
+ {
+ "name": "text_color",
+ "value": "#182431"
+ },
+ {
+ "name": "button_color",
+ "value": "#182431"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json
index 51aeb0059ce9ff1532c80bc800f52ad416ef23eb..c8d10991d67b86589cd2d8fc78970850f27999ab 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/main/resources/base/element/float.json
@@ -1,8 +1,8 @@
-{
- "float": [
- {
- "name": "font_size",
- "value": "16fp"
- }
- ]
+{
+ "float": [
+ {
+ "name": "font_size",
+ "value": "16fp"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts
index dbbf08e5292486204cef219969154b1b20c21178..69eaf0c33edd29ce360ff25dcb87a4cbf66c3119 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/ets/util/Logger.ts
@@ -1,49 +1,49 @@
-/*
- * Copyright (c) 2023 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 '@ohos.hilog'
-
-class Logger {
- private domain: number;
- private prefix: string;
- private format: string = '%{public}s, %{public}s';
-
- constructor(prefix: string) {
- this.prefix = prefix;
- this.domain = 0xFF00;
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN);
- hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR);
- }
-
- 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);
- }
-}
-
+/*
+ * Copyright (c) 2023 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 '@ohos.hilog'
+
+class Logger {
+ private domain: number;
+ private prefix: string;
+ private format: string = '%{public}s, %{public}s';
+
+ constructor(prefix: string) {
+ this.prefix = prefix;
+ this.domain = 0xFF00;
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.INFO);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.DEBUG);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.WARN);
+ hilog.isLoggable(this.domain, prefix, hilog.LogLevel.ERROR);
+ }
+
+ 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);
+ }
+}
+
export let logger = new Logger('[Basic capabilities are enhanced]');
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5
index 0511adbc861eba4c62107d508b88a550567331aa..c6ad62fbbd46259bb51381022bcdce57349e123c 100644
--- a/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/entry/src/ohosTest/module.json5
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2023 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "default"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntry": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "exported": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
-}
+/*
+ * Copyright (c) 2023 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5
index b84b124bfadf1c52f5df987d3193ec1a3768aaaf..69b4a2dad77150c87f3186d5d296756443ca6b3f 100644
--- a/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/hvigor/hvigor-config.json5
@@ -1,6 +1,6 @@
-{
- "hvigorVersion": "4.1.2",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "4.1.2"
- }
+{
+ "hvigorVersion": "4.1.2",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "4.1.2"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityFeature/oh-package.json5 b/code/BasicFeature/Ability/AbilityFeature/oh-package.json5
index 1919d17c03c8556675bf79bccdedcc07e6536db7..6daa33b9126c1fd7df3cbb16a02467793281ac34 100644
--- a/code/BasicFeature/Ability/AbilityFeature/oh-package.json5
+++ b/code/BasicFeature/Ability/AbilityFeature/oh-package.json5
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "author": "",
- "name": "abilityFeature",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "author": "",
+ "name": "abilityFeature",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/Ability/AbilityFeature/ohosTest.md b/code/BasicFeature/Ability/AbilityFeature/ohosTest.md
index de91defcc09e02e0964f5c6990a22cb8a3b57e07..dd6adf53fb18889283ccd3914693c37a4cdf6d94 100644
--- a/code/BasicFeature/Ability/AbilityFeature/ohosTest.md
+++ b/code/BasicFeature/Ability/AbilityFeature/ohosTest.md
@@ -1,15 +1,15 @@
-# 基础能力增强测试用例
-
-## 用例表
-
-| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
-| ----------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- |
-| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换英文语言'的ListItem | 当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' | Yes | Pass |
-| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换中文语言'的ListItem | 当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强' | Yes | Pass |
-| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换深色模式'的ListItem | 当前页面颜色切换为深色,弹出Toast提示'切换成功' | Yes | Pass |
-| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换浅色模式'的ListItem | 当前页面颜色切换为浅色,弹出Toast提示'切换成功' | Yes | Pass |
-| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动弹窗'的ListItem | 弹出Toast提示'隐式启动弹窗',并且弹出弹窗,弹窗标题为'未找到文件' | Yes | Pass |
-| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动不弹窗'的ListItem | 弹出Toast提示'隐式启动不弹窗',且无弹窗 | Yes | Pass |
-| 应用可以设置启动参数启动Ability能力 | 设备正常运行 | 1.应用启动成功,点击''启动动画'的“开启”的按钮
2.点击''StartOptions配置'的ListItem | 1.按钮变为“关闭”
2.应用启动NewAbility | Yes | Pass |
-| 应用清理自己的数据的能力 | 设备正常运行 | 1.应用启动成功,点击'创建数据'的ListItem
2.点击'检查数据'的ListItem
3.点击'清除数据'的ListItem
4.点击应用图标
5.点击'检查数据'的ListItem | 1.弹出Toast提示'创建缓存文件成功'
2.弹出Toast提示'查询到缓存文件',
3.应用退出
4.重新启动应用
5.弹出Toast提示'未找到缓存文件' | No | Pass |
-
+# 基础能力增强测试用例
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+| ----------------------------------------- | ------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | -------- |
+| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换英文语言'的ListItem | 当前页面切换为英文,标题'基础能力增强'切换成'Basic capabilities are enhanced' | Yes | Pass |
+| 应用切换语言的能力 | 设备正常运行 | 应用启动成功,点击'切换中文语言'的ListItem | 当前页面切换为中文,标题'Basic capabilities are enhanced'切换成'基础能力增强' | Yes | Pass |
+| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换深色模式'的ListItem | 当前页面颜色切换为深色,弹出Toast提示'切换成功' | Yes | Pass |
+| 应用切换颜色模式的能力 | 设备正常运行 | 应用启动成功,点击'切换浅色模式'的ListItem | 当前页面颜色切换为浅色,弹出Toast提示'切换成功' | Yes | Pass |
+| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动弹窗'的ListItem | 弹出Toast提示'隐式启动弹窗',并且弹出弹窗,弹窗标题为'未找到文件' | Yes | Pass |
+| 应用隐式启动个数为0时不触发提示弹框的特性 | 设备正常运行 | 应用启动成功,点击'隐式启动不弹窗'的ListItem | 弹出Toast提示'隐式启动不弹窗',且无弹窗 | Yes | Pass |
+| 应用可以设置启动参数启动Ability能力 | 设备正常运行 | 1.应用启动成功,点击''启动动画'的“开启”的按钮
2.点击''StartOptions配置'的ListItem | 1.按钮变为“关闭”
2.应用启动NewAbility | Yes | Pass |
+| 应用清理自己的数据的能力 | 设备正常运行 | 1.应用启动成功,点击'创建数据'的ListItem
2.点击'检查数据'的ListItem
3.点击'清除数据'的ListItem
4.点击应用图标
5.点击'检查数据'的ListItem | 1.弹出Toast提示'创建缓存文件成功'
2.弹出Toast提示'查询到缓存文件',
3.应用退出
4.重新启动应用
5.弹出Toast提示'未找到缓存文件' | No | Pass |
+
diff --git a/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5 b/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5
index 38b4d0880e972eefc5d73315f4dc61ed343fe650..c15af56bb0a4212ab1f58ab8ac746d1c43e9d22f 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/AppScope/app.json5
@@ -1,28 +1,28 @@
-/*
- * Copyright (c) 2024 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.abilityruntime",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name",
- "multiAppMode": {
- "multiAppModeType": "appClone",
- "maxCount": 5
- }
- }
-}
+/*
+ * Copyright (c) 2024 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.abilityruntime",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name",
+ "multiAppMode": {
+ "multiAppModeType": "appClone",
+ "maxCount": 5
+ }
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json
index 7de244d006478b63a9a60309dda74d6c4c4d1ca7..07d445beadfec06f249f471ba539e66301f9a32c 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/Ability/AbilityRuntime/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "AbilityRuntime"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AbilityRuntime"
+ }
+ ]
+}
diff --git a/code/BasicFeature/Ability/AbilityRuntime/README_zh.md b/code/BasicFeature/Ability/AbilityRuntime/README_zh.md
index 81b3f5aae92b2c50991460d49ff267039cd6ccac..486d032d946f500ee5e29a2cd997d616b2825ac0 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/README_zh.md
+++ b/code/BasicFeature/Ability/AbilityRuntime/README_zh.md
@@ -1,204 +1,204 @@
-# 基础能力增强
-
-### 介绍
-
-本示例使用 [AppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager.md) ,[dataUriUtils](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-dataUriUtils.md),[WantAgent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-wantAgent.md),[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md),[errorManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-errorManager.md),[UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)中的接口进行实现。
-
-### 效果预览
-
-| 主页面 | appManager开发示例 | errorManager开发示例 | UIAbilityContext开发示例 |
-| :----------------------------------------------: | :---------------------------------------------------: | :-----------------------------------------------------: | :---------------------------------------------------------: |
-|
|
|
|
|
-
-### 使用说明
-
-AppManager对应接口
-
-1.点击主页面**appManager开发示例**按钮,跳转到'appManager开发示例'界面;
-
-2.点击**isRunningInStabilityTest callback**按钮,弹出'isRunningInStabilityTest(callback) success...'信息;
-
-3.点击**isRunningInStabilityTest promise**按钮,弹出提示'isRunningInStabilityTest(promise) success...'信息;
-
-4.点击**isRamConstrainedDevice callback**按钮,弹出提示'isRamConstrainedDevice(callback) success...'信息;
-
-5.点击**isRamConstrainedDevice promise**按钮,弹出提示'isRamConstrainedDevice(promise) success...'信息;
-
-6.点击**getAppMemorySize callback**按钮,弹出提示'getAppMemorySize(callback) success...'信息;
-
-7.点击**getAppMemorySize promise**按钮,弹出提示'getAppMemorySize(promise) success...'信息;
-
-8.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation(callback) success...'信息;
-
-9.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation(promise) success...'信息;
-
-
-
-dataUriUtils对应接口
-
-1.点击主页面**dataUriUtils开发示例**按钮,跳转到'dataUriUtils开发示例'界面;
-
-2.点击**getId**按钮,弹出提示'dataUriUtils.getId() called...'信息;
-
-3.点击**attachId**按钮,弹出提示'dataUriUtils.attachd() called...'信息;
-
-4.点击**deleteId**按钮,弹出提示'dataUriUtils.deleteId() called...'信息;
-
-5.点击**updateId**按钮,弹出提示'dataUriUtils.updateId() called...'信息;
-
-
-
-WantAgent对应接口
-
-1.点击主页面**WantAgent开发示例**按钮,跳转到'WantAgent开发示例'界面;
-
-2.点击**getBundleName callback**按钮,弹出提示'getBundleName(callback) success...'信息;
-
-3.点击**getBundleName promise**按钮,弹出提示'getBundleName(promise) success...'信息;
-
-4.点击**getUid callback**按钮,弹出提示'getUid(callback) success...'信息;
-
-5.点击**getUid promise**按钮,弹出提示'getUid(promise) success...'信息;
-
-6.点击**cancel callback**按钮,弹出提示'cancel(callback) success'信息;
-
-7.点击**cancel promise**按钮,弹出提示'cancel(promise) success'信息;
-
-8.点击**equal callback**按钮,弹出提示'equal(callback) success...'信息;
-
-9.点击**equal promise**按钮,弹出提示'equal(promise) success...'信息;
-
-10.点击**getOperationType callback**按钮,弹出提示'getOperationType(callback) success...'信息;
-
-11.点击**getOperationType promise**按钮,弹出提示'getOperationType(promise) success...'信息;
-
-12.点击**trigger**按钮,弹出提示'trigger success...'信息;
-
-
-
-ApplicationContext对应接口
-
-1.点击主页面**ApplicationContext开发示例**按钮,跳转到'ApplicationContext开发示例'界面;
-
-2.点击**setFont**按钮,弹出提示'setFont successfully'信息;
-
-3.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation promise successfully...'信息;
-
-4.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation callback successfully...'信息;
-
-5.点击**getCurrentAppCloneIndex**按钮,弹出提示'getCurrentAppCloneIndex successfully...'信息;
-
-
-
-errorManager对应接口
-
-1.点击主页面**errorManager开发示例**按钮,跳转到'errorManager开发示例'界面;
-
-2.点击**注册LoopObserver**按钮,弹出提示'loopObserver registered successfully...'信息;
-
-3.点击**注册UnhandledRejectionObserver**按钮,弹出提示'unhandledRejection registered successfully'信息,列表中增加**模拟UnhandledRejection**按钮,并且原**注册UnhandledRejectionObserver**按钮变为**注销UnhandledRejectionObserver**按钮
-
-4.点击**模拟UnhandledRejection**按钮,弹出提示'UnhandledRejectionObserver reason...'信息;
-
-5.点击**注销UnhandledRejection**按钮,弹出提示'unhandledRejection unregistered successfully'信息,**注销UnhandledRejectionObserver**按钮变回**注册UnhandledRejectionObserver**按钮,列表中**模拟UnhandledRejection**按钮消失;
-
-
-
-UIAbilityContext对应接口
-
-1.点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面;
-
-2.点击**moveAbilityToBackground**按钮,将启动的Ability移动到后台,页面显示为主页面,触发AbilityLifecycleCallback中的生命周期;
-
-3.再次点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面,点击**terminateSelf**按钮,回到主页面;
-
-### 工程目录
-
-```
-entry/src/main/ets/
-|---abilitylifecyclecallback
-| |---AbilityLifecycleCallback.ets //AbilityLifecycleCallback生命周期
-|---abilitypages
-| |---ApplicationContext.ets //ApplicationContext中对应接口
-| |---AppManager.ets //AppManager中对应接口
-| |---DataUriUtils.ets //DataUriUtils中对应接口
-| |---ErrorManager.ets //ErrorManager中对应接口
-| |---UIAbilityContext.ets //UIAbilityContext中对应接口
-| |---WantAgent.ets //WantAgent中对应接口
-|---entryability
-| |---EntryAbility.ets // 首页的Ability
-|---pages
-| |---Index.ets // 首页
-```
-
-### 具体实现
-
-* AppManager对应接口实现,源码参考[AppManager.ets](entry/src/main/ets/abilitypages/appManager.ets)
-
- * isRunningInStabilityTest(callback)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用callback异步回调,并将弹出Toast信息的功能;
- * isRunningInStabilityTest(promise)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用Promise异步回调,并将弹出Toast信息的功能;
- * isRamConstrainedDevice(callback)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用callback异步回调,并将弹出Toast信息的功能;
- * isRamConstrainedDevice(promise)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用Promise异步回调,并将弹出Toast信息的功能;
- * getAppMemorySize(callback)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用callback异步回调,并将弹出Toast信息的功能;
- * getAppMemorySize(promise)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用Promise异步回调,并将弹出Toast信息的功能;
- * getRunningProcessInformation(callback)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用callback异步回调,并将弹出Toast信息的功能;
- * getRunningProcessInformation(promise)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用Promise异步回调,并将弹出Toast信息的功能;
-* dataUriUtils对应接口实现,源码参考[DataUriUtils.ets](entry/src/main/ets/abilitypages/DataUriUtils.ets)
-
- * getId接口实现:通过调用dataUriUtils.getId()接口,获取指定uri路径末尾的ID的功能;
- * attachId接口实现:通过调用dataUriUtils.attachId()接口,将ID附加到uri的路径末尾的功能;
- * deleteId接口实现:通过调用dataUriUtils.deleteId()接口,删除指定uri路径末尾的ID的功能;
- * updateId接口实现:通过调用dataUriUtils.updateId()接口,更新指定uri中的ID的功能;
-* WantAgent对应接口实现,源码参考[WantAgent.ets](entry/src/main/ets/abilitypages/WantAgent.ets)
-
- * getBundleName(callback)接口实现:通过调用this.getBundleNameCallback()接口,获取WantAgent实例的包名;
- * getBundleName(promise)接口实现:通过调用this.getBundleNamePromise()接口,获取WantAgent实例的包名;
- * getUid(callback)接口实现:通过调用this.getUidCallback()接口,获取WantAgent实例的用户ID;
- * getUid(promise)接口实现:通过调用this.getUidPromise接口,获取WantAgent实例的用户ID;
- * cancel(callback)接口实现:通过调用this.cancelCallback()接口,取消WantAgent实例;
- * cancel(promise)接口实现:通过调用this.cancelPromise()接口,取消WantAgent实例;
- * equal(callback)接口实现:通过调用this.equalCallback()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的回调方法。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
- * equal(promise)接口实现:通过调用this.equalPromise()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的结果。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
- * getOperationType(callback)接口实现:通过调用this.getOperationTypeCallback()接口,获取一个WantAgent的OperationType信息;
- * getOperationType(promise)接口实现:通过调用this.getOperationTypePromise()接口,获取一个WantAgent的OperationType信息;
- * trigger接口实现:通过调用this.trigger()接口,主动激发WantAgent实例;
-* ApplicationContext对应接口实现,源码参考[ApplicationContext.ets](entry/src/main/ets/abilitypages/ApplicationContext.ets)
-
- * setFont接口实现:通过调用applicationContext.setFont接口,设置应用的字体类型。仅支持主线程调用,设置字体类型,字体可以通过font.registerFont方法进行注册使用;
- * getRunningProcessInformation(callback)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
- * getRunningProcessInformation(promise)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
- * getCurrentAppCloneIndex接口实现:通过调用ApplicationContext.getCurrentAppCloneIndex接口,获取当前应用的分身索引;
-* errorManager对应接口实现,源码参考[ErrorManager.ets](entry/src/main/ets/abilitypages/ErrorManager.ets)
- * 注册on(loopObserver类型)接口实现:通过调用errorManager.on 接口,注册监听loopObserver,注册后可以捕获到应用主线程处理消息的具体执行时间,触发onLoopTimeOut,之后注销监听;
- * 注册on(unhandledRejection类型)接口实现:通过调用errorManager.on接口,注册监听unhandledRejection,注册后可以捕获到当前线程中未被捕获到的promise rejection,模拟unhandledRejection类型错误,触发监听,之后注销监听;
-* UIAbilityContext对应接口实现:源码参考[UIAbilityContext.ets](entry/src/main/ets/abilitypages/UIAbilityContext.ets)
- * moveAbilityToBackground接口实现:通过调用context.moveAbilityToBackground()接口,将处于前台的Ability移动到后台,调用context.terminateSelf(),停止Ability自身,触发AbilityLifecycleCallback中的生命周期;
-
-### 相关权限
-
-不涉及。
-
-### 依赖
-
-不涉及。
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568;
-
-2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31;
-
-3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.502, built on July 28, 2024)才可编译运行;
-
-### 下载
-
-```shell
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Ability/AbilityRuntime > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
-
-
-
+# 基础能力增强
+
+### 介绍
+
+本示例使用 [AppManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-appManager.md) ,[dataUriUtils](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-ability-dataUriUtils.md),[WantAgent](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-wantAgent.md),[ApplicationContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-applicationContext.md),[errorManager](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-app-ability-errorManager.md),[UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md)中的接口进行实现。
+
+### 效果预览
+
+| 主页面 | appManager开发示例 | errorManager开发示例 | UIAbilityContext开发示例 |
+| :----------------------------------------------: | :---------------------------------------------------: | :-----------------------------------------------------: | :---------------------------------------------------------: |
+|
|
|
|
|
+
+### 使用说明
+
+AppManager对应接口
+
+1.点击主页面**appManager开发示例**按钮,跳转到'appManager开发示例'界面;
+
+2.点击**isRunningInStabilityTest callback**按钮,弹出'isRunningInStabilityTest(callback) success...'信息;
+
+3.点击**isRunningInStabilityTest promise**按钮,弹出提示'isRunningInStabilityTest(promise) success...'信息;
+
+4.点击**isRamConstrainedDevice callback**按钮,弹出提示'isRamConstrainedDevice(callback) success...'信息;
+
+5.点击**isRamConstrainedDevice promise**按钮,弹出提示'isRamConstrainedDevice(promise) success...'信息;
+
+6.点击**getAppMemorySize callback**按钮,弹出提示'getAppMemorySize(callback) success...'信息;
+
+7.点击**getAppMemorySize promise**按钮,弹出提示'getAppMemorySize(promise) success...'信息;
+
+8.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation(callback) success...'信息;
+
+9.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation(promise) success...'信息;
+
+
+
+dataUriUtils对应接口
+
+1.点击主页面**dataUriUtils开发示例**按钮,跳转到'dataUriUtils开发示例'界面;
+
+2.点击**getId**按钮,弹出提示'dataUriUtils.getId() called...'信息;
+
+3.点击**attachId**按钮,弹出提示'dataUriUtils.attachd() called...'信息;
+
+4.点击**deleteId**按钮,弹出提示'dataUriUtils.deleteId() called...'信息;
+
+5.点击**updateId**按钮,弹出提示'dataUriUtils.updateId() called...'信息;
+
+
+
+WantAgent对应接口
+
+1.点击主页面**WantAgent开发示例**按钮,跳转到'WantAgent开发示例'界面;
+
+2.点击**getBundleName callback**按钮,弹出提示'getBundleName(callback) success...'信息;
+
+3.点击**getBundleName promise**按钮,弹出提示'getBundleName(promise) success...'信息;
+
+4.点击**getUid callback**按钮,弹出提示'getUid(callback) success...'信息;
+
+5.点击**getUid promise**按钮,弹出提示'getUid(promise) success...'信息;
+
+6.点击**cancel callback**按钮,弹出提示'cancel(callback) success'信息;
+
+7.点击**cancel promise**按钮,弹出提示'cancel(promise) success'信息;
+
+8.点击**equal callback**按钮,弹出提示'equal(callback) success...'信息;
+
+9.点击**equal promise**按钮,弹出提示'equal(promise) success...'信息;
+
+10.点击**getOperationType callback**按钮,弹出提示'getOperationType(callback) success...'信息;
+
+11.点击**getOperationType promise**按钮,弹出提示'getOperationType(promise) success...'信息;
+
+12.点击**trigger**按钮,弹出提示'trigger success...'信息;
+
+
+
+ApplicationContext对应接口
+
+1.点击主页面**ApplicationContext开发示例**按钮,跳转到'ApplicationContext开发示例'界面;
+
+2.点击**setFont**按钮,弹出提示'setFont successfully'信息;
+
+3.点击**getRunningProcessInformation promise**按钮,弹出提示'getRunningProcessInformation promise successfully...'信息;
+
+4.点击**getRunningProcessInformation callback**按钮,弹出提示'getRunningProcessInformation callback successfully...'信息;
+
+5.点击**getCurrentAppCloneIndex**按钮,弹出提示'getCurrentAppCloneIndex successfully...'信息;
+
+
+
+errorManager对应接口
+
+1.点击主页面**errorManager开发示例**按钮,跳转到'errorManager开发示例'界面;
+
+2.点击**注册LoopObserver**按钮,弹出提示'loopObserver registered successfully...'信息;
+
+3.点击**注册UnhandledRejectionObserver**按钮,弹出提示'unhandledRejection registered successfully'信息,列表中增加**模拟UnhandledRejection**按钮,并且原**注册UnhandledRejectionObserver**按钮变为**注销UnhandledRejectionObserver**按钮
+
+4.点击**模拟UnhandledRejection**按钮,弹出提示'UnhandledRejectionObserver reason...'信息;
+
+5.点击**注销UnhandledRejection**按钮,弹出提示'unhandledRejection unregistered successfully'信息,**注销UnhandledRejectionObserver**按钮变回**注册UnhandledRejectionObserver**按钮,列表中**模拟UnhandledRejection**按钮消失;
+
+
+
+UIAbilityContext对应接口
+
+1.点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面;
+
+2.点击**moveAbilityToBackground**按钮,将启动的Ability移动到后台,页面显示为主页面,触发AbilityLifecycleCallback中的生命周期;
+
+3.再次点击主页面**UIAbilityContext开发示例**按钮,启动新的Ability显示'UIAbilityContext开发示例'界面,点击**terminateSelf**按钮,回到主页面;
+
+### 工程目录
+
+```
+entry/src/main/ets/
+|---abilitylifecyclecallback
+| |---AbilityLifecycleCallback.ets //AbilityLifecycleCallback生命周期
+|---abilitypages
+| |---ApplicationContext.ets //ApplicationContext中对应接口
+| |---AppManager.ets //AppManager中对应接口
+| |---DataUriUtils.ets //DataUriUtils中对应接口
+| |---ErrorManager.ets //ErrorManager中对应接口
+| |---UIAbilityContext.ets //UIAbilityContext中对应接口
+| |---WantAgent.ets //WantAgent中对应接口
+|---entryability
+| |---EntryAbility.ets // 首页的Ability
+|---pages
+| |---Index.ets // 首页
+```
+
+### 具体实现
+
+* AppManager对应接口实现,源码参考[AppManager.ets](entry/src/main/ets/abilitypages/appManager.ets)
+
+ * isRunningInStabilityTest(callback)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用callback异步回调,并将弹出Toast信息的功能;
+ * isRunningInStabilityTest(promise)接口实现:通过调用appManager.isRunningInStabilityTest()接口,查询当前是否处于稳定性测试场景。使用Promise异步回调,并将弹出Toast信息的功能;
+ * isRamConstrainedDevice(callback)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用callback异步回调,并将弹出Toast信息的功能;
+ * isRamConstrainedDevice(promise)接口实现:通过调用appManager.isRamConstrainedDevice()接口,查询是否为ram受限设备。使用Promise异步回调,并将弹出Toast信息的功能;
+ * getAppMemorySize(callback)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用callback异步回调,并将弹出Toast信息的功能;
+ * getAppMemorySize(promise)接口实现:通过调用appManager.getAppMemorySize()接口,获取当前应用程序可以使用的内存的值。使用Promise异步回调,并将弹出Toast信息的功能;
+ * getRunningProcessInformation(callback)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用callback异步回调,并将弹出Toast信息的功能;
+ * getRunningProcessInformation(promise)接口实现:通过调用appManager.getRunningProcessInformation()接口,获取当前运行进程的有关信息。使用Promise异步回调,并将弹出Toast信息的功能;
+* dataUriUtils对应接口实现,源码参考[DataUriUtils.ets](entry/src/main/ets/abilitypages/DataUriUtils.ets)
+
+ * getId接口实现:通过调用dataUriUtils.getId()接口,获取指定uri路径末尾的ID的功能;
+ * attachId接口实现:通过调用dataUriUtils.attachId()接口,将ID附加到uri的路径末尾的功能;
+ * deleteId接口实现:通过调用dataUriUtils.deleteId()接口,删除指定uri路径末尾的ID的功能;
+ * updateId接口实现:通过调用dataUriUtils.updateId()接口,更新指定uri中的ID的功能;
+* WantAgent对应接口实现,源码参考[WantAgent.ets](entry/src/main/ets/abilitypages/WantAgent.ets)
+
+ * getBundleName(callback)接口实现:通过调用this.getBundleNameCallback()接口,获取WantAgent实例的包名;
+ * getBundleName(promise)接口实现:通过调用this.getBundleNamePromise()接口,获取WantAgent实例的包名;
+ * getUid(callback)接口实现:通过调用this.getUidCallback()接口,获取WantAgent实例的用户ID;
+ * getUid(promise)接口实现:通过调用this.getUidPromise接口,获取WantAgent实例的用户ID;
+ * cancel(callback)接口实现:通过调用this.cancelCallback()接口,取消WantAgent实例;
+ * cancel(promise)接口实现:通过调用this.cancelPromise()接口,取消WantAgent实例;
+ * equal(callback)接口实现:通过调用this.equalCallback()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的回调方法。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
+ * equal(promise)接口实现:通过调用this.equalPromise()接口,以此来判断是否是来自同一应用的相同操作,判断两个WantAgent实例是否相等的结果。返回true表示两个WantAgent实例相等,false表示两个WantAgent实例不相等;
+ * getOperationType(callback)接口实现:通过调用this.getOperationTypeCallback()接口,获取一个WantAgent的OperationType信息;
+ * getOperationType(promise)接口实现:通过调用this.getOperationTypePromise()接口,获取一个WantAgent的OperationType信息;
+ * trigger接口实现:通过调用this.trigger()接口,主动激发WantAgent实例;
+* ApplicationContext对应接口实现,源码参考[ApplicationContext.ets](entry/src/main/ets/abilitypages/ApplicationContext.ets)
+
+ * setFont接口实现:通过调用applicationContext.setFont接口,设置应用的字体类型。仅支持主线程调用,设置字体类型,字体可以通过font.registerFont方法进行注册使用;
+ * getRunningProcessInformation(callback)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
+ * getRunningProcessInformation(promise)接口实现:通过调用ApplicationContext.getRunningProcessInformation接口,获取有关运行进程的信息;
+ * getCurrentAppCloneIndex接口实现:通过调用ApplicationContext.getCurrentAppCloneIndex接口,获取当前应用的分身索引;
+* errorManager对应接口实现,源码参考[ErrorManager.ets](entry/src/main/ets/abilitypages/ErrorManager.ets)
+ * 注册on(loopObserver类型)接口实现:通过调用errorManager.on 接口,注册监听loopObserver,注册后可以捕获到应用主线程处理消息的具体执行时间,触发onLoopTimeOut,之后注销监听;
+ * 注册on(unhandledRejection类型)接口实现:通过调用errorManager.on接口,注册监听unhandledRejection,注册后可以捕获到当前线程中未被捕获到的promise rejection,模拟unhandledRejection类型错误,触发监听,之后注销监听;
+* UIAbilityContext对应接口实现:源码参考[UIAbilityContext.ets](entry/src/main/ets/abilitypages/UIAbilityContext.ets)
+ * moveAbilityToBackground接口实现:通过调用context.moveAbilityToBackground()接口,将处于前台的Ability移动到后台,调用context.terminateSelf(),停止Ability自身,触发AbilityLifecycleCallback中的生命周期;
+
+### 相关权限
+
+不涉及。
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568;
+
+2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31;
+
+3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.502, built on July 28, 2024)才可编译运行;
+
+### 下载
+
+```shell
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Ability/AbilityRuntime > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
+
+
+
diff --git a/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5 b/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5
index 96292e1b2c960be8f23d27bb37ad8f5b12b9738a..7848132072eeab1ffb83134de010a80b4d2a968c 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/build-profile.json5
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2024 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": {
- "signingConfigs": [
- ],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compatibleSdkVersion": 12,
- "compileSdkVersion": 12,
- "runtimeOS": "OpenHarmony",
- }
- ],
- "buildModeSet": [
- {
- "name": "debug",
- },
- {
- "name": "release"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2024 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": {
+ "signingConfigs": [
+ ],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": 12,
+ "compileSdkVersion": 12,
+ "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/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5
index d04cb6b90c59558304ba27b9c22f604769997bf1..b4c2311b76761268310e37bd9be997808d39880e 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/build-profile.json5
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2024 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",
- }
- ]
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5
index 65ca50243f0eee898fd9c639fe4c431c5a66a15a..3d327009e012ac531803ce2d2db2968d07446d17 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/oh-package.json5
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2024 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": {}
-}
-
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets
index 430cc485375e48ef471e61dfe5e3b4bdf38b6953..3500fd2007c837849eff203b31cbe9df075ada1a 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets
@@ -1,240 +1,240 @@
-/*
- * Copyright (c) 2024 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, AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit';
-import { BusinessError } from '@ohos.base';
-import { window } from '@kit.ArkUI';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-
-const TAG: string = '[AbilityLifecycleCallback]';
-const DOMAIN: number = 0xFF00;
-
-export class GlobalContext {
- private constructor() {
- }
-
- private static instance: GlobalContext;
- private _objects = new Map();
-
- public static getContext(): GlobalContext {
- if (!GlobalContext.instance) {
- GlobalContext.instance = new GlobalContext();
- }
- return GlobalContext.instance;
- }
-
- getObject(value: string): Object | undefined {
- return this._objects.get(value);
- }
-
- setObject(key: string, objectClass: Object): void {
- this._objects.set(key, objectClass);
- }
-}
-
-// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册
-let abilityLifecycleCallback: AbilityLifecycleCallback = {
- onAbilityCreate(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityCreate.');
- },
- onWindowStageCreate(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageCreate.');
- },
- onWindowStageActive(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageActive.');
- },
- onWindowStageInactive(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageInactive.');
- },
- onWindowStageDestroy(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageDestroy.');
- },
- onAbilityDestroy(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityDestroy.');
- },
- onAbilityForeground(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityForeground.');
- },
- onAbilityBackground(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityBackground.');
- },
- onAbilityContinue(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityContinue.');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发后回调。
- onNewWant(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onNewWant');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发前回调。
- onWillNewWant(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWillNewWant');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onCreate]触发前回调。
- onAbilityWillCreate(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillCreate');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageCreate]触发前回调。
- onWindowStageWillCreate(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillCreate');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageDestroy]触发前回调。
- onWindowStageWillDestroy(ability, windowStage) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillDestroy');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onDestroy]触发前回调。
- onAbilityWillDestroy(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillDestroy');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onForeground]触发前回调。
- onAbilityWillForeground(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillForeground');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onBackground]触发前回调。
- onAbilityWillBackground(ability) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillBackground');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发前回调。
- onAbilityWillSaveState(ability: UIAbility) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillSaveState.');
- },
- // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发后回调。
- onAbilitySaveState(ability: UIAbility) {
- hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilitySaveState.');
- }
-};
-
-export default class AbilityLifecycle extends UIAbility {
- onCreate() {
- hilog.info(DOMAIN, TAG, 'MyAbilityStage onCreate');
-
- // 1.通过context属性获取applicationContext
- let applicationContext = this.context.getApplicationContext();
- // 2.通过applicationContext注册监听应用内生命周期
- try {
- let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
- GlobalContext.getContext().setObject('lifecycleId', lifecycleId);
- hilog.info(DOMAIN, TAG,
- `registerAbilityLifecycleCallback lifecycleId: ${GlobalContext.getContext().getObject('lifecycleId')}`);
- } catch (paramError) {
- hilog.error(DOMAIN, TAG, `error: ${paramError.code}, ${paramError.message}`);
- }
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- hilog.info(DOMAIN, TAG, 'onWindowStageCreate');
-
- let windowClass: window.Window | undefined = undefined;
- windowStage.getMainWindow((err: BusinessError, data) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- windowClass = data;
- let systemBarProperties: window.SystemBarProperties = {
- statusBarColor: '#f1f3f5',
- navigationBarColor: '#f1f3f5',
- };
- try {
- windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
- });
- } catch (exception) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
- }
- });
-
- windowStage.loadContent('abilitypages/UIAbilityContext', (err, data) => {
- if (err.code) {
- return;
- }
- });
- }
-
- onBackground() {
- hilog.info(DOMAIN, TAG, 'onBackground');
- }
-
- onForeground() {
- hilog.info(DOMAIN, TAG, 'onBackground');
- }
-
- onPrepareToTerminate() {
- hilog.info(DOMAIN, TAG, 'onPrepareToTerminate');
- // 开发者定义预关闭动作
- // 例如拉起另一个ability,根据ability处理结果执行异步关闭
- let want: Want = {
- bundleName: 'com.samples.abilityruntime',
- abilityName: 'AbilityLifecycleAbility'
- }
- this.context.startAbilityForResult(want)
- .then((result) => {
- // 获取ability处理结果,当返回结果的resultCode为0关闭当前UIAbility
- hilog.info(DOMAIN, TAG, 'startAbilityForResult success, resultCode is ' + result.resultCode);
- if (result.resultCode === 0) {
- this.context.terminateSelf();
- }
- }).catch((err: BusinessError) => {
- // 异常处理
- hilog.error(DOMAIN, TAG, 'startAbilityForResult failed, err:' + JSON.stringify(err));
- this.context.terminateSelf();
- })
-
- return true; // 已定义预关闭操作后,返回true表示UIAbility取消关闭
- }
-
- onWindowStageWillDestroy(windowStage: window.WindowStage) {
- hilog.info(DOMAIN, TAG, 'onWindowStageWillDestroy');
- }
-
- onWindowStageRestore(windowStage: window.WindowStage) {
- hilog.info(DOMAIN, TAG, 'onWindowStageRestore');
- }
-
- onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
- // No need to save state
- hilog.info(DOMAIN, TAG, 'onSaveState');
- return AbilityConstant.OnSaveResult.ALL_REJECT;
- }
-
- onWindowStageDestroy() {
- hilog.info(DOMAIN, TAG, 'onWindowStageDestroy');
- }
-
- onDestroy() {
- let applicationContext = this.context.getApplicationContext();
- let lifecycleId = GlobalContext.getContext().getObject('lifecycleId') as number;
- try {
- // 3.通过applicationContext注销监听应用内生命周期
- applicationContext.off('abilityLifecycle', lifecycleId, (error) => {
- if (error && error.code !== 0) {
- hilog.error(DOMAIN, TAG, `unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}`);
- } else {
- hilog.info(DOMAIN, TAG, 'unregisterAbilityLifecycleCallback success.');
- }
- });
- } catch (paramError) {
- hilog.error(DOMAIN, TAG,
- `error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
- }
- }
+/*
+ * Copyright (c) 2024 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, AbilityLifecycleCallback, UIAbility } from '@kit.AbilityKit';
+import { BusinessError } from '@ohos.base';
+import { window } from '@kit.ArkUI';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+const TAG: string = '[AbilityLifecycleCallback]';
+const DOMAIN: number = 0xFF00;
+
+export class GlobalContext {
+ private constructor() {
+ }
+
+ private static instance: GlobalContext;
+ private _objects = new Map();
+
+ public static getContext(): GlobalContext {
+ if (!GlobalContext.instance) {
+ GlobalContext.instance = new GlobalContext();
+ }
+ return GlobalContext.instance;
+ }
+
+ getObject(value: string): Object | undefined {
+ return this._objects.get(value);
+ }
+
+ setObject(key: string, objectClass: Object): void {
+ this._objects.set(key, objectClass);
+ }
+}
+
+// 声明ability生命周期回调,需配置所有回调后才可以在applicationContext注册
+let abilityLifecycleCallback: AbilityLifecycleCallback = {
+ onAbilityCreate(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityCreate.');
+ },
+ onWindowStageCreate(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageCreate.');
+ },
+ onWindowStageActive(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageActive.');
+ },
+ onWindowStageInactive(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageInactive.');
+ },
+ onWindowStageDestroy(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageDestroy.');
+ },
+ onAbilityDestroy(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityDestroy.');
+ },
+ onAbilityForeground(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityForeground.');
+ },
+ onAbilityBackground(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityBackground.');
+ },
+ onAbilityContinue(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityContinue.');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发后回调。
+ onNewWant(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onNewWant');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onNewWant]触发前回调。
+ onWillNewWant(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWillNewWant');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onCreate]触发前回调。
+ onAbilityWillCreate(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillCreate');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageCreate]触发前回调。
+ onWindowStageWillCreate(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillCreate');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onWindowStageDestroy]触发前回调。
+ onWindowStageWillDestroy(ability, windowStage) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onWindowStageWillDestroy');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onDestroy]触发前回调。
+ onAbilityWillDestroy(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillDestroy');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onForeground]触发前回调。
+ onAbilityWillForeground(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillForeground');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onBackground]触发前回调。
+ onAbilityWillBackground(ability) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillBackground');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发前回调。
+ onAbilityWillSaveState(ability: UIAbility) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilityWillSaveState.');
+ },
+ // 注册监听应用上下文的生命周期后,在UIAbility的[onSaveState]触发后回调。
+ onAbilitySaveState(ability: UIAbility) {
+ hilog.info(DOMAIN, TAG, 'AbilityLifecycleCallback onAbilitySaveState.');
+ }
+};
+
+export default class AbilityLifecycle extends UIAbility {
+ onCreate() {
+ hilog.info(DOMAIN, TAG, 'MyAbilityStage onCreate');
+
+ // 1.通过context属性获取applicationContext
+ let applicationContext = this.context.getApplicationContext();
+ // 2.通过applicationContext注册监听应用内生命周期
+ try {
+ let lifecycleId = applicationContext.on('abilityLifecycle', abilityLifecycleCallback);
+ GlobalContext.getContext().setObject('lifecycleId', lifecycleId);
+ hilog.info(DOMAIN, TAG,
+ `registerAbilityLifecycleCallback lifecycleId: ${GlobalContext.getContext().getObject('lifecycleId')}`);
+ } catch (paramError) {
+ hilog.error(DOMAIN, TAG, `error: ${paramError.code}, ${paramError.message}`);
+ }
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ hilog.info(DOMAIN, TAG, 'onWindowStageCreate');
+
+ let windowClass: window.Window | undefined = undefined;
+ windowStage.getMainWindow((err: BusinessError, data) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ windowClass = data;
+ let systemBarProperties: window.SystemBarProperties = {
+ statusBarColor: '#f1f3f5',
+ navigationBarColor: '#f1f3f5',
+ };
+ try {
+ windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
+ });
+ } catch (exception) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
+ }
+ });
+
+ windowStage.loadContent('abilitypages/UIAbilityContext', (err, data) => {
+ if (err.code) {
+ return;
+ }
+ });
+ }
+
+ onBackground() {
+ hilog.info(DOMAIN, TAG, 'onBackground');
+ }
+
+ onForeground() {
+ hilog.info(DOMAIN, TAG, 'onBackground');
+ }
+
+ onPrepareToTerminate() {
+ hilog.info(DOMAIN, TAG, 'onPrepareToTerminate');
+ // 开发者定义预关闭动作
+ // 例如拉起另一个ability,根据ability处理结果执行异步关闭
+ let want: Want = {
+ bundleName: 'com.samples.abilityruntime',
+ abilityName: 'AbilityLifecycleAbility'
+ }
+ this.context.startAbilityForResult(want)
+ .then((result) => {
+ // 获取ability处理结果,当返回结果的resultCode为0关闭当前UIAbility
+ hilog.info(DOMAIN, TAG, 'startAbilityForResult success, resultCode is ' + result.resultCode);
+ if (result.resultCode === 0) {
+ this.context.terminateSelf();
+ }
+ }).catch((err: BusinessError) => {
+ // 异常处理
+ hilog.error(DOMAIN, TAG, 'startAbilityForResult failed, err:' + JSON.stringify(err));
+ this.context.terminateSelf();
+ })
+
+ return true; // 已定义预关闭操作后,返回true表示UIAbility取消关闭
+ }
+
+ onWindowStageWillDestroy(windowStage: window.WindowStage) {
+ hilog.info(DOMAIN, TAG, 'onWindowStageWillDestroy');
+ }
+
+ onWindowStageRestore(windowStage: window.WindowStage) {
+ hilog.info(DOMAIN, TAG, 'onWindowStageRestore');
+ }
+
+ onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
+ // No need to save state
+ hilog.info(DOMAIN, TAG, 'onSaveState');
+ return AbilityConstant.OnSaveResult.ALL_REJECT;
+ }
+
+ onWindowStageDestroy() {
+ hilog.info(DOMAIN, TAG, 'onWindowStageDestroy');
+ }
+
+ onDestroy() {
+ let applicationContext = this.context.getApplicationContext();
+ let lifecycleId = GlobalContext.getContext().getObject('lifecycleId') as number;
+ try {
+ // 3.通过applicationContext注销监听应用内生命周期
+ applicationContext.off('abilityLifecycle', lifecycleId, (error) => {
+ if (error && error.code !== 0) {
+ hilog.error(DOMAIN, TAG, `unregisterAbilityLifecycleCallback fail, error: ${JSON.stringify(error)}`);
+ } else {
+ hilog.info(DOMAIN, TAG, 'unregisterAbilityLifecycleCallback success.');
+ }
+ });
+ } catch (paramError) {
+ hilog.error(DOMAIN, TAG,
+ `error: ${(paramError as BusinessError).code}, ${(paramError as BusinessError).message}`);
+ }
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets
index d9d9c9df20fb95c9cdb119bec8a1bdbb9ef292cf..a87a3f5b41a435b912fa51e854d3bd18c74488c1 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/AppManager.ets
@@ -1,349 +1,349 @@
-/*
- * Copyright (c) 2024 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 { appManager } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { promptAction } from '@kit.ArkUI';
-
-const TAG: string = 'AppManager';
-const DOMAIN: number = 0xFF00;
-
-@Entry
-@Component
-struct AppManager {
- private promptDuration: number = 2000;
-
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.AppManager'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('7.18%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
- .margin({
- top: '7.18%',
- bottom: '6.41%',
- left: '3.33%'
- })
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.isRunningInStabilityTestCallback'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('isRunningInStabilityTestCallback')
- }
- .onClick(() => {
- try {
- appManager.isRunningInStabilityTest((err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of isRunningInStabilityTest(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `isRunningInStabilityTest(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(callback) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.isRunningInStabilityTestPromise'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('isRunningInStabilityTestPromise')
- }
- .onClick(() => {
- try {
- appManager.isRunningInStabilityTest().then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of isRunningInStabilityTest(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `isRunningInStabilityTest(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(promise) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.isRamConstrainedDeviceCallback'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('isRamConstrainedDeviceCallback')
- }
- .onClick(() => {
- try {
- appManager.isRamConstrainedDevice((err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of isRamConstrainedDevice(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `isRamConstrainedDevice(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(callback) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.isRamConstrainedDevicePromise'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('isRamConstrainedDevicePromise')
- }
- .onClick(() => {
- try {
- appManager.isRamConstrainedDevice().then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of isRamConstrainedDevice(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `isRamConstrainedDevice(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(promise) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.getAppMemorySizeCallback'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('getAppMemorySizeCallback')
- }
- .onClick(() => {
- try {
- appManager.getAppMemorySize((err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getAppMemorySize(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getAppMemorySize(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `getAppMemorySize(callback) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.getAppMemorySizePromise'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('getAppMemorySizePromise')
- }
- .onClick(() => {
- try {
- appManager.getAppMemorySize().then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getAppMemorySize(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getAppMemorySize(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `getAppMemorySize(promise) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.getRunningProcessInformationCallback'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('getRunningProcessInformationCallback')
- }
- .onClick(() => {
- try {
- appManager.getRunningProcessInformation((err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getRunningProcessInformation(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getRunningProcessInformation(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `getRunningProcessInformation(callback) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.getRunningProcessInformationPromise'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- .id('getRunningProcessInformationPromise')
- }
- .onClick(() => {
- try {
- appManager.getRunningProcessInformation().then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getRunningProcessInformation(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getRunningProcessInformation(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG, `getRunningProcessInformation(promise) fail, err: ${JSON.stringify(err)}`);
- }
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .width('100%')
- .height('100%')
- .backgroundColor($r('app.color.backGrounding'))
- }
+/*
+ * Copyright (c) 2024 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 { appManager } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { promptAction } from '@kit.ArkUI';
+
+const TAG: string = 'AppManager';
+const DOMAIN: number = 0xFF00;
+
+@Entry
+@Component
+struct AppManager {
+ private promptDuration: number = 2000;
+
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.AppManager'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('7.18%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+ .margin({
+ top: '7.18%',
+ bottom: '6.41%',
+ left: '3.33%'
+ })
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.isRunningInStabilityTestCallback'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('isRunningInStabilityTestCallback')
+ }
+ .onClick(() => {
+ try {
+ appManager.isRunningInStabilityTest((err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of isRunningInStabilityTest(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `isRunningInStabilityTest(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(callback) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.isRunningInStabilityTestPromise'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('isRunningInStabilityTestPromise')
+ }
+ .onClick(() => {
+ try {
+ appManager.isRunningInStabilityTest().then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of isRunningInStabilityTest(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `isRunningInStabilityTest(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `isRunningInStabilityTest(promise) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.isRamConstrainedDeviceCallback'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('isRamConstrainedDeviceCallback')
+ }
+ .onClick(() => {
+ try {
+ appManager.isRamConstrainedDevice((err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of isRamConstrainedDevice(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `isRamConstrainedDevice(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(callback) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.isRamConstrainedDevicePromise'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('isRamConstrainedDevicePromise')
+ }
+ .onClick(() => {
+ try {
+ appManager.isRamConstrainedDevice().then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of isRamConstrainedDevice(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `isRamConstrainedDevice(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `isRamConstrainedDevice(promise) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.getAppMemorySizeCallback'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('getAppMemorySizeCallback')
+ }
+ .onClick(() => {
+ try {
+ appManager.getAppMemorySize((err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getAppMemorySize(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getAppMemorySize(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `getAppMemorySize(callback) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.getAppMemorySizePromise'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('getAppMemorySizePromise')
+ }
+ .onClick(() => {
+ try {
+ appManager.getAppMemorySize().then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getAppMemorySize(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getAppMemorySize(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `getAppMemorySize(promise) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.getRunningProcessInformationCallback'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('getRunningProcessInformationCallback')
+ }
+ .onClick(() => {
+ try {
+ appManager.getRunningProcessInformation((err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getRunningProcessInformation(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getRunningProcessInformation(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `getRunningProcessInformation(callback) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.getRunningProcessInformationPromise'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ .id('getRunningProcessInformationPromise')
+ }
+ .onClick(() => {
+ try {
+ appManager.getRunningProcessInformation().then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getRunningProcessInformation(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getRunningProcessInformation(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `getRunningProcessInformation(promise) fail, err: ${JSON.stringify(err)}`);
+ }
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets
index ea2e6252237d4d9e25c8de27c412eb1f95631ab1..18c221ec1d33db18beae27a2ce0679dd75c14f7f 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ApplicationContext.ets
@@ -1,225 +1,225 @@
-/*
- * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { font, promptAction } from '@kit.ArkUI';
-
-const TAG: string = 'ApplicationContext';
-const DOMAIN: number = 0xFF00;
-
-@Entry
-@Component
-struct ApplicationContext {
- private promptDuration: number = 2000;
-
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ApplicationContext'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('14.36%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ApplicationContext_getCurrentAppCloneIndex'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getCurrentAppCloneIndex')
- .onClick(() => {
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex begin.');
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let applicationContext = context.getApplicationContext();
- try {
- let index = applicationContext.getCurrentAppCloneIndex();
- let msg = `getCurrentAppCloneIndex successfully, index: ${index}`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- } catch (error) {
- hilog.info(DOMAIN, TAG,
- `ApplicationContext.getCurrentAppCloneIndex fail, error: ${JSON.stringify(error)}`);
- }
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex succeed.');
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ApplicationContext_getRunningProcessInformation_callback'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getRunningProcessInformationCallback')
- .onClick(() => {
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback begin.');
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let applicationContext = context.getApplicationContext();
-
- try {
- applicationContext.getRunningProcessInformation((err, data) => {
- let msg = `getRunningProcessInformation callback successfully, data: ${JSON.stringify(data)}`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG,
- `ApplicationContext.getRunningProcessInformation callback fail, error: ${JSON.stringify(err)}`);
- }
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback succeed.');
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ApplicationContext_getRunningProcessInformation_promise'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getRunningProcessInformationPromise')
- .onClick(() => {
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise begin.');
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let applicationContext = context.getApplicationContext();
-
- try {
- applicationContext.getRunningProcessInformation().then((data) => {
- let msg = `getRunningProcessInformation promise successfully, data: ${JSON.stringify(data)}`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG,
- `ApplicationContext.getRunningProcessInformation promise fail, error: ${JSON.stringify(err)}`);
- }
- hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise succeed.');
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ApplicationContext_setFont'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('100%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('setFont')
- .onClick(() => {
- font.registerFont({
- familyName: 'fontName',
- familySrc: $rawfile('font/Roboto-Regular.ttf')
- })
-
- hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont begin.');
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let applicationContext = context.getApplicationContext();
-
- try {
- applicationContext.setFont('fontName');
- let msg = `setFont successfully`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- } catch (err) {
- hilog.info(DOMAIN, TAG,
- `ApplicationContext.setFont fail, error: ${JSON.stringify(err)}`);
- }
- hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont succeed.');
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .height('100%')
- .width('100%')
- }
+/*
+ * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { font, promptAction } from '@kit.ArkUI';
+
+const TAG: string = 'ApplicationContext';
+const DOMAIN: number = 0xFF00;
+
+@Entry
+@Component
+struct ApplicationContext {
+ private promptDuration: number = 2000;
+
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ApplicationContext'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('14.36%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ApplicationContext_getCurrentAppCloneIndex'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getCurrentAppCloneIndex')
+ .onClick(() => {
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex begin.');
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let applicationContext = context.getApplicationContext();
+ try {
+ let index = applicationContext.getCurrentAppCloneIndex();
+ let msg = `getCurrentAppCloneIndex successfully, index: ${index}`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ } catch (error) {
+ hilog.info(DOMAIN, TAG,
+ `ApplicationContext.getCurrentAppCloneIndex fail, error: ${JSON.stringify(error)}`);
+ }
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getCurrentAppCloneIndex succeed.');
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ApplicationContext_getRunningProcessInformation_callback'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getRunningProcessInformationCallback')
+ .onClick(() => {
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback begin.');
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let applicationContext = context.getApplicationContext();
+
+ try {
+ applicationContext.getRunningProcessInformation((err, data) => {
+ let msg = `getRunningProcessInformation callback successfully, data: ${JSON.stringify(data)}`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG,
+ `ApplicationContext.getRunningProcessInformation callback fail, error: ${JSON.stringify(err)}`);
+ }
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation callback succeed.');
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ApplicationContext_getRunningProcessInformation_promise'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getRunningProcessInformationPromise')
+ .onClick(() => {
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise begin.');
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let applicationContext = context.getApplicationContext();
+
+ try {
+ applicationContext.getRunningProcessInformation().then((data) => {
+ let msg = `getRunningProcessInformation promise successfully, data: ${JSON.stringify(data)}`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG,
+ `ApplicationContext.getRunningProcessInformation promise fail, error: ${JSON.stringify(err)}`);
+ }
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.getRunningProcessInformation promise succeed.');
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ApplicationContext_setFont'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('100%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('setFont')
+ .onClick(() => {
+ font.registerFont({
+ familyName: 'fontName',
+ familySrc: $rawfile('font/Roboto-Regular.ttf')
+ })
+
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont begin.');
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let applicationContext = context.getApplicationContext();
+
+ try {
+ applicationContext.setFont('fontName');
+ let msg = `setFont successfully`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ } catch (err) {
+ hilog.info(DOMAIN, TAG,
+ `ApplicationContext.setFont fail, error: ${JSON.stringify(err)}`);
+ }
+ hilog.info(DOMAIN, TAG, 'ApplicationContext.setFont succeed.');
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .height('100%')
+ .width('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets
index 274b22b686e2d15420eae399f2c0b51253b1f993..f969d2154da7856e69c6f0590a0628ade7753e7f 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/DataUriUtils.ets
@@ -1,198 +1,198 @@
-/*
- * Copyright (c) 2024 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 { dataUriUtils } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { promptAction } from '@kit.ArkUI';
-
-const TAG: string = 'DataUriUtils';
-const DOMAIN: number = 0xFF00;
-const ID = 1122;
-
-@Entry
-@Component
-struct DataUriUtils {
- private promptDuration: number = 2000;
- @State loopObserverRegistered: boolean = false;
- @State unhandledRejectionRegistered: boolean = false;
-
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.DataUriUtils'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('14.36%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.getId'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getId')
- .onClick(() => {
- ((): void => {
- try {
- let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
- hilog.info(DOMAIN, TAG, `dataUriUtils.getId() called. id: ${id}`);
- promptAction.showToast({
- message: `dataUriUtils.getId() called. id: ${id}`,
- duration: this.promptDuration
- });
- } catch (err) {
- hilog.info(DOMAIN, TAG, `dataUriUtils.getId() error: ${err}`);
- promptAction.showToast({
- message: `dataUriUtils.getId() error: ${err}`,
- duration: this.promptDuration
- });
- }
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.attachId'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('attachId')
- .onClick(() => {
- ((): void => {
- let id = 1122;
- let uri = dataUriUtils.attachId(
- 'com.example.dataUriUtils',
- id,
- );
- promptAction.showToast({
- message: `dataUriUtils.attachId() called. uri: ${JSON.stringify(uri)}`,
- duration: this.promptDuration
- });
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.deleteId'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('deleteId')
- .onClick(() => {
- ((): void => {
- let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
- promptAction.showToast({
- message: `dataUriUtils.deleteId() called. uri: ${JSON.stringify(uri)}`,
- duration: this.promptDuration
- });
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.updateId'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('updateId')
- .onClick(() => {
- ((): void => {
- let uri = dataUriUtils.updateId(
- 'com.example.dataUriUtils/1221',
- ID
- );
- promptAction.showToast({
- message: `dataUriUtils.updateId() called. uri: ${JSON.stringify(uri)}`,
- duration: this.promptDuration
- });
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .height('100%')
- .width('100%')
- }
+/*
+ * Copyright (c) 2024 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 { dataUriUtils } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { promptAction } from '@kit.ArkUI';
+
+const TAG: string = 'DataUriUtils';
+const DOMAIN: number = 0xFF00;
+const ID = 1122;
+
+@Entry
+@Component
+struct DataUriUtils {
+ private promptDuration: number = 2000;
+ @State loopObserverRegistered: boolean = false;
+ @State unhandledRejectionRegistered: boolean = false;
+
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.DataUriUtils'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('14.36%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.getId'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getId')
+ .onClick(() => {
+ ((): void => {
+ try {
+ let id = dataUriUtils.getId('com.example.dataUriUtils/1221');
+ hilog.info(DOMAIN, TAG, `dataUriUtils.getId() called. id: ${id}`);
+ promptAction.showToast({
+ message: `dataUriUtils.getId() called. id: ${id}`,
+ duration: this.promptDuration
+ });
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, `dataUriUtils.getId() error: ${err}`);
+ promptAction.showToast({
+ message: `dataUriUtils.getId() error: ${err}`,
+ duration: this.promptDuration
+ });
+ }
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.attachId'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('attachId')
+ .onClick(() => {
+ ((): void => {
+ let id = 1122;
+ let uri = dataUriUtils.attachId(
+ 'com.example.dataUriUtils',
+ id,
+ );
+ promptAction.showToast({
+ message: `dataUriUtils.attachId() called. uri: ${JSON.stringify(uri)}`,
+ duration: this.promptDuration
+ });
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.deleteId'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('deleteId')
+ .onClick(() => {
+ ((): void => {
+ let uri = dataUriUtils.deleteId('com.example.dataUriUtils/1221');
+ promptAction.showToast({
+ message: `dataUriUtils.deleteId() called. uri: ${JSON.stringify(uri)}`,
+ duration: this.promptDuration
+ });
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.updateId'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('updateId')
+ .onClick(() => {
+ ((): void => {
+ let uri = dataUriUtils.updateId(
+ 'com.example.dataUriUtils/1221',
+ ID
+ );
+ promptAction.showToast({
+ message: `dataUriUtils.updateId() called. uri: ${JSON.stringify(uri)}`,
+ duration: this.promptDuration
+ });
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .height('100%')
+ .width('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets
index 701e0d6c81e88cdca042a77491c646610ac18083..84c71b39b539b6166f5f0b761a9088db3e933159 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/ErrorManager.ets
@@ -1,195 +1,195 @@
-/*
- * Copyright (c) 2024 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 { errorManager } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { promptAction } from '@kit.ArkUI';
-
-const TAG: string = 'ErrorManager';
-const DOMAIN: number = 0xFF00;
-
-let observer: errorManager.LoopObserver = {
- onLoopTimeOut(timeout: number) {
- hilog.info(DOMAIN, TAG, `onLoopTimeOut, timeout: ${timeout}`)
- errorManager.off('loopObserver');
- }
-};
-
-@Entry
-@Component
-struct ErrorManager {
- private promptDuration: number = 2000;
- private loopTimeOut: number = 20;
- @State unhandledRejectionRegistered: boolean = false;
-
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.ErrorManager'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('14.36%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.registerLoopObserver'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('registerLoopObserver')
- .onClick(() => {
- ((): void => {
- try {
- errorManager.on('loopObserver', this.loopTimeOut, observer);
- let msg = `loopObserver registered successfully, loopTimeOut: ${this.loopTimeOut}`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- } catch (error) {
- hilog.info(DOMAIN, TAG, `errorManager.on('loopObserver') failed, error: ${JSON.stringify(error)}`);
- }
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text(this.unhandledRejectionRegistered ?
- $r('app.string.unregisterUnhandledRejection') : $r('app.string.registerUnhandledRejection'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id(this.unhandledRejectionRegistered ? ('unregisterUnhandledRejection') : ('registerUnhandledRejection'))
- .onClick(() => {
- ((): void => {
- if (this.unhandledRejectionRegistered == false) {
- let observer: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise) => {
- let msg = `UnhandledRejectionObserver reason: ${JSON.stringify(reason)}`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- };
-
- try {
- errorManager.on('unhandledRejection', observer);
- this.unhandledRejectionRegistered = true;
- let msg = `unhandledRejection registered successfully`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- } catch (error) {
- hilog.info(DOMAIN, TAG,
- `errorManager.on('unhandledRejection') failed, error: ${JSON.stringify(error)}`);
- this.unhandledRejectionRegistered = false;
- }
-
- } else {
- try {
- errorManager.off('unhandledRejection');
- this.unhandledRejectionRegistered = false;
- let msg: string = `unhandledRejection unregistered successfully`;
- hilog.info(DOMAIN, TAG, msg);
- promptAction.showToast({
- message: msg,
- duration: this.promptDuration
- })
- } catch (error) {
- this.unhandledRejectionRegistered = true;
- hilog.info(DOMAIN, TAG, `unhandledRejection unregistered failed, error: ${JSON.stringify(error)}`);
- }
- }
- })()
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- if (this.unhandledRejectionRegistered) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.simulateUnhandledRejection'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('simulateUnhandledRejection')
- .onClick(() => {
- Promise.reject({ name: 'test', message: 'simulateUnhandledRejection' });
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .height('100%')
- .width('100%')
- }
+/*
+ * Copyright (c) 2024 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 { errorManager } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { promptAction } from '@kit.ArkUI';
+
+const TAG: string = 'ErrorManager';
+const DOMAIN: number = 0xFF00;
+
+let observer: errorManager.LoopObserver = {
+ onLoopTimeOut(timeout: number) {
+ hilog.info(DOMAIN, TAG, `onLoopTimeOut, timeout: ${timeout}`)
+ errorManager.off('loopObserver');
+ }
+};
+
+@Entry
+@Component
+struct ErrorManager {
+ private promptDuration: number = 2000;
+ private loopTimeOut: number = 20;
+ @State unhandledRejectionRegistered: boolean = false;
+
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.ErrorManager'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('14.36%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.registerLoopObserver'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('registerLoopObserver')
+ .onClick(() => {
+ ((): void => {
+ try {
+ errorManager.on('loopObserver', this.loopTimeOut, observer);
+ let msg = `loopObserver registered successfully, loopTimeOut: ${this.loopTimeOut}`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ } catch (error) {
+ hilog.info(DOMAIN, TAG, `errorManager.on('loopObserver') failed, error: ${JSON.stringify(error)}`);
+ }
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text(this.unhandledRejectionRegistered ?
+ $r('app.string.unregisterUnhandledRejection') : $r('app.string.registerUnhandledRejection'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id(this.unhandledRejectionRegistered ? ('unregisterUnhandledRejection') : ('registerUnhandledRejection'))
+ .onClick(() => {
+ ((): void => {
+ if (this.unhandledRejectionRegistered == false) {
+ let observer: errorManager.UnhandledRejectionObserver = (reason: Error, promise: Promise) => {
+ let msg = `UnhandledRejectionObserver reason: ${JSON.stringify(reason)}`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ };
+
+ try {
+ errorManager.on('unhandledRejection', observer);
+ this.unhandledRejectionRegistered = true;
+ let msg = `unhandledRejection registered successfully`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ } catch (error) {
+ hilog.info(DOMAIN, TAG,
+ `errorManager.on('unhandledRejection') failed, error: ${JSON.stringify(error)}`);
+ this.unhandledRejectionRegistered = false;
+ }
+
+ } else {
+ try {
+ errorManager.off('unhandledRejection');
+ this.unhandledRejectionRegistered = false;
+ let msg: string = `unhandledRejection unregistered successfully`;
+ hilog.info(DOMAIN, TAG, msg);
+ promptAction.showToast({
+ message: msg,
+ duration: this.promptDuration
+ })
+ } catch (error) {
+ this.unhandledRejectionRegistered = true;
+ hilog.info(DOMAIN, TAG, `unhandledRejection unregistered failed, error: ${JSON.stringify(error)}`);
+ }
+ }
+ })()
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ if (this.unhandledRejectionRegistered) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.simulateUnhandledRejection'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('simulateUnhandledRejection')
+ .onClick(() => {
+ Promise.reject({ name: 'test', message: 'simulateUnhandledRejection' });
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .height('100%')
+ .width('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets
index 26baf797fd911d53e28213acb9c6c2635f29d947..914f1337b5c61db817baf2356a7f61c3bca10cab 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/UIAbilityContext.ets
@@ -1,113 +1,113 @@
-/*
- * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
-import { BusinessError } from '@kit.BasicServicesKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-
-const TAG: string = 'UIAbilityContext';
-const DOMAIN: number = 0xFF00;
-
-@Entry
-@Component
-struct UIAbilityContext {
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.UIAbilityContext'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('14.36%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.UIAbilityContext_moveAbilityToBackground'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('moveAbilityToBackground')
- .onClick(() => {
- let context = getContext(this) as common.UIAbilityContext;
- context.moveAbilityToBackground().then(() => {
- hilog.info(DOMAIN, TAG, 'moveAbilityToBackground success.');
- }).catch((err: BusinessError) => {
- hilog.info(DOMAIN, TAG, `moveAbilityToBackground error: ${JSON.stringify(err)}.`);
- });
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r('app.string.UIAbilityContext_terminateSelf'))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('terminateSelf')
- .onClick(() => {
- let context = getContext(this) as common.UIAbilityContext;
- context.terminateSelf().then(() => {
- hilog.info(DOMAIN, TAG, 'terminateSelf success.');
- }).catch((err: BusinessError) => {
- hilog.info(DOMAIN, TAG, `terminateSelf error: ${JSON.stringify(err)}.`);
- });
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .backgroundColor($r('app.color.backGrounding'))
- .width('100%')
- .height('100%')
- }
+/*
+ * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
+import { BusinessError } from '@kit.BasicServicesKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+const TAG: string = 'UIAbilityContext';
+const DOMAIN: number = 0xFF00;
+
+@Entry
+@Component
+struct UIAbilityContext {
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.UIAbilityContext'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('14.36%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.UIAbilityContext_moveAbilityToBackground'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('moveAbilityToBackground')
+ .onClick(() => {
+ let context = getContext(this) as common.UIAbilityContext;
+ context.moveAbilityToBackground().then(() => {
+ hilog.info(DOMAIN, TAG, 'moveAbilityToBackground success.');
+ }).catch((err: BusinessError) => {
+ hilog.info(DOMAIN, TAG, `moveAbilityToBackground error: ${JSON.stringify(err)}.`);
+ });
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.UIAbilityContext_terminateSelf'))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('terminateSelf')
+ .onClick(() => {
+ let context = getContext(this) as common.UIAbilityContext;
+ context.terminateSelf().then(() => {
+ hilog.info(DOMAIN, TAG, 'terminateSelf success.');
+ }).catch((err: BusinessError) => {
+ hilog.info(DOMAIN, TAG, `terminateSelf error: ${JSON.stringify(err)}.`);
+ });
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .backgroundColor($r('app.color.backGrounding'))
+ .width('100%')
+ .height('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets
index 8e4bad93d05284834649bafcd57ad6d3e09ae3e9..33c1177c84e803e013e0e08ae425af90023b347e 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/abilitypages/WantAgent.ets
@@ -1,506 +1,506 @@
-/*
- * Copyright (c) 2024 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 { wantAgent } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { promptAction } from '@kit.ArkUI';
-
-const TAG: string = 'WantAgent';
-const DOMAIN: number = 0xFF00;
-
-@Entry
-@Component
-struct WantAgentClass {
- private promptDuration: number = 2000;
- private wantAgentInfo: wantAgent.WantAgentInfo = {
- wants: [
- {
- bundleName: 'com.samples.abilityruntime',
- abilityName: 'EntryAbility',
- }
- ],
- actionType: wantAgent.OperationType.START_ABILITY,
- requestCode: 0,
- actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
- }
-
- async getBundleNameCallback(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getBundleName(dataBase, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getBundleName(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getBundleName(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async getBundleNamePromise(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getBundleName(dataBase).then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getBundleName(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getBundleName(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async getUidCallback(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getUid(dataBase, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getUid(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getUid(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async getUidPromise(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getUid(dataBase).then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getUid(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getUid(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async cancelCallback(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.cancel(dataBase, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of cancel(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `cancel(callback) success`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async cancelPromise(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.cancel(dataBase).then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of cancel(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `cancel(promise) success`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async equalCallback(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.equal(dataBase, dataBase, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of equal(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `equal(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async equalPromise(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.equal(dataBase, dataBase).then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of equal(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `equal(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async getOperationTypeCallback(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getOperationType(dataBase, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getOperationType(callback) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getOperationType(callback) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async getOperationTypePromise(): Promise {
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.getOperationType(dataBase).then((data) => {
- hilog.info(DOMAIN, TAG,
- `The result of getOperationType(promise) is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `getOperationType(promise) success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- async trigger(): Promise {
- let triggerInfo: wantAgent.TriggerInfo = {
- code: 0,
- want: {
- bundleName: 'com.samples.abilityruntime',
- abilityName: 'EntryAbility',
- },
- permission: '',
- extraInfo: {
- test: 'this is a test value'
- }
- }
-
- wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
- wantAgent.trigger(dataBase, triggerInfo, (err, data) => {
- hilog.info(DOMAIN, TAG,
- `The result of trigger is: ${JSON.stringify(data)}`);
- promptAction.showToast({
- message: `trigger success, data: ${JSON.stringify(data)}`,
- duration: this.promptDuration
- })
- })
- console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
- })
- }
-
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.WantAgent'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .margin({
- top: 8,
- bottom: 8,
- left: 12
- })
- }
- }
- .width('100%')
- .height('14.36%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
-
- List({ initialIndex: 0 }) {
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getBundleNameCallback`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getBundleNameCallback')
- .onClick(() => {
- this.getBundleNameCallback();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getBundleNamePromise`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getBundleNamePromise')
- .onClick(() => {
- this.getBundleNamePromise();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getUidCallback`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getUidCallback')
- .onClick(() => {
- this.getUidCallback();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getUidPromise`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getUidPromise')
- .onClick(() => {
- this.getUidPromise();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.cancelCallback`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('cancelCallback')
- .onClick(() => {
- this.cancelCallback();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.cancelPromise`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('cancelPromise')
- .onClick(() => {
- this.cancelPromise();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.equalCallback`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('equalCallback')
- .onClick(() => {
- this.equalCallback();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.equalPromise`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('equalPromise')
- .onClick(() => {
- this.equalPromise();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getOperationTypeCallback`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getOperationTypeCallback')
- .onClick(() => {
- this.getOperationTypeCallback();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.getOperationTypePromise`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('getOperationTypePromise')
- .onClick(() => {
- this.getOperationTypePromise();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
-
- ListItem() {
- Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
- Text($r(`app.string.trigger`))
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- .margin({
- top: 17,
- bottom: 17,
- left: 12
- })
- .fontSize(16)
- .width('77.87%')
- .height('39.29%')
- .fontColor($r('app.color.text_color'))
- }
- .id('trigger')
- .onClick(() => {
- this.trigger();
- })
- }
- .height('8.45%')
- .backgroundColor($r('app.color.start_window_background'))
- .borderRadius(24)
- .margin({ top: 12, right: 12, left: 12 })
- }
- .height('86%')
- .backgroundColor($r('app.color.backGrounding'))
- }
- .width('100%')
- }
+/*
+ * Copyright (c) 2024 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 { wantAgent } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { promptAction } from '@kit.ArkUI';
+
+const TAG: string = 'WantAgent';
+const DOMAIN: number = 0xFF00;
+
+@Entry
+@Component
+struct WantAgentClass {
+ private promptDuration: number = 2000;
+ private wantAgentInfo: wantAgent.WantAgentInfo = {
+ wants: [
+ {
+ bundleName: 'com.samples.abilityruntime',
+ abilityName: 'EntryAbility',
+ }
+ ],
+ actionType: wantAgent.OperationType.START_ABILITY,
+ requestCode: 0,
+ actionFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
+ }
+
+ async getBundleNameCallback(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getBundleName(dataBase, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getBundleName(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getBundleName(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async getBundleNamePromise(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getBundleName(dataBase).then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getBundleName(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getBundleName(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async getUidCallback(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getUid(dataBase, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getUid(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getUid(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async getUidPromise(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getUid(dataBase).then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getUid(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getUid(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async cancelCallback(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.cancel(dataBase, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of cancel(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `cancel(callback) success`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async cancelPromise(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.cancel(dataBase).then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of cancel(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `cancel(promise) success`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async equalCallback(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.equal(dataBase, dataBase, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of equal(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `equal(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async equalPromise(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.equal(dataBase, dataBase).then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of equal(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `equal(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async getOperationTypeCallback(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getOperationType(dataBase, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getOperationType(callback) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getOperationType(callback) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async getOperationTypePromise(): Promise {
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.getOperationType(dataBase).then((data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of getOperationType(promise) is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `getOperationType(promise) success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ async trigger(): Promise {
+ let triggerInfo: wantAgent.TriggerInfo = {
+ code: 0,
+ want: {
+ bundleName: 'com.samples.abilityruntime',
+ abilityName: 'EntryAbility',
+ },
+ permission: '',
+ extraInfo: {
+ test: 'this is a test value'
+ }
+ }
+
+ wantAgent.getWantAgent(this.wantAgentInfo).then((dataBase) => {
+ wantAgent.trigger(dataBase, triggerInfo, (err, data) => {
+ hilog.info(DOMAIN, TAG,
+ `The result of trigger is: ${JSON.stringify(data)}`);
+ promptAction.showToast({
+ message: `trigger success, data: ${JSON.stringify(data)}`,
+ duration: this.promptDuration
+ })
+ })
+ console.info(`${TAG} getWantAgent success: ${JSON.stringify(dataBase)}`)
+ })
+ }
+
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.WantAgent'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .margin({
+ top: 8,
+ bottom: 8,
+ left: 12
+ })
+ }
+ }
+ .width('100%')
+ .height('14.36%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+
+ List({ initialIndex: 0 }) {
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getBundleNameCallback`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getBundleNameCallback')
+ .onClick(() => {
+ this.getBundleNameCallback();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getBundleNamePromise`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getBundleNamePromise')
+ .onClick(() => {
+ this.getBundleNamePromise();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getUidCallback`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getUidCallback')
+ .onClick(() => {
+ this.getUidCallback();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getUidPromise`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getUidPromise')
+ .onClick(() => {
+ this.getUidPromise();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.cancelCallback`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('cancelCallback')
+ .onClick(() => {
+ this.cancelCallback();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.cancelPromise`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('cancelPromise')
+ .onClick(() => {
+ this.cancelPromise();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.equalCallback`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('equalCallback')
+ .onClick(() => {
+ this.equalCallback();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.equalPromise`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('equalPromise')
+ .onClick(() => {
+ this.equalPromise();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getOperationTypeCallback`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getOperationTypeCallback')
+ .onClick(() => {
+ this.getOperationTypeCallback();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.getOperationTypePromise`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('getOperationTypePromise')
+ .onClick(() => {
+ this.getOperationTypePromise();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+
+ ListItem() {
+ Flex({ justifyContent: FlexAlign.SpaceBetween, alignContent: FlexAlign.Center }) {
+ Text($r(`app.string.trigger`))
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ .margin({
+ top: 17,
+ bottom: 17,
+ left: 12
+ })
+ .fontSize(16)
+ .width('77.87%')
+ .height('39.29%')
+ .fontColor($r('app.color.text_color'))
+ }
+ .id('trigger')
+ .onClick(() => {
+ this.trigger();
+ })
+ }
+ .height('8.45%')
+ .backgroundColor($r('app.color.start_window_background'))
+ .borderRadius(24)
+ .margin({ top: 12, right: 12, left: 12 })
+ }
+ .height('86%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .width('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets
index 57f379afafd78e29bf9929ba5faf57ed2f1db886..9b1882bc130db6a5d1d451809c9b7639a1bc50fe 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit';
-import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { window } from '@kit.ArkUI';
-
-const TAG: string = 'EntryAbility';
-const DOMAIN: number = 0xFF00;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate');
- }
-
- onDestroy(): void {
- hilog.info(DOMAIN, TAG, 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN, TAG, 'Ability onWindowStageCreate');
-
- let windowClass: window.Window | undefined = undefined;
- windowStage.getMainWindow((err: BusinessError, data) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- windowClass = data;
- let systemBarProperties: window.SystemBarProperties = {
- statusBarColor: '#f1f3f5',
- navigationBarColor: '#f1f3f5',
- };
- try {
- windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
- });
- } catch (exception) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
- }
- });
-
- windowStage.loadContent('pages/Index', (err) => {
- if (err.code) {
- hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
- });
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN, TAG, 'Ability onWindowStageDestroy');
- }
-
- onForeground(): void {
- // Ability has brought to foreground
- hilog.info(DOMAIN, TAG, 'Ability onForeground');
- }
-
- onBackground(): void {
- // Ability has back to background
- hilog.info(DOMAIN, TAG, 'Ability onBackground');
- }
-}
+/*
+ * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit';
+import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+const TAG: string = 'EntryAbility';
+const DOMAIN: number = 0xFF00;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(DOMAIN, TAG, 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN, TAG, 'Ability onWindowStageCreate');
+
+ let windowClass: window.Window | undefined = undefined;
+ windowStage.getMainWindow((err: BusinessError, data) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ windowClass = data;
+ let systemBarProperties: window.SystemBarProperties = {
+ statusBarColor: '#f1f3f5',
+ navigationBarColor: '#f1f3f5',
+ };
+ try {
+ windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
+ });
+ } catch (exception) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
+ }
+ });
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN, TAG, 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(DOMAIN, TAG, 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(DOMAIN, TAG, 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index b72fc477d96447e221cf45c9c6671c8018ae05f3..dc55c03d3eea7ce53d5346c732a39ce9bf5267e1 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,12 +1,12 @@
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
-
-export default class EntryBackupAbility extends BackupExtensionAbility {
- async onBackup() {
- hilog.info(0x0000, 'testTag', 'onBackup ok');
- }
-
- async onRestore(bundleVersion: BundleVersion) {
- hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
- }
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5
index f7ffb1e19b00d4a35828f8a673f3ba8b6c429488..b46bb5595a8f18e3aa0abf23ae5f8aa66b755f0e 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/module.json5
@@ -1,87 +1,87 @@
-/*
- * Copyright (c) 2024 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:startIcon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:startIcon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "recoverable": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- },
- {
- "name": "AbilityLifecycleAbility",
- "srcEntry": "./ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:startIcon",
- "label": "$string:EntryAbility_label",
- "recoverable": true,
- "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"
- }
- ]
- },
- ],
- }
+/*
+ * Copyright (c) 2024 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:startIcon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "recoverable": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "AbilityLifecycleAbility",
+ "srcEntry": "./ets/abilitylifecyclecallback/AbilityLifecycleCallback.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:startIcon",
+ "label": "$string:EntryAbility_label",
+ "recoverable": true,
+ "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"
+ }
+ ]
+ },
+ ],
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json
index 73d32c4c75edccd6fab2427bf3977e8bd43a7e90..6cdb3e3002dfe27880828a3b181946668beef78c 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/element/color.json
@@ -1,16 +1,16 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "backGrounding",
- "value": "#f1f3f5"
- },
- {
- "name": "text_color",
- "value": "#182431"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "backGrounding",
+ "value": "#f1f3f5"
+ },
+ {
+ "name": "text_color",
+ "value": "#182431"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json
index d742c2f96e7dd0f406f499941f3147345e998f95..78f40ae7c494d71e2482278f359ec790ca73471a 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/main/resources/base/profile/backup_config.json
@@ -1,3 +1,3 @@
-{
- "allowToBackupRestore": true
+{
+ "allowToBackupRestore": true
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5
index 93f5a2e5d62e1291b55d7da9c6a5d3e424b2301d..556081afc70bbbf25783da08557005cb84a80c85 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/entry/src/ohosTest/module.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2024 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
- }
-}
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5
index ab4cf8bc329595e8f37227a3cb8e175d8f4645b3..3ac9626c8b452bddbb689aaff5ec6cbd4180caf7 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/hvigor/hvigor-config.json5
@@ -1,19 +1,19 @@
-/*
- * Copyright (c) 2024 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": {
- }
+/*
+ * Copyright (c) 2024 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": {
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5 b/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5
index 5d3d2f801cb089d08fb1f3a91bb7fd51d244c08b..4b93216c0453e48ea6e6728e3d962d09e8a11e05 100644
--- a/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5
+++ b/code/BasicFeature/Ability/AbilityRuntime/oh-package.json5
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2024 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"
- }
-}
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/AppScope/app.json5 b/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5
index 036de8101091e501c88e8c1ef276997595681f67..e0633485236121045966166739a42d330593b124 100644
--- a/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5
+++ b/code/BasicFeature/Ability/UniversalLink/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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.example.universallink",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * Copyright (c) 2024 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.example.universallink",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json b/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json
index f9a2f3aa9d1f31c0b66ddfabeaac7769729b5691..c8e33e8783751102f9bf7b274ab5827e27ec933a 100644
--- a/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/Ability/UniversalLink/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "UniversalLink"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "UniversalLink"
+ }
+ ]
+}
diff --git a/code/BasicFeature/Ability/UniversalLink/README_zh.md b/code/BasicFeature/Ability/UniversalLink/README_zh.md
index 6482300789f6f00863260dc15c1e74382c3bb2af..0009ef24e40e74140bc85af931569f34762fa116 100644
--- a/code/BasicFeature/Ability/UniversalLink/README_zh.md
+++ b/code/BasicFeature/Ability/UniversalLink/README_zh.md
@@ -1,66 +1,66 @@
-# 基础能力增强
-
-### 介绍
-
-本示例使用 [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) 接口实现了通过AppLinking启动UIAbility功能。
-
-### 效果预览
-
-| 主页面 | 点击按钮拉起Ability |
-| :----------------------------------------------: | :---------------------------------------------------: |
-|
|
|
-
-### 使用说明
-
-UniversalLink基础能力展示
-
-1.点击主页面**openLink(promise)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功';
-
-2.点击主页面**openLink(callback)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功';
-
-### 工程目录
-
-```
-entry/src/main/ets/
-|---entryability
-| |---EntryAbility.ets // 首页的Ability
-| |---OpenLinkAbility.ets // UIAbility(用于验证UniversalLink功能使用)
-|---pages
-| |---Index.ets // 首页(包含openLink接口的调用)
-| |---UniversalLinkIndex.ets // 被启动的UIAbility的展示页
-```
-
-### 具体实现
-
-* UniversalLink基础能力实现,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets)
-
- * openLink(promise)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能;
- * openLink(callback)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能;
-
-
-### 相关权限
-
-不涉及。
-
-### 依赖
-
-不涉及。
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568;
-
-2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31;
-
-3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行;
-
-### 下载
-
-```shell
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Ability/UniversalLink/ > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
-
+# 基础能力增强
+
+### 介绍
+
+本示例使用 [UIAbilityContext](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-ability-kit/js-apis-inner-application-uiAbilityContext.md) 接口实现了通过AppLinking启动UIAbility功能。
+
+### 效果预览
+
+| 主页面 | 点击按钮拉起Ability |
+| :----------------------------------------------: | :---------------------------------------------------: |
+|
|
|
+
+### 使用说明
+
+UniversalLink基础能力展示
+
+1.点击主页面**openLink(promise)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功';
+
+2.点击主页面**openLink(callback)拉起应用**按钮,拉起新的Ability,页面显示'UniversalLink方式拉起Ability成功';
+
+### 工程目录
+
+```
+entry/src/main/ets/
+|---entryability
+| |---EntryAbility.ets // 首页的Ability
+| |---OpenLinkAbility.ets // UIAbility(用于验证UniversalLink功能使用)
+|---pages
+| |---Index.ets // 首页(包含openLink接口的调用)
+| |---UniversalLinkIndex.ets // 被启动的UIAbility的展示页
+```
+
+### 具体实现
+
+* UniversalLink基础能力实现,源码参考[Index.ets](entry/src/main/ets/pages/Index.ets)
+
+ * openLink(promise)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能;
+ * openLink(callback)接口实现:通过调用context.openLink接口,传入与要拉起的应用相同的配置,实现拉起应用的功能;
+
+
+### 相关权限
+
+不涉及。
+
+### 依赖
+
+不涉及。
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568;
+
+2.本示例为Stage模型,支持API12版本SDK,版本号:5.0.0.31;
+
+3.本示例需要使用DevEco Studio NEXT Developer Beta1 (Build Version: 5.0.3.403, built on June 20, 2024)才可编译运行;
+
+### 下载
+
+```shell
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Ability/UniversalLink/ > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
+
diff --git a/code/BasicFeature/Ability/UniversalLink/build-profile.json5 b/code/BasicFeature/Ability/UniversalLink/build-profile.json5
index f0b12f54c143d8dbc3f7093b44d7591b4c62cbb3..6774a445081b2bb2d3c125696c625a15faf308e0 100644
--- a/code/BasicFeature/Ability/UniversalLink/build-profile.json5
+++ b/code/BasicFeature/Ability/UniversalLink/build-profile.json5
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2024 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": {
- "signingConfigs": [
- ],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compatibleSdkVersion": 12,
- "compileSdkVersion": 12,
- "runtimeOS": "OpenHarmony",
- }
- ],
- "buildModeSet": [
- {
- "name": "debug",
- },
- {
- "name": "release"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2024 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": {
+ "signingConfigs": [
+ ],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compatibleSdkVersion": 12,
+ "compileSdkVersion": 12,
+ "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/BasicFeature/Ability/UniversalLink/entry/build-profile.json5 b/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5
index 97f563b45aac28e7e3ae336f7c0eb06b7b789179..63b88fb1a0053e40acb2391457a7e9d71af748fe 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5
+++ b/code/BasicFeature/Ability/UniversalLink/entry/build-profile.json5
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2024 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",
- }
- ]
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/entry/oh-package.json5 b/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5
index 41a4755f666bbe0bb1a9ebbedd6fb045727e62fb..4e54d14e1b444a338b2c922f94a4fe4deed5be45 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5
+++ b/code/BasicFeature/Ability/UniversalLink/entry/oh-package.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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": {}
-}
-
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets
index 3722d79ef8d33545f91f33f548a48ada9a0c41be..08928746d7d90cb450028ec3a60994017bc32c66 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,88 +1,88 @@
-/*
- * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { window } from '@kit.ArkUI';
-import { BusinessError } from '@kit.BasicServicesKit';
-
-const TAG: string = '[EntryAbility]';
-const DOMAIN: number = 0xFF00;
-
-export default class EntryAbility extends UIAbility {
- onCreate(): void {
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate');
- }
-
- onDestroy(): void {
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate');
-
- let windowClass: window.Window | undefined = undefined;
- windowStage.getMainWindow((err: BusinessError, data) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- windowClass = data;
- let systemBarProperties: window.SystemBarProperties = {
- statusBarColor: '#f1f3f5',
- navigationBarColor: '#f1f3f5',
- };
- try {
- windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
- });
- } catch (exception) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
- }
- });
-
- windowStage.loadContent('pages/Index', (err) => {
- if (err.code) {
- hilog.info(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
- });
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground(): void {
- // Ability has brought to foreground
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground');
- }
-
- onBackground(): void {
- // Ability has back to background
- hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground');
- }
-}
+/*
+ * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+const TAG: string = '[EntryAbility]';
+const DOMAIN: number = 0xFF00;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(): void {
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageCreate');
+
+ let windowClass: window.Window | undefined = undefined;
+ windowStage.getMainWindow((err: BusinessError, data) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ windowClass = data;
+ let systemBarProperties: window.SystemBarProperties = {
+ statusBarColor: '#f1f3f5',
+ navigationBarColor: '#f1f3f5',
+ };
+ try {
+ windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
+ });
+ } catch (exception) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
+ }
+ });
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.info(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(DOMAIN, TAG, '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets
index 08686c38189af1b85f9ce11dc6410f6c73ab5d0f..e836d7f74c05450cd2d33006f7906729881714f0 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entryability/OpenLinkAbility.ets
@@ -1,86 +1,86 @@
-/*
- * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit';
-import { UIAbility } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { window } from '@kit.ArkUI';
-
-const TAG: string = '[OpenLinkAbility]';
-const DOMAIN: number = 0xFF00;
-
-export default class OpenLinkAbility extends UIAbility {
- onCreate(): void {
- hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onCreate');
- }
-
- onForeground() {
- hilog.info(DOMAIN, TAG, `OpenLinkAbility onForeground`);
- }
-
- onBackground() {
- hilog.info(DOMAIN, TAG, `OpenLinkAbility onBackground`);
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onWindowStageCreate');
-
- let windowClass: window.Window | undefined = undefined;
- windowStage.getMainWindow((err: BusinessError, data) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- windowClass = data;
- let systemBarProperties: window.SystemBarProperties = {
- statusBarColor: '#f1f3f5',
- navigationBarColor: '#f1f3f5',
- };
- try {
- windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
- const errCode: number = err.code;
- if (errCode) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
- });
- } catch (exception) {
- hilog.error(DOMAIN, TAG,
- `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
- }
- });
-
- windowStage.loadContent('pages/UniversalLinkIndex', (err) => {
- if (err.code) {
- hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
- });
- }
-
- onDestroy(): void {
- hilog.info(DOMAIN, TAG, 'OpenLinkAbility onDestroy');
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN, TAG, 'OpenLinkAbility onWindowStageDestroy');
- }
+/*
+ * Copyright (c) 2024 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 { BusinessError } from '@kit.BasicServicesKit';
+import { UIAbility } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+const TAG: string = '[OpenLinkAbility]';
+const DOMAIN: number = 0xFF00;
+
+export default class OpenLinkAbility extends UIAbility {
+ onCreate(): void {
+ hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onCreate');
+ }
+
+ onForeground() {
+ hilog.info(DOMAIN, TAG, `OpenLinkAbility onForeground`);
+ }
+
+ onBackground() {
+ hilog.info(DOMAIN, TAG, `OpenLinkAbility onBackground`);
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN, TAG, '%{public}s', 'OpenLinkAbility onWindowStageCreate');
+
+ let windowClass: window.Window | undefined = undefined;
+ windowStage.getMainWindow((err: BusinessError, data) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG, `Failed to obtain the main window. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ windowClass = data;
+ let systemBarProperties: window.SystemBarProperties = {
+ statusBarColor: '#f1f3f5',
+ navigationBarColor: '#f1f3f5',
+ };
+ try {
+ windowClass.setWindowSystemBarProperties(systemBarProperties, (err: BusinessError) => {
+ const errCode: number = err.code;
+ if (errCode) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${err.code}, message: ${err.message}`);
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in setting the system bar properties.');
+ });
+ } catch (exception) {
+ hilog.error(DOMAIN, TAG,
+ `Failed to set the system bar properties. Cause code: ${exception.code}, message: ${exception.message}`);
+ }
+ });
+
+ windowStage.loadContent('pages/UniversalLinkIndex', (err) => {
+ if (err.code) {
+ hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
+ });
+ }
+
+ onDestroy(): void {
+ hilog.info(DOMAIN, TAG, 'OpenLinkAbility onDestroy');
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN, TAG, 'OpenLinkAbility onWindowStageDestroy');
+ }
};
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index b72fc477d96447e221cf45c9c6671c8018ae05f3..dc55c03d3eea7ce53d5346c732a39ce9bf5267e1 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,12 +1,12 @@
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
-
-export default class EntryBackupAbility extends BackupExtensionAbility {
- async onBackup() {
- hilog.info(0x0000, 'testTag', 'onBackup ok');
- }
-
- async onRestore(bundleVersion: BundleVersion) {
- hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
- }
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets
index 6c706d3e123fe9f7897c9eb15c48e95f4efec6f5..b86832a068a4464614ce122ec1a7558113daa512 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/ets/pages/UniversalLinkIndex.ets
@@ -1,38 +1,38 @@
-/*
- * Copyright (c) 2024 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.
- */
-
-@Entry
-@Component
-struct UniversalLinkIndex {
- build() {
- Column() {
- Row() {
- Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
- Text($r('app.string.OpenLinkTitle'))
- .fontSize(30)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- }
- }
- .width('100%')
- .height('80%')
- .justifyContent(FlexAlign.Start)
- .backgroundColor($r('app.color.backGrounding'))
- }
- .width('100%')
- .height('100%')
- .backgroundColor($r('app.color.backGrounding'))
- }
-}
+/*
+ * Copyright (c) 2024 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.
+ */
+
+@Entry
+@Component
+struct UniversalLinkIndex {
+ build() {
+ Column() {
+ Row() {
+ Flex({ justifyContent: FlexAlign.Start, alignContent: FlexAlign.Center }) {
+ Text($r('app.string.OpenLinkTitle'))
+ .fontSize(30)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ }
+ }
+ .width('100%')
+ .height('80%')
+ .justifyContent(FlexAlign.Start)
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor($r('app.color.backGrounding'))
+ }
+}
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5 b/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5
index 5c5e88d321ff3f1df13dae9aa2f867c55b0f19e6..1e83bc34d3caa305360a74494cb356e347128eb2 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/module.json5
@@ -1,97 +1,97 @@
-/*
- * Copyright (c) 2024 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:startIcon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:startIcon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- },
- {
- "name": "OpenLinkAbility",
- "srcEntry": "./ets/entryability/OpenLinkAbility.ets",
- "description": "uri",
- "icon": "$media:layered_image",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:startIcon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "entities": [
- "entity.system.home",
- "entity.system.browsable"
- ],
- "actions": [
- "action.system.home",
- "ohos.want.action.viewData"
- ],
- "uris": [
- {
- // scheme可以自定义
- "scheme": "http",
- // host须配置关联的域名
- "host": "docs.openharmony.cn",
- // path可选,为了避免匹配到多个应用,建议配置该字段
- "path": ""
- }
- ]
- }
- ]
- }
- ],
- "extensionAbilities": [
- {
- "name": "EntryBackupAbility",
- "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
- "type": "backup",
- "exported": false,
- "metadata": [
- {
- "name": "ohos.extension.backup",
- "resource": "$profile:backup_config"
- }
- ]
- }
- ]
- }
+/*
+ * Copyright (c) 2024 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:startIcon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "OpenLinkAbility",
+ "srcEntry": "./ets/entryability/OpenLinkAbility.ets",
+ "description": "uri",
+ "icon": "$media:layered_image",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home",
+ "entity.system.browsable"
+ ],
+ "actions": [
+ "action.system.home",
+ "ohos.want.action.viewData"
+ ],
+ "uris": [
+ {
+ // scheme可以自定义
+ "scheme": "http",
+ // host须配置关联的域名
+ "host": "docs.openharmony.cn",
+ // path可选,为了避免匹配到多个应用,建议配置该字段
+ "path": ""
+ }
+ ]
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "EntryBackupAbility",
+ "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
+ "type": "backup",
+ "exported": false,
+ "metadata": [
+ {
+ "name": "ohos.extension.backup",
+ "resource": "$profile:backup_config"
+ }
+ ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json
index 73d32c4c75edccd6fab2427bf3977e8bd43a7e90..6cdb3e3002dfe27880828a3b181946668beef78c 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/element/color.json
@@ -1,16 +1,16 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "backGrounding",
- "value": "#f1f3f5"
- },
- {
- "name": "text_color",
- "value": "#182431"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "backGrounding",
+ "value": "#f1f3f5"
+ },
+ {
+ "name": "text_color",
+ "value": "#182431"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json
index d742c2f96e7dd0f406f499941f3147345e998f95..78f40ae7c494d71e2482278f359ec790ca73471a 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/main/resources/base/profile/backup_config.json
@@ -1,3 +1,3 @@
-{
- "allowToBackupRestore": true
+{
+ "allowToBackupRestore": true
}
\ No newline at end of file
diff --git a/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5 b/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5
index 1f646ea03f584d15f4a5406ea548af0214a093d4..5f63462032245655b8df990c83c5d7312015c089 100644
--- a/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/Ability/UniversalLink/entry/src/ohosTest/module.json5
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2024 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
- }
-}
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5 b/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5
index 5f9d8a57584fa98d3e8f6c63a304213b801d0dff..76e3231223076011f7f4400f54fa73a5ab0141d4 100644
--- a/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/Ability/UniversalLink/hvigor/hvigor-config.json5
@@ -1,37 +1,37 @@
-/*
- * Copyright (c) 2024 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*/
- }
-}
+/*
+ * Copyright (c) 2024 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/BasicFeature/Ability/UniversalLink/oh-package.json5 b/code/BasicFeature/Ability/UniversalLink/oh-package.json5
index d645a02be51ec3ec6bec2da93c5350d0b80b935f..a941f4458316c00220a8f9a3b0c15342b6b6255b 100644
--- a/code/BasicFeature/Ability/UniversalLink/oh-package.json5
+++ b/code/BasicFeature/Ability/UniversalLink/oh-package.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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"
- }
-}
+/*
+ * Copyright (c) 2024 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/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5
old mode 100755
new mode 100644
index 9933eb9fd509c087acc391262ab33e116c26c7a1..8a01fbc442dcdb3996aa38265a48ee4a0fe3380a
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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.bundlemanagement",
- "vendor": "samples",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * Copyright (c) 2024 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.bundlemanagement",
+ "vendor": "samples",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json
old mode 100755
new mode 100644
index 5987cf90b2d1595accad39e2b15fe3d33ccabc9e..6e551034bff4efca47cfac83c2662cca5d2c5fae
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "bundleManagement"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "bundleManagement"
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/AppScope/resources/base/media/app_icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/README_zh.md
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5
old mode 100755
new mode 100644
index b38a57b1059331878ebb82aec7a79aebb5e5a45a..f2e5bbf7eaabad09449575051cf484543b407ecf
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/build-profile.json5
@@ -1,67 +1,67 @@
-/**
- * Copyright (c) 2024 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": {
- "signingConfigs": [],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compileSdkVersion": 12,
- "compatibleSdkVersion": 12,
- "runtimeOS": "OpenHarmony"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- },
- {
- "name": "libraryOverlay",
- "srcPath": "./libraryOverlay",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- },
- {
- "name": "libraryRuntimeOverlay",
- "srcPath": "./libraryRuntimeOverlay",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
-}
+/**
+ * Copyright (c) 2024 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": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compileSdkVersion": 12,
+ "compatibleSdkVersion": 12,
+ "runtimeOS": "OpenHarmony"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "libraryOverlay",
+ "srcPath": "./libraryOverlay",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "libraryRuntimeOverlay",
+ "srcPath": "./libraryRuntimeOverlay",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5
old mode 100755
new mode 100644
index f6cbf2f1e1662bf11f099bb743387f0eebe953d4..85d986b1fcb577c8016bc56ef1577c4d509626ee
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/build-profile.json5
@@ -1,28 +1,28 @@
-/*
-* Copyright (c) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+* Copyright (c) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/hvigorfile.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5
old mode 100755
new mode 100644
index 57a65bc4999dbe974ae64cf7850f4f6bdf71f74a..bf70bbf4667a5a35c5834f72a76091460f7aacdb
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/oh-package.json5
@@ -1,13 +1,13 @@
-{
- "license": "",
- "devDependencies": {},
- "author": "",
- "name": "entry",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {
- "libraryOverlay": "file:../libraryOverlay",
- "libraryRuntimeOverlay": "file:../libraryRuntimeOverlay"
- }
-}
+{
+ "license": "",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {
+ "libraryOverlay": "file:../libraryOverlay",
+ "libraryRuntimeOverlay": "file:../libraryRuntimeOverlay"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts
old mode 100755
new mode 100644
index 40c6f70ca40e26ca147d61bb324a1b03a9fb6dc7..e4316af59182323c6503a865214d9e14c90b2524
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,80 +1,80 @@
-/*
- * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
-import { window } from '@kit.ArkUI';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-
-const TAG: string = 'entryAbility';
-const DOMAIN_NUMBER: number = 0xFF00;
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate');
- }
-
- onDestroy() {
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
-
- windowStage.getMainWindow((err, data) => {
- if (err.code) {
- hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
- return;
- }
- let windowClass = data;
- hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
-
- let SystemBarProperties = {
- statusBarColor: "#f1f3f5",
- navigationBarColor: "#f1f3f5"
- };
- windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
- if (err) {
- hilog.error(DOMAIN_NUMBER, TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
- return;
- }
- hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in setting the system bar properties.');
- });
- })
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground');
- }
+/*
+ * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
+import { window } from '@kit.ArkUI';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+const TAG: string = 'entryAbility';
+const DOMAIN_NUMBER: number = 0xFF00;
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+
+ windowStage.getMainWindow((err, data) => {
+ if (err.code) {
+ hilog.error(DOMAIN_NUMBER, TAG, 'Failed to obtain the main window. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ let windowClass = data;
+ hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in obtaining the main window. Data: ' + JSON.stringify(data));
+
+ let SystemBarProperties = {
+ statusBarColor: "#f1f3f5",
+ navigationBarColor: "#f1f3f5"
+ };
+ windowClass.setWindowSystemBarProperties(SystemBarProperties, (err) => {
+ if (err) {
+ hilog.error(DOMAIN_NUMBER, TAG, 'Failed to set the system bar properties. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in setting the system bar properties.');
+ });
+ })
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onBackground');
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts
old mode 100755
new mode 100644
index 587e40dce9c69c5403fd8c3f1f86540ab04106b1..3d4d3890460e29e7aeb57a46eb3c766ac27afd6d
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newability/NewAbility.ts
@@ -1,60 +1,60 @@
-/*
- * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
-import { window } from '@kit.ArkUI';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-
-const TAG: string = 'newAbility';
-const DOMAIN_NUMBER: number = 0xFF00;
-
-export default class NewAbility extends UIAbility {
- onCreate(want, launchParam) {
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onCreate');
- }
-
- onDestroy() {
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageCreate');
-
- windowStage.loadContent('pages/NewPage', (err, data) => {
- if (err.code) {
- hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
-
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onBackground');
- }
+/*
+ * Copyright (c) 2024 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 { UIAbility } from '@kit.AbilityKit';
+import { window } from '@kit.ArkUI';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+const TAG: string = 'newAbility';
+const DOMAIN_NUMBER: number = 0xFF00;
+
+export default class NewAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageCreate');
+
+ windowStage.loadContent('pages/NewPage', (err, data) => {
+ if (err.code) {
+ hilog.error(DOMAIN_NUMBER, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(DOMAIN_NUMBER, TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'NewAbility onBackground');
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets
old mode 100755
new mode 100644
index 272295249708067d08d45163c27a53ff39f0d080..c78ee214701d9267e7b68e705610f51b0874bd94
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/newuiextability/NewUIExtAbility.ets
@@ -1,42 +1,42 @@
-/*
- * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit';
-
-export default class NewUIExtAbility extends UIExtensionAbility {
- onCreate() {
- }
-
- onDestroy() {
- }
-
- onSessionCreate(want: Want, session: UIExtensionContentSession) {
- let param: Record = {
- 'session': session,
- 'want': want
- };
-
- let storage: LocalStorage = new LocalStorage(param);
- session.loadContent('pages/NewPage', storage);
- }
-
- onForeground() {
- // Ability has brought to foreground
- }
-
- onBackground() {
- // Ability has back to background
- }
+/*
+ * Copyright (c) 2024 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 { Want, UIExtensionAbility, UIExtensionContentSession } from '@kit.AbilityKit';
+
+export default class NewUIExtAbility extends UIExtensionAbility {
+ onCreate() {
+ }
+
+ onDestroy() {
+ }
+
+ onSessionCreate(want: Want, session: UIExtensionContentSession) {
+ let param: Record = {
+ 'session': session,
+ 'want': want
+ };
+
+ let storage: LocalStorage = new LocalStorage(param);
+ session.loadContent('pages/NewPage', storage);
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ }
+
+ onBackground() {
+ // Ability has back to background
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets
old mode 100755
new mode 100644
index 9cab3d3b3eaf218a666c338ab39846fbb42cd55d..93826059c749c52456087e5f00a4d0fb1d5e32f0
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/ets/pages/NewPage.ets
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-
-const TAG: string = '[Sample_ShortCut]';
-const DOMAIN_NUMBER: number = 0xFF00;
-
-@Entry
-@Component
-struct NewPage {
- private context = getContext(this) as common.UIAbilityContext;
-
- build() {
- Column() {
- Row() {
- Image($r('app.media.ic_back'))
- .size({ width: 20, height: 18 })
- .margin({ right: 18 })
- .onClick(() => {
- this.context.terminateSelf(() => {
- hilog.info(DOMAIN_NUMBER, TAG, 'terminateSelf');
- })
- })
- Text($r('app.string.NewAbility_label'))
- .fontSize(20)
- .fontWeight(FontWeight.Bold)
- }.height(56)
- .padding({ left: 26, right: 26 })
- .width('100%')
-
- Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) {
- Column() {
- Image($r('app.media.pic_empty')).width('33%')
- Text($r('app.string.empty'))
- .fontSize(14)
- }
- }.width('100%')
- .height('90%')
- }
- .width('100%')
- .height('100%')
- .padding({ top: 36, bottom: 0 })
- .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
- }
+/*
+ * Copyright (c) 2024 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 { common } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+
+const TAG: string = '[Sample_ShortCut]';
+const DOMAIN_NUMBER: number = 0xFF00;
+
+@Entry
+@Component
+struct NewPage {
+ private context = getContext(this) as common.UIAbilityContext;
+
+ build() {
+ Column() {
+ Row() {
+ Image($r('app.media.ic_back'))
+ .size({ width: 20, height: 18 })
+ .margin({ right: 18 })
+ .onClick(() => {
+ this.context.terminateSelf(() => {
+ hilog.info(DOMAIN_NUMBER, TAG, 'terminateSelf');
+ })
+ })
+ Text($r('app.string.NewAbility_label'))
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }.height(56)
+ .padding({ left: 26, right: 26 })
+ .width('100%')
+
+ Flex({ justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center, alignContent: FlexAlign.Center }) {
+ Column() {
+ Image($r('app.media.pic_empty')).width('33%')
+ Text($r('app.string.empty'))
+ .fontSize(14)
+ }
+ }.width('100%')
+ .height('90%')
+ }
+ .width('100%')
+ .height('100%')
+ .padding({ top: 36, bottom: 0 })
+ .backgroundColor($r('sys.color.ohos_id_color_text_field_sub_bg'))
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5
old mode 100755
new mode 100644
index cc8bd34fc23790183865833c8980ab8436210035..b6e22c8236b255d587bab862ebdd30313a9e41ad
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/module.json5
@@ -1,102 +1,102 @@
-/*
- * Copyright (c) 2024 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.ts",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ],
- "uris": [
- {
- "scheme": "http"
- }
- ]
- }
- ],
- "metadata": [
- {
- "name": "ohos.ability.shortcuts",
- "resource": "$profile:shortcuts_config"
- }
- ]
- },
- {
- "name": "NewAbility",
- "srcEntry": "./ets/newability/NewAbility.ts",
- "description": "$string:NewAbility_desc",
- "icon": "$media:icon",
- "label": "$string:NewAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "metadata": [
- {
- "name": "ohos.ability.NewAbility",
- "resource": "$profile:shortcuts_config"
- }
- ]
- }
- ],
- "extensionAbilities": [
- {
- "name": "NewUIExtAbility",
- "icon": "$media:icon",
- "description": "NewUIExtAbility",
- "exported": true,
- "type": "sysPicker/share",
- "srcEntry": "./ets/newuiextability/NewUIExtAbility.ets",
- "metadata": [
- {
- "name": "ohos.ability.NewUIExtAbility",
- "resource": "$profile:shortcuts_config"
- }
- ]
- }
- ],
- "requestPermissions": [
- {
- "name": "ohos.permission.RUN_DYN_CODE",
- }
- ],
- "querySchemes": [
- "http"
- ]
- }
+/*
+ * Copyright (c) 2024 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.ts",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ],
+ "uris": [
+ {
+ "scheme": "http"
+ }
+ ]
+ }
+ ],
+ "metadata": [
+ {
+ "name": "ohos.ability.shortcuts",
+ "resource": "$profile:shortcuts_config"
+ }
+ ]
+ },
+ {
+ "name": "NewAbility",
+ "srcEntry": "./ets/newability/NewAbility.ts",
+ "description": "$string:NewAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:NewAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "metadata": [
+ {
+ "name": "ohos.ability.NewAbility",
+ "resource": "$profile:shortcuts_config"
+ }
+ ]
+ }
+ ],
+ "extensionAbilities": [
+ {
+ "name": "NewUIExtAbility",
+ "icon": "$media:icon",
+ "description": "NewUIExtAbility",
+ "exported": true,
+ "type": "sysPicker/share",
+ "srcEntry": "./ets/newuiextability/NewUIExtAbility.ets",
+ "metadata": [
+ {
+ "name": "ohos.ability.NewUIExtAbility",
+ "resource": "$profile:shortcuts_config"
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.RUN_DYN_CODE",
+ }
+ ],
+ "querySchemes": [
+ "http"
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json
old mode 100755
new mode 100644
index 397f3ddb2b31d903d416d57db6b3d620d7ee0246..8fe12b6f07e4a587f7b61e7622c8366f7854bed4
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/color.json
@@ -1,20 +1,20 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "button_color",
- "value": "#027DFF"
- },
- {
- "name": "backGrounding",
- "value": "#f1f3f5"
- },
- {
- "name": "text_color",
- "value": "#000"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "button_color",
+ "value": "#027DFF"
+ },
+ {
+ "name": "backGrounding",
+ "value": "#f1f3f5"
+ },
+ {
+ "name": "text_color",
+ "value": "#000"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/ic_back.svg
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/media/pic_empty.svg
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/main_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/shortcuts_config.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/base/profile/shortcuts_config.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/en_US/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/main/resources/zh_CN/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/Ability.test.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/test/List.test.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/TestAbility.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testability/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5
old mode 100755
new mode 100644
index 0ea2ffbd558bdf27353ca4579aef9823fee5c79d..91e15a07aef33644652ef6c612dfe7d0c8c41c40
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/module.json5
@@ -1,52 +1,52 @@
-/*
-* Copyright (c) 2024 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntry": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "exported": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
+/*
+* Copyright (c) 2024 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/color.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/base/profile/test_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/en_US/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/entry/src/ohosTest/resources/zh_CN/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5
old mode 100755
new mode 100644
index fb29482d10a201e0e40fc37b3f492317c45910c5..9a7908507630143024c38e9f282d4d3cd05ef126
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-config.json5
@@ -1,21 +1,21 @@
-/*
- * Copyright (c) 2024 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.
- */
-
-{
- "hvigorVersion": "4.0.2",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "4.0.2"
- }
+/*
+ * Copyright (c) 2024 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.
+ */
+
+{
+ "hvigorVersion": "4.0.2",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "4.0.2"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-wrapper.js b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigor/hvigor-wrapper.js
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorfile.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw.bat b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/hvigorw.bat
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5
old mode 100755
new mode 100644
index 28dd9a05d1e3c7b10ee44bcb97cfc9554aa2cf97..26d4447c1161fb39d6eeaa1da5e7eb4e07974040
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/build-profile.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- }
- ]
+/*
+ * Copyright (c) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/hvigorfile.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5
old mode 100755
new mode 100644
index 2c177c4b11f80e383029b82f9cdb3b3dd019cfd8..8921a9e7f61193863f3bd3128c02b902414de887
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/oh-package.json5
@@ -1,10 +1,10 @@
-{
- "license": "Apache-2.0",
- "devDependencies": {},
- "author": "",
- "name": "libraryOverlay",
- "description": "Please describe the basic information.",
- "main": "./src/main/ets/Index.ets",
- "version": "1.0.0",
- "dependencies": {}
-}
+{
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "author": "",
+ "name": "libraryOverlay",
+ "description": "Please describe the basic information.",
+ "main": "./src/main/ets/Index.ets",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets
old mode 100755
new mode 100644
index ac3645ba793388b3bff3e02ebe9005d557fd9f72..8facc0b5e707c9d1b5f08c5fac5f7698a6b098f3
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/Index.ets
@@ -1,16 +1,16 @@
-/*
- * Copyright (c) 2024 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.
- */
-
+/*
+ * Copyright (c) 2024 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 { add } from './utils/Calc'
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/utils/Calc.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/ets/utils/Calc.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5
old mode 100755
new mode 100644
index 35e810f31bda428e9856325e85b036da151daa84..e576fbd6bd7423adf051a3963a128e9d262f97eb
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/module.json5
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2024 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": "libraryOverlay",
- "type": "shared",
- "description": "$string:shared_desc",
- "targetModuleName":"entry",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "pages": "$profile:main_pages"
- }
+/*
+ * Copyright (c) 2024 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": "libraryOverlay",
+ "type": "shared",
+ "description": "$string:shared_desc",
+ "targetModuleName":"entry",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "pages": "$profile:main_pages"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/color.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json
old mode 100755
new mode 100644
index 8ff4fc989c899f0db87436de16a37ef3f60072c9..e5e5574f732b85e60e36335fcc849273953e1c7e
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/element/string.json
@@ -1,12 +1,12 @@
-{
- "string": [
- {
- "name": "shared_desc",
- "value": "description"
- },
- {
- "name": "test_string",
- "value": "base_overlay_test"
- }
- ]
+{
+ "string": [
+ {
+ "name": "shared_desc",
+ "value": "description"
+ },
+ {
+ "name": "test_string",
+ "value": "base_overlay_test"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/media/setting.jpeg
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/base/profile/main_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/en_US/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryOverlay/src/main/resources/zh_CN/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5
old mode 100755
new mode 100644
index 28dd9a05d1e3c7b10ee44bcb97cfc9554aa2cf97..26d4447c1161fb39d6eeaa1da5e7eb4e07974040
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/build-profile.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- }
- ]
+/*
+ * Copyright (c) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/hvigorfile.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/hvigorfile.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5
old mode 100755
new mode 100644
index 52496b1d38c98b74a28f11ecce8e0398ea1aaaf3..fff6109ffbb636629f85b13edf4aed7296f1f31e
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/oh-package.json5
@@ -1,10 +1,10 @@
-{
- "license": "Apache-2.0",
- "devDependencies": {},
- "author": "",
- "name": "libraryRuntimeOverlay",
- "description": "Please describe the basic information.",
- "main": "./src/main/ets/Index.ets",
- "version": "1.0.0",
- "dependencies": {}
-}
+{
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "author": "",
+ "name": "libraryRuntimeOverlay",
+ "description": "Please describe the basic information.",
+ "main": "./src/main/ets/Index.ets",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets
old mode 100755
new mode 100644
index ac3645ba793388b3bff3e02ebe9005d557fd9f72..8facc0b5e707c9d1b5f08c5fac5f7698a6b098f3
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/Index.ets
@@ -1,16 +1,16 @@
-/*
- * Copyright (c) 2024 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.
- */
-
+/*
+ * Copyright (c) 2024 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 { add } from './utils/Calc'
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/pages/Index.ets b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/utils/Calc.ts b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/ets/utils/Calc.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5
old mode 100755
new mode 100644
index b43187367782c38be6e908fcad95743e81bc545f..f110da50736c0ddd7fa5b97534562808fabbfe97
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/module.json5
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2024 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": "libraryRuntimeOverlay",
- "type": "shared",
- "description": "$string:shared_desc",
- "targetModuleName":"entry",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "pages": "$profile:main_pages"
- }
+/*
+ * Copyright (c) 2024 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": "libraryRuntimeOverlay",
+ "type": "shared",
+ "description": "$string:shared_desc",
+ "targetModuleName":"entry",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "pages": "$profile:main_pages"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/color.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json
old mode 100755
new mode 100644
index 6175c8ac06a81be44a917fe60af4e712715309f3..999663191370eba1f0ce98b600336e16bbe83eaa
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/element/string.json
@@ -1,12 +1,12 @@
-{
- "string": [
- {
- "name": "shared_desc",
- "value": "description"
- },
- {
- "name": "test_string",
- "value": "en_US_overlay_RUNTIME"
- }
- ]
+{
+ "string": [
+ {
+ "name": "shared_desc",
+ "value": "description"
+ },
+ {
+ "name": "test_string",
+ "value": "en_US_overlay_RUNTIME"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/media/setting.jpeg
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/base/profile/main_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/en_US/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/en_US/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/libraryRuntimeOverlay/src/main/resources/zh_CN/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5 b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5
old mode 100755
new mode 100644
index 5092a626e51126911ca564a804eefcabe4583ad0..6faa9e99fcf33988268cb08b749a31f0a5f26043
--- a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/oh-package.json5
@@ -1,12 +1,12 @@
-{
- "license": "",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "author": "",
- "name": "shortcut",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+{
+ "license": "",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "author": "",
+ "name": "shortcut",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ohosTest.md b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/ohosTest.md
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/Scene-directory.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png b/code/BasicFeature/ApplicationModels/BundleManager/BundleManagement/sceenshots/device/snapshot_directory.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5
index 375c5a9b4b0aa4e25dab9f3cf874067afe9d74d6..615d9c69bc5e83bd8ad2e1bc82f91fb9a0e32c02 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/app.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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.navigation",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+* Copyright (C) 2024 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.navigation",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json
index f2fd092934af1e589c8767bd12ee162272ac12e4..03ada0a8e4aaf97e7e46249cd02c9bc407d865fe 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "Navigation"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "Navigation"
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md b/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md
index e149ceff523a61be6abf51de6501c4aa86a47f9a..2e2b728c43a9c7fe186649368426b6aabeba380b 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/README_zh.md
@@ -1,86 +1,86 @@
-# Navigation动态路由
-
-### 介绍
-
-本项目提供动态路由的验证,运用了WrapperBuilder的自定义函数打包能力,以及动态路由的跨模块文件引用的能力,解除了har包和hap包的依赖关系,实现了
-即使hap包不引用har包,依然能跳转到har包中的页面的能力
-目前还不支持动态import变量表达式和跨模块相对路径的文件,所以代码中使用switch作为替代,若后续版本支持,会出相应的补丁
-由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写
-
-### 效果预览
-
-
-
-
-使用说明
-
-1. 主页会提供一个NavIndex的导航页,点击按钮会跳转到不同的来自har包的页面
-
-2. 每个har包的页面也存在跳转到别的页面的按钮
-
-### 工程目录
-
-```
-.
-├── entry // 主页面
-│ ├── pages
-│ │ ├── Index.ets
-│ ├── entryability
-│ │ ├── EntryAbility.ets
-├── harA
-│ ├── pages
-│ │ ├── page1.ets
-│ │ ├── page2.ets
-│ │ ├── page3.ets
-│ ├── entryability
-│ │ ├── EntryAbility.ets
-├── harB
-│ ├── pages
-│ │ ├── page1.ets
-│ │ ├── page2.ets
-│ │ ├── page3.ets
-│ ├── entryability
-│ │ ├── EntryAbility.ets
-├── RouterModule
-│ ├── utils
-│ │ ├── RouterModule.ets
-│ ├── entryability
-│ │ ├── EntryAbility.ets
-.
-```
-
-### 具体实现
-
-1.创建hapA harA harB
-
-2.创建路由框架RouterModule,使用map存储hap包的路由和har包的页面信息
-
-3.在RouterModule中封装get和set方法,并对外开放,允许外部模块引用和调用
-
-4.创建push方法,允许传入一串url,并对其进行解析,通过拆解出路由名称从map中获取到路由栈,并将目标页面压栈
-
-5.在hap和har包中引入RouterModule,将hap包的路由栈和har包的页面信息通过开放的set方法存入RouterModule
-
-### 相关权限
-
-不涉及
-
-### 约束与限制
-
-1. 本示例仅支持标准系统上运行,支持设备:RK3568。
-
-2. 本示例需要使用DevEco Studio 版本号(Build Version: 4.1.1.500, built on January 21, 2024)及以上版本才可编译运行。
-
-3. 本示例为Stage模型,支持API11版本SDK,SDK版本号(4.1.6.3以上),镜像版本号(4.1.6.3以上)。
-
-### 下载
-
-如需单独下载本工程,执行如下命令:
-
-```
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/ApplicationModels/DynamicRouter > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
+# Navigation动态路由
+
+### 介绍
+
+本项目提供动态路由的验证,运用了WrapperBuilder的自定义函数打包能力,以及动态路由的跨模块文件引用的能力,解除了har包和hap包的依赖关系,实现了
+即使hap包不引用har包,依然能跳转到har包中的页面的能力
+目前还不支持动态import变量表达式和跨模块相对路径的文件,所以代码中使用switch作为替代,若后续版本支持,会出相应的补丁
+由于环境的差异,不建议下载后直接编译,应先当创建项目,参考示例代码进行编写
+
+### 效果预览
+
+
+
+
+使用说明
+
+1. 主页会提供一个NavIndex的导航页,点击按钮会跳转到不同的来自har包的页面
+
+2. 每个har包的页面也存在跳转到别的页面的按钮
+
+### 工程目录
+
+```
+.
+├── entry // 主页面
+│ ├── pages
+│ │ ├── Index.ets
+│ ├── entryability
+│ │ ├── EntryAbility.ets
+├── harA
+│ ├── pages
+│ │ ├── page1.ets
+│ │ ├── page2.ets
+│ │ ├── page3.ets
+│ ├── entryability
+│ │ ├── EntryAbility.ets
+├── harB
+│ ├── pages
+│ │ ├── page1.ets
+│ │ ├── page2.ets
+│ │ ├── page3.ets
+│ ├── entryability
+│ │ ├── EntryAbility.ets
+├── RouterModule
+│ ├── utils
+│ │ ├── RouterModule.ets
+│ ├── entryability
+│ │ ├── EntryAbility.ets
+.
+```
+
+### 具体实现
+
+1.创建hapA harA harB
+
+2.创建路由框架RouterModule,使用map存储hap包的路由和har包的页面信息
+
+3.在RouterModule中封装get和set方法,并对外开放,允许外部模块引用和调用
+
+4.创建push方法,允许传入一串url,并对其进行解析,通过拆解出路由名称从map中获取到路由栈,并将目标页面压栈
+
+5.在hap和har包中引入RouterModule,将hap包的路由栈和har包的页面信息通过开放的set方法存入RouterModule
+
+### 相关权限
+
+不涉及
+
+### 约束与限制
+
+1. 本示例仅支持标准系统上运行,支持设备:RK3568。
+
+2. 本示例需要使用DevEco Studio 版本号(Build Version: 4.1.1.500, built on January 21, 2024)及以上版本才可编译运行。
+
+3. 本示例为Stage模型,支持API11版本SDK,SDK版本号(4.1.6.3以上),镜像版本号(4.1.6.3以上)。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/ApplicationModels/DynamicRouter > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets
index f5920d2bb661095ed236416c4940d123b8fcd962..e1547ce35a4e8ca1e5529affeab25c557f69b9de 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/Index.ets
@@ -1,14 +1,14 @@
-/*
-* Copyright (C) 2024 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.
-*/
+/*
+* Copyright (C) 2024 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.
+*/
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5
index ac6f2b3a182125d02ee6857a13d3954859665255..6a291812425481b231600ab8a2be2cbd37d333a0 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/build-profile.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- }
- ]
-}
+/*
+* Copyright (C) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5
index 1be403cb8b384ab001edf0714ac0003acd32a765..e71c1f8b1f29b1c2b1bd90cca7a8d9bca27ab789 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/oh-package.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "license": "Apache-2.0",
- "devDependencies": {},
- "author": "",
- "name": "routermodule",
- "description": "Please describe the basic information.",
- "main": "Index.ets",
- "version": "1.0.0",
- "dependencies": {}
-}
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "author": "",
+ "name": "routermodule",
+ "description": "Please describe the basic information.",
+ "main": "Index.ets",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets
index a6c3b72b49670045c874b047c4b0d254978201d8..5c2269bf6346ed64d70da0fc7e9a49aaa74a2899 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/ets/utils/RouterModule.ets
@@ -1,72 +1,72 @@
-/*
-* Copyright (C) 2024 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 class RouterModule {
- static builderMap: Map> = new Map>();
- static routerMap: Map = new Map();
-
- // 通过名称注册builder
- public static registerBuilder(builderName: string, builder: WrappedBuilder<[object]>): void{
- RouterModule.builderMap.set(builderName, builder);
- }
-
- // 通过名称获取builder
- public static getBuilder(builderName: string): WrappedBuilder<[object]>{
- let builder = RouterModule.builderMap.get(builderName);
- return builder as WrappedBuilder<[object]>;
- }
-
- // 通过名称注册router
- public static createRouter(routerName: string, router: NavPathStack): void{
- RouterModule.routerMap.set(routerName, router);
- }
-
- // 通过名称获取router
- public static getRouter(routerName: string): NavPathStack{
- let router = RouterModule.routerMap.get(routerName);
- return router as NavPathStack;
- }
-
- // 通过获取页面栈跳转到指定页面
- public static async push(url: string): Promise{
- // 分解url
- // 获取包名、路由名、页面名
- let params = url.split("/");
- const harName = params[0];
- let context = params[params.length - 1].split("-");
- const routerName = context[0];
- const builderName = context[1];
- // 获取路径
- let path = ".";
- for (let i = 1; i < params.length - 1; i++) {
- path += "/" + params[i];
- }
- // 动态引入要跳转的页面
- let ns: ESObject = await import(harName);
- ns.harInit(path);
- RouterModule.getRouter(routerName).pushPathByName(builderName, null);
- }
-
- // 通过获取页面栈并pop
- public static pop(routerName: string): void {
- // 查找到对应的路由栈进行pop
- RouterModule.getRouter(routerName).pop();
- }
-
- // 通过获取页面栈并将其清空
- public static clear(routerName: string): void {
- // 查找到对应的路由栈进行pop
- RouterModule.getRouter(routerName).clear();
- }
-}
+/*
+* Copyright (C) 2024 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 class RouterModule {
+ static builderMap: Map> = new Map>();
+ static routerMap: Map = new Map();
+
+ // 通过名称注册builder
+ public static registerBuilder(builderName: string, builder: WrappedBuilder<[object]>): void{
+ RouterModule.builderMap.set(builderName, builder);
+ }
+
+ // 通过名称获取builder
+ public static getBuilder(builderName: string): WrappedBuilder<[object]>{
+ let builder = RouterModule.builderMap.get(builderName);
+ return builder as WrappedBuilder<[object]>;
+ }
+
+ // 通过名称注册router
+ public static createRouter(routerName: string, router: NavPathStack): void{
+ RouterModule.routerMap.set(routerName, router);
+ }
+
+ // 通过名称获取router
+ public static getRouter(routerName: string): NavPathStack{
+ let router = RouterModule.routerMap.get(routerName);
+ return router as NavPathStack;
+ }
+
+ // 通过获取页面栈跳转到指定页面
+ public static async push(url: string): Promise{
+ // 分解url
+ // 获取包名、路由名、页面名
+ let params = url.split("/");
+ const harName = params[0];
+ let context = params[params.length - 1].split("-");
+ const routerName = context[0];
+ const builderName = context[1];
+ // 获取路径
+ let path = ".";
+ for (let i = 1; i < params.length - 1; i++) {
+ path += "/" + params[i];
+ }
+ // 动态引入要跳转的页面
+ let ns: ESObject = await import(harName);
+ ns.harInit(path);
+ RouterModule.getRouter(routerName).pushPathByName(builderName, null);
+ }
+
+ // 通过获取页面栈并pop
+ public static pop(routerName: string): void {
+ // 查找到对应的路由栈进行pop
+ RouterModule.getRouter(routerName).pop();
+ }
+
+ // 通过获取页面栈并将其清空
+ public static clear(routerName: string): void {
+ // 查找到对应的路由栈进行pop
+ RouterModule.getRouter(routerName).clear();
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5
index 8d6911a8ce26188348e77371fc73ae7ee39ca78f..e72c17c68e850608af5b3fd46303c17ff21bd19d 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/RouterModule/src/main/module.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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": "RouterModule",
- "type": "har",
- "deviceTypes": [
- "default",
- "tablet"
- ]
- }
+/*
+* Copyright (C) 2024 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": "RouterModule",
+ "type": "har",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5
index 774f06a9c7f48b5803feade5def0d8d06a0104c3..08a3adf541e9f79f99f6d0c162b30cb5f49b8ac7 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/build-profile.json5
@@ -1,53 +1,53 @@
-/*
-* Copyright (C) 2024 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",
- "runtimeOS": "OpenHarmony",
- "compileSdkVersion": 11,
- "compatibleSdkVersion": 11
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- },
- {
- "name": "harA",
- "srcPath": "./harA"
- },
- {
- "name": "harB",
- "srcPath": "./harB"
- },
- {
- "name": "RouterModule",
- "srcPath": "./RouterModule"
- }
- ]
+/*
+* Copyright (C) 2024 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",
+ "runtimeOS": "OpenHarmony",
+ "compileSdkVersion": 11,
+ "compatibleSdkVersion": 11
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "harA",
+ "srcPath": "./harA"
+ },
+ {
+ "name": "harB",
+ "srcPath": "./harB"
+ },
+ {
+ "name": "RouterModule",
+ "srcPath": "./RouterModule"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5
index 8a11f781240548477f6af2699554a3f080d3138a..5afd0f621bd261dbad47f74479f98d1063cfc5cf 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/build-profile.json5
@@ -1,37 +1,37 @@
-/*
-* Copyright (C) 2024 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": {
- "arkOptions": {
- "runtimeOnly": {
- "sources": [
- ],
- "packages": [
- "HarA",
- "HarB"
- ]
- }
- }
- },
- "targets": [
- {
- "name": "default"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+* Copyright (C) 2024 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": {
+ "arkOptions": {
+ "runtimeOnly": {
+ "sources": [
+ ],
+ "packages": [
+ "HarA",
+ "HarB"
+ ]
+ }
+ }
+ },
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5
index 6262463277d0b0ac008930edec242f86180d204a..4413194cad1a21d3fb9b3ce8d88227844da7999d 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package-lock.json5
@@ -1,43 +1,43 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "lockfileVersion": 3,
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
- "specifiers": {
- "HarB@../harB": "HarB@../harB",
- "RouterModule@../RouterModule": "RouterModule@../RouterModule",
- "HarA@../harA": "HarA@../harA"
- },
- "packages": {
- "HarB@../harB": {
- "mtime": "1707210920658.4658",
- "resolved": "../harB",
- "dependencies": {
- "RouterModule": "file:../RouterModule"
- }
- },
- "RouterModule@../RouterModule": {
- "mtime": "1707210724992.75",
- "resolved": "../RouterModule"
- },
- "HarA@../harA": {
- "mtime": "1707210916733.4844",
- "resolved": "../harA",
- "dependencies": {
- "RouterModule": "file:../RouterModule"
- }
- }
- }
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "lockfileVersion": 3,
+ "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
+ "specifiers": {
+ "HarB@../harB": "HarB@../harB",
+ "RouterModule@../RouterModule": "RouterModule@../RouterModule",
+ "HarA@../harA": "HarA@../harA"
+ },
+ "packages": {
+ "HarB@../harB": {
+ "mtime": "1707210920658.4658",
+ "resolved": "../harB",
+ "dependencies": {
+ "RouterModule": "file:../RouterModule"
+ }
+ },
+ "RouterModule@../RouterModule": {
+ "mtime": "1707210724992.75",
+ "resolved": "../RouterModule"
+ },
+ "HarA@../harA": {
+ "mtime": "1707210916733.4844",
+ "resolved": "../harA",
+ "dependencies": {
+ "RouterModule": "file:../RouterModule"
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5
index 73a404a398a60d2b720b130a8de410007436038d..f95a2f9fba096ec94fb08cbd532feb34ff048d46 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/oh-package.json5
@@ -1,28 +1,28 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "license": "",
- "devDependencies": {},
- "author": "",
- "name": "entry",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {
- "RouterModule": "file:../RouterModule",
- "HarA": "file:../harA",
- "HarB": "file:../harB"
- }
-}
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "license": "",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {
+ "RouterModule": "file:../RouterModule",
+ "HarA": "file:../harA",
+ "HarB": "file:../harB"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts
index 42252a5bd21b40fcb14f7df4c558815b2e9402e2..0037532ae8024301130767e18d7517fbfe970f67 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,57 +1,57 @@
-/*
-* Copyright (C) 2024 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 from '@ohos.app.ability.AbilityConstant';
-import hilog from '@ohos.hilog';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import Want from '@ohos.app.ability.Want';
-import window from '@ohos.window';
-
-export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy(): void {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground(): void {
- // Ability has brought to foreground
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground(): void {
- // Ability has back to background
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
- }
-}
+/*
+* Copyright (C) 2024 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 from '@ohos.app.ability.AbilityConstant';
+import hilog from '@ohos.hilog';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import Want from '@ohos.app.ability.Want';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5
index 89ec46f0396c816c680631e7e517e4bc311e99af..11e428235ec35a98e7c0a5a25f89e5165ab2448a 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/module.json5
@@ -1,51 +1,51 @@
-/*
-* Copyright (C) 2024 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.ts",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:startIcon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- }
- ]
- }
+/*
+* Copyright (C) 2024 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.ts",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:startIcon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json
index d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/main/resources/base/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5
index 7c9a2ac3fb02ac14c1a58fbd6e231cc1621b11fd..4a6cc8c2ccb76abaaca6a9ed7908623ca9b2fc67 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/entry/src/ohosTest/module.json5
@@ -1,51 +1,51 @@
-/*
-* Copyright (C) 2024 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntry": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "exported": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
-}
+/*
+* Copyright (C) 2024 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets
index b739b34f383cbe6fcb9745c0e25d155021e9d7d9..e68e860c43a562a96f60d07676aca24c431acf5b 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/Index.ets
@@ -1,30 +1,30 @@
-/*
-* Copyright (C) 2024 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 function harInit(path: string): void{
- // 动态引入要跳转的页面
- switch (path) {
- case "./src/main/ets/components/mainpage/page1":
- import("./src/main/ets/components/mainpage/page1");
- break;
- case "./src/main/ets/components/mainpage/page2":
- import("./src/main/ets/components/mainpage/page2");
- break;
- case "./src/main/ets/components/mainpage/page3":
- import("./src/main/ets/components/mainpage/page3");
- break;
- default:
- break;
- }
-}
+/*
+* Copyright (C) 2024 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 function harInit(path: string): void{
+ // 动态引入要跳转的页面
+ switch (path) {
+ case "./src/main/ets/components/mainpage/page1":
+ import("./src/main/ets/components/mainpage/page1");
+ break;
+ case "./src/main/ets/components/mainpage/page2":
+ import("./src/main/ets/components/mainpage/page2");
+ break;
+ case "./src/main/ets/components/mainpage/page3":
+ import("./src/main/ets/components/mainpage/page3");
+ break;
+ default:
+ break;
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5
index ac6f2b3a182125d02ee6857a13d3954859665255..6a291812425481b231600ab8a2be2cbd37d333a0 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/build-profile.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- }
- ]
-}
+/*
+* Copyright (C) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5
index 595baf01e17b56a3be982a651d9532cc4bdfe8d0..4d162199c600fe61542078e84876d46d3f7b6fe4 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package-lock.json5
@@ -1,27 +1,27 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "lockfileVersion": 3,
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
- "specifiers": {
- "RouterModule@../RouterModule": "RouterModule@../RouterModule"
- },
- "packages": {
- "RouterModule@../RouterModule": {
- "mtime": "1707210724992.75",
- "resolved": "../RouterModule"
- }
- }
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "lockfileVersion": 3,
+ "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
+ "specifiers": {
+ "RouterModule@../RouterModule": "RouterModule@../RouterModule"
+ },
+ "packages": {
+ "RouterModule@../RouterModule": {
+ "mtime": "1707210724992.75",
+ "resolved": "../RouterModule"
+ }
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5
index 84ed860c140fd455bc3d3ed19bbe4f84d9d3518f..2f818abe093b750be4d97bde8dc1bd8125cffc90 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/oh-package.json5
@@ -1,26 +1,26 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "license": "Apache-2.0",
- "devDependencies": {},
- "author": "",
- "name": "hara",
- "description": "Please describe the basic information.",
- "main": "Index.ets",
- "version": "1.0.0",
- "dependencies": {
- "RouterModule": "file:../RouterModule"
- }
-}
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "author": "",
+ "name": "hara",
+ "description": "Please describe the basic information.",
+ "main": "Index.ets",
+ "version": "1.0.0",
+ "dependencies": {
+ "RouterModule": "file:../RouterModule"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets
index 2ceb4ad898fddf6d1632fa3f80b3b8171ab4637e..8b117082b476ed45903ffcfed317486e8b6f0579 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page1.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarA_Page1')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarA_Page1_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
-}
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarA_Page1')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarA_Page1_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets
index 30ab96b16172cc61e2a2374c13b42168b7b5cddc..047e4ba416b1feec0738b2f644629bb873824e47 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page2.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarA_Page2')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarA_Page2_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarA_Page2')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarA_Page2_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets
index 2fbd970720bfe029a18aa796f8a4da9a29a4ce38..eb1adce692cafe72cab74f01fa1b14042edbe611 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/ets/components/mainpage/page3.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarA_Page3')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarA_Page3_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_harb_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page1/HapA_Router-HarB_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page2/HapA_Router-HarB_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_harb_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarB/src/main/ets/components/mainpage/page3/HapA_Router-HarB_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarA_Page3')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarA_Page3_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5
index a0c6877ad90c19e1cdad51929647b38bddc98046..5d4200318679b26de5a82c5545f4dd6cb469a7e3 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harA/src/main/module.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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": "harA",
- "type": "har",
- "deviceTypes": [
- "default",
- "tablet"
- ]
- }
-}
+/*
+* Copyright (C) 2024 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": "harA",
+ "type": "har",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ]
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets
index b739b34f383cbe6fcb9745c0e25d155021e9d7d9..e68e860c43a562a96f60d07676aca24c431acf5b 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/Index.ets
@@ -1,30 +1,30 @@
-/*
-* Copyright (C) 2024 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 function harInit(path: string): void{
- // 动态引入要跳转的页面
- switch (path) {
- case "./src/main/ets/components/mainpage/page1":
- import("./src/main/ets/components/mainpage/page1");
- break;
- case "./src/main/ets/components/mainpage/page2":
- import("./src/main/ets/components/mainpage/page2");
- break;
- case "./src/main/ets/components/mainpage/page3":
- import("./src/main/ets/components/mainpage/page3");
- break;
- default:
- break;
- }
-}
+/*
+* Copyright (C) 2024 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 function harInit(path: string): void{
+ // 动态引入要跳转的页面
+ switch (path) {
+ case "./src/main/ets/components/mainpage/page1":
+ import("./src/main/ets/components/mainpage/page1");
+ break;
+ case "./src/main/ets/components/mainpage/page2":
+ import("./src/main/ets/components/mainpage/page2");
+ break;
+ case "./src/main/ets/components/mainpage/page3":
+ import("./src/main/ets/components/mainpage/page3");
+ break;
+ default:
+ break;
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5
index 2783f9a949c5ed6037669e607c3356d682d4566f..c776629856763c44cb9db724bdfea7e24d46bdc0 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/build-profile.json5
@@ -1,25 +1,25 @@
-/*
-* Copyright (C) 2024 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": {
- },
- "targets": [
- {
- "name": "default"
- }
- ]
-}
+/*
+* Copyright (C) 2024 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": {
+ },
+ "targets": [
+ {
+ "name": "default"
+ }
+ ]
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5
index 595baf01e17b56a3be982a651d9532cc4bdfe8d0..4d162199c600fe61542078e84876d46d3f7b6fe4 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package-lock.json5
@@ -1,27 +1,27 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "lockfileVersion": 3,
- "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
- "specifiers": {
- "RouterModule@../RouterModule": "RouterModule@../RouterModule"
- },
- "packages": {
- "RouterModule@../RouterModule": {
- "mtime": "1707210724992.75",
- "resolved": "../RouterModule"
- }
- }
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "lockfileVersion": 3,
+ "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.",
+ "specifiers": {
+ "RouterModule@../RouterModule": "RouterModule@../RouterModule"
+ },
+ "packages": {
+ "RouterModule@../RouterModule": {
+ "mtime": "1707210724992.75",
+ "resolved": "../RouterModule"
+ }
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5
index 489a3704df4abeaabf91ba20c68244e3e09dbdaa..584b7808d56340d46a69faba09d5ef65794ef232 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/oh-package.json5
@@ -1,26 +1,26 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "license": "Apache-2.0",
- "devDependencies": {},
- "author": "",
- "name": "harb",
- "description": "Please describe the basic information.",
- "main": "Index.ets",
- "version": "1.0.0",
- "dependencies": {
- "RouterModule": "file:../RouterModule"
- }
-}
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "license": "Apache-2.0",
+ "devDependencies": {},
+ "author": "",
+ "name": "harb",
+ "description": "Please describe the basic information.",
+ "main": "Index.ets",
+ "version": "1.0.0",
+ "dependencies": {
+ "RouterModule": "file:../RouterModule"
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets
index 8f9752914dae5c5d7ce781b24740461e2d47322f..b0f04cedae21ee3efa9e7cf031b0a2729c98f36e 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page1.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarB_Page1')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarB_Page1_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
-}
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarB_Page1')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarB_Page1_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets
index 6ff8d325a646dd11c46f21e90b5c730a2c85e488..6fef357292f71f7350fd4bbd032653d89bc194db 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page2.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarB_Page2')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarB_Page2_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
-}
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarB_Page2')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarB_Page2_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets
index a8f0b9e4ff39d17c8a828a28f4f2705b06573f5b..b4922252f889c5744d3996d623b718071536e7e5 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/ets/components/mainpage/page3.ets
@@ -1,65 +1,65 @@
-/*
-* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
-
-@Builder
-export function harBuilder(value: object) {
- NavDestination(){
- Column(){
- Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let routerName = "HapA_Router";
- RouterModule.clear(routerName);
- })
- Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
- RouterModule.push(url);
- })
- Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
- .width('80%')
- .height(40)
- .margin(20)
- .onClick(() => {
- let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
- RouterModule.push(url);
- })
- }.width('100%').height('100%')
- }.title('HarB_Page3')
- .onBackPressed(() => {
- RouterModule.pop("HapA_Router");
- return true;
- })
-}
-
-let builderName = 'HarB_Page3_Builder';
-if (!RouterModule.getBuilder(builderName)) {
- let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
- RouterModule.registerBuilder(builderName, builder);
-}
+/*
+* Copyright (C) 2024 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 { RouterModule } from "RouterModule/src/main/ets/utils/RouterModule";
+
+@Builder
+export function harBuilder(value: object) {
+ NavDestination(){
+ Column(){
+ Button($r("app.string.to_index"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let routerName = "HapA_Router";
+ RouterModule.clear(routerName);
+ })
+ Button($r("app.string.to_hara_page1"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page1/HapA_Router-HarA_Page1_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page2"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page2/HapA_Router-HarA_Page2_Builder";
+ RouterModule.push(url);
+ })
+ Button($r("app.string.to_hara_page3"), { stateEffect: true, type: ButtonType.Capsule })
+ .width('80%')
+ .height(40)
+ .margin(20)
+ .onClick(() => {
+ let url = "HarA/src/main/ets/components/mainpage/page3/HapA_Router-HarA_Page3_Builder";
+ RouterModule.push(url);
+ })
+ }.width('100%').height('100%')
+ }.title('HarB_Page3')
+ .onBackPressed(() => {
+ RouterModule.pop("HapA_Router");
+ return true;
+ })
+}
+
+let builderName = 'HarB_Page3_Builder';
+if (!RouterModule.getBuilder(builderName)) {
+ let builder: WrappedBuilder<[object]> = wrapBuilder(harBuilder);
+ RouterModule.registerBuilder(builderName, builder);
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5
index 51a6edaffbf91b53b8a8017944112c4d0063a942..a052108752cb82eb1b034a4f1966ad50756c7667 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/harB/src/main/module.json5
@@ -1,24 +1,24 @@
-/*
-* Copyright (C) 2024 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": "harB",
- "type": "har",
- "deviceTypes": [
- "default",
- "tablet"
- ]
- }
-}
+/*
+* Copyright (C) 2024 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": "harB",
+ "type": "har",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ]
+ }
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5
index e1b617db91f338598ae6d118b6866a33cba4042d..0b5647c97e634a2746cae72de8f7b6a26692fd87 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/hvigor/hvigor-config.json5
@@ -1,6 +1,6 @@
-{
- "hvigorVersion": "4.0.2",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "4.0.2"
- }
+{
+ "hvigorVersion": "4.0.2",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "4.0.2"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5 b/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5
index dce34f96c0f184c1a1c138b7896f7b17e431475a..41f1d62f0d4e2cb0c13d60e57d515a8d51c886d6 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/oh-package.json5
@@ -1,26 +1,26 @@
-/*
-* Copyright (C) 2024 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.
-*/
-{
- "license": "",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "author": "",
- "name": "myapplication",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+/*
+* Copyright (C) 2024 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.
+*/
+{
+ "license": "",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "author": "",
+ "name": "myapplication",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md b/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md
index 74fe3b6ece37080728c3f5c036e8d421f4f5e2c6..8d459c87e35aaaf95672e3011763c426ff8aad85 100644
--- a/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md
+++ b/code/BasicFeature/ApplicationModels/DynamicRouter/ohosTest.md
@@ -1,10 +1,10 @@
-# FileManager 测试用例归档
-
-## 用例表
-
-| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果|
-|----------------|----------|-----------|--------------|--------------------------------|--------------------------------|
-| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass|
-| 从首页跳转到harA页面 | 进入首页 | 点击ToHarA | 成功跳转到harA页面 |是|Pass|
-| 从harA跳转到harB页面 | 进入HarA页面 | 点击ToHarB | 成功跳转跳转到harB页面 |是|Pass|
+# FileManager 测试用例归档
+
+## 用例表
+
+| 测试功能 | 预置条件 | 输入 | 预期输出 |是否自动|测试结果|
+|----------------|----------|-----------|--------------|--------------------------------|--------------------------------|
+| 拉起应用 | 设备正常运行 | | 成功拉起应用 |是|Pass|
+| 从首页跳转到harA页面 | 进入首页 | 点击ToHarA | 成功跳转到harA页面 |是|Pass|
+| 从harA跳转到harB页面 | 进入HarA页面 | 点击ToHarB | 成功跳转跳转到harB页面 |是|Pass|
| 从harB跳转到首页 | 进入HarB页面 | 点击ToIndex | 成功跳转到首页 |是|Pass|
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5
index 7422edb8a7cae8445cc8df0b5551e92be3cea203..f8349cd66b3ccf7b539c3c52eb1bfc7701fcec61 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/app.json5
@@ -1,24 +1,24 @@
-/*
- * 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.multiplefilesdownload",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * 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.multiplefilesdownload",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json
index f5b165b8435a9f736e04891cf68477b44f7d5eec..35ce4d49ab8cd241f966b9b9e3e8a805e34f6435 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "MultipleFilesDownload"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "MultipleFilesDownload"
+ }
+ ]
+}
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md b/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md
index b75f037faf819330f7aaab4be3bd379bad2e7c54..281c945193cb5e1b7dbc5822e0492d3b83d87481 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/README.md
@@ -1,201 +1,201 @@
-
-
-# 多文件下载监听案例
-
-### 介绍
-
-多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。下载历史页面展示的是下载完成的文件,可对页面中已删除的文件进行重新下载 。每个应用至多支持创建10个未完成的任务,相关规格说明请参考[request.agent.create](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md#requestagentcreate10)。
-
-### 效果图预览
-
-
-
-**使用说明**
-
-1. 连接网络。进入页面,点击“全部开始”,启动所有文件的下载任务。点击“全部暂停”,暂停所有文件下载任务。再次点击“全部开始”,可重新启动未完成的下载任务。如出现下载失败,一般是网络不稳定,点击“全部开始”即可重新下载。
-2. 下载完成的文件会保存在应用缓存路径下,出现在下载历史页面中。
-3. 可点击删除按钮,在应用缓存路径下删除该文件存储的数据。
-4. 点击文件,若文件中在应用缓存路径下存在,弹窗提示用户“文件已存在”;否则弹窗提示用户“文件不存在,是否重新下载?”,点击确认按钮,该条文件数据会出现在下载列表中,可点击“全部开始“按钮重新下载。
-
-### 实现思路
-
-1. 配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务中请按实际情况按需配置。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。
-
- ```typescript
- let config: request.agent.Config = {
- action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务
- url: downloadUrl, // 配置下载任务url
- overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件
- method: 'GET', // HTTP标准方法。下载时,使用GET或POST。
- saveas: './', // 这里'./'表示下载至应用当前缓存路径下。
- mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。
- gauge: true // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。
- };
- ```
-
-2. 创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听,需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从而实现多文件下载监听。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。
-
- ```typescript
- ForEach(this.downloadConfigArray, (item: request.agent.Config) => {
- ListItem() {
- // 创建文件下载监听实例
- FileDownloadItem({
- downloadConfig: item, // 文件下载配置
- isStartAllDownload: this.isStartAllDownload, // 是否全部开始下载
- downloadCount: this.downloadCount // 待下载任务数量
- downloadFailCount: this.downloadFailCount // 下载失败任务数量
- })
- }
- }, (item: request.agent.Config) => JSON.stringify(item))
- ```
-
-3. 创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。
-
- ```typescript
- request.agent.create(context, this.downloadConfig).then((task: request.agent.Task) => {
- // 注册下载任务相关回调
- task.on('completed', this.completedCallback); // 下载任务完成回调
- task.on('failed', this.failedCallback); // 下载任务失败回调
- task.on('pause', this.pauseCallback); // 暂停任务回调
- task.on('resume', this.resumeCallback); // 重新启动任务回调
- task.on('progress', this.progressCallback); // 下载进度更新回调
- }).catch((err: BusinessError) => {
- logger.error(TAG, `Failed to task create with error message: ${err.message}, error code: ${err.code}`);
- });
- ```
-
-4. 启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。
-
- ```typescript
- task.start((err: BusinessError) => {
- if (err) {
- logger.error(TAG, `Failed to task start with error message: ${err.message}, error code: ${err.code}`);
- return;
- }
- this.downloadTask = task;
- })
- ```
-
-5. 删除文件。使用fs.unlink删除该条数据应用文件路径
-
- ```typescript
- // TODO:知识点:删除该条数据应用文件路径
- fs.unlink(filePath).then(() => {
- // 文件状态变为已删除
- this.FileInfo.fileStatus = 3;
- promptAction.showToast({
- message: $r('app.string.multiple_files_download_history_toast_text_del'),
- duration: 2000,
- bottom: '50%',
- })
- }).catch((error: BusinessError) => {
- logger.error("remove file failed with error:" + error);
- });
- ```
-
-6. 重新下载已删除的文件。使用fs.access判断文件是否已经存在,若不存在弹窗提示用户是否重新下载。
-
- ```typescript
- // 获取应用文件路径
- const cacheDir = context.cacheDir;
- const FilePath: string = `${cacheDir}/${this.fileName}`;
-
- // TODO:知识点:使用fs.access判断目录是否已经存在。
- fs.access(FilePath).then((res: boolean) => {
- if (!res) {
- // 文件已删除,弹窗提示是否重新下载
- AlertDialog.show({
- message: `${this.fileName}文件不存在,是否重新下载?`,
- alignment: DialogAlignment.Center, // 弹窗在竖直方向上的对齐方式。
- autoCancel: false, // 点击遮罩层时,是否关闭弹窗。默认值:true
- primaryButton: {
- value: $r('app.string.multiple_files_download_history_button_text_cancel'),
- fontColor: $r('app.color.multiple_files_download_text_color'),
- action: () => {
- logger.info('已取消');
- }
- },
- secondaryButton: {
- value: $r('app.string.multiple_files_download_history_button_text_confirm'),
- fontColor: $r('app.color.multiple_files_download_del_bgc'),
- action: () => {
- // 更改该条数据下载状态
- this.FileInfo.fileStatus = 0;
- // 该条数据加入下载列表数组中
- this.downloadFileArray.push(this.FileInfo);
- // 下载历史列表删除该条数据
- this.historyArray = this.historyArray.filter( ( item: downloadFilesData ) => {
- return item.id !== this.FileInfo.id;
- });
- // 更新待下载任务数量
- this.downloadCount = this.downloadFileArray.length;
- }
- },
- cornerRadius: $r('app.integer.multiple_files_download_borderRadius_twelve'), // 弹窗边框弧度
- width: $r('app.string.multiple_files_download_list_height'), // 弹窗宽度
- cancel: () => {
- logger.info('点击关闭按钮');
- }
- });
- } else {
- // 文件已下载到本地,弹窗提示文件已存在
- promptAction.showToast({
- message: $r('app.string.multiple_files_download_history_toast_text_exist'),
- duration: 1000,
- bottom: '50%',
- })
- }
- ```
-
-### 高性能知识点
-
-本示例中注册了progress下载进度更新监听,不建议在下载进度更新回调中加日志打印,以减少不必要的性能损耗。
-
-### FAQ
-
-1. 无网络时,点击”全部开始“,下载队列中的任务状态却显示”已暂停“。
-
- 答:request.agent.Config有一个参数retry默认是true,如果没有网络或者网络不满足时,会自动暂停waiting,所以在没网络的时候下载底层逻辑会走暂停回调,应用侧在暂停回调里设置了显示当前下载状态,所以无网络时,点击”全部开始“,下载队列中的任务状态显示”已暂停“。目前本例中已经把retry设置为false,没网络时,开启下载任务会直接走入失败回调,直接显示”下载失败“。
-
-### 工程结构&模块类型
-
- ```
- multiplefilesdownload // har类型
- |---view
- | |---MultipleFilesDownload.ets // 视图层-文件下载页面
- | |---FileDownloadItem.ets // 视图层-单个文件下载组件
- | |---HistoryItem.ets // 视图层-单个文件历史组件
- ```
-
-### 参考资料
-
-[上传下载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)
-
-### 相关权限
-
-| 权限名 | 权限说明 | 级别 |
-| ------------------------ | -------------------- | ------ |
-| ohos.permission.INTERNET | 允许使用Interent网络 | normal |
-
-### 依赖
-
-不涉及。
-### 约束与限制
-
-1.本示例仅支持标准系统上运行。
-
-2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release)。
-
-3.本示例需要使用DevEco Studio版本号(DevEco Studio 5.0.0 Release)及以上版本才可编译运行。
-
-### 下载
-
-如需单独下载本工程,执行如下命令:
-
-```shell
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Connectivity/MultipleFilesDownload > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
+
+
+# 多文件下载监听案例
+
+### 介绍
+
+多文件下载监听在应用开发中是一个非常常见的需求。本示例将介绍如何使用request上传下载模块实现多文件下载监听,如监听每个文件下载任务的进度,任务暂停,下载完成等下载情况。下载历史页面展示的是下载完成的文件,可对页面中已删除的文件进行重新下载 。每个应用至多支持创建10个未完成的任务,相关规格说明请参考[request.agent.create](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md#requestagentcreate10)。
+
+### 效果图预览
+
+
+
+**使用说明**
+
+1. 连接网络。进入页面,点击“全部开始”,启动所有文件的下载任务。点击“全部暂停”,暂停所有文件下载任务。再次点击“全部开始”,可重新启动未完成的下载任务。如出现下载失败,一般是网络不稳定,点击“全部开始”即可重新下载。
+2. 下载完成的文件会保存在应用缓存路径下,出现在下载历史页面中。
+3. 可点击删除按钮,在应用缓存路径下删除该文件存储的数据。
+4. 点击文件,若文件中在应用缓存路径下存在,弹窗提示用户“文件已存在”;否则弹窗提示用户“文件不存在,是否重新下载?”,点击确认按钮,该条文件数据会出现在下载列表中,可点击“全部开始“按钮重新下载。
+
+### 实现思路
+
+1. 配置下载参数。一个下载任务需要配置对应一套下载参数request.agent.Config。本例中使用downloadConfig方法简单配置了下载文件的url,实际业务中请按实际情况按需配置。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。
+
+ ```typescript
+ let config: request.agent.Config = {
+ action: request.agent.Action.DOWNLOAD, // 配置任务选项,这里配置为下载任务
+ url: downloadUrl, // 配置下载任务url
+ overwrite: true, // 下载过程中路径已存在时的解决方案选择。true表示覆盖已存在的文件
+ method: 'GET', // HTTP标准方法。下载时,使用GET或POST。
+ saveas: './', // 这里'./'表示下载至应用当前缓存路径下。
+ mode: request.agent.Mode.BACKGROUND, // 任务模式设置后台任务。
+ gauge: true // 后台任务的过程进度通知策略,仅应用于后台任务。true表示发出每个进度已完成或失败的通知。
+ };
+ ```
+
+2. 创建多个文件下载监听实例。单个文件下载监听只需要配置下载参数,创建下载任务,注册下载任务相关监听,启动下载任务即可实现。而要实现多文件下载监听,需要每个下载任务注册独立的下载监听回调。本例通过封装自定义组件FileDownloadItem,在每个FileDownloadItem中创建各自的下载任务和监听回调,从而实现多文件下载监听。源码参考[MultipleFilesDownload.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/MultipleFilesDownload.ets)。
+
+ ```typescript
+ ForEach(this.downloadConfigArray, (item: request.agent.Config) => {
+ ListItem() {
+ // 创建文件下载监听实例
+ FileDownloadItem({
+ downloadConfig: item, // 文件下载配置
+ isStartAllDownload: this.isStartAllDownload, // 是否全部开始下载
+ downloadCount: this.downloadCount // 待下载任务数量
+ downloadFailCount: this.downloadFailCount // 下载失败任务数量
+ })
+ }
+ }, (item: request.agent.Config) => JSON.stringify(item))
+ ```
+
+3. 创建下载任务,并注册下载任务相关监听。本例在每个FileDownloadItem中使用request.agent.create创建下载任务。然后在下载任务创建成功后,注册各自下载任务相关监听。本例中注册了下载任务完成回调,下载任务失败回调,下载进度更新回调,暂停任务回调,重新启动任务回调。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。
+
+ ```typescript
+ request.agent.create(context, this.downloadConfig).then((task: request.agent.Task) => {
+ // 注册下载任务相关回调
+ task.on('completed', this.completedCallback); // 下载任务完成回调
+ task.on('failed', this.failedCallback); // 下载任务失败回调
+ task.on('pause', this.pauseCallback); // 暂停任务回调
+ task.on('resume', this.resumeCallback); // 重新启动任务回调
+ task.on('progress', this.progressCallback); // 下载进度更新回调
+ }).catch((err: BusinessError) => {
+ logger.error(TAG, `Failed to task create with error message: ${err.message}, error code: ${err.code}`);
+ });
+ ```
+
+4. 启动下载任务。本例在每个FileDownloadItem中使用task.start方法启动各自的下载任务。源码参考[FileDownloadItem.ets](./casesfeature/multiplefilesdownload/src/main/ets/view/FileDownloadItem.ets)。
+
+ ```typescript
+ task.start((err: BusinessError) => {
+ if (err) {
+ logger.error(TAG, `Failed to task start with error message: ${err.message}, error code: ${err.code}`);
+ return;
+ }
+ this.downloadTask = task;
+ })
+ ```
+
+5. 删除文件。使用fs.unlink删除该条数据应用文件路径
+
+ ```typescript
+ // TODO:知识点:删除该条数据应用文件路径
+ fs.unlink(filePath).then(() => {
+ // 文件状态变为已删除
+ this.FileInfo.fileStatus = 3;
+ promptAction.showToast({
+ message: $r('app.string.multiple_files_download_history_toast_text_del'),
+ duration: 2000,
+ bottom: '50%',
+ })
+ }).catch((error: BusinessError) => {
+ logger.error("remove file failed with error:" + error);
+ });
+ ```
+
+6. 重新下载已删除的文件。使用fs.access判断文件是否已经存在,若不存在弹窗提示用户是否重新下载。
+
+ ```typescript
+ // 获取应用文件路径
+ const cacheDir = context.cacheDir;
+ const FilePath: string = `${cacheDir}/${this.fileName}`;
+
+ // TODO:知识点:使用fs.access判断目录是否已经存在。
+ fs.access(FilePath).then((res: boolean) => {
+ if (!res) {
+ // 文件已删除,弹窗提示是否重新下载
+ AlertDialog.show({
+ message: `${this.fileName}文件不存在,是否重新下载?`,
+ alignment: DialogAlignment.Center, // 弹窗在竖直方向上的对齐方式。
+ autoCancel: false, // 点击遮罩层时,是否关闭弹窗。默认值:true
+ primaryButton: {
+ value: $r('app.string.multiple_files_download_history_button_text_cancel'),
+ fontColor: $r('app.color.multiple_files_download_text_color'),
+ action: () => {
+ logger.info('已取消');
+ }
+ },
+ secondaryButton: {
+ value: $r('app.string.multiple_files_download_history_button_text_confirm'),
+ fontColor: $r('app.color.multiple_files_download_del_bgc'),
+ action: () => {
+ // 更改该条数据下载状态
+ this.FileInfo.fileStatus = 0;
+ // 该条数据加入下载列表数组中
+ this.downloadFileArray.push(this.FileInfo);
+ // 下载历史列表删除该条数据
+ this.historyArray = this.historyArray.filter( ( item: downloadFilesData ) => {
+ return item.id !== this.FileInfo.id;
+ });
+ // 更新待下载任务数量
+ this.downloadCount = this.downloadFileArray.length;
+ }
+ },
+ cornerRadius: $r('app.integer.multiple_files_download_borderRadius_twelve'), // 弹窗边框弧度
+ width: $r('app.string.multiple_files_download_list_height'), // 弹窗宽度
+ cancel: () => {
+ logger.info('点击关闭按钮');
+ }
+ });
+ } else {
+ // 文件已下载到本地,弹窗提示文件已存在
+ promptAction.showToast({
+ message: $r('app.string.multiple_files_download_history_toast_text_exist'),
+ duration: 1000,
+ bottom: '50%',
+ })
+ }
+ ```
+
+### 高性能知识点
+
+本示例中注册了progress下载进度更新监听,不建议在下载进度更新回调中加日志打印,以减少不必要的性能损耗。
+
+### FAQ
+
+1. 无网络时,点击”全部开始“,下载队列中的任务状态却显示”已暂停“。
+
+ 答:request.agent.Config有一个参数retry默认是true,如果没有网络或者网络不满足时,会自动暂停waiting,所以在没网络的时候下载底层逻辑会走暂停回调,应用侧在暂停回调里设置了显示当前下载状态,所以无网络时,点击”全部开始“,下载队列中的任务状态显示”已暂停“。目前本例中已经把retry设置为false,没网络时,开启下载任务会直接走入失败回调,直接显示”下载失败“。
+
+### 工程结构&模块类型
+
+ ```
+ multiplefilesdownload // har类型
+ |---view
+ | |---MultipleFilesDownload.ets // 视图层-文件下载页面
+ | |---FileDownloadItem.ets // 视图层-单个文件下载组件
+ | |---HistoryItem.ets // 视图层-单个文件历史组件
+ ```
+
+### 参考资料
+
+[上传下载](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)
+
+### 相关权限
+
+| 权限名 | 权限说明 | 级别 |
+| ------------------------ | -------------------- | ------ |
+| ohos.permission.INTERNET | 允许使用Interent网络 | normal |
+
+### 依赖
+
+不涉及。
+### 约束与限制
+
+1.本示例仅支持标准系统上运行。
+
+2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12 Release)。
+
+3.本示例需要使用DevEco Studio版本号(DevEco Studio 5.0.0 Release)及以上版本才可编译运行。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```shell
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Connectivity/MultipleFilesDownload > .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/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5
index 62ec91ec46e3e6364d3cdef3e7cd648156a763d4..3bd213566f375a40ef87008867db312b57cbbabe 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/build-profile.json5
@@ -1,60 +1,60 @@
-/*
- * 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": {
- "signingConfigs": [],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- compileSdkVersion: 12,
- "compatibleSdkVersion": 12,
- "runtimeOS": "OpenHarmony",
- "buildOption": {
- "strictMode": {
- "caseSensitiveCheck": true,
- "useNormalizedOHMUrl": true
- }
- }
- }
- ],
- "buildModeSet": [
- {
- "name": "debug"
- },
- {
- "name": "release"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- },
- {
- "name": "multiplefilesdownload",
- "srcPath": "./casesfeature/multiplefilesdownload"
- }
- ]
+/*
+ * 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": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ compileSdkVersion: 12,
+ "compatibleSdkVersion": 12,
+ "runtimeOS": "OpenHarmony",
+ "buildOption": {
+ "strictMode": {
+ "caseSensitiveCheck": true,
+ "useNormalizedOHMUrl": true
+ }
+ }
+ }
+ ],
+ "buildModeSet": [
+ {
+ "name": "debug"
+ },
+ {
+ "name": "release"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "multiplefilesdownload",
+ "srcPath": "./casesfeature/multiplefilesdownload"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5
index b6a8c714facd51937a0a2f470bb24ecea17e4cd3..2464e14a8cd5370489c5259f0b0b20f68ed0f15d 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/casesfeature/multiplefilesdownload/oh-package.json5
@@ -1,23 +1,23 @@
-/*
- * 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" : "multiplefilesdownload",
- "version" : "1.0.0",
- "description" : "Please describe the basic information.",
- "main" : "Index.ets",
- "author" : "",
- "license" : "Apache-2.0",
- "dependencies" : { }
+/*
+ * 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" : "multiplefilesdownload",
+ "version" : "1.0.0",
+ "description" : "Please describe the basic information.",
+ "main" : "Index.ets",
+ "author" : "",
+ "license" : "Apache-2.0",
+ "dependencies" : { }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5
index b4d65d490ef6cbe22d933b9231555210f1555786..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/build-profile.json5
@@ -1,43 +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": false,
- "files": [
- "./obfuscation-rules.txt"
- ]
- }
- }
- }
- },
- ],
- "targets": [
- {
- "name": "default"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+ * 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": false,
+ "files": [
+ "./obfuscation-rules.txt"
+ ]
+ }
+ }
+ }
+ },
+ ],
+ "targets": [
+ {
+ "name": "default"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5
index f24d0a9a5ec9e1d584e09fddc01b076e7336bf22..71c70d510aef177dcc607ad38ce9f097c7bcb213 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/oh-package.json5
@@ -1,26 +1,26 @@
-/*
- * 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": {
- "multiplefilesdownload": "file:../casesfeature/multiplefilesdownload"
- }
+/*
+ * 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": {
+ "multiplefilesdownload": "file:../casesfeature/multiplefilesdownload"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets
index 3e77e4b9f7946d80aa77e6b2dcfe40b23ccf6178..edc2839f203ba057c186e19b0cbbbf80c8faa8b3 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entryability/EntryAbility.ets
@@ -1,57 +1,57 @@
-/*
- * 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, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
-import { hilog } from '@kit.PerformanceAnalysisKit';
-import { window } from '@kit.ArkUI';
-
-export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
- this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy(): void {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage): void {
- // Main window is created, set main page for this ability
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err) => {
- if (err.code) {
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
- });
- }
-
- onWindowStageDestroy(): void {
- // Main window is destroyed, release UI related resources
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground(): void {
- // Ability has brought to foreground
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground(): void {
- // Ability has back to background
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
- }
+/*
+ * 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, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
+import { hilog } from '@kit.PerformanceAnalysisKit';
+import { window } from '@kit.ArkUI';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
+ this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy(): void {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage): void {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
index 1504a74f09dfdcfae408be979f99369a2c5affab..b1e212947256c5533c7b06285a597c94f840a6e3 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets
@@ -1,27 +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 { hilog } from '@kit.PerformanceAnalysisKit';
-import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
-
-export default class EntryBackupAbility extends BackupExtensionAbility {
- async onBackup() {
- hilog.info(0x0000, 'testTag', 'onBackup ok');
- }
-
- async onRestore(bundleVersion: BundleVersion) {
- hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
- }
+/*
+ * 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';
+import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
+
+export default class EntryBackupAbility extends BackupExtensionAbility {
+ async onBackup() {
+ hilog.info(0x0000, 'testTag', 'onBackup ok');
+ }
+
+ async onRestore(bundleVersion: BundleVersion) {
+ hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5
index dfbe47e6ac287d71e455c7f49cef83dd292447e6..9deddb7dec7ee08ea3fea42236e640756faa9e43 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/module.json5
@@ -1,66 +1,66 @@
-/*
- * 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"
- }
- ]
- }
- ]
- }
+/*
+ * 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"
+ }
+ ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json
index d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json
index d742c2f96e7dd0f406f499941f3147345e998f95..78f40ae7c494d71e2482278f359ec790ca73471a 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/base/profile/backup_config.json
@@ -1,3 +1,3 @@
-{
- "allowToBackupRestore": true
+{
+ "allowToBackupRestore": true
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json
index 438d5bc43bb23c59c210d586b96635a72da5b64a..79b11c2747aec33e710fd3a7b2b3c94dd9965499 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/main/resources/dark/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#000000"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#000000"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5
index 9983b2ba4e55e31a172f0328c82c9a75bfa00ded..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/entry/src/ohosTest/module.json5
@@ -1,27 +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
- }
-}
+/*
+ * 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/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5
index dccc142c233ab36842dfb663f67d845e5446179d..5282eefe0593f56f8ddabfbf05783dc836c3c8b4 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/hvigor/hvigor-config.json5
@@ -1,36 +1,36 @@
-/*
- * 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.1",
- "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*/
- }
-}
+/*
+ * 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.1",
+ "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/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5 b/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5
index eaef52736f22c14e04fca386ba01611ab32a7e4a..e41bae026aab3b50d0abb42fece08ba43b4a772b 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/oh-package.json5
@@ -1,25 +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.1",
- "description": "Please describe the basic information.",
- "dependencies": {
- },
- "devDependencies": {
- "@ohos/hypium": "1.0.19",
- "@ohos/hamock": "1.0.0"
- }
-}
+/*
+ * 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.1",
+ "description": "Please describe the basic information.",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.19",
+ "@ohos/hamock": "1.0.0"
+ }
+}
diff --git a/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md b/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md
index 7691735123dfcf4320758d8d5074bb5bcbada342..1d79cbba9d9146cdb7cf0503f64d6a34322d14a9 100644
--- a/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md
+++ b/code/BasicFeature/Connectivity/MultipleFilesDownload/ohosTest.md
@@ -1,13 +1,13 @@
-# 多文件下载监听案例 测试用例归档
-
-## 用例表
-
-|测试功能|预置条件|输入|预期输出|是否自动|测试结果|
-|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
-|点击“全部开始”功能是否正常启动下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始” |点击“全部开始”,下载队列中两个任务能正常下载|是|Pass|
-|点击“全部暂停”功能是否能正常暂停下载| 1.进入案例页面 2.正常连接网络 | 点击“全部暂停” |点击“全部暂停”,下载队列中正在下载的任务被暂停了|是|Pass|
-|点击“全部开始”,然后在下载完成前点击“全部暂停”,然后再次点击“全部开始”查看被暂停的下载任务能否正常恢复下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,然后在下载完成前点击点击“全部暂停”,然后再次点击“全部开始” |下载任务重新恢复下载|是|Pass|
-|下载文件保存是否正常| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,等待下载完成后,查看下载的文件是否保存在应用缓存路径下。(手工可用hdc shell cd /data/app/el2/100/base/com/north.cases/haps/entry/cache/) |下载完成后,在案例应用缓存路径下可以找到下载的文件:favor_list_tea.png favor_list_tree.png|是|Pass|
-|在下载历史中已下载的文件是否能删除|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击“删除”| 点击“删除”,文件被删除样式发生变化且在案例应用缓存路径下不能找到已删除的文件 |是|Pass|
-|点击下载历史中的文件,是否能把已删除的文件重新下载|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已删除文件|弹出“xxx文件已被删除,是否重新下载”的弹窗提示用户是否重新下载,若用户点击“确认”文件重新下载|是|Pass|
-|在下载历史中点击已下载的文件是否弹出“文件已存在”信息|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已下载文件|弹出“文件已存在”toast|是|Pass|
+# 多文件下载监听案例 测试用例归档
+
+## 用例表
+
+|测试功能|预置条件|输入|预期输出|是否自动|测试结果|
+|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|--------------------------------|
+|点击“全部开始”功能是否正常启动下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始” |点击“全部开始”,下载队列中两个任务能正常下载|是|Pass|
+|点击“全部暂停”功能是否能正常暂停下载| 1.进入案例页面 2.正常连接网络 | 点击“全部暂停” |点击“全部暂停”,下载队列中正在下载的任务被暂停了|是|Pass|
+|点击“全部开始”,然后在下载完成前点击“全部暂停”,然后再次点击“全部开始”查看被暂停的下载任务能否正常恢复下载| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,然后在下载完成前点击点击“全部暂停”,然后再次点击“全部开始” |下载任务重新恢复下载|是|Pass|
+|下载文件保存是否正常| 1.进入案例页面 2.正常连接网络 | 点击“全部开始”,等待下载完成后,查看下载的文件是否保存在应用缓存路径下。(手工可用hdc shell cd /data/app/el2/100/base/com/north.cases/haps/entry/cache/) |下载完成后,在案例应用缓存路径下可以找到下载的文件:favor_list_tea.png favor_list_tree.png|是|Pass|
+|在下载历史中已下载的文件是否能删除|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击“删除”| 点击“删除”,文件被删除样式发生变化且在案例应用缓存路径下不能找到已删除的文件 |是|Pass|
+|点击下载历史中的文件,是否能把已删除的文件重新下载|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已删除文件|弹出“xxx文件已被删除,是否重新下载”的弹窗提示用户是否重新下载,若用户点击“确认”文件重新下载|是|Pass|
+|在下载历史中点击已下载的文件是否弹出“文件已存在”信息|1.进入案例页面 2.正常连接网络 3.点击下载历史tab|点击已下载文件|弹出“文件已存在”toast|是|Pass|
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md
index a5e7b5a88257babe4b9a7265b5c1a971ee18c7b0..9536aca54575ccabd165ba0c1768f78a599cbb4b 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/README_zh.md
@@ -1,152 +1,152 @@
-# 上传和下载
-
-### 介绍
-本示例使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)接口创建上传和下载任务,实现上传、下载功能,hfs作为服务器,实现了文件的上传和下载和任务的查询功能。
-
-### 效果预览
-
-| 主页 | 上传 | 片段上传 | 下载 | 证书锁定 |
-| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- |
-|  |  |  |  |  |
-
-使用说明
-
-1.本示例功能需要先配置服务器环境后使用,具体配置见[上传下载服务配置](./environment)。
-
-2.首页展示上传、下载和证书锁定三个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。
-
-3.上传页面:
-
-点击 **+**,**从相册选择**拉起图库选择照片,图片选择页面支持拍照,选择照片后点击**上传**进行上传。
-
-可选的,点击缩略图,显示文件片段上传配置选项弹窗,可以配置上传起点和终点,取值为闭区间;起点默认为0,终点默认为文件结尾。点击**上传**进行选中文件片段以及后续文件全部内容上传。
-
-点击**返回**键或片段上传配置选项弹窗外区域,取消片段上传。
-
-在首页中打开后台任务开关后,上传页面开启的是后台上传任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。
-
-后台上传**暂停**时,需要服务器支持上传暂停服务(HFS暂不支持此操作)。如仍然使用HFS作为服务器,此时HFS服务将中断文件写入,立即将当前传输的数据保存为文件片段。点击**继续**时则会重新生成一份文件,并在新文件中开始写入。
-
-4.下载页面:
-
-点击文件列表选择要下载的文件后,点击**下载**选择指定路径后开始下载。
-
-点击**查看下载文件**进入下载文件页面,点击文件夹查看文件夹内的文件。
-
-在首页中打开后台任务开关后,下载页面开启的是后台下载任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。
-
-前台下载时只支持单文件下载,后台下载时支持选择多个文件下载。
-
-后台下载**暂停**时,本示例功能将自动记录断点。此时HFS服务仍会进行一定时间的传输,但是传输的数据并不会被接受。点击**继续**后将会从上次暂停的断点继续下载。
-
-5.证书锁定页面:
-
-点击**下载**按钮会使用get方式访问百度,并在空白处显示返回的响应header内容。
-
-点击**上传**按钮会使用post方式访问百度,并在空白处显示返回的响应header内容。
-
-以上功能需要在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应;否则将无法正常访问百度,会通过toast提示上传或者下载失败,日志中会有具体错误信息。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放到src/main/resources/resfile目录下。
-
-如示例中访问百度,则digest需要取百度服务器的证书生成:
-
-```bash
-cat server.crt \
-| openssl x509 -noout -pubkey \
-| openssl pkey -pubin -outform der \
-| openssl dgst -sha256 -binary \
-| openssl enc -base64
-```
-
-因为服务器证书可能定期更新,所以digest的值需要与服务端证书对应,及时更新。
-
-
-
-
-
-
-### 工程目录
-
-```
-UploadAndDownload
-├── AppScope
-│ └── app.json5 //APP信息配置文件
-├── entry/src/main //应用首页
-│ ├── ets
-│ │ ├── entryability
-│ │ ├── components //自定义组件
-│ │ ├── pages
-│ │ │ ├── Index.ets //主页入口
-│ │ │ ├── Download.ets //下载页面
-│ │ │ ├── DownloadFiles.ets //查看下载文件页面
-│ │ │ ├── Upload.ets //上传页面
-│ │ │ ├── CertLock.ets //证书锁定页面
-│ └── module.json5
-│
-├── features/uploadanddownload/src/main //上传和下载
-│ ├── ets
-│ │ ├── Index.ets //对外提供的接口列表
-│ │ ├── components
-│ │ │ └── FileBrowse.ets //查看下载文件组件
-│ │ ├── download //下载任务相关
-│ │ ├── upload //上传任务相关
-│ │ ├── utils //相关工具类
-│ └── module.json5
-```
-
-### 具体实现
-
-* 该示例分为三个模块:
- * 上传模块
- * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,支持多个文件上传及片段上传。
- * 源码链接:[RequestUpload.ets](./features/uploadanddownload/src/main/ets/upload/RequestUpload.ets),[AddPictures.ets](./entry/src/main/ets/components/AddPictures.ets),[Upload.ets](./entry/src/main/ets/pages/Upload.ets)
- * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)
-
- * 下载模块
-
- * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。
- * 源码链接:[RequestDownload.ets](./features/uploadanddownload/src/main/ets/download/RequestDownload.ets),[Download.ets](./entry/src/main/ets/pages/Download.ets),[FileUtils.ets](./features/uploadanddownload/src/main/ets/utils/FileUtils.ets),[FileBrowse.ets](./features/uploadanddownload/src/main/ets/components/FileBrowse.ets)
- * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)
-
- * 证书锁定模块
-
- * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现通过get或者post方式访问指定的网页,点击按钮后会在空白处显示返回的响应header内容。你需要提前在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放在src/main/resources/resfile目录下。
-
- * 源码链接,[CertLock.ets](./entry/src/main/ets/pages/CertLock.ets)
-
- * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)
-
-
-
-
-
-### 相关权限
-
-[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
-
-[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media)
-
-### 依赖
-
-[上传下载服务配置](./environment)。
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568。
-
-2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0)
-
-3.本示例需要使用DevEco Studio 版本号(4.1 Release)及以上版本才可编译运行。
-
-4.运行本示例需全程联网。
-
-### 下载
-
-如需单独下载本工程,执行如下命令:
-
-```bash
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Connectivity/UploadAndDownload/ > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
+# 上传和下载
+
+### 介绍
+本示例使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)接口创建上传和下载任务,实现上传、下载功能,hfs作为服务器,实现了文件的上传和下载和任务的查询功能。
+
+### 效果预览
+
+| 主页 | 上传 | 片段上传 | 下载 | 证书锁定 |
+| :---------------------------------------: | :---------------------------------------: | :--------------------------------------: | :--------------------------------------: | ---------------------------------------- |
+|  |  |  |  |  |
+
+使用说明
+
+1.本示例功能需要先配置服务器环境后使用,具体配置见[上传下载服务配置](./environment)。
+
+2.首页展示上传、下载和证书锁定三个入口组件,点击进入对应的页面,如果要使用后台下载任务,请开启后台任务开关。
+
+3.上传页面:
+
+点击 **+**,**从相册选择**拉起图库选择照片,图片选择页面支持拍照,选择照片后点击**上传**进行上传。
+
+可选的,点击缩略图,显示文件片段上传配置选项弹窗,可以配置上传起点和终点,取值为闭区间;起点默认为0,终点默认为文件结尾。点击**上传**进行选中文件片段以及后续文件全部内容上传。
+
+点击**返回**键或片段上传配置选项弹窗外区域,取消片段上传。
+
+在首页中打开后台任务开关后,上传页面开启的是后台上传任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。
+
+后台上传**暂停**时,需要服务器支持上传暂停服务(HFS暂不支持此操作)。如仍然使用HFS作为服务器,此时HFS服务将中断文件写入,立即将当前传输的数据保存为文件片段。点击**继续**时则会重新生成一份文件,并在新文件中开始写入。
+
+4.下载页面:
+
+点击文件列表选择要下载的文件后,点击**下载**选择指定路径后开始下载。
+
+点击**查看下载文件**进入下载文件页面,点击文件夹查看文件夹内的文件。
+
+在首页中打开后台任务开关后,下载页面开启的是后台下载任务,后台任务在应用退出到后台时可以在通知栏看到任务状态。
+
+前台下载时只支持单文件下载,后台下载时支持选择多个文件下载。
+
+后台下载**暂停**时,本示例功能将自动记录断点。此时HFS服务仍会进行一定时间的传输,但是传输的数据并不会被接受。点击**继续**后将会从上次暂停的断点继续下载。
+
+5.证书锁定页面:
+
+点击**下载**按钮会使用get方式访问百度,并在空白处显示返回的响应header内容。
+
+点击**上传**按钮会使用post方式访问百度,并在空白处显示返回的响应header内容。
+
+以上功能需要在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应;否则将无法正常访问百度,会通过toast提示上传或者下载失败,日志中会有具体错误信息。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放到src/main/resources/resfile目录下。
+
+如示例中访问百度,则digest需要取百度服务器的证书生成:
+
+```bash
+cat server.crt \
+| openssl x509 -noout -pubkey \
+| openssl pkey -pubin -outform der \
+| openssl dgst -sha256 -binary \
+| openssl enc -base64
+```
+
+因为服务器证书可能定期更新,所以digest的值需要与服务端证书对应,及时更新。
+
+
+
+
+
+
+### 工程目录
+
+```
+UploadAndDownload
+├── AppScope
+│ └── app.json5 //APP信息配置文件
+├── entry/src/main //应用首页
+│ ├── ets
+│ │ ├── entryability
+│ │ ├── components //自定义组件
+│ │ ├── pages
+│ │ │ ├── Index.ets //主页入口
+│ │ │ ├── Download.ets //下载页面
+│ │ │ ├── DownloadFiles.ets //查看下载文件页面
+│ │ │ ├── Upload.ets //上传页面
+│ │ │ ├── CertLock.ets //证书锁定页面
+│ └── module.json5
+│
+├── features/uploadanddownload/src/main //上传和下载
+│ ├── ets
+│ │ ├── Index.ets //对外提供的接口列表
+│ │ ├── components
+│ │ │ └── FileBrowse.ets //查看下载文件组件
+│ │ ├── download //下载任务相关
+│ │ ├── upload //上传任务相关
+│ │ ├── utils //相关工具类
+│ └── module.json5
+```
+
+### 具体实现
+
+* 该示例分为三个模块:
+ * 上传模块
+ * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,支持多个文件上传及片段上传。
+ * 源码链接:[RequestUpload.ets](./features/uploadanddownload/src/main/ets/upload/RequestUpload.ets),[AddPictures.ets](./entry/src/main/ets/components/AddPictures.ets),[Upload.ets](./entry/src/main/ets/pages/Upload.ets)
+ * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.picker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-picker.md)
+
+ * 下载模块
+
+ * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现上传任务的创建、取消、进度加载,失败的任务会调用查询接口获取失败原因并打印在日志中,前台下载任务只支持单个文件下载,后台下载任务支持多文件下载。使用[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)完成指定路径的创建和查询已下载的文件。
+ * 源码链接:[RequestDownload.ets](./features/uploadanddownload/src/main/ets/download/RequestDownload.ets),[Download.ets](./entry/src/main/ets/pages/Download.ets),[FileUtils.ets](./features/uploadanddownload/src/main/ets/utils/FileUtils.ets),[FileBrowse.ets](./features/uploadanddownload/src/main/ets/components/FileBrowse.ets)
+ * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md),[@ohos.file.fs](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-core-file-kit/js-apis-file-fs.md)
+
+ * 证书锁定模块
+
+ * 使用[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)中API 12接口agent.create创建上传任务,调用@ohos.request中的Task相关接口实现通过get或者post方式访问指定的网页,点击按钮后会在空白处显示返回的响应header内容。你需要提前在src/main/resources/base/profile/network_config.json中配置domains和digest,只有你配置的证书信息通过验证,上传和下载才可以正常响应。如果你要访问的服务器根证书不在系统中,你需要把它的根证书放在src/main/resources/resfile目录下。
+
+ * 源码链接,[CertLock.ets](./entry/src/main/ets/pages/CertLock.ets)
+
+ * 参考接口:[@ohos.request](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis-basic-services-kit/js-apis-request.md)
+
+
+
+
+
+### 相关权限
+
+[ohos.permission.INTERNET](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet)
+
+[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionread_media)
+
+### 依赖
+
+[上传下载服务配置](./environment)。
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568。
+
+2.本示例为Stage模型,支持API12版本SDK,SDK版本号(API Version 12),镜像版本号(5.0)
+
+3.本示例需要使用DevEco Studio 版本号(4.1 Release)及以上版本才可编译运行。
+
+4.运行本示例需全程联网。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```bash
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Connectivity/UploadAndDownload/ > .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/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5
index 49dfabaaebd6ee47414f91c55299f79b16629226..39778e6c094b450e56dc8e3a120ad7cc27d9f776 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/build-profile.json5
@@ -1,48 +1,48 @@
-/*
- * Copyright (c) 2023 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": {
- "signingConfigs": [
- ],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- "compileSdkVersion": 12,
- "compatibleSdkVersion": 12,
- "runtimeOS": "OpenHarmony"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- },
- {
- "name": "uploadanddownload",
- "srcPath": "./features/uploadanddownload"
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ "signingConfigs": [
+ ],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ "compileSdkVersion": 12,
+ "compatibleSdkVersion": 12,
+ "runtimeOS": "OpenHarmony"
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "uploadanddownload",
+ "srcPath": "./features/uploadanddownload"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets
index 5a026070811206ebe9ab3ed0923553f91206dbe5..1ded11e16cec9222008c044133a01e2f5ee0d57c 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/CertLock.ets
@@ -1,192 +1,192 @@
-/*
- * Copyright (c) 2024 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 common from '@ohos.app.ability.common';
-import promptAction from '@ohos.promptAction';
-import request from '@ohos.request';
-import connection from '@ohos.net.connection';
-import router from '@ohos.router';
-import { BusinessError } from '@ohos.base';
-import { logger, TOAST_BOTTOM } from '@ohos/uploaddownload';
-
-const TAG: string = 'CertLockSample';
-
-@Entry
-@Component
-struct CertLock {
- @State message: string = ''
- @State taskId: string = '';
- @State progress: string = '0%';
-
- build() {
- Navigation() {
- Text(this.message)
- .fontSize(16)
- .fontColor($r('app.color.text_message'))
- .textAlign(TextAlign.Start)
- .id('http_response')
- .width('90%')
- .height('80%')
- .maxLines(30)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
-
- Button($r('app.string.upload'))
- .id('upload')
- .width('90%')
- .fontSize(16)
- .height(40)
- .margin({ top: 10, bottom: 20 })
- .enabled(true)
- .backgroundColor($r('app.color.button_blue'))
- .onClick(() => {
- this.uploadTask();
- })
-
- Button($r('app.string.download'))
- .id('download')
- .type(ButtonType.Capsule)
- .width('90%')
- .fontSize(16)
- .fontColor($r('app.color.btn_text_blue'))
- .height(40)
- .margin({ bottom: 10 })
- .enabled(true)
- .backgroundColor($r('app.color.button_light_gray'))
- .onClick(() => {
- this.DownloadTask();
- })
- }
- .width('100%')
- .height('100%')
- .hideBackButton(false)
- .titleMode(NavigationTitleMode.Mini)
- .mode(NavigationMode.Stack)
- .backgroundColor($r('app.color.light_gray'))
- .hideToolBar(false)
- .title($r('app.string.cert_lock'))
- }
-
- static task: request.agent.Task;
- static netConnection = connection.createNetConnection();
-
- async DownloadTask() {
- logger.debug(TAG, 'DownloadTask');
- let config: request.agent.Config = {
- action: request.agent.Action.DOWNLOAD,
- url: 'https://www.baidu.com',
- gauge: true,
- overwrite: true,
- method: 'GET',
- network: request.agent.Network.ANY,
- };
- let task: request.agent.Task = await request.agent.create(getContext(), config);
- CertLock.task = task;
- task.on('progress', async (progress) => {
- logger.debug(TAG, `/Request download status ${progress.state}, downloaded ${progress.processed}`);
- promptAction.showToast({
- message: $r('app.string.download_finish'),
- bottom: TOAST_BOTTOM,
- offset: { dx: 10, dy: 96 }
- });
- this.taskId = task.tid;
- })
- let responseOnCallback = (response: request.agent.HttpResponse) => {
- logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`)
- let headers: string = '';
- for (let k of response.headers.keys()) {
- headers = headers + k + ':' + response.headers.get(k) + '\r\n';
- ;
- logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`)
- }
- this.message = headers;
- };
- task.on('response', responseOnCallback);
-
- task.on('failed', async (progress) => {
- this.message = JSON.stringify(progress);
- logger.debug(TAG, `/Request download failed ${(JSON.stringify(progress))}`);
- promptAction.showToast({ message: $r('app.string.download_fail'), bottom: TOAST_BOTTOM });
- })
- logger.debug(TAG, 'Downloading before');
- await task.start();
- logger.debug(TAG, 'Downloading started');
- }
-
- async uploadTask() {
- logger.debug(TAG, 'uploadTask');
- let attachments: Array = [];
- let attachment: request.agent.FormItem = {
- name: 'test',
- value: [
- {
- filename: 'testUpload.txt',
- path: './testUpload.txt',
- },
- ]
- };
- attachments.push(attachment);
- let config: request.agent.Config = {
- action: request.agent.Action.UPLOAD,
- url: 'https://www.baidu.com',
- title: 'taskOnTest',
- mode: request.agent.Mode.FOREGROUND,
- overwrite: true,
- method: 'POST',
- data: attachments,
- saveas: './'
- };
- let createOnCallback = (progress: request.agent.Progress) => {
- let txt: string = $r('app.string.upload_fail').bundleName;
- this.progress = txt + ((progress.processed / 1024 / 1024));
- promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM });
- };
- request.agent.create(getContext(), config).then((task: request.agent.Task) => {
- task.start((err: BusinessError) => {
- if (err) {
- this.progress = `Failed to start the upload task, Code: ${err.code} message: ${err.message}`;
- return;
- }
- });
- task.on('progress', createOnCallback);
- let responseOnCallback = (response: request.agent.HttpResponse) => {
- logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`)
- let headers: string = '';
- for (let k of response.headers.keys()) {
- headers = headers + k + ':' + response.headers.get(k) + '\r\n';
- ;
- logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`)
- }
- this.message = headers;
- };
- task.on('response', responseOnCallback);
- task.on('failed', async (progress) => {
- this.message = JSON.stringify(progress);
- logger.debug(TAG, `/Request upload failed ${(JSON.stringify(progress))}`);
- promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM });
- })
- logger.debug(TAG, `Succeeded in creating a upload task. result: ${task.tid}`);
- }).catch((err: BusinessError) => {
- this.progress = `Failed to create a upload task, Code: ${err.code}, message: ${err.message}`;
- });
- }
-
- aboutToAppear() {
- logger.debug(TAG, 'aboutToAppear');
- }
-
- stateChange() {
- logger.debug(TAG, 'stateChange');
- }
+/*
+ * Copyright (c) 2024 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 common from '@ohos.app.ability.common';
+import promptAction from '@ohos.promptAction';
+import request from '@ohos.request';
+import connection from '@ohos.net.connection';
+import router from '@ohos.router';
+import { BusinessError } from '@ohos.base';
+import { logger, TOAST_BOTTOM } from '@ohos/uploaddownload';
+
+const TAG: string = 'CertLockSample';
+
+@Entry
+@Component
+struct CertLock {
+ @State message: string = ''
+ @State taskId: string = '';
+ @State progress: string = '0%';
+
+ build() {
+ Navigation() {
+ Text(this.message)
+ .fontSize(16)
+ .fontColor($r('app.color.text_message'))
+ .textAlign(TextAlign.Start)
+ .id('http_response')
+ .width('90%')
+ .height('80%')
+ .maxLines(30)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+
+ Button($r('app.string.upload'))
+ .id('upload')
+ .width('90%')
+ .fontSize(16)
+ .height(40)
+ .margin({ top: 10, bottom: 20 })
+ .enabled(true)
+ .backgroundColor($r('app.color.button_blue'))
+ .onClick(() => {
+ this.uploadTask();
+ })
+
+ Button($r('app.string.download'))
+ .id('download')
+ .type(ButtonType.Capsule)
+ .width('90%')
+ .fontSize(16)
+ .fontColor($r('app.color.btn_text_blue'))
+ .height(40)
+ .margin({ bottom: 10 })
+ .enabled(true)
+ .backgroundColor($r('app.color.button_light_gray'))
+ .onClick(() => {
+ this.DownloadTask();
+ })
+ }
+ .width('100%')
+ .height('100%')
+ .hideBackButton(false)
+ .titleMode(NavigationTitleMode.Mini)
+ .mode(NavigationMode.Stack)
+ .backgroundColor($r('app.color.light_gray'))
+ .hideToolBar(false)
+ .title($r('app.string.cert_lock'))
+ }
+
+ static task: request.agent.Task;
+ static netConnection = connection.createNetConnection();
+
+ async DownloadTask() {
+ logger.debug(TAG, 'DownloadTask');
+ let config: request.agent.Config = {
+ action: request.agent.Action.DOWNLOAD,
+ url: 'https://www.baidu.com',
+ gauge: true,
+ overwrite: true,
+ method: 'GET',
+ network: request.agent.Network.ANY,
+ };
+ let task: request.agent.Task = await request.agent.create(getContext(), config);
+ CertLock.task = task;
+ task.on('progress', async (progress) => {
+ logger.debug(TAG, `/Request download status ${progress.state}, downloaded ${progress.processed}`);
+ promptAction.showToast({
+ message: $r('app.string.download_finish'),
+ bottom: TOAST_BOTTOM,
+ offset: { dx: 10, dy: 96 }
+ });
+ this.taskId = task.tid;
+ })
+ let responseOnCallback = (response: request.agent.HttpResponse) => {
+ logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`)
+ let headers: string = '';
+ for (let k of response.headers.keys()) {
+ headers = headers + k + ':' + response.headers.get(k) + '\r\n';
+ ;
+ logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`)
+ }
+ this.message = headers;
+ };
+ task.on('response', responseOnCallback);
+
+ task.on('failed', async (progress) => {
+ this.message = JSON.stringify(progress);
+ logger.debug(TAG, `/Request download failed ${(JSON.stringify(progress))}`);
+ promptAction.showToast({ message: $r('app.string.download_fail'), bottom: TOAST_BOTTOM });
+ })
+ logger.debug(TAG, 'Downloading before');
+ await task.start();
+ logger.debug(TAG, 'Downloading started');
+ }
+
+ async uploadTask() {
+ logger.debug(TAG, 'uploadTask');
+ let attachments: Array = [];
+ let attachment: request.agent.FormItem = {
+ name: 'test',
+ value: [
+ {
+ filename: 'testUpload.txt',
+ path: './testUpload.txt',
+ },
+ ]
+ };
+ attachments.push(attachment);
+ let config: request.agent.Config = {
+ action: request.agent.Action.UPLOAD,
+ url: 'https://www.baidu.com',
+ title: 'taskOnTest',
+ mode: request.agent.Mode.FOREGROUND,
+ overwrite: true,
+ method: 'POST',
+ data: attachments,
+ saveas: './'
+ };
+ let createOnCallback = (progress: request.agent.Progress) => {
+ let txt: string = $r('app.string.upload_fail').bundleName;
+ this.progress = txt + ((progress.processed / 1024 / 1024));
+ promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM });
+ };
+ request.agent.create(getContext(), config).then((task: request.agent.Task) => {
+ task.start((err: BusinessError) => {
+ if (err) {
+ this.progress = `Failed to start the upload task, Code: ${err.code} message: ${err.message}`;
+ return;
+ }
+ });
+ task.on('progress', createOnCallback);
+ let responseOnCallback = (response: request.agent.HttpResponse) => {
+ logger.debug(TAG, `response : ${response.version} ${response.statusCode} ${response.reason} ${response.headers} ${response.headers.size}`)
+ let headers: string = '';
+ for (let k of response.headers.keys()) {
+ headers = headers + k + ':' + response.headers.get(k) + '\r\n';
+ ;
+ logger.debug(TAG, `response 1 ${k}, ${response.headers.get(k)}`)
+ }
+ this.message = headers;
+ };
+ task.on('response', responseOnCallback);
+ task.on('failed', async (progress) => {
+ this.message = JSON.stringify(progress);
+ logger.debug(TAG, `/Request upload failed ${(JSON.stringify(progress))}`);
+ promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM });
+ })
+ logger.debug(TAG, `Succeeded in creating a upload task. result: ${task.tid}`);
+ }).catch((err: BusinessError) => {
+ this.progress = `Failed to create a upload task, Code: ${err.code}, message: ${err.message}`;
+ });
+ }
+
+ aboutToAppear() {
+ logger.debug(TAG, 'aboutToAppear');
+ }
+
+ stateChange() {
+ logger.debug(TAG, 'stateChange');
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets
index 86f662222dd22f84372d6ee674273b61a430513b..21827b079c7ab885831931ce99dc2476e9f85762 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Download.ets
@@ -1,332 +1,332 @@
-/*
- * Copyright (c) 2023 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 promptAction from '@ohos.promptAction';
-import router from '@ohos.router';
-import { CustomDataSource } from '../components/CustomDataSource';
-import {
- FileModel,
- FileType,
- fileUtils,
- logger,
- requestFiles,
- requestDownload,
- BackgroundTaskState,
- TOAST_BOTTOM
-} from '@ohos/uploaddownload';
-import { SelectFolderDialog } from '../components/SelectFolderDialog';
-
-const TAG: string = 'DownloadSample';
-
-@Entry
-@Component
-struct Download {
- private fileData: CustomDataSource = new CustomDataSource([]);
- @StorageLink('isBackground') isBackground: boolean = false;
- @StorageLink('backDownTaskState') backDownTaskState: BackgroundTaskState = BackgroundTaskState.NONE;
- @Provide downloadFolder: Array = [];
- @State isGetData: boolean = false;
- @State checkFile: Array = [];
- @State checkList: Array = [];
- @State isRunning: boolean = false;
- @State isPause: boolean = false;
- @State progress: number = 0;
- private selectFolder = (folder: string) => {
- logger.info(TAG, `selectFolder = ${folder}`);
- this.download(folder);
- }
- private folderDialogController: CustomDialogController = new CustomDialogController({
- builder: SelectFolderDialog({ selectFolder: this.selectFolder }),
- autoCancel: true,
- alignment: DialogAlignment.Bottom,
- offset: { dx: 0, dy: -12 }
- });
-
- build() {
- Navigation() {
- Column() {
- if (this.isGetData) {
- LoadingProgress()
- .width(100)
- .layoutWeight(1)
- } else {
- List({ space: 12 }) {
- LazyForEach(this.fileData, (item: FileModel, index?: number) => {
- ListItem() {
- if (index !== undefined) {
- this.FileItem(item, index)
- }
- }
- }, (item: FileModel) => JSON.stringify(item))
- }
- .width('100%')
- .scrollBar(BarState.Off)
- .layoutWeight(1)
- .backgroundColor(Color.White)
- .borderRadius(24)
- .padding({ top: 4, bottom: 4 })
- .divider({ strokeWidth: 1, startMargin: 44, endMargin: 12 })
- }
- this.BottomView()
- }
- .padding({ left: 12, right: 12, bottom: 12 })
- .height('100%')
- }
- .width('100%')
- .height('100%')
- .hideBackButton(false)
- .titleMode(NavigationTitleMode.Mini)
- .mode(NavigationMode.Stack)
- .backgroundColor($r('app.color.light_gray'))
- .hideToolBar(false)
- .title($r('app.string.download'))
- }
-
- @Builder
- FileItem(file: FileModel, index: number) {
- Row() {
- Row() {
- if (file.fileType === FileType.FOLDER) {
- Image($r('app.media.ic_files_folder'))
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Contain)
- } else if (file.fileType === FileType.IMAGE) {
- Image($r('app.media.ic_public_picture'))
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Contain)
- } else if (file.fileType === FileType.MUSIC) {
- Image($r('app.media.ic_public_music'))
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Contain)
- } else if (file.fileType === FileType.Video) {
- Image($r('app.media.ic_public_video'))
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Contain)
- } else {
- Image($r('app.media.ic_public_document'))
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Contain)
- }
-
- Text(decodeURIComponent(file.name))
- .fontSize(16)
- .fontWeight(400)
- .layoutWeight(1)
- .maxLines(1)
- .textOverflow({ overflow: TextOverflow.Ellipsis })
- .margin({ left: 12 })
- }
- .layoutWeight(1)
-
- Checkbox({ name: '', group: 'checkboxGroup' })
- .select(this.checkList[index])
- .selectedColor($r('app.color.button_blue'))
- .margin({ left: 12 })
- .hitTestBehavior(HitTestMode.None)
- }
- .width('100%')
- .padding({ left: 12, right: 12 })
- .height(48)
- .onClick(() => {
- this.fileCheck(index);
- })
- }
-
- @Builder
- BottomView() {
- Column({ space: 12 }) {
- if (this.isBackground && this.backDownTaskState !== BackgroundTaskState.NONE) {
- Button() {
- Row() {
- Text(this.backDownTaskState === BackgroundTaskState.PAUSE ? $r('app.string.continue') : $r('app.string.pause'))
- .fontColor(Color.White)
- .fontSize(16)
- }
- }
- .id('download_to')
- .type(ButtonType.Capsule)
- .height(45)
- .width('100%')
- .backgroundColor($r('app.color.button_blue'))
- .onClick(() => {
- requestDownload.pauseOrResume();
- })
-
- Button() {
- Row() {
- Text($r('app.string.cancel'))
- .fontColor(Color.White)
- .fontSize(16)
- }
- }
- .id('download_to')
- .type(ButtonType.Capsule)
- .height(45)
- .width('100%')
- .backgroundColor($r('app.color.button_blue'))
- .onClick(() => {
- requestDownload.deleteAllBackTasks();
- })
- }
- if (!this.isBackground || this.isBackground && this.backDownTaskState === BackgroundTaskState.NONE) {
- Button() {
- Row() {
- if (!this.isBackground && this.isRunning) {
- Text(`${this.progress}%`)
- .fontColor(Color.White)
- .fontSize(16)
- Text($r('app.string.downloading'))
- .fontColor(Color.White)
- .fontSize(16)
- .margin({ left: 12 })
- } else {
- Text($r('app.string.download'))
- .fontColor(Color.White)
- .fontSize(16)
- }
- }
- }
- .id('download_to')
- .type(ButtonType.Capsule)
- .height(45)
- .width('100%')
- .backgroundColor($r('app.color.button_blue'))
- .onClick(() => {
- if (!this.isRunning) {
- this.folderDialogController.open();
- }
- })
- }
- Button($r('app.string.view_download_files'))
- .id('view_download_files')
- .type(ButtonType.Capsule)
- .backgroundColor($r('sys.color.ohos_id_color_button_normal'))
- .width('100%')
- .fontSize(16)
- .margin({ bottom: 12 })
- .fontColor($r('app.color.btn_text_blue'))
- .onClick(() => {
- router.pushUrl({
- url: 'pages/DownloadFiles'
- });
- })
- }
- .margin({ top: 12, left: 12, right: 12 })
- }
-
- aboutToAppear() {
- logger.debug(TAG, 'aboutToAppear');
- this.isRunning = false;
- this.isPause = false;
- this.isGetData = true;
- requestFiles.requestFiles().then((data: FileModel[]) => {
- this.checkList = [];
- this.isRunning = false;
- this.fileData.dataArray = data;
- this.fileData.dataArray.forEach((item: FileModel) => {
- this.checkList.push(false);
- })
- this.isGetData = false;
- this.fileData.notifyDataReload();
- })
- fileUtils.listFolders().then((folders: Array) => {
- this.downloadFolder = folders;
- })
- }
-
- fileCheck(index: number) {
- logger.debug(TAG, `fileCheck= ${index}`);
- if (!this.isBackground) {
- for (let i = 0; i < this.checkList.length; i++) {
- if (i !== index) {
- this.checkList[i] = false;
- }
- }
- }
- this.checkList[index] = !this.checkList[index];
- logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`);
- }
-
- download(folder: string) {
- logger.debug(TAG, `download folder= ${folder}`);
- this.checkFile = [];
- if (this.checkList === undefined) {
- return;
- }
- logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`);
- for (let i = 0; i < this.checkList.length; i++) {
- if (this.checkList[i]) {
- let fileModel = this.fileData.getData(i);
- logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`);
- fileModel.files.forEach((url: string) => {
- let splitUrl = url.split('//')[1].split('/');
- if (splitUrl[splitUrl.length-1] !== '') {
- this.checkFile.push(url);
- }
- });
- }
- }
- logger.info(TAG, `this.checkFile = ${JSON.stringify(this.checkFile)}`);
- if (this.checkFile.length === 0) {
- promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM });
- return;
- }
- this.progress = 0;
- logger.info(TAG, `this.isBackground = ${JSON.stringify(this.isBackground)}`);
- if (this.isBackground) {
- this.isRunning = false;
- this.backDownTaskState = BackgroundTaskState.RUNNING;
- requestDownload.downloadFilesBackground(folder, this.checkFile);
- this.checkFile = [];
- this.checkList = [];
- this.fileData.dataArray.forEach((item: FileModel) => {
- this.checkList.push(false);
- })
- this.fileData.notifyDataReload();
- promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM });
- } else {
- this.isRunning = true;
- requestDownload.downloadFile(folder, this.checkFile[0], this.downloadFileCallback);
- }
- }
-
- downloadFilesCallback = (downloadCount: number, isSuccess: boolean) => {
- logger.debug(TAG, 'downloadFilesCallback');
- this.progress = downloadCount;
- if (downloadCount === this.checkFile.length) {
- this.downloadFinish(isSuccess);
- }
- }
- downloadFileCallback = (progress: number, isSuccess: boolean) => {
- logger.debug(TAG, 'downloadFileCallback');
- this.progress = progress;
- if (this.progress === 100) {
- this.downloadFinish(isSuccess);
- }
- }
-
- downloadFinish(isSuccess: boolean) {
- logger.debug(TAG, 'downloadFinish');
- this.isRunning = false;
- this.checkFile = [];
- this.checkList = [];
- this.fileData.dataArray.forEach((item: FileModel) => {
- this.checkList.push(false);
- })
- this.fileData.notifyDataReload();
- let message = isSuccess ? $r('app.string.download_finish') : $r('app.string.download_fail');
- promptAction.showToast({ message: message, bottom: TOAST_BOTTOM });
- }
+/*
+ * Copyright (c) 2023 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 promptAction from '@ohos.promptAction';
+import router from '@ohos.router';
+import { CustomDataSource } from '../components/CustomDataSource';
+import {
+ FileModel,
+ FileType,
+ fileUtils,
+ logger,
+ requestFiles,
+ requestDownload,
+ BackgroundTaskState,
+ TOAST_BOTTOM
+} from '@ohos/uploaddownload';
+import { SelectFolderDialog } from '../components/SelectFolderDialog';
+
+const TAG: string = 'DownloadSample';
+
+@Entry
+@Component
+struct Download {
+ private fileData: CustomDataSource = new CustomDataSource([]);
+ @StorageLink('isBackground') isBackground: boolean = false;
+ @StorageLink('backDownTaskState') backDownTaskState: BackgroundTaskState = BackgroundTaskState.NONE;
+ @Provide downloadFolder: Array = [];
+ @State isGetData: boolean = false;
+ @State checkFile: Array = [];
+ @State checkList: Array = [];
+ @State isRunning: boolean = false;
+ @State isPause: boolean = false;
+ @State progress: number = 0;
+ private selectFolder = (folder: string) => {
+ logger.info(TAG, `selectFolder = ${folder}`);
+ this.download(folder);
+ }
+ private folderDialogController: CustomDialogController = new CustomDialogController({
+ builder: SelectFolderDialog({ selectFolder: this.selectFolder }),
+ autoCancel: true,
+ alignment: DialogAlignment.Bottom,
+ offset: { dx: 0, dy: -12 }
+ });
+
+ build() {
+ Navigation() {
+ Column() {
+ if (this.isGetData) {
+ LoadingProgress()
+ .width(100)
+ .layoutWeight(1)
+ } else {
+ List({ space: 12 }) {
+ LazyForEach(this.fileData, (item: FileModel, index?: number) => {
+ ListItem() {
+ if (index !== undefined) {
+ this.FileItem(item, index)
+ }
+ }
+ }, (item: FileModel) => JSON.stringify(item))
+ }
+ .width('100%')
+ .scrollBar(BarState.Off)
+ .layoutWeight(1)
+ .backgroundColor(Color.White)
+ .borderRadius(24)
+ .padding({ top: 4, bottom: 4 })
+ .divider({ strokeWidth: 1, startMargin: 44, endMargin: 12 })
+ }
+ this.BottomView()
+ }
+ .padding({ left: 12, right: 12, bottom: 12 })
+ .height('100%')
+ }
+ .width('100%')
+ .height('100%')
+ .hideBackButton(false)
+ .titleMode(NavigationTitleMode.Mini)
+ .mode(NavigationMode.Stack)
+ .backgroundColor($r('app.color.light_gray'))
+ .hideToolBar(false)
+ .title($r('app.string.download'))
+ }
+
+ @Builder
+ FileItem(file: FileModel, index: number) {
+ Row() {
+ Row() {
+ if (file.fileType === FileType.FOLDER) {
+ Image($r('app.media.ic_files_folder'))
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Contain)
+ } else if (file.fileType === FileType.IMAGE) {
+ Image($r('app.media.ic_public_picture'))
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Contain)
+ } else if (file.fileType === FileType.MUSIC) {
+ Image($r('app.media.ic_public_music'))
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Contain)
+ } else if (file.fileType === FileType.Video) {
+ Image($r('app.media.ic_public_video'))
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Contain)
+ } else {
+ Image($r('app.media.ic_public_document'))
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Contain)
+ }
+
+ Text(decodeURIComponent(file.name))
+ .fontSize(16)
+ .fontWeight(400)
+ .layoutWeight(1)
+ .maxLines(1)
+ .textOverflow({ overflow: TextOverflow.Ellipsis })
+ .margin({ left: 12 })
+ }
+ .layoutWeight(1)
+
+ Checkbox({ name: '', group: 'checkboxGroup' })
+ .select(this.checkList[index])
+ .selectedColor($r('app.color.button_blue'))
+ .margin({ left: 12 })
+ .hitTestBehavior(HitTestMode.None)
+ }
+ .width('100%')
+ .padding({ left: 12, right: 12 })
+ .height(48)
+ .onClick(() => {
+ this.fileCheck(index);
+ })
+ }
+
+ @Builder
+ BottomView() {
+ Column({ space: 12 }) {
+ if (this.isBackground && this.backDownTaskState !== BackgroundTaskState.NONE) {
+ Button() {
+ Row() {
+ Text(this.backDownTaskState === BackgroundTaskState.PAUSE ? $r('app.string.continue') : $r('app.string.pause'))
+ .fontColor(Color.White)
+ .fontSize(16)
+ }
+ }
+ .id('download_to')
+ .type(ButtonType.Capsule)
+ .height(45)
+ .width('100%')
+ .backgroundColor($r('app.color.button_blue'))
+ .onClick(() => {
+ requestDownload.pauseOrResume();
+ })
+
+ Button() {
+ Row() {
+ Text($r('app.string.cancel'))
+ .fontColor(Color.White)
+ .fontSize(16)
+ }
+ }
+ .id('download_to')
+ .type(ButtonType.Capsule)
+ .height(45)
+ .width('100%')
+ .backgroundColor($r('app.color.button_blue'))
+ .onClick(() => {
+ requestDownload.deleteAllBackTasks();
+ })
+ }
+ if (!this.isBackground || this.isBackground && this.backDownTaskState === BackgroundTaskState.NONE) {
+ Button() {
+ Row() {
+ if (!this.isBackground && this.isRunning) {
+ Text(`${this.progress}%`)
+ .fontColor(Color.White)
+ .fontSize(16)
+ Text($r('app.string.downloading'))
+ .fontColor(Color.White)
+ .fontSize(16)
+ .margin({ left: 12 })
+ } else {
+ Text($r('app.string.download'))
+ .fontColor(Color.White)
+ .fontSize(16)
+ }
+ }
+ }
+ .id('download_to')
+ .type(ButtonType.Capsule)
+ .height(45)
+ .width('100%')
+ .backgroundColor($r('app.color.button_blue'))
+ .onClick(() => {
+ if (!this.isRunning) {
+ this.folderDialogController.open();
+ }
+ })
+ }
+ Button($r('app.string.view_download_files'))
+ .id('view_download_files')
+ .type(ButtonType.Capsule)
+ .backgroundColor($r('sys.color.ohos_id_color_button_normal'))
+ .width('100%')
+ .fontSize(16)
+ .margin({ bottom: 12 })
+ .fontColor($r('app.color.btn_text_blue'))
+ .onClick(() => {
+ router.pushUrl({
+ url: 'pages/DownloadFiles'
+ });
+ })
+ }
+ .margin({ top: 12, left: 12, right: 12 })
+ }
+
+ aboutToAppear() {
+ logger.debug(TAG, 'aboutToAppear');
+ this.isRunning = false;
+ this.isPause = false;
+ this.isGetData = true;
+ requestFiles.requestFiles().then((data: FileModel[]) => {
+ this.checkList = [];
+ this.isRunning = false;
+ this.fileData.dataArray = data;
+ this.fileData.dataArray.forEach((item: FileModel) => {
+ this.checkList.push(false);
+ })
+ this.isGetData = false;
+ this.fileData.notifyDataReload();
+ })
+ fileUtils.listFolders().then((folders: Array) => {
+ this.downloadFolder = folders;
+ })
+ }
+
+ fileCheck(index: number) {
+ logger.debug(TAG, `fileCheck= ${index}`);
+ if (!this.isBackground) {
+ for (let i = 0; i < this.checkList.length; i++) {
+ if (i !== index) {
+ this.checkList[i] = false;
+ }
+ }
+ }
+ this.checkList[index] = !this.checkList[index];
+ logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`);
+ }
+
+ download(folder: string) {
+ logger.debug(TAG, `download folder= ${folder}`);
+ this.checkFile = [];
+ if (this.checkList === undefined) {
+ return;
+ }
+ logger.info(TAG, `this.checkList = ${JSON.stringify(this.checkList)}`);
+ for (let i = 0; i < this.checkList.length; i++) {
+ if (this.checkList[i]) {
+ let fileModel = this.fileData.getData(i);
+ logger.info(TAG, `fileModel = ${JSON.stringify(fileModel)}`);
+ fileModel.files.forEach((url: string) => {
+ let splitUrl = url.split('//')[1].split('/');
+ if (splitUrl[splitUrl.length-1] !== '') {
+ this.checkFile.push(url);
+ }
+ });
+ }
+ }
+ logger.info(TAG, `this.checkFile = ${JSON.stringify(this.checkFile)}`);
+ if (this.checkFile.length === 0) {
+ promptAction.showToast({ message: $r('app.string.check_file_tips'), bottom: TOAST_BOTTOM });
+ return;
+ }
+ this.progress = 0;
+ logger.info(TAG, `this.isBackground = ${JSON.stringify(this.isBackground)}`);
+ if (this.isBackground) {
+ this.isRunning = false;
+ this.backDownTaskState = BackgroundTaskState.RUNNING;
+ requestDownload.downloadFilesBackground(folder, this.checkFile);
+ this.checkFile = [];
+ this.checkList = [];
+ this.fileData.dataArray.forEach((item: FileModel) => {
+ this.checkList.push(false);
+ })
+ this.fileData.notifyDataReload();
+ promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM });
+ } else {
+ this.isRunning = true;
+ requestDownload.downloadFile(folder, this.checkFile[0], this.downloadFileCallback);
+ }
+ }
+
+ downloadFilesCallback = (downloadCount: number, isSuccess: boolean) => {
+ logger.debug(TAG, 'downloadFilesCallback');
+ this.progress = downloadCount;
+ if (downloadCount === this.checkFile.length) {
+ this.downloadFinish(isSuccess);
+ }
+ }
+ downloadFileCallback = (progress: number, isSuccess: boolean) => {
+ logger.debug(TAG, 'downloadFileCallback');
+ this.progress = progress;
+ if (this.progress === 100) {
+ this.downloadFinish(isSuccess);
+ }
+ }
+
+ downloadFinish(isSuccess: boolean) {
+ logger.debug(TAG, 'downloadFinish');
+ this.isRunning = false;
+ this.checkFile = [];
+ this.checkList = [];
+ this.fileData.dataArray.forEach((item: FileModel) => {
+ this.checkList.push(false);
+ })
+ this.fileData.notifyDataReload();
+ let message = isSuccess ? $r('app.string.download_finish') : $r('app.string.download_fail');
+ promptAction.showToast({ message: message, bottom: TOAST_BOTTOM });
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets
index a2ed4f2e8e9a7474c0a19f792de9ef08d864266c..7d201e0a0df57b16a1ce01a946118d59df9abf3b 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Index.ets
@@ -1,136 +1,136 @@
-/*
- * Copyright (c) 2023 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 notificationManager from '@ohos.notificationManager';
-import router from '@ohos.router';
-import common from '@ohos.app.ability.common';
-import { urlUtils } from '@ohos/uploaddownload';
-import util from '@ohos.util';
-
-@Styles
-function itemStyle() {
- .width('100%')
- .height(56)
- .padding({ top: 17, bottom: 17, left: 12, right: 12 })
- .backgroundColor(Color.White)
- .borderRadius(24)
- .margin({ top: 20 })
-}
-
-@Extend(Text)
-function textStyle() {
- .fontColor($r('app.color.text_normal'))
- .fontWeight(400)
- .fontFamily('HarmonyHeiTi')
- .fontSize(16)
-}
-
-@Entry
-@Component
-struct Index {
- @StorageLink('isBackground') isBackground: boolean = false;
-
- aboutToAppear() {
- notificationManager.requestEnableNotification();
- }
-
- build() {
- Navigation() {
- Scroll() {
- Column() {
- Row() {
- Text($r('app.string.background_tips'))
- .textStyle()
- Blank()
- Toggle({ type: ToggleType.Switch, isOn: this.isBackground })
- .width(40)
- .height(24)
- .onChange((isOn: boolean) => {
- this.isBackground = isOn;
- AppStorage.setOrCreate('isBackground', isOn);
- })
- }
- .itemStyle()
- .margin({ top: 20 })
-
- Row() {
- Text($r('app.string.HFS_tips'))
- .textStyle()
- Blank()
- TextInput()
- .width(250)
- .height(40)
- .margin({left : 20})
- .onChange((val) => urlUtils.saveUrl(getContext(this) as common.UIAbilityContext,val))
- }
-
- .itemStyle()
- .margin({ top: 15 })
-
- this.CapabilityView($r('app.media.ic_upload'), $r('app.string.upload'), 'btn_upload', () => {
- router.pushUrl({
- url: 'pages/Upload'
- })
- })
- this.CapabilityView($r('app.media.ic_download'), $r('app.string.download'), 'btn_download', () => {
- router.pushUrl({
- url: 'pages/Download'
- })
- })
- this.CapabilityView($r('app.media.ic_certified'), $r('app.string.cert_lock'), 'btn_cert_lock', () => {
- router.pushUrl({
- url: 'pages/CertLock'
- })
- })
- }
- .width('100%')
- .margin({ left:-12 })
- }
- .padding({ left: 12, right: 6 })
- .height('100%')
- .align(Alignment.Top)
- }
- .width('100%')
- .height('100%')
- .hideBackButton(true)
- .titleMode(NavigationTitleMode.Mini)
- .backgroundColor($r('app.color.light_gray'))
- .title({
- main: this.getResourceString($r('app.string.EntryAbility_label')),
- sub: this.getResourceString($r('app.string.home_tips'))
- })
- .padding({ top:5 })
- }
-
- @Builder
- CapabilityView(image: Resource, text: Resource, id: string, onClick: () => void) {
- Row() {
- Image(image)
- .size({ width: 24, height: 24 })
- .objectFit(ImageFit.Cover)
- Text(text)
- .textStyle()
- .margin({ left: 12 })
- }
- .itemStyle()
- .id(id)
- .onClick(onClick)
- }
-
- getResourceString(resource: Resource) {
- let context = getContext(this) as common.UIAbilityContext;
- return context.resourceManager.getStringSync(resource.id);
- }
+/*
+ * Copyright (c) 2023 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 notificationManager from '@ohos.notificationManager';
+import router from '@ohos.router';
+import common from '@ohos.app.ability.common';
+import { urlUtils } from '@ohos/uploaddownload';
+import util from '@ohos.util';
+
+@Styles
+function itemStyle() {
+ .width('100%')
+ .height(56)
+ .padding({ top: 17, bottom: 17, left: 12, right: 12 })
+ .backgroundColor(Color.White)
+ .borderRadius(24)
+ .margin({ top: 20 })
+}
+
+@Extend(Text)
+function textStyle() {
+ .fontColor($r('app.color.text_normal'))
+ .fontWeight(400)
+ .fontFamily('HarmonyHeiTi')
+ .fontSize(16)
+}
+
+@Entry
+@Component
+struct Index {
+ @StorageLink('isBackground') isBackground: boolean = false;
+
+ aboutToAppear() {
+ notificationManager.requestEnableNotification();
+ }
+
+ build() {
+ Navigation() {
+ Scroll() {
+ Column() {
+ Row() {
+ Text($r('app.string.background_tips'))
+ .textStyle()
+ Blank()
+ Toggle({ type: ToggleType.Switch, isOn: this.isBackground })
+ .width(40)
+ .height(24)
+ .onChange((isOn: boolean) => {
+ this.isBackground = isOn;
+ AppStorage.setOrCreate('isBackground', isOn);
+ })
+ }
+ .itemStyle()
+ .margin({ top: 20 })
+
+ Row() {
+ Text($r('app.string.HFS_tips'))
+ .textStyle()
+ Blank()
+ TextInput()
+ .width(250)
+ .height(40)
+ .margin({left : 20})
+ .onChange((val) => urlUtils.saveUrl(getContext(this) as common.UIAbilityContext,val))
+ }
+
+ .itemStyle()
+ .margin({ top: 15 })
+
+ this.CapabilityView($r('app.media.ic_upload'), $r('app.string.upload'), 'btn_upload', () => {
+ router.pushUrl({
+ url: 'pages/Upload'
+ })
+ })
+ this.CapabilityView($r('app.media.ic_download'), $r('app.string.download'), 'btn_download', () => {
+ router.pushUrl({
+ url: 'pages/Download'
+ })
+ })
+ this.CapabilityView($r('app.media.ic_certified'), $r('app.string.cert_lock'), 'btn_cert_lock', () => {
+ router.pushUrl({
+ url: 'pages/CertLock'
+ })
+ })
+ }
+ .width('100%')
+ .margin({ left:-12 })
+ }
+ .padding({ left: 12, right: 6 })
+ .height('100%')
+ .align(Alignment.Top)
+ }
+ .width('100%')
+ .height('100%')
+ .hideBackButton(true)
+ .titleMode(NavigationTitleMode.Mini)
+ .backgroundColor($r('app.color.light_gray'))
+ .title({
+ main: this.getResourceString($r('app.string.EntryAbility_label')),
+ sub: this.getResourceString($r('app.string.home_tips'))
+ })
+ .padding({ top:5 })
+ }
+
+ @Builder
+ CapabilityView(image: Resource, text: Resource, id: string, onClick: () => void) {
+ Row() {
+ Image(image)
+ .size({ width: 24, height: 24 })
+ .objectFit(ImageFit.Cover)
+ Text(text)
+ .textStyle()
+ .margin({ left: 12 })
+ }
+ .itemStyle()
+ .id(id)
+ .onClick(onClick)
+ }
+
+ getResourceString(resource: Resource) {
+ let context = getContext(this) as common.UIAbilityContext;
+ return context.resourceManager.getStringSync(resource.id);
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets
index 33bb2eb4adad8c8e5493bfcba1eff8c30e5d6f67..be9defe7129716335dd094a7e2b93c926b81161b 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/ets/pages/Upload.ets
@@ -1,246 +1,246 @@
-/*
- * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
-import fs from '@ohos.file.fs';
-import promptAction from '@ohos.promptAction';
-import { AddPictures } from '../components/AddPictures';
-import { ConfigFileChunkDialog } from '../components/ConfigFileChunkDialog';
-import { BackgroundTaskState, requestUpload, logger, TOAST_BOTTOM, NO_IMAGE_SELECTED } from '@ohos/uploaddownload';
-
-const TIME_MAX: number = 5;
-const TAG: string = 'UploadSample';
-
-@Entry
-@Component
-struct Upload {
- @StorageLink('isBackground') isBackground: boolean = false;
- @StorageLink('backTaskState') @Watch('stateChange') backTaskState: BackgroundTaskState = BackgroundTaskState.NONE;
- @State isBegin: boolean = false;
- @Provide imageList: Array = [];
- @State progress: number = 0;
- @State countdown: number = 0;
- @Provide @Watch('onChunkImgIndexChange') chunkImgIndex: number = NO_IMAGE_SELECTED;
- @Provide chunkInputEnable: boolean = false;
- @Provide chunkParaBegins: number = 0;
- @Provide chunkParaEnds: number = -1;
- chunkDialog: CustomDialogController = new CustomDialogController({
- builder: ConfigFileChunkDialog({
- upload: this.uploadFiles
- }),
- alignment: DialogAlignment.Bottom,
- offset: { dx: 0, dy: -12 },
- cancel: this.onChunkDiaglogCancel
- });
-
- build() {
- Navigation() {
- Scroll() {
- AddPictures()
- }
- .padding({ left: 24, right: 24 })
- .width('100%')
- .layoutWeight(1)
- .align(Alignment.Top)
- .margin({ bottom: 24 })
-
- Column() {
- Button() {
- if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) {
- if (this.backTaskState === BackgroundTaskState.RUNNING) {
- Text($r('app.string.pause'))
- .fontSize(16)
- .fontWeight(500)
- .fontColor($r('app.color.white'))
- } else {
- Text($r('app.string.continue'))
- .fontSize(16)
- .fontWeight(500)
- .fontColor($r('app.color.white'))
- }
- } else if (this.isBegin && !this.isBackground) {
- Row() {
- Progress({ value: this.progress, type: ProgressType.Ring })
- .width(20)
- .height(20)
- .backgroundColor('#FFFFFF')
- .color('#558DFF')
- .style({ strokeWidth: 2, scaleCount: 100, scaleWidth: 2 })
- Text(`${this.getResourceString($r('app.string.uploading'))}${this.progress}%`)
- .fontSize(16)
- .fontColor(0xffffff)
- .fontWeight(500)
- .margin({ left: 12 })
- }.alignItems(VerticalAlign.Center)
- } else {
- if (this.countdown > 0) {
- Text(`${this.countdown}s`)
- .fontSize(16)
- .fontWeight(500)
- .fontColor($r('app.color.white'))
- } else {
- Text($r('app.string.upload'))
- .fontSize(16)
- .fontWeight(500)
- .fontColor($r('app.color.white'))
- }
- }
- }
- .id('publish')
- .width('100%')
- .height(40)
- .margin({ bottom: this.isBegin ? 16 : 24 })
- .enabled(this.countdown > 0 ? false : true)
- .backgroundColor($r('app.color.button_blue'))
- .onClick(() => {
- if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) {
- requestUpload.pauseOrResume();
- } else {
- this.uploadFiles();
- }
- })
-
- if (this.isBegin) {
- Button() {
- Text($r('app.string.cancel'))
- .fontSize(16)
- .fontWeight(500)
- .fontColor($r('app.color.btn_text_blue'))
- }
- .id('cancel')
- .width('100%')
- .height(40)
- .margin({ bottom: 24 })
- .backgroundColor($r('app.color.button_light_gray'))
- .onClick(() => {
- // 取消上传任务
- requestUpload.cancelTask();
- this.progress = 0;
- this.isBegin = false;
- })
- }
- }
- .width('100%')
- .padding({ left: 24, right: 24 })
- }
- .width('100%')
- .height('100%')
- .backgroundColor($r('app.color.light_gray'))
- .title($r('app.string.upload'))
- .hideBackButton(false)
- .titleMode(NavigationTitleMode.Mini)
- .mode(NavigationMode.Stack)
- }
-
- aboutToAppear() {
- logger.debug(TAG, 'aboutToAppear');
- this.isBegin = false;
- this.backTaskState = BackgroundTaskState.NONE;
- }
-
- stateChange() {
- logger.debug(TAG, 'stateChange');
- if (this.backTaskState === BackgroundTaskState.NONE) {
- this.imageList = [];
- }
- }
-
- uploadFiles() {
- logger.debug(TAG, 'uploadFiles');
- if (this.imageList.length == 0) {
- return;
- }
-
- if (this.chunkInputEnable) { // 选中checkbox,从该文件分段上传
- this.isBegin = true;
- this.progress = 0;
- let index = this.chunkImgIndex;
- let fileUris = this.imageList.slice(index);
- console.debug(TAG + 'fileuri:' + fileUris);
- requestUpload.uploadFileChunk(fileUris, this.chunkParaBegins, this.chunkParaEnds, (progress: number, isSucceed: boolean) => {
- this.progress = progress;
- if (this.progress === 100 && isSucceed) {
- this.isBegin = false;
- this.imageList = this.imageList.slice(0, index);
- promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM });
- }
- if (this.progress === 100 && isSucceed === false) {
- this.isBegin = false;
- this.countdown = TIME_MAX;
- let interval = setInterval(() => {
- if (this.countdown > 0) {
- this.countdown--;
- } else {
- clearInterval(interval);
- }
- }, 1000);
- promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM });
- }
- });
- return;
- }
- console.debug(TAG + ':imageList:' + this.imageList);
- if (this.isBackground) {
- AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING);
- requestUpload.uploadFilesBackground(this.imageList);
- promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM });
- } else {
- this.isBegin = true;
- this.progress = 0;
- requestUpload.uploadFiles(this.imageList, (progress: number, isSucceed: boolean) => {
- this.progress = progress;
- if (this.progress === 100 && isSucceed) {
- this.isBegin = false;
- this.imageList = [];
- promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM })
- }
- if (this.progress === 100 && isSucceed === false) {
- this.isBegin = false;
- this.countdown = TIME_MAX;
- let interval = setInterval(() => {
- if (this.countdown > 0) {
- this.countdown--;
- } else {
- clearInterval(interval);
- }
- }, 1000);
- promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM })
- }
- });
- }
- }
-
- getResourceString(resource: Resource) {
- let context = getContext(this) as common.UIAbilityContext;
- let res = context.resourceManager.getStringSync(resource.id);
- logger.debug(TAG + ':****' + res);
- return res;
- }
-
- onChunkImgIndexChange(propName: string) {
- logger.debug(TAG, 'onChunkImgIndexChange');
- if (this.chunkImgIndex != NO_IMAGE_SELECTED) {
- this.chunkDialog.open();
- }
- this.chunkInputEnable = false;
- this.chunkParaBegins = 0;
- this.chunkParaEnds = -1;
- }
-
- onChunkDiaglogCancel() {
- logger.debug(TAG, 'onChunkDiaglogCancel');
- this.chunkImgIndex = NO_IMAGE_SELECTED;
- }
+/*
+ * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
+import fs from '@ohos.file.fs';
+import promptAction from '@ohos.promptAction';
+import { AddPictures } from '../components/AddPictures';
+import { ConfigFileChunkDialog } from '../components/ConfigFileChunkDialog';
+import { BackgroundTaskState, requestUpload, logger, TOAST_BOTTOM, NO_IMAGE_SELECTED } from '@ohos/uploaddownload';
+
+const TIME_MAX: number = 5;
+const TAG: string = 'UploadSample';
+
+@Entry
+@Component
+struct Upload {
+ @StorageLink('isBackground') isBackground: boolean = false;
+ @StorageLink('backTaskState') @Watch('stateChange') backTaskState: BackgroundTaskState = BackgroundTaskState.NONE;
+ @State isBegin: boolean = false;
+ @Provide imageList: Array = [];
+ @State progress: number = 0;
+ @State countdown: number = 0;
+ @Provide @Watch('onChunkImgIndexChange') chunkImgIndex: number = NO_IMAGE_SELECTED;
+ @Provide chunkInputEnable: boolean = false;
+ @Provide chunkParaBegins: number = 0;
+ @Provide chunkParaEnds: number = -1;
+ chunkDialog: CustomDialogController = new CustomDialogController({
+ builder: ConfigFileChunkDialog({
+ upload: this.uploadFiles
+ }),
+ alignment: DialogAlignment.Bottom,
+ offset: { dx: 0, dy: -12 },
+ cancel: this.onChunkDiaglogCancel
+ });
+
+ build() {
+ Navigation() {
+ Scroll() {
+ AddPictures()
+ }
+ .padding({ left: 24, right: 24 })
+ .width('100%')
+ .layoutWeight(1)
+ .align(Alignment.Top)
+ .margin({ bottom: 24 })
+
+ Column() {
+ Button() {
+ if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) {
+ if (this.backTaskState === BackgroundTaskState.RUNNING) {
+ Text($r('app.string.pause'))
+ .fontSize(16)
+ .fontWeight(500)
+ .fontColor($r('app.color.white'))
+ } else {
+ Text($r('app.string.continue'))
+ .fontSize(16)
+ .fontWeight(500)
+ .fontColor($r('app.color.white'))
+ }
+ } else if (this.isBegin && !this.isBackground) {
+ Row() {
+ Progress({ value: this.progress, type: ProgressType.Ring })
+ .width(20)
+ .height(20)
+ .backgroundColor('#FFFFFF')
+ .color('#558DFF')
+ .style({ strokeWidth: 2, scaleCount: 100, scaleWidth: 2 })
+ Text(`${this.getResourceString($r('app.string.uploading'))}${this.progress}%`)
+ .fontSize(16)
+ .fontColor(0xffffff)
+ .fontWeight(500)
+ .margin({ left: 12 })
+ }.alignItems(VerticalAlign.Center)
+ } else {
+ if (this.countdown > 0) {
+ Text(`${this.countdown}s`)
+ .fontSize(16)
+ .fontWeight(500)
+ .fontColor($r('app.color.white'))
+ } else {
+ Text($r('app.string.upload'))
+ .fontSize(16)
+ .fontWeight(500)
+ .fontColor($r('app.color.white'))
+ }
+ }
+ }
+ .id('publish')
+ .width('100%')
+ .height(40)
+ .margin({ bottom: this.isBegin ? 16 : 24 })
+ .enabled(this.countdown > 0 ? false : true)
+ .backgroundColor($r('app.color.button_blue'))
+ .onClick(() => {
+ if (this.isBackground && this.backTaskState !== BackgroundTaskState.NONE) {
+ requestUpload.pauseOrResume();
+ } else {
+ this.uploadFiles();
+ }
+ })
+
+ if (this.isBegin) {
+ Button() {
+ Text($r('app.string.cancel'))
+ .fontSize(16)
+ .fontWeight(500)
+ .fontColor($r('app.color.btn_text_blue'))
+ }
+ .id('cancel')
+ .width('100%')
+ .height(40)
+ .margin({ bottom: 24 })
+ .backgroundColor($r('app.color.button_light_gray'))
+ .onClick(() => {
+ // 取消上传任务
+ requestUpload.cancelTask();
+ this.progress = 0;
+ this.isBegin = false;
+ })
+ }
+ }
+ .width('100%')
+ .padding({ left: 24, right: 24 })
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor($r('app.color.light_gray'))
+ .title($r('app.string.upload'))
+ .hideBackButton(false)
+ .titleMode(NavigationTitleMode.Mini)
+ .mode(NavigationMode.Stack)
+ }
+
+ aboutToAppear() {
+ logger.debug(TAG, 'aboutToAppear');
+ this.isBegin = false;
+ this.backTaskState = BackgroundTaskState.NONE;
+ }
+
+ stateChange() {
+ logger.debug(TAG, 'stateChange');
+ if (this.backTaskState === BackgroundTaskState.NONE) {
+ this.imageList = [];
+ }
+ }
+
+ uploadFiles() {
+ logger.debug(TAG, 'uploadFiles');
+ if (this.imageList.length == 0) {
+ return;
+ }
+
+ if (this.chunkInputEnable) { // 选中checkbox,从该文件分段上传
+ this.isBegin = true;
+ this.progress = 0;
+ let index = this.chunkImgIndex;
+ let fileUris = this.imageList.slice(index);
+ console.debug(TAG + 'fileuri:' + fileUris);
+ requestUpload.uploadFileChunk(fileUris, this.chunkParaBegins, this.chunkParaEnds, (progress: number, isSucceed: boolean) => {
+ this.progress = progress;
+ if (this.progress === 100 && isSucceed) {
+ this.isBegin = false;
+ this.imageList = this.imageList.slice(0, index);
+ promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM });
+ }
+ if (this.progress === 100 && isSucceed === false) {
+ this.isBegin = false;
+ this.countdown = TIME_MAX;
+ let interval = setInterval(() => {
+ if (this.countdown > 0) {
+ this.countdown--;
+ } else {
+ clearInterval(interval);
+ }
+ }, 1000);
+ promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM });
+ }
+ });
+ return;
+ }
+ console.debug(TAG + ':imageList:' + this.imageList);
+ if (this.isBackground) {
+ AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING);
+ requestUpload.uploadFilesBackground(this.imageList);
+ promptAction.showToast({ message: $r('app.string.background_task_start'), bottom: TOAST_BOTTOM });
+ } else {
+ this.isBegin = true;
+ this.progress = 0;
+ requestUpload.uploadFiles(this.imageList, (progress: number, isSucceed: boolean) => {
+ this.progress = progress;
+ if (this.progress === 100 && isSucceed) {
+ this.isBegin = false;
+ this.imageList = [];
+ promptAction.showToast({ message: $r('app.string.upload_success'), bottom: TOAST_BOTTOM })
+ }
+ if (this.progress === 100 && isSucceed === false) {
+ this.isBegin = false;
+ this.countdown = TIME_MAX;
+ let interval = setInterval(() => {
+ if (this.countdown > 0) {
+ this.countdown--;
+ } else {
+ clearInterval(interval);
+ }
+ }, 1000);
+ promptAction.showToast({ message: $r('app.string.upload_fail'), bottom: TOAST_BOTTOM })
+ }
+ });
+ }
+ }
+
+ getResourceString(resource: Resource) {
+ let context = getContext(this) as common.UIAbilityContext;
+ let res = context.resourceManager.getStringSync(resource.id);
+ logger.debug(TAG + ':****' + res);
+ return res;
+ }
+
+ onChunkImgIndexChange(propName: string) {
+ logger.debug(TAG, 'onChunkImgIndexChange');
+ if (this.chunkImgIndex != NO_IMAGE_SELECTED) {
+ this.chunkDialog.open();
+ }
+ this.chunkInputEnable = false;
+ this.chunkParaBegins = 0;
+ this.chunkParaEnds = -1;
+ }
+
+ onChunkDiaglogCancel() {
+ logger.debug(TAG, 'onChunkDiaglogCancel');
+ this.chunkImgIndex = NO_IMAGE_SELECTED;
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json
index c11c9fb28463f284c8e19aca39faf9ce31a12b44..123baf3b97b69c545c97d196af63d233e37eddfa 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/color.json
@@ -1,44 +1,44 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "text_normal",
- "value": "#182431"
- },
- {
- "name": "button_light_gray",
- "value": "#0C182431"
- },
- {
- "name": "button_blue",
- "value": "#007DFF"
- },
- {
- "name": "btn_text_blue",
- "value": "#007DFF"
- },
- {
- "name": "maskColor",
- "value": "#66182431"
- },
- {
- "name": "white",
- "value": "#FFFFFF"
- },
- {
- "name": "gray",
- "value": "#F7F7F7"
- },
- {
- "name": "light_gray",
- "value": "#F1F3F5"
- },
- {
- "name": "text_message",
- "value": "#99182431"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "text_normal",
+ "value": "#182431"
+ },
+ {
+ "name": "button_light_gray",
+ "value": "#0C182431"
+ },
+ {
+ "name": "button_blue",
+ "value": "#007DFF"
+ },
+ {
+ "name": "btn_text_blue",
+ "value": "#007DFF"
+ },
+ {
+ "name": "maskColor",
+ "value": "#66182431"
+ },
+ {
+ "name": "white",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "gray",
+ "value": "#F7F7F7"
+ },
+ {
+ "name": "light_gray",
+ "value": "#F1F3F5"
+ },
+ {
+ "name": "text_message",
+ "value": "#99182431"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json
index f2f3603345c9a27a841d2e68c39898a5f00ad1d2..2be6aa8fe3d3c44f56eb7daac216e6a0d0757977 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/element/string.json
@@ -1,144 +1,144 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "UploadAndDownload"
- },
- {
- "name": "upload",
- "value": "Upload"
- },
- {
- "name": "upload_fail",
- "value": "Upload fail,resume upload later"
- },
- {
- "name": "upload_success",
- "value": "Upload success,continue upload"
- },
- {
- "name": "uploading",
- "value": "Uploading"
- },
- {
- "name": "user_tip",
- "value": "Feature development"
- },
- {
- "name": "open",
- "value": "Open"
- },
- {
- "name": "anyone",
- "value": "Anyone"
- },
- {
- "name": "gps",
- "value": "Location"
- },
- {
- "name": "tip",
- "value": "Thoughts of the moment..."
- },
- {
- "name": "pick_album",
- "value": "Pick from album"
- },
- {
- "name": "ok",
- "value": "OK"
- },
- {
- "name": "cancel",
- "value": "Cancel"
- },
- {
- "name": "check_file_tips",
- "value": "Please check files"
- },
- {
- "name": "download",
- "value": "Download"
- },
- {
- "name": "download_to",
- "value": "Select a download location"
- },
- {
- "name": "view_download_files",
- "value": "View download files"
- },
- {
- "name": "download_finish",
- "value": "Download finish"
- },
- {
- "name": "download_fail",
- "value": "Download fail"
- },
- {
- "name": "pause",
- "value": "Pause"
- },
- {
- "name": "downloading",
- "value": "Downloading"
- },
- {
- "name": "continue",
- "value": "Continue"
- },
- {
- "name": "media_permission",
- "value": "Allows the app to read media file information from the user's external storage"
- },
- {
- "name": "media_internet_permission",
- "value": "Allow access to the network"
- },
- {
- "name": "background_tips",
- "value": "Whether to start background tasks"
- },
- {
- "name": "HFS_tips",
- "value": "HFS Address"
- },
- {
- "name": "home_tips",
- "value": "Demonstrate foreground and background upload and download tasks"
- },
- {
- "name": "background_task_start",
- "value": "The background task has started, and you can check the download status in the notification bar"
- },
- {
- "name": "chunk_checkbox_tips",
- "value": "Upload from this file's chunk"
- },
- {
- "name": "chunk_begins",
- "value": "Null, input the value which uploading from the certain byte"
- },
- {
- "name": "chunk_ends",
- "value": "Null, input the value which uploading to the certain byte"
- },
- {
- "name": "chunk_para_invalid",
- "value": "Begins or Ends is invalid"
- },
- {
- "name": "cert_lock",
- "value": "Cert lock"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "UploadAndDownload"
+ },
+ {
+ "name": "upload",
+ "value": "Upload"
+ },
+ {
+ "name": "upload_fail",
+ "value": "Upload fail,resume upload later"
+ },
+ {
+ "name": "upload_success",
+ "value": "Upload success,continue upload"
+ },
+ {
+ "name": "uploading",
+ "value": "Uploading"
+ },
+ {
+ "name": "user_tip",
+ "value": "Feature development"
+ },
+ {
+ "name": "open",
+ "value": "Open"
+ },
+ {
+ "name": "anyone",
+ "value": "Anyone"
+ },
+ {
+ "name": "gps",
+ "value": "Location"
+ },
+ {
+ "name": "tip",
+ "value": "Thoughts of the moment..."
+ },
+ {
+ "name": "pick_album",
+ "value": "Pick from album"
+ },
+ {
+ "name": "ok",
+ "value": "OK"
+ },
+ {
+ "name": "cancel",
+ "value": "Cancel"
+ },
+ {
+ "name": "check_file_tips",
+ "value": "Please check files"
+ },
+ {
+ "name": "download",
+ "value": "Download"
+ },
+ {
+ "name": "download_to",
+ "value": "Select a download location"
+ },
+ {
+ "name": "view_download_files",
+ "value": "View download files"
+ },
+ {
+ "name": "download_finish",
+ "value": "Download finish"
+ },
+ {
+ "name": "download_fail",
+ "value": "Download fail"
+ },
+ {
+ "name": "pause",
+ "value": "Pause"
+ },
+ {
+ "name": "downloading",
+ "value": "Downloading"
+ },
+ {
+ "name": "continue",
+ "value": "Continue"
+ },
+ {
+ "name": "media_permission",
+ "value": "Allows the app to read media file information from the user's external storage"
+ },
+ {
+ "name": "media_internet_permission",
+ "value": "Allow access to the network"
+ },
+ {
+ "name": "background_tips",
+ "value": "Whether to start background tasks"
+ },
+ {
+ "name": "HFS_tips",
+ "value": "HFS Address"
+ },
+ {
+ "name": "home_tips",
+ "value": "Demonstrate foreground and background upload and download tasks"
+ },
+ {
+ "name": "background_task_start",
+ "value": "The background task has started, and you can check the download status in the notification bar"
+ },
+ {
+ "name": "chunk_checkbox_tips",
+ "value": "Upload from this file's chunk"
+ },
+ {
+ "name": "chunk_begins",
+ "value": "Null, input the value which uploading from the certain byte"
+ },
+ {
+ "name": "chunk_ends",
+ "value": "Null, input the value which uploading to the certain byte"
+ },
+ {
+ "name": "chunk_para_invalid",
+ "value": "Begins or Ends is invalid"
+ },
+ {
+ "name": "cert_lock",
+ "value": "Cert lock"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json
index f76da0fb65f7dfc8edd9922a4d60325a7239f631..7f87ebc087ba6e758dbcfd93fb9a0717898e8884 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/main_pages.json
@@ -1,9 +1,9 @@
-{
- "src": [
- "pages/Index",
- "pages/Upload",
- "pages/Download",
- "pages/CertLock",
- "pages/DownloadFiles"
- ]
+{
+ "src": [
+ "pages/Index",
+ "pages/Upload",
+ "pages/Download",
+ "pages/CertLock",
+ "pages/DownloadFiles"
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json
index 9f8de4095b47ede4c43bf246c68c2176e74bba74..58d3c06a31785e6be2a7ca4552e6c145aa5f418d 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/base/profile/network_config.json
@@ -1,24 +1,24 @@
-{
- "network-security-config": {
- "domain-config": [
- {
- "domains": [
- {
- "include-subdomains": true,
- "name": "www.baidu.com"
- }
- ],
- "trust-anchors": [{"certificates": "/data/storage/el1/bundle/entry/resources/resfile/"}],
- "pin-set": {
- "expiration": "2025-04-08",
- "pin": [
- {
- "digest-algorithm": "sha256",
- "digest": "g8CsdcpyAKxmLoWFvMd2hC7ZDUy7L4E2NYOi1i8qEtE="
- }
- ]
- }
- }
- ]
- }
+{
+ "network-security-config": {
+ "domain-config": [
+ {
+ "domains": [
+ {
+ "include-subdomains": true,
+ "name": "www.baidu.com"
+ }
+ ],
+ "trust-anchors": [{"certificates": "/data/storage/el1/bundle/entry/resources/resfile/"}],
+ "pin-set": {
+ "expiration": "2025-04-08",
+ "pin": [
+ {
+ "digest-algorithm": "sha256",
+ "digest": "g8CsdcpyAKxmLoWFvMd2hC7ZDUy7L4E2NYOi1i8qEtE="
+ }
+ ]
+ }
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json
index 751ab62d304e701efd05b5e01b206a67ef66f67c..d169c649cbf1c453e7a659cad50958b2e4a27cf0 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/en_US/element/string.json
@@ -1,144 +1,144 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "UploadAndDownload"
- },
- {
- "name": "upload",
- "value": "Upload"
- },
- {
- "name": "upload_fail",
- "value": "Upload fail,resume upload later"
- },
- {
- "name": "upload_success",
- "value": "Upload success,continue upload"
- },
- {
- "name": "uploading",
- "value": "Uploading"
- },
- {
- "name": "user_tip",
- "value": "Feature development"
- },
- {
- "name": "open",
- "value": "Open"
- },
- {
- "name": "anyone",
- "value": "Anyone"
- },
- {
- "name": "gps",
- "value": "Location"
- },
- {
- "name": "tip",
- "value": "Thoughts of the moment..."
- },
- {
- "name": "pick_album",
- "value": "Pick from album"
- },
- {
- "name": "ok",
- "value": "OK"
- },
- {
- "name": "cancel",
- "value": "Cancel"
- },
- {
- "name": "check_file_tips",
- "value": "Please check files"
- },
- {
- "name": "download",
- "value": "Download"
- },
- {
- "name": "downloading",
- "value": "Downloading"
- },
- {
- "name": "download_to",
- "value": "Select a download location"
- },
- {
- "name": "view_download_files",
- "value": "View download files"
- },
- {
- "name": "download_finish",
- "value": "Download finish"
- },
- {
- "name": "download_fail",
- "value": "Download fail"
- },
- {
- "name": "pause",
- "value": "Pause"
- },
- {
- "name": "continue",
- "value": "Continue"
- },
- {
- "name": "media_permission",
- "value": "Allows the app to read media file information from the user's external storage"
- },
- {
- "name": "media_internet_permission",
- "value": "Allow access to the network"
- },
- {
- "name": "background_tips",
- "value": "Whether to start background tasks"
- },
- {
- "name": "HFS_tips",
- "value": "HFS Address"
- },
- {
- "name": "home_tips",
- "value": "Demonstrate foreground and background upload and download tasks"
- },
- {
- "name": "background_task_start",
- "value": "The background task has started, and you can check the download status in the notification bar"
- },
- {
- "name": "chunk_checkbox_tips",
- "value": "Upload from this file's chunk"
- },
- {
- "name": "chunk_begins",
- "value": "Null, input the value which uploading from the certain byte"
- },
- {
- "name": "chunk_ends",
- "value": "Null, input the value which uploading to the certain byte"
- },
- {
- "name": "chunk_para_invalid",
- "value": "Begins or Ends is invalid"
- },
- {
- "name": "cert_lock",
- "value": "Cert lock"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "UploadAndDownload"
+ },
+ {
+ "name": "upload",
+ "value": "Upload"
+ },
+ {
+ "name": "upload_fail",
+ "value": "Upload fail,resume upload later"
+ },
+ {
+ "name": "upload_success",
+ "value": "Upload success,continue upload"
+ },
+ {
+ "name": "uploading",
+ "value": "Uploading"
+ },
+ {
+ "name": "user_tip",
+ "value": "Feature development"
+ },
+ {
+ "name": "open",
+ "value": "Open"
+ },
+ {
+ "name": "anyone",
+ "value": "Anyone"
+ },
+ {
+ "name": "gps",
+ "value": "Location"
+ },
+ {
+ "name": "tip",
+ "value": "Thoughts of the moment..."
+ },
+ {
+ "name": "pick_album",
+ "value": "Pick from album"
+ },
+ {
+ "name": "ok",
+ "value": "OK"
+ },
+ {
+ "name": "cancel",
+ "value": "Cancel"
+ },
+ {
+ "name": "check_file_tips",
+ "value": "Please check files"
+ },
+ {
+ "name": "download",
+ "value": "Download"
+ },
+ {
+ "name": "downloading",
+ "value": "Downloading"
+ },
+ {
+ "name": "download_to",
+ "value": "Select a download location"
+ },
+ {
+ "name": "view_download_files",
+ "value": "View download files"
+ },
+ {
+ "name": "download_finish",
+ "value": "Download finish"
+ },
+ {
+ "name": "download_fail",
+ "value": "Download fail"
+ },
+ {
+ "name": "pause",
+ "value": "Pause"
+ },
+ {
+ "name": "continue",
+ "value": "Continue"
+ },
+ {
+ "name": "media_permission",
+ "value": "Allows the app to read media file information from the user's external storage"
+ },
+ {
+ "name": "media_internet_permission",
+ "value": "Allow access to the network"
+ },
+ {
+ "name": "background_tips",
+ "value": "Whether to start background tasks"
+ },
+ {
+ "name": "HFS_tips",
+ "value": "HFS Address"
+ },
+ {
+ "name": "home_tips",
+ "value": "Demonstrate foreground and background upload and download tasks"
+ },
+ {
+ "name": "background_task_start",
+ "value": "The background task has started, and you can check the download status in the notification bar"
+ },
+ {
+ "name": "chunk_checkbox_tips",
+ "value": "Upload from this file's chunk"
+ },
+ {
+ "name": "chunk_begins",
+ "value": "Null, input the value which uploading from the certain byte"
+ },
+ {
+ "name": "chunk_ends",
+ "value": "Null, input the value which uploading to the certain byte"
+ },
+ {
+ "name": "chunk_para_invalid",
+ "value": "Begins or Ends is invalid"
+ },
+ {
+ "name": "cert_lock",
+ "value": "Cert lock"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json
index 94ea0de964e570fad3648c6e35964bb2f15a1e72..dafe8357696d0b8e2f6d5523f1be64a11c74d5f4 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/entry/src/main/resources/zh_CN/element/string.json
@@ -1,144 +1,144 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "上传下载"
- },
- {
- "name": "upload",
- "value": "上传"
- },
- {
- "name": "upload_fail",
- "value": "上传失败,稍后继续上传"
- },
- {
- "name": "upload_success",
- "value": "上传成功,继续上传"
- },
- {
- "name": "uploading",
- "value": "已上传"
- },
- {
- "name": "user_tip",
- "value": "功能开发中"
- },
- {
- "name": "open",
- "value": "公开"
- },
- {
- "name": "anyone",
- "value": "谁可以看"
- },
- {
- "name": "gps",
- "value": "所在位置"
- },
- {
- "name": "tip",
- "value": "这一刻的想法..."
- },
- {
- "name": "pick_album",
- "value": "从相册选择"
- },
- {
- "name": "ok",
- "value": "确定"
- },
- {
- "name": "cancel",
- "value": "取消"
- },
- {
- "name": "check_file_tips",
- "value": "请选择文件"
- },
- {
- "name": "download",
- "value": "下载"
- },
- {
- "name": "downloading",
- "value": "已下载"
- },
- {
- "name": "view_download_files",
- "value": "查看下载文件"
- },
- {
- "name": "download_to",
- "value": "选择下载位置"
- },
- {
- "name": "download_finish",
- "value": "下载完成"
- },
- {
- "name": "download_fail",
- "value": "下载失败"
- },
- {
- "name": "pause",
- "value": "暂停"
- },
- {
- "name": "continue",
- "value": "继续"
- },
- {
- "name": "media_permission",
- "value": "允许应用读取用户外部存储中的媒体文件信息"
- },
- {
- "name": "media_internet_permission",
- "value": "允许访问网络"
- },
- {
- "name": "background_tips",
- "value": "是否开启后台任务"
- },
- {
- "name": "HFS_tips",
- "value": "HFS 地址"
- },
- {
- "name": "home_tips",
- "value": "演示前台和后台上传和下载任务"
- },
- {
- "name": "background_task_start",
- "value": "后台任务已开始,可在通知栏查看下载状态"
- },
- {
- "name": "chunk_checkbox_tips",
- "value": "从当前文件开始片段上传"
- },
- {
- "name": "chunk_begins",
- "value": "空,填入任意数值,表示从某字节开始上传该文件"
- },
- {
- "name": "chunk_ends",
- "value": "空,填入任意数值,表示从某字节结束上传该文件"
- },
- {
- "name": "chunk_para_invalid",
- "value": "Begins 或 Ends 无效"
- },
- {
- "name": "cert_lock",
- "value": "证书锁定"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "上传下载"
+ },
+ {
+ "name": "upload",
+ "value": "上传"
+ },
+ {
+ "name": "upload_fail",
+ "value": "上传失败,稍后继续上传"
+ },
+ {
+ "name": "upload_success",
+ "value": "上传成功,继续上传"
+ },
+ {
+ "name": "uploading",
+ "value": "已上传"
+ },
+ {
+ "name": "user_tip",
+ "value": "功能开发中"
+ },
+ {
+ "name": "open",
+ "value": "公开"
+ },
+ {
+ "name": "anyone",
+ "value": "谁可以看"
+ },
+ {
+ "name": "gps",
+ "value": "所在位置"
+ },
+ {
+ "name": "tip",
+ "value": "这一刻的想法..."
+ },
+ {
+ "name": "pick_album",
+ "value": "从相册选择"
+ },
+ {
+ "name": "ok",
+ "value": "确定"
+ },
+ {
+ "name": "cancel",
+ "value": "取消"
+ },
+ {
+ "name": "check_file_tips",
+ "value": "请选择文件"
+ },
+ {
+ "name": "download",
+ "value": "下载"
+ },
+ {
+ "name": "downloading",
+ "value": "已下载"
+ },
+ {
+ "name": "view_download_files",
+ "value": "查看下载文件"
+ },
+ {
+ "name": "download_to",
+ "value": "选择下载位置"
+ },
+ {
+ "name": "download_finish",
+ "value": "下载完成"
+ },
+ {
+ "name": "download_fail",
+ "value": "下载失败"
+ },
+ {
+ "name": "pause",
+ "value": "暂停"
+ },
+ {
+ "name": "continue",
+ "value": "继续"
+ },
+ {
+ "name": "media_permission",
+ "value": "允许应用读取用户外部存储中的媒体文件信息"
+ },
+ {
+ "name": "media_internet_permission",
+ "value": "允许访问网络"
+ },
+ {
+ "name": "background_tips",
+ "value": "是否开启后台任务"
+ },
+ {
+ "name": "HFS_tips",
+ "value": "HFS 地址"
+ },
+ {
+ "name": "home_tips",
+ "value": "演示前台和后台上传和下载任务"
+ },
+ {
+ "name": "background_task_start",
+ "value": "后台任务已开始,可在通知栏查看下载状态"
+ },
+ {
+ "name": "chunk_checkbox_tips",
+ "value": "从当前文件开始片段上传"
+ },
+ {
+ "name": "chunk_begins",
+ "value": "空,填入任意数值,表示从某字节开始上传该文件"
+ },
+ {
+ "name": "chunk_ends",
+ "value": "空,填入任意数值,表示从某字节结束上传该文件"
+ },
+ {
+ "name": "chunk_para_invalid",
+ "value": "Begins 或 Ends 无效"
+ },
+ {
+ "name": "cert_lock",
+ "value": "证书锁定"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets
index 4c58ce38c62dbc61c13e7468a701277fd0721275..19f6715ce2f348e58e683d692a70cc377a9bec29 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/download/RequestDownload.ets
@@ -1,227 +1,227 @@
-/*
- * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
-import request from '@ohos.request';
-import promptAction from '@ohos.promptAction';
-import { logger } from '../utils/Logger';
-import { BackgroundTaskState, TASK_MAX, TOAST_BOTTOM } from '../utils/Constants';
-
-const TAG: string = 'RequestDownload';
-
-class RequestDownload {
- private context: common.UIAbilityContext | undefined = undefined;
- private waitList: Array = [];
- private downloadTask: request.agent.Task | undefined = undefined;
- private backgroundDownloadTaskList: Array = [];
-
- constructor() {
- setInterval(() => {
- this.flushBackgroundTask()
- }, 2000);
- }
-
- async downloadFilesBackground(folder: string, files: Array) {
- logger.info(TAG, 'downloadFiles');
- this.context = getContext(this) as common.UIAbilityContext;
- files.forEach((item: string) => {
- this.waitList.push([folder, item]);
- });
- }
-
- async flushBackgroundTask() {
- let tasks = await request.agent.search({
- state: request.agent.State.RUNNING
- });
- if (tasks.length < TASK_MAX && this.waitList.length > 0) {
- let downloadList: Array = [];
- if (this.waitList.length <= TASK_MAX - tasks.length) {
- downloadList = this.waitList;
- this.waitList = [];
- } else {
- downloadList = this.waitList.slice(0, TASK_MAX - tasks.length);
- this.waitList = this.waitList.slice(TASK_MAX - tasks.length, this.waitList.length);
- }
- logger.info(TAG, `this.waitList = ${JSON.stringify(this.waitList)}`);
- this.createBackgroundTask(downloadList);
- } else {
- let state = AppStorage.get('backDownTaskState');
- logger.info(TAG, `backLists = ${this.backgroundDownloadTaskList.map(i => i.tid)}`);
- if (state === BackgroundTaskState.RUNNING) {
- if (tasks.length === 0) {
- AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE);
- this.backgroundDownloadTaskList = [];
- }
- }
- }
- }
-
- async createBackgroundTask(downloadList: Array) {
- if (this.context === undefined) {
- return;
- }
- for (let i = 0; i < downloadList.length; i++) {
- try {
- let splitUrl = downloadList[i][1].split('//')[1].split('/');
- let downloadConfig: request.agent.Config = {
- action: request.agent.Action.DOWNLOAD,
- url: downloadList[i][1],
- method: 'POST',
- title: 'download',
- mode: request.agent.Mode.BACKGROUND,
- network: request.agent.Network.ANY,
- saveas: `./${downloadList[i][0]}/${splitUrl[splitUrl.length-1]}`,
- overwrite: true,
- gauge: true
- }
- let downTask = await request.agent.create(this.context, downloadConfig);
- if (this.backgroundDownloadTaskList.findIndex(task => task.config.url === downTask.config.url) === -1) {
- this.backgroundDownloadTaskList.push(downTask);
- }
- await downTask.start();
- } catch (err) {
- logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
- this.waitList.push(downloadList[i]);
- }
- }
- }
-
- async downloadFile(folder: string, url: string, callback: (progress: number, isSuccess: boolean) => void) {
- logger.info(TAG, 'downloadFile');
- // 查询到存在正在执行的下载任务,提示并返回
- let tasks = await request.agent.search({
- state: request.agent.State.RUNNING,
- action: request.agent.Action.DOWNLOAD,
- mode: request.agent.Mode.FOREGROUND
- });
- if (tasks.length > 0) {
- promptAction.showToast({ message: $r('app.string.have_download_task_tips'), bottom: TOAST_BOTTOM });
- return;
- }
- let splitUrl = url.split('//')[1].split('/');
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let downloadConfig: request.agent.Config = {
- action: request.agent.Action.DOWNLOAD,
- url: url,
- method: 'POST',
- title: 'download',
- mode: request.agent.Mode.FOREGROUND,
- network: request.agent.Network.ANY,
- saveas: `./${folder}/${splitUrl[splitUrl.length-1]}`,
- overwrite: true
- }
- logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`);
- try {
- this.downloadTask = await request.agent.create(context, downloadConfig);
- this.downloadTask.on('progress', (progress: request.agent.Progress) => {
- logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`);
- let processed = Number(progress.processed.toString()).valueOf();
- let size = progress.sizes[0];
- let process: number = Math.floor(processed / size * 100);
- if (process < 100) {
- callback(process, false);
- }
- })
- this.downloadTask.on('completed', (progress: request.agent.Progress) => {
- logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}`);
- callback(100, true);
- this.deleteTask();
- })
- this.downloadTask.on('failed', async (progress: request.agent.Progress) => {
- if (this.downloadTask) {
- let taskInfo = await request.agent.show(this.downloadTask.tid);
- logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
- }
- callback(100, false);
- this.deleteTask();
- })
- await this.downloadTask.start();
- } catch (err) {
- logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
- callback(100, false);
- }
- }
-
- async pauseOrResume() {
- let state = AppStorage.get('backDownTaskState');
- if (state === BackgroundTaskState.RUNNING) {
- await this.pause();
- AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.PAUSE);
- } else if (state === BackgroundTaskState.PAUSE) {
- await this.resume();
- AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.RUNNING);
- } else {
- logger.info(TAG, 'this task state is error');
- }
- }
-
- async pause() {
- logger.info(TAG, 'pause');
- if (this.backgroundDownloadTaskList.length === 0) {
- return;
- }
- try {
- this.backgroundDownloadTaskList.forEach(async task => {
- await task.pause();
- })
- } catch (err) {
- logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`);
- }
- }
-
- async resume() {
- logger.info(TAG, 'resume');
- if (this.backgroundDownloadTaskList.length === 0) {
- return;
- }
- try {
- this.backgroundDownloadTaskList.forEach(async task => {
- await task.resume();
- })
- } catch (err) {
- logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`);
- }
- }
-
- async deleteTask() {
- if (this.downloadTask) {
- try {
- this.downloadTask.off('progress');
- this.downloadTask.off('completed');
- this.downloadTask.off('failed');
- await request.agent.remove(this.downloadTask.tid);
- } catch (err) {
- logger.info(TAG, `deleteTask fail, err= ${JSON.stringify(err)}`);
- }
- }
- this.downloadTask = undefined;
- }
-
- async deleteAllBackTasks() {
- if (this.backgroundDownloadTaskList.length > 0) {
- try {
- this.backgroundDownloadTaskList.forEach(async task => {
- await request.agent.remove(task.tid);
- })
- this.backgroundDownloadTaskList = [];
- AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE);
- } catch (err) {
- logger.info(TAG, `deleteAllTask fail, err= ${JSON.stringify(err)}`);
- }
- }
- }
-}
-
+/*
+ * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
+import request from '@ohos.request';
+import promptAction from '@ohos.promptAction';
+import { logger } from '../utils/Logger';
+import { BackgroundTaskState, TASK_MAX, TOAST_BOTTOM } from '../utils/Constants';
+
+const TAG: string = 'RequestDownload';
+
+class RequestDownload {
+ private context: common.UIAbilityContext | undefined = undefined;
+ private waitList: Array = [];
+ private downloadTask: request.agent.Task | undefined = undefined;
+ private backgroundDownloadTaskList: Array = [];
+
+ constructor() {
+ setInterval(() => {
+ this.flushBackgroundTask()
+ }, 2000);
+ }
+
+ async downloadFilesBackground(folder: string, files: Array) {
+ logger.info(TAG, 'downloadFiles');
+ this.context = getContext(this) as common.UIAbilityContext;
+ files.forEach((item: string) => {
+ this.waitList.push([folder, item]);
+ });
+ }
+
+ async flushBackgroundTask() {
+ let tasks = await request.agent.search({
+ state: request.agent.State.RUNNING
+ });
+ if (tasks.length < TASK_MAX && this.waitList.length > 0) {
+ let downloadList: Array = [];
+ if (this.waitList.length <= TASK_MAX - tasks.length) {
+ downloadList = this.waitList;
+ this.waitList = [];
+ } else {
+ downloadList = this.waitList.slice(0, TASK_MAX - tasks.length);
+ this.waitList = this.waitList.slice(TASK_MAX - tasks.length, this.waitList.length);
+ }
+ logger.info(TAG, `this.waitList = ${JSON.stringify(this.waitList)}`);
+ this.createBackgroundTask(downloadList);
+ } else {
+ let state = AppStorage.get('backDownTaskState');
+ logger.info(TAG, `backLists = ${this.backgroundDownloadTaskList.map(i => i.tid)}`);
+ if (state === BackgroundTaskState.RUNNING) {
+ if (tasks.length === 0) {
+ AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE);
+ this.backgroundDownloadTaskList = [];
+ }
+ }
+ }
+ }
+
+ async createBackgroundTask(downloadList: Array) {
+ if (this.context === undefined) {
+ return;
+ }
+ for (let i = 0; i < downloadList.length; i++) {
+ try {
+ let splitUrl = downloadList[i][1].split('//')[1].split('/');
+ let downloadConfig: request.agent.Config = {
+ action: request.agent.Action.DOWNLOAD,
+ url: downloadList[i][1],
+ method: 'POST',
+ title: 'download',
+ mode: request.agent.Mode.BACKGROUND,
+ network: request.agent.Network.ANY,
+ saveas: `./${downloadList[i][0]}/${splitUrl[splitUrl.length-1]}`,
+ overwrite: true,
+ gauge: true
+ }
+ let downTask = await request.agent.create(this.context, downloadConfig);
+ if (this.backgroundDownloadTaskList.findIndex(task => task.config.url === downTask.config.url) === -1) {
+ this.backgroundDownloadTaskList.push(downTask);
+ }
+ await downTask.start();
+ } catch (err) {
+ logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
+ this.waitList.push(downloadList[i]);
+ }
+ }
+ }
+
+ async downloadFile(folder: string, url: string, callback: (progress: number, isSuccess: boolean) => void) {
+ logger.info(TAG, 'downloadFile');
+ // 查询到存在正在执行的下载任务,提示并返回
+ let tasks = await request.agent.search({
+ state: request.agent.State.RUNNING,
+ action: request.agent.Action.DOWNLOAD,
+ mode: request.agent.Mode.FOREGROUND
+ });
+ if (tasks.length > 0) {
+ promptAction.showToast({ message: $r('app.string.have_download_task_tips'), bottom: TOAST_BOTTOM });
+ return;
+ }
+ let splitUrl = url.split('//')[1].split('/');
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let downloadConfig: request.agent.Config = {
+ action: request.agent.Action.DOWNLOAD,
+ url: url,
+ method: 'POST',
+ title: 'download',
+ mode: request.agent.Mode.FOREGROUND,
+ network: request.agent.Network.ANY,
+ saveas: `./${folder}/${splitUrl[splitUrl.length-1]}`,
+ overwrite: true
+ }
+ logger.info(TAG, `downloadFile, downloadConfig = ${JSON.stringify(downloadConfig)}`);
+ try {
+ this.downloadTask = await request.agent.create(context, downloadConfig);
+ this.downloadTask.on('progress', (progress: request.agent.Progress) => {
+ logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`);
+ let processed = Number(progress.processed.toString()).valueOf();
+ let size = progress.sizes[0];
+ let process: number = Math.floor(processed / size * 100);
+ if (process < 100) {
+ callback(process, false);
+ }
+ })
+ this.downloadTask.on('completed', (progress: request.agent.Progress) => {
+ logger.info(TAG, `download complete, file= ${url}, progress = ${progress.processed}`);
+ callback(100, true);
+ this.deleteTask();
+ })
+ this.downloadTask.on('failed', async (progress: request.agent.Progress) => {
+ if (this.downloadTask) {
+ let taskInfo = await request.agent.show(this.downloadTask.tid);
+ logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
+ }
+ callback(100, false);
+ this.deleteTask();
+ })
+ await this.downloadTask.start();
+ } catch (err) {
+ logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
+ callback(100, false);
+ }
+ }
+
+ async pauseOrResume() {
+ let state = AppStorage.get('backDownTaskState');
+ if (state === BackgroundTaskState.RUNNING) {
+ await this.pause();
+ AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.PAUSE);
+ } else if (state === BackgroundTaskState.PAUSE) {
+ await this.resume();
+ AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.RUNNING);
+ } else {
+ logger.info(TAG, 'this task state is error');
+ }
+ }
+
+ async pause() {
+ logger.info(TAG, 'pause');
+ if (this.backgroundDownloadTaskList.length === 0) {
+ return;
+ }
+ try {
+ this.backgroundDownloadTaskList.forEach(async task => {
+ await task.pause();
+ })
+ } catch (err) {
+ logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`);
+ }
+ }
+
+ async resume() {
+ logger.info(TAG, 'resume');
+ if (this.backgroundDownloadTaskList.length === 0) {
+ return;
+ }
+ try {
+ this.backgroundDownloadTaskList.forEach(async task => {
+ await task.resume();
+ })
+ } catch (err) {
+ logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`);
+ }
+ }
+
+ async deleteTask() {
+ if (this.downloadTask) {
+ try {
+ this.downloadTask.off('progress');
+ this.downloadTask.off('completed');
+ this.downloadTask.off('failed');
+ await request.agent.remove(this.downloadTask.tid);
+ } catch (err) {
+ logger.info(TAG, `deleteTask fail, err= ${JSON.stringify(err)}`);
+ }
+ }
+ this.downloadTask = undefined;
+ }
+
+ async deleteAllBackTasks() {
+ if (this.backgroundDownloadTaskList.length > 0) {
+ try {
+ this.backgroundDownloadTaskList.forEach(async task => {
+ await request.agent.remove(task.tid);
+ })
+ this.backgroundDownloadTaskList = [];
+ AppStorage.setOrCreate('backDownTaskState', BackgroundTaskState.NONE);
+ } catch (err) {
+ logger.info(TAG, `deleteAllTask fail, err= ${JSON.stringify(err)}`);
+ }
+ }
+ }
+}
+
export const requestDownload = new RequestDownload();
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets
index 4f97c704188e47a04707896f21e12b078ec0896b..9c5201fe4b90879ff7f524f8729660b7d37b5a06 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/upload/RequestUpload.ets
@@ -1,307 +1,307 @@
-/*
- * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
-import request from '@ohos.request';
-import promptAction from '@ohos.promptAction';
-import { urlUtils } from '../utils/UrlUtils';
-import { logger } from '../utils/Logger';
-import { MediaUtils } from '../utils/MediaUtils';
-import { BackgroundTaskState, UPLOAD_TOKEN, TOAST_BOTTOM, TASK_MAX } from '../utils/Constants';
-
-const TAG: string = 'RequestUpload';
-const HEADER: Record = { 'Content-Type': 'multipart/form-data' };
-
-class Upload {
- private mediaUtils: MediaUtils = new MediaUtils();
- private config: request.agent.Config = {
- action: request.agent.Action.UPLOAD,
- headers: HEADER,
- url: '',
- mode: request.agent.Mode.FOREGROUND,
- method: 'POST',
- title: 'upload',
- network: request.agent.Network.ANY,
- data: [],
- token: UPLOAD_TOKEN
- }
- private context: common.UIAbilityContext | undefined = undefined;
- private uploadTask: request.agent.Task | undefined = undefined;
- private backgroundTask: request.agent.Task | undefined = undefined;
- private waitList: Array = [];
-
- constructor() {
- setInterval(() => {
- this.flushBackgroundTask()
- }, 2000);
- }
-
- getFileName(filePath: string): string {
- const lastSlashIndex = filePath.lastIndexOf('/');
- if (lastSlashIndex === -1) {
- return filePath;
- }
- return filePath.substring(lastSlashIndex + 1);
- }
-
- async uploadFilesBackground(fileUris: Array): Promise {
- logger.info(TAG, `uploadFilesBackground:uploadFiles begin, ${JSON.stringify(fileUris)}`);
- this.context = getContext(this) as common.UIAbilityContext;
- if (fileUris.length === 0) {
- return;
- }
- fileUris.forEach((item: string) => {
- this.waitList.push(item);
- });
- }
-
- async flushBackgroundTask() {
- logger.info(TAG, 'flushBackgroundTask:uploadFiles begin');
- let tasks = await request.agent.search({
- state: request.agent.State.RUNNING
- });
- let state = AppStorage.get('backTaskState');
- if (state === BackgroundTaskState.RUNNING) {
- if (tasks.length < TASK_MAX && this.waitList.length > 0) {
- this.createBackgroundTask(this.waitList);
- this.waitList = [];
- } else {
- if (this.backgroundTask === undefined || tasks.indexOf(this.backgroundTask.tid) === -1) {
- AppStorage.setOrCreate('backTaskState', BackgroundTaskState.NONE);
- this.backgroundTask = undefined;
- }
- }
- }
- }
-
- async createBackgroundTask(fileUris: Array) {
- logger.info(TAG, `createBackgroundTask:uploadFiles begin, ${JSON.stringify(fileUris)}`);
- if (this.context === undefined) {
- return;
- }
- this.config.url = await urlUtils.getUrl(this.context);
- this.config.data = await this.getFilesAndData(this.context.cacheDir, fileUris);
- this.config.mode = request.agent.Mode.BACKGROUND;
- try {
- this.backgroundTask = await request.agent.create(this.context, this.config);
- await this.backgroundTask.start();
- let state = AppStorage.get('backTaskState');
- if (state === BackgroundTaskState.PAUSE) {
- await this.backgroundTask.pause();
- }
- logger.info(TAG, `createBackgroundTask success`);
- } catch (err) {
- logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
- }
- }
-
- async uploadFiles(fileUris: Array, callback: (progress: number, isSucceed: boolean) => void): Promise {
- logger.info(TAG, `uploadFiles begin, ${JSON.stringify(fileUris)}`);
- if (fileUris.length === 0) {
- return;
- }
- // 查询到存在正在执行的上传任务,提示并返回
- let tasks = await request.agent.search({
- state: request.agent.State.RUNNING,
- action: request.agent.Action.UPLOAD,
- mode: request.agent.Mode.FOREGROUND
- });
- if (tasks.length > 0) {
- promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM });
- return;
- }
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- this.config.data = await this.getFilesAndData(context.cacheDir, fileUris);
- logger.info(TAG, `config data:${JSON.stringify(this.config.data)}`);
- this.config.url = await urlUtils.getUrl(context);
- logger.info(TAG, `config url:${JSON.stringify(this.config.url)}`);
- this.config.mode = request.agent.Mode.FOREGROUND;
- try {
- this.uploadTask = await request.agent.create(context, this.config);
- this.uploadTask.on('progress', (progress: request.agent.Progress) => {
- logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`);
- let processed = Number(progress.processed.toString()).valueOf();
- let size = progress.sizes[0];
- let process: number = Math.floor(processed / size * 100);
- if (process < 100) {
- callback(process, false);
- }
- });
- this.uploadTask.on('completed', (progress: request.agent.Progress) => {
- logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`);
- callback(100, true);
- this.cancelTask();
- });
- this.uploadTask.on('failed', async (progress: request.agent.Progress) => {
- if (this.uploadTask) {
- let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN);
- logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
- }
- callback(100, false);
- this.cancelTask();
- });
- await this.uploadTask.start();
- } catch (err) {
- logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
- callback(100, false);
- }
- }
-
- async uploadFileChunk(fileUris: Array, begin: number, end: number, callback: (progress: number, isSucceed: boolean) => void): Promise {
- logger.info(TAG, `uploadFileChunk begin,${fileUris}, begin:${begin}, end:${end}`);
- // 查询到存在正在执行的上传任务,提示并返回
- let tasks = await request.agent.search({
- state: request.agent.State.RUNNING,
- action: request.agent.Action.UPLOAD,
- mode: request.agent.Mode.FOREGROUND
- });
- if (tasks.length > 0) {
- promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM });
- return;
- }
- let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
- let config: request.agent.Config = {
- action: request.agent.Action.UPLOAD,
- headers: HEADER,
- url: await urlUtils.getUrl(context),
- mode: request.agent.Mode.FOREGROUND,
- method: 'POST',
- title: 'upload',
- network: request.agent.Network.ANY,
- data: await this.getFilesAndData(context.cacheDir, fileUris),
- token: UPLOAD_TOKEN,
- index: 0, // 指定片段上传的文件
- begins: begin,
- ends: end
- };
-
- try {
- this.uploadTask = await request.agent.create(context, config);
- this.uploadTask.on('progress', (progress: request.agent.Progress) => {
- let processed = Number(progress.processed.toString()).valueOf();
- let size = progress.sizes[progress.index];
- if (progress.index === 0) {
- if (end === -1) {
- size -= begin;
- } else {
- size = end - begin + 1;
- }
- }
- logger.info(TAG, `progress, index:${progress.index}, progressed = ${progress.processed}, size=${size}`);
- let process: number = Math.floor(processed / size * 100);
- if (process < 100) {
- callback(process, false);
- }
- });
- this.uploadTask.on('completed', (progress: request.agent.Progress) => {
- logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`);
- callback(100, true);
- this.cancelTask();
- });
- this.uploadTask.on('failed', async (progress: request.agent.Progress) => {
- if (this.uploadTask) {
- let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN);
- logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
- }
- callback(100, false);
- this.cancelTask();
- })
- await this.uploadTask.start();
- } catch (err) {
- logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
- callback(100, false);
- }
- }
-
- async cancelTask() {
- logger.info(TAG, 'cancelTask');
- if (this.uploadTask === undefined) {
- return;
- }
- try {
- this.uploadTask.off('progress');
- this.uploadTask.off('failed');
- this.uploadTask.off('completed');
- await this.uploadTask.stop();
- await request.agent.remove(this.uploadTask.tid);
- } catch (err) {
- logger.info(TAG, `deleteTask fail,err= ${JSON.stringify(err)}`);
- }
- this.uploadTask = undefined;
- }
-
- async pauseOrResume() {
- logger.info(TAG, 'pauseOrResume');
- let state = AppStorage.get('backTaskState');
- if (state === BackgroundTaskState.RUNNING) {
- await this.pause();
- AppStorage.setOrCreate('backTaskState', BackgroundTaskState.PAUSE);
- } else if (state === BackgroundTaskState.PAUSE) {
- await this.resume();
- AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING);
- } else {
- logger.info(TAG, 'this task state is error');
- }
- }
-
- async pause() {
- logger.info(TAG, 'pause');
- if (this.backgroundTask === undefined) {
- return;
- }
- try {
- await this.backgroundTask.pause();
- } catch (err) {
- logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`);
- }
- }
-
- async resume() {
- logger.info(TAG, 'resume');
- if (this.backgroundTask === undefined) {
- return;
- }
- try {
- await this.backgroundTask.resume();
- } catch (err) {
- logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`);
- }
- }
-
- private async getFilesAndData(cacheDir: string, fileUris: Array): Promise> {
- logger.info(TAG, `getFilesAndData begin`);
- let files: Array = [];
- for (let i = 0; i < fileUris.length; i++) {
- logger.info(TAG, `getFile fileUri = ${fileUris[i]}`);
- let imagePath = fileUris[i];
- logger.info(TAG, `getFilesAndData imagePath: ${JSON.stringify(imagePath)}`);
- let fileName = this.getFileName(imagePath);
- let file: request.agent.FormItem = {
- name: 'createTest',
- value: {
- filename: fileName,
- mimeType: 'application/octet-stream',
- path: imagePath,
- }
- }
- logger.info(TAG, `getFile file = ${JSON.stringify(file)}`);
- files.push(file);
- }
- logger.info(TAG, `getFilesAndData ${JSON.stringify(files)}`);
- return files;
- }
-}
-
+/*
+ * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
+import request from '@ohos.request';
+import promptAction from '@ohos.promptAction';
+import { urlUtils } from '../utils/UrlUtils';
+import { logger } from '../utils/Logger';
+import { MediaUtils } from '../utils/MediaUtils';
+import { BackgroundTaskState, UPLOAD_TOKEN, TOAST_BOTTOM, TASK_MAX } from '../utils/Constants';
+
+const TAG: string = 'RequestUpload';
+const HEADER: Record = { 'Content-Type': 'multipart/form-data' };
+
+class Upload {
+ private mediaUtils: MediaUtils = new MediaUtils();
+ private config: request.agent.Config = {
+ action: request.agent.Action.UPLOAD,
+ headers: HEADER,
+ url: '',
+ mode: request.agent.Mode.FOREGROUND,
+ method: 'POST',
+ title: 'upload',
+ network: request.agent.Network.ANY,
+ data: [],
+ token: UPLOAD_TOKEN
+ }
+ private context: common.UIAbilityContext | undefined = undefined;
+ private uploadTask: request.agent.Task | undefined = undefined;
+ private backgroundTask: request.agent.Task | undefined = undefined;
+ private waitList: Array = [];
+
+ constructor() {
+ setInterval(() => {
+ this.flushBackgroundTask()
+ }, 2000);
+ }
+
+ getFileName(filePath: string): string {
+ const lastSlashIndex = filePath.lastIndexOf('/');
+ if (lastSlashIndex === -1) {
+ return filePath;
+ }
+ return filePath.substring(lastSlashIndex + 1);
+ }
+
+ async uploadFilesBackground(fileUris: Array): Promise {
+ logger.info(TAG, `uploadFilesBackground:uploadFiles begin, ${JSON.stringify(fileUris)}`);
+ this.context = getContext(this) as common.UIAbilityContext;
+ if (fileUris.length === 0) {
+ return;
+ }
+ fileUris.forEach((item: string) => {
+ this.waitList.push(item);
+ });
+ }
+
+ async flushBackgroundTask() {
+ logger.info(TAG, 'flushBackgroundTask:uploadFiles begin');
+ let tasks = await request.agent.search({
+ state: request.agent.State.RUNNING
+ });
+ let state = AppStorage.get('backTaskState');
+ if (state === BackgroundTaskState.RUNNING) {
+ if (tasks.length < TASK_MAX && this.waitList.length > 0) {
+ this.createBackgroundTask(this.waitList);
+ this.waitList = [];
+ } else {
+ if (this.backgroundTask === undefined || tasks.indexOf(this.backgroundTask.tid) === -1) {
+ AppStorage.setOrCreate('backTaskState', BackgroundTaskState.NONE);
+ this.backgroundTask = undefined;
+ }
+ }
+ }
+ }
+
+ async createBackgroundTask(fileUris: Array) {
+ logger.info(TAG, `createBackgroundTask:uploadFiles begin, ${JSON.stringify(fileUris)}`);
+ if (this.context === undefined) {
+ return;
+ }
+ this.config.url = await urlUtils.getUrl(this.context);
+ this.config.data = await this.getFilesAndData(this.context.cacheDir, fileUris);
+ this.config.mode = request.agent.Mode.BACKGROUND;
+ try {
+ this.backgroundTask = await request.agent.create(this.context, this.config);
+ await this.backgroundTask.start();
+ let state = AppStorage.get('backTaskState');
+ if (state === BackgroundTaskState.PAUSE) {
+ await this.backgroundTask.pause();
+ }
+ logger.info(TAG, `createBackgroundTask success`);
+ } catch (err) {
+ logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
+ }
+ }
+
+ async uploadFiles(fileUris: Array, callback: (progress: number, isSucceed: boolean) => void): Promise {
+ logger.info(TAG, `uploadFiles begin, ${JSON.stringify(fileUris)}`);
+ if (fileUris.length === 0) {
+ return;
+ }
+ // 查询到存在正在执行的上传任务,提示并返回
+ let tasks = await request.agent.search({
+ state: request.agent.State.RUNNING,
+ action: request.agent.Action.UPLOAD,
+ mode: request.agent.Mode.FOREGROUND
+ });
+ if (tasks.length > 0) {
+ promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM });
+ return;
+ }
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ this.config.data = await this.getFilesAndData(context.cacheDir, fileUris);
+ logger.info(TAG, `config data:${JSON.stringify(this.config.data)}`);
+ this.config.url = await urlUtils.getUrl(context);
+ logger.info(TAG, `config url:${JSON.stringify(this.config.url)}`);
+ this.config.mode = request.agent.Mode.FOREGROUND;
+ try {
+ this.uploadTask = await request.agent.create(context, this.config);
+ this.uploadTask.on('progress', (progress: request.agent.Progress) => {
+ logger.info(TAG, `progress, progress = ${progress.processed} ${progress.state}`);
+ let processed = Number(progress.processed.toString()).valueOf();
+ let size = progress.sizes[0];
+ let process: number = Math.floor(processed / size * 100);
+ if (process < 100) {
+ callback(process, false);
+ }
+ });
+ this.uploadTask.on('completed', (progress: request.agent.Progress) => {
+ logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`);
+ callback(100, true);
+ this.cancelTask();
+ });
+ this.uploadTask.on('failed', async (progress: request.agent.Progress) => {
+ if (this.uploadTask) {
+ let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN);
+ logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
+ }
+ callback(100, false);
+ this.cancelTask();
+ });
+ await this.uploadTask.start();
+ } catch (err) {
+ logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
+ callback(100, false);
+ }
+ }
+
+ async uploadFileChunk(fileUris: Array, begin: number, end: number, callback: (progress: number, isSucceed: boolean) => void): Promise {
+ logger.info(TAG, `uploadFileChunk begin,${fileUris}, begin:${begin}, end:${end}`);
+ // 查询到存在正在执行的上传任务,提示并返回
+ let tasks = await request.agent.search({
+ state: request.agent.State.RUNNING,
+ action: request.agent.Action.UPLOAD,
+ mode: request.agent.Mode.FOREGROUND
+ });
+ if (tasks.length > 0) {
+ promptAction.showToast({ message: $r('app.string.have_upload_task_tips'), bottom: TOAST_BOTTOM });
+ return;
+ }
+ let context: common.UIAbilityContext = getContext(this) as common.UIAbilityContext;
+ let config: request.agent.Config = {
+ action: request.agent.Action.UPLOAD,
+ headers: HEADER,
+ url: await urlUtils.getUrl(context),
+ mode: request.agent.Mode.FOREGROUND,
+ method: 'POST',
+ title: 'upload',
+ network: request.agent.Network.ANY,
+ data: await this.getFilesAndData(context.cacheDir, fileUris),
+ token: UPLOAD_TOKEN,
+ index: 0, // 指定片段上传的文件
+ begins: begin,
+ ends: end
+ };
+
+ try {
+ this.uploadTask = await request.agent.create(context, config);
+ this.uploadTask.on('progress', (progress: request.agent.Progress) => {
+ let processed = Number(progress.processed.toString()).valueOf();
+ let size = progress.sizes[progress.index];
+ if (progress.index === 0) {
+ if (end === -1) {
+ size -= begin;
+ } else {
+ size = end - begin + 1;
+ }
+ }
+ logger.info(TAG, `progress, index:${progress.index}, progressed = ${progress.processed}, size=${size}`);
+ let process: number = Math.floor(processed / size * 100);
+ if (process < 100) {
+ callback(process, false);
+ }
+ });
+ this.uploadTask.on('completed', (progress: request.agent.Progress) => {
+ logger.info(TAG, `complete, progress = ${progress.processed} ${progress.state}`);
+ callback(100, true);
+ this.cancelTask();
+ });
+ this.uploadTask.on('failed', async (progress: request.agent.Progress) => {
+ if (this.uploadTask) {
+ let taskInfo = await request.agent.touch(this.uploadTask.tid, UPLOAD_TOKEN);
+ logger.info(TAG, `fail, resean = ${taskInfo.reason}, faults = ${JSON.stringify(taskInfo.faults)}`);
+ }
+ callback(100, false);
+ this.cancelTask();
+ })
+ await this.uploadTask.start();
+ } catch (err) {
+ logger.error(TAG, `task err, err = ${JSON.stringify(err)}`);
+ callback(100, false);
+ }
+ }
+
+ async cancelTask() {
+ logger.info(TAG, 'cancelTask');
+ if (this.uploadTask === undefined) {
+ return;
+ }
+ try {
+ this.uploadTask.off('progress');
+ this.uploadTask.off('failed');
+ this.uploadTask.off('completed');
+ await this.uploadTask.stop();
+ await request.agent.remove(this.uploadTask.tid);
+ } catch (err) {
+ logger.info(TAG, `deleteTask fail,err= ${JSON.stringify(err)}`);
+ }
+ this.uploadTask = undefined;
+ }
+
+ async pauseOrResume() {
+ logger.info(TAG, 'pauseOrResume');
+ let state = AppStorage.get('backTaskState');
+ if (state === BackgroundTaskState.RUNNING) {
+ await this.pause();
+ AppStorage.setOrCreate('backTaskState', BackgroundTaskState.PAUSE);
+ } else if (state === BackgroundTaskState.PAUSE) {
+ await this.resume();
+ AppStorage.setOrCreate('backTaskState', BackgroundTaskState.RUNNING);
+ } else {
+ logger.info(TAG, 'this task state is error');
+ }
+ }
+
+ async pause() {
+ logger.info(TAG, 'pause');
+ if (this.backgroundTask === undefined) {
+ return;
+ }
+ try {
+ await this.backgroundTask.pause();
+ } catch (err) {
+ logger.info(TAG, `pause fail,err= ${JSON.stringify(err)}`);
+ }
+ }
+
+ async resume() {
+ logger.info(TAG, 'resume');
+ if (this.backgroundTask === undefined) {
+ return;
+ }
+ try {
+ await this.backgroundTask.resume();
+ } catch (err) {
+ logger.info(TAG, `resume fail,err= ${JSON.stringify(err)}`);
+ }
+ }
+
+ private async getFilesAndData(cacheDir: string, fileUris: Array): Promise> {
+ logger.info(TAG, `getFilesAndData begin`);
+ let files: Array = [];
+ for (let i = 0; i < fileUris.length; i++) {
+ logger.info(TAG, `getFile fileUri = ${fileUris[i]}`);
+ let imagePath = fileUris[i];
+ logger.info(TAG, `getFilesAndData imagePath: ${JSON.stringify(imagePath)}`);
+ let fileName = this.getFileName(imagePath);
+ let file: request.agent.FormItem = {
+ name: 'createTest',
+ value: {
+ filename: fileName,
+ mimeType: 'application/octet-stream',
+ path: imagePath,
+ }
+ }
+ logger.info(TAG, `getFile file = ${JSON.stringify(file)}`);
+ files.push(file);
+ }
+ logger.info(TAG, `getFilesAndData ${JSON.stringify(files)}`);
+ return files;
+ }
+}
+
export const requestUpload = new Upload();
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets
index 67a4a64cff13bf014067c07874a4b6ee8b6d0aec..8bb5482b04aa9f7e4670e07510e3a2e916efda14 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/Constants.ets
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2023 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 const TOAST_BOTTOM: number = 200;
-export const UPLOAD_TOKEN: string = 'upload_token';
-export const TASK_MAX: number = 10;
-export enum BackgroundTaskState {
- NONE = 0,
- RUNNING = 1,
- PAUSE = 2
-}
+/*
+ * Copyright (c) 2023 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 const TOAST_BOTTOM: number = 200;
+export const UPLOAD_TOKEN: string = 'upload_token';
+export const TASK_MAX: number = 10;
+export enum BackgroundTaskState {
+ NONE = 0,
+ RUNNING = 1,
+ PAUSE = 2
+}
export const NO_IMAGE_SELECTED: number = -1;
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets
index 8262e18cae50abccb5e6161f77ea1299242ea936..a06833d2f7190051ee4601c9f420100f473a0bff 100644
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets
+++ b/code/BasicFeature/Connectivity/UploadAndDownLoad/features/uploadanddownload/src/main/ets/utils/UrlUtils.ets
@@ -1,47 +1,47 @@
-/*
- * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
-import commonEventManager from '@ohos.commonEventManager';
-import preferences from '@ohos.data.preferences';
-import { CommonEventData } from './commonEvent/commonEventData';
-import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber';
-import { logger } from './Logger';
-
-const TAG: string = 'UrlUtils';
-const URL_KEY: string = 'url';
-const STORE_NAME: string = 'server_url';
-const DEFAULT_SERVER_URL: string = 'http://192.168.1.1/';
-
-class UrlUtil {
- async getUrl(context: common.UIAbilityContext): Promise {
- let preference = await preferences.getPreferences(context, STORE_NAME);
- let url = await preference.get(URL_KEY, '') as string;
- if (url == '') {
- url = DEFAULT_SERVER_URL;
- logger.info(TAG, 'config url is null');
- }
- logger.info(TAG, `getUrl,url= ${url}`);
- return url;
- }
-
- async saveUrl(context: common.UIAbilityContext, url: string) {
- let preference = await preferences.getPreferences(context, STORE_NAME);
- await preference.put(URL_KEY, url);
- await preference.flush();
- }
-}
-
-export const urlUtils = new UrlUtil();
+/*
+ * Copyright (c) 2023 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 common from '@ohos.app.ability.common';
+import commonEventManager from '@ohos.commonEventManager';
+import preferences from '@ohos.data.preferences';
+import { CommonEventData } from './commonEvent/commonEventData';
+import { CommonEventSubscriber } from './commonEvent/commonEventSubscriber';
+import { logger } from './Logger';
+
+const TAG: string = 'UrlUtils';
+const URL_KEY: string = 'url';
+const STORE_NAME: string = 'server_url';
+const DEFAULT_SERVER_URL: string = 'http://192.168.1.1/';
+
+class UrlUtil {
+ async getUrl(context: common.UIAbilityContext): Promise {
+ let preference = await preferences.getPreferences(context, STORE_NAME);
+ let url = await preference.get(URL_KEY, '') as string;
+ if (url == '') {
+ url = DEFAULT_SERVER_URL;
+ logger.info(TAG, 'config url is null');
+ }
+ logger.info(TAG, `getUrl,url= ${url}`);
+ return url;
+ }
+
+ async saveUrl(context: common.UIAbilityContext, url: string) {
+ let preference = await preferences.getPreferences(context, STORE_NAME);
+ await preference.put(URL_KEY, url);
+ await preference.flush();
+ }
+}
+
+export const urlUtils = new UrlUtil();
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5
deleted file mode 100644
index 64655e6970c2acdf5708226c4d5a584ca52b6f37..0000000000000000000000000000000000000000
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-config.json5
+++ /dev/null
@@ -1,6 +0,0 @@
-{
- "hvigorVersion": "3.2.4",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "3.2.4"
- }
-}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js b/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js
deleted file mode 100644
index 372eae8eb4a124095936f9cd78df5c6756746f3f..0000000000000000000000000000000000000000
--- a/code/BasicFeature/Connectivity/UploadAndDownLoad/hvigor/hvigor-wrapper.js
+++ /dev/null
@@ -1 +0,0 @@
-"use strict";var u=require("path"),D=require("os"),e=require("fs"),t=require("crypto"),r=require("child_process"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},i={},C={},F=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(C,"__esModule",{value:!0}),C.maxPathLength=C.isMac=C.isLinux=C.isWindows=void 0;const E=F(D),A="Windows_NT",o="Darwin";function a(){return E.default.type()===A}function c(){return E.default.type()===o}C.isWindows=a,C.isLinux=function(){return"Linux"===E.default.type()},C.isMac=c,C.maxPathLength=function(){return c()?1016:a()?259:4095},function(e){var t=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),r=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),i=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&t(D,u,e);return r(D,u),D};Object.defineProperty(e,"__esModule",{value:!0}),e.WORK_SPACE=e.HVIGOR_PROJECT_WRAPPER_HOME=e.HVIGOR_PROJECT_ROOT_DIR=e.HVIGOR_PROJECT_CACHES_HOME=e.HVIGOR_PNPM_STORE_PATH=e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=e.PROJECT_CACHES=e.HVIGOR_WRAPPER_TOOLS_HOME=e.HVIGOR_USER_HOME=e.DEFAULT_PACKAGE_JSON=e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME=e.PNPM=e.HVIGOR=e.NPM_TOOL=e.PNPM_TOOL=e.HVIGOR_ENGINE_PACKAGE_NAME=void 0;const F=i(D),E=i(u),A=C;e.HVIGOR_ENGINE_PACKAGE_NAME="@ohos/hvigor",e.PNPM_TOOL=(0,A.isWindows)()?"pnpm.cmd":"pnpm",e.NPM_TOOL=(0,A.isWindows)()?"npm.cmd":"npm",e.HVIGOR="hvigor",e.PNPM="pnpm",e.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME="hvigor-config.json5",e.DEFAULT_PACKAGE_JSON="package.json",e.HVIGOR_USER_HOME=E.resolve(F.homedir(),".hvigor"),e.HVIGOR_WRAPPER_TOOLS_HOME=E.resolve(e.HVIGOR_USER_HOME,"wrapper","tools"),e.PROJECT_CACHES="project_caches",e.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH=E.resolve(e.HVIGOR_WRAPPER_TOOLS_HOME,"node_modules",".bin",e.PNPM_TOOL),e.HVIGOR_PNPM_STORE_PATH=E.resolve(e.HVIGOR_USER_HOME,"caches"),e.HVIGOR_PROJECT_CACHES_HOME=E.resolve(e.HVIGOR_USER_HOME,e.PROJECT_CACHES),e.HVIGOR_PROJECT_ROOT_DIR=process.cwd(),e.HVIGOR_PROJECT_WRAPPER_HOME=E.resolve(e.HVIGOR_PROJECT_ROOT_DIR,e.HVIGOR),e.WORK_SPACE="workspace"}(i);var s={},l={};Object.defineProperty(l,"__esModule",{value:!0}),l.logInfoPrintConsole=l.logErrorAndExit=void 0,l.logErrorAndExit=function(u){u instanceof Error?console.error(u.message):console.error(u),process.exit(-1)},l.logInfoPrintConsole=function(u){console.log(u)};var B=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),d=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),f=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&B(D,u,e);return d(D,u),D};Object.defineProperty(s,"__esModule",{value:!0});var _=s.executeBuild=void 0;const p=f(e),O=f(u),h=l;_=s.executeBuild=function(u){const D=O.resolve(u,"node_modules","@ohos","hvigor","bin","hvigor.js");try{const u=p.realpathSync(D);require(u)}catch(e){(0,h.logErrorAndExit)(`Error: ENOENT: no such file ${D},delete ${u} and retry.`)}};var P={},v={};!function(u){var D=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(u,"__esModule",{value:!0}),u.hashFile=u.hash=u.createHash=void 0;const r=D(t),i=D(e);u.createHash=(u="MD5")=>r.default.createHash(u);u.hash=(D,e)=>(0,u.createHash)(e).update(D).digest("hex");u.hashFile=(D,e)=>{if(i.default.existsSync(D))return(0,u.hash)(i.default.readFileSync(D,"utf-8"),e)}}(v);var g={},m={},R={};Object.defineProperty(R,"__esModule",{value:!0}),R.Unicode=void 0;class y{}R.Unicode=y,y.SPACE_SEPARATOR=/[\u1680\u2000-\u200A\u202F\u205F\u3000]/,y.ID_START=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,y.ID_CONTINUE=/[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/,Object.defineProperty(m,"__esModule",{value:!0}),m.JudgeUtil=void 0;const I=R;m.JudgeUtil=class{static isIgnoreChar(u){return"string"==typeof u&&("\t"===u||"\v"===u||"\f"===u||" "===u||" "===u||"\ufeff"===u||"\n"===u||"\r"===u||"\u2028"===u||"\u2029"===u)}static isSpaceSeparator(u){return"string"==typeof u&&I.Unicode.SPACE_SEPARATOR.test(u)}static isIdStartChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||I.Unicode.ID_START.test(u))}static isIdContinueChar(u){return"string"==typeof u&&(u>="a"&&u<="z"||u>="A"&&u<="Z"||u>="0"&&u<="9"||"$"===u||"_"===u||""===u||""===u||I.Unicode.ID_CONTINUE.test(u))}static isDigitWithoutZero(u){return/[1-9]/.test(u)}static isDigit(u){return"string"==typeof u&&/[0-9]/.test(u)}static isHexDigit(u){return"string"==typeof u&&/[0-9A-Fa-f]/.test(u)}};var N=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(g,"__esModule",{value:!0}),g.parseJsonText=g.parseJsonFile=void 0;const b=N(e),S=N(D),w=N(u),H=m;var x;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(x||(x={}));let M,T,V,G,j,J,W="start",U=[],L=0,$=1,k=0,K=!1,z="default",q="'",Z=1;function X(u,D=!1){T=String(u),W="start",U=[],L=0,$=1,k=0,G=void 0,K=D;do{M=Q(),nu[W]()}while("eof"!==M.type);return G}function Q(){for(z="default",j="",q="'",Z=1;;){J=Y();const u=Du[z]();if(u)return u}}function Y(){if(T[L])return String.fromCodePoint(T.codePointAt(L))}function uu(){const u=Y();return"\n"===u?($++,k=0):u?k+=u.length:k++,u&&(L+=u.length),u}g.parseJsonFile=function(u,D=!1,e="utf-8"){const t=b.default.readFileSync(w.default.resolve(u),{encoding:e});try{return X(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${S.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},g.parseJsonText=X;const Du={default(){switch(J){case"/":return uu(),void(z="comment");case void 0:return uu(),eu("eof")}if(!H.JudgeUtil.isIgnoreChar(J)&&!H.JudgeUtil.isSpaceSeparator(J))return Du[W]();uu()},start(){z="value"},beforePropertyName(){switch(J){case"$":case"_":return j=uu(),void(z="identifierName");case"\\":return uu(),void(z="identifierNameStartEscape");case"}":return eu("punctuator",uu());case'"':case"'":return q=J,uu(),void(z="string")}if(H.JudgeUtil.isIdStartChar(J))return j+=uu(),void(z="identifierName");throw Eu(x.Char,uu())},afterPropertyName(){if(":"===J)return eu("punctuator",uu());throw Eu(x.Char,uu())},beforePropertyValue(){z="value"},afterPropertyValue(){switch(J){case",":case"}":return eu("punctuator",uu())}throw Eu(x.Char,uu())},beforeArrayValue(){if("]"===J)return eu("punctuator",uu());z="value"},afterArrayValue(){switch(J){case",":case"]":return eu("punctuator",uu())}throw Eu(x.Char,uu())},end(){throw Eu(x.Char,uu())},comment(){switch(J){case"*":return uu(),void(z="multiLineComment");case"/":return uu(),void(z="singleLineComment")}throw Eu(x.Char,uu())},multiLineComment(){switch(J){case"*":return uu(),void(z="multiLineCommentAsterisk");case void 0:throw Eu(x.Char,uu())}uu()},multiLineCommentAsterisk(){switch(J){case"*":return void uu();case"/":return uu(),void(z="default");case void 0:throw Eu(x.Char,uu())}uu(),z="multiLineComment"},singleLineComment(){switch(J){case"\n":case"\r":case"\u2028":case"\u2029":return uu(),void(z="default");case void 0:return uu(),eu("eof")}uu()},value(){switch(J){case"{":case"[":return eu("punctuator",uu());case"n":return uu(),tu("ull"),eu("null",null);case"t":return uu(),tu("rue"),eu("boolean",!0);case"f":return uu(),tu("alse"),eu("boolean",!1);case"-":case"+":return"-"===uu()&&(Z=-1),void(z="numerical");case".":case"0":case"I":case"N":return void(z="numerical");case'"':case"'":return q=J,uu(),j="",void(z="string")}if(void 0===J||!H.JudgeUtil.isDigitWithoutZero(J))throw Eu(x.Char,uu());z="numerical"},numerical(){switch(J){case".":return j=uu(),void(z="decimalPointLeading");case"0":return j=uu(),void(z="zero");case"I":return uu(),tu("nfinity"),eu("numeric",Z*(1/0));case"N":return uu(),tu("aN"),eu("numeric",NaN)}if(void 0!==J&&H.JudgeUtil.isDigitWithoutZero(J))return j=uu(),void(z="decimalInteger");throw Eu(x.Char,uu())},zero(){switch(J){case".":case"e":case"E":return void(z="decimal");case"x":case"X":return j+=uu(),void(z="hexadecimal")}return eu("numeric",0)},decimalInteger(){switch(J){case".":case"e":case"E":return void(z="decimal")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimal(){switch(J){case".":j+=uu(),z="decimalFraction";break;case"e":case"E":j+=uu(),z="decimalExponent"}},decimalPointLeading(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalFraction");throw Eu(x.Char,uu())},decimalFraction(){switch(J){case"e":case"E":return j+=uu(),void(z="decimalExponent")}if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},decimalExponent(){switch(J){case"+":case"-":return j+=uu(),void(z="decimalExponentSign")}if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentSign(){if(H.JudgeUtil.isDigit(J))return j+=uu(),void(z="decimalExponentInteger");throw Eu(x.Char,uu())},decimalExponentInteger(){if(!H.JudgeUtil.isDigit(J))return eu("numeric",Z*Number(j));j+=uu()},hexadecimal(){if(H.JudgeUtil.isHexDigit(J))return j+=uu(),void(z="hexadecimalInteger");throw Eu(x.Char,uu())},hexadecimalInteger(){if(!H.JudgeUtil.isHexDigit(J))return eu("numeric",Z*Number(j));j+=uu()},identifierNameStartEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":break;default:if(!H.JudgeUtil.isIdStartChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},identifierName(){switch(J){case"$":case"_":case"":case"":return void(j+=uu());case"\\":return uu(),void(z="identifierNameEscape")}if(!H.JudgeUtil.isIdContinueChar(J))return eu("identifier",j);j+=uu()},identifierNameEscape(){if("u"!==J)throw Eu(x.Char,uu());uu();const u=ru();switch(u){case"$":case"_":case"":case"":break;default:if(!H.JudgeUtil.isIdContinueChar(u))throw Eu(x.Identifier)}j+=u,z="identifierName"},string(){switch(J){case"\\":return uu(),void(j+=function(){const u=Y(),D=function(){switch(Y()){case"b":return uu(),"\b";case"f":return uu(),"\f";case"n":return uu(),"\n";case"r":return uu(),"\r";case"t":return uu(),"\t";case"v":return uu(),"\v"}return}();if(D)return D;switch(u){case"0":if(uu(),H.JudgeUtil.isDigit(Y()))throw Eu(x.Char,uu());return"\0";case"x":return uu(),function(){let u="",D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());if(u+=uu(),D=Y(),!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());return u+=uu(),String.fromCodePoint(parseInt(u,16))}();case"u":return uu(),ru();case"\n":case"\u2028":case"\u2029":return uu(),"";case"\r":return uu(),"\n"===Y()&&uu(),""}if(void 0===u||H.JudgeUtil.isDigitWithoutZero(u))throw Eu(x.Char,uu());return uu()}());case'"':case"'":if(J===q){const u=eu("string",j);return uu(),u}return void(j+=uu());case"\n":case"\r":case void 0:throw Eu(x.Char,uu());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Fu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(J)}j+=uu()}};function eu(u,D){return{type:u,value:D,line:$,column:k}}function tu(u){for(const D of u){if(Y()!==D)throw Eu(x.Char,uu());uu()}}function ru(){let u="",D=4;for(;D-- >0;){const D=Y();if(!H.JudgeUtil.isHexDigit(D))throw Eu(x.Char,uu());u+=uu()}return String.fromCodePoint(parseInt(u,16))}const nu={start(){if("eof"===M.type)throw Eu(x.EOF);iu()},beforePropertyName(){switch(M.type){case"identifier":case"string":return V=M.value,void(W="afterPropertyName");case"punctuator":return void Cu();case"eof":throw Eu(x.EOF)}},afterPropertyName(){if("eof"===M.type)throw Eu(x.EOF);W="beforePropertyValue"},beforePropertyValue(){if("eof"===M.type)throw Eu(x.EOF);iu()},afterPropertyValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforePropertyName");case"}":Cu()}},beforeArrayValue(){if("eof"===M.type)throw Eu(x.EOF);"punctuator"!==M.type||"]"!==M.value?iu():Cu()},afterArrayValue(){if("eof"===M.type)throw Eu(x.EOF);switch(M.value){case",":return void(W="beforeArrayValue");case"]":Cu()}},end(){}};function iu(){const u=function(){let u;switch(M.type){case"punctuator":switch(M.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=M.value}return u}();if(K&&"object"==typeof u&&(u._line=$,u._column=k),void 0===G)G=u;else{const D=U[U.length-1];Array.isArray(D)?K&&"object"!=typeof u?D.push({value:u,_line:$,_column:k}):D.push(u):D[V]=K&&"object"!=typeof u?{value:u,_line:$,_column:k}:u}!function(u){if(u&&"object"==typeof u)U.push(u),W=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function Cu(){U.pop();const u=U[U.length-1];W=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Fu(u){const D={"'":"\\'",'"':'\\"',"\\":"\\\\","\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r","\t":"\\t","\v":"\\v","\0":"\\0","\u2028":"\\u2028","\u2029":"\\u2029"};if(D[u])return D[u];if(u<" "){const D=u.charCodeAt(0).toString(16);return`\\x${`00${D}`.substring(D.length)}`}return u}function Eu(u,D){let e="";switch(u){case x.Char:e=void 0===D?`JSON5: invalid end of input at ${$}:${k}`:`JSON5: invalid character '${Fu(D)}' at ${$}:${k}`;break;case x.EOF:e=`JSON5: invalid end of input at ${$}:${k}`;break;case x.Identifier:k-=5,e=`JSON5: invalid identifier character at ${$}:${k}`}const t=new Au(e);return t.lineNumber=$,t.columnNumber=k,t}class Au extends SyntaxError{}var ou={},au=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),cu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),su=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&au(D,u,e);return cu(D,u),D},lu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(ou,"__esModule",{value:!0}),ou.isFileExists=ou.offlinePluginConversion=ou.executeCommand=ou.getNpmPath=ou.hasNpmPackInPaths=void 0;const Bu=r,du=lu(e),fu=su(u),_u=i,pu=l;ou.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},ou.getNpmPath=function(){const u=process.execPath;return fu.join(fu.dirname(u),_u.NPM_TOOL)},ou.executeCommand=function(u,D,e){0!==(0,Bu.spawnSync)(u,D,e).status&&(0,pu.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},ou.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?fu.resolve(u,_u.HVIGOR,D.replace("file:","")):D},ou.isFileExists=function(u){return du.default.existsSync(u)&&du.default.statSync(u).isFile()};var Ou=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),hu=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),Pu=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&Ou(D,u,e);return hu(D,u),D},vu=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(P,"__esModule",{value:!0});var gu=P.initProjectWorkSpace=void 0;const mu=Pu(e),Ru=vu(D),yu=Pu(u),Iu=v,Nu=i,bu=g,Su=l,wu=ou;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===yu.normalize(e.dependencies[u])}function Vu(){const u=yu.join(Mu,Nu.WORK_SPACE);if((0,Su.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=yu.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,wu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(yu.resolve(u,D),{recursive:!0})}))}catch(D){(0,Su.logErrorAndExit)(`The hvigor build tool cannot be installed. Please manually clear the workspace directory and synchronize the project again.\n\n Workspace Path: ${u}.`)}}gu=P.initProjectWorkSpace=function(){if(Hu=function(){const u=yu.resolve(Nu.HVIGOR_PROJECT_WRAPPER_HOME,Nu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Su.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,bu.parseJsonFile)(u)}(),Mu=function(u){let D;D=function(u){let D=u.hvigorVersion;if(D.startsWith("file:")||D.endsWith(".tgz"))return!1;const e=u.dependencies,t=Object.getOwnPropertyNames(e);for(const u of t){const D=e[u];if(D.startsWith("file:")||D.endsWith(".tgz"))return!1}if(1===t.length&&"@ohos/hvigor-ohos-plugin"===t[0])return D>"2.5.0";return!1}(u)?function(u){let D=`${Nu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,Iu.hash)(D)}(u):(0,Iu.hash)(process.cwd());return yu.resolve(Ru.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=yu.resolve(Mu,Nu.WORK_SPACE,Nu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,bu.parseJsonFile)(u):{dependencies:{}}}(),!(0,wu.hasNpmPackInPaths)(Nu.HVIGOR_ENGINE_PACKAGE_NAME,[yu.join(Mu,Nu.WORK_SPACE)])||(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]||!function(){function u(u){const D=null==u?void 0:u.dependencies;return void 0===D?0:Object.getOwnPropertyNames(D).length}const D=u(Hu),e=u(xu);if(D+1!==e)return!1;for(const u in null==Hu?void 0:Hu.dependencies)if(!(0,wu.hasNpmPackInPaths)(u,[yu.join(Mu,Nu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Su.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[Nu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,wu.offlinePluginConversion)(Nu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=yu.join(Mu,Nu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=yu.resolve(D,Nu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Su.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",Nu.HVIGOR_PNPM_STORE_PATH],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:yu.join(Mu,Nu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,wu.executeCommand)(Nu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Su.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(t){var C=n&&n.__createBinding||(Object.create?function(u,D,e,t){void 0===t&&(t=e);var r=Object.getOwnPropertyDescriptor(D,e);r&&!("get"in r?!D.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return D[e]}}),Object.defineProperty(u,t,r)}:function(u,D,e,t){void 0===t&&(t=e),u[t]=D[e]}),F=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),E=n&&n.__importStar||function(u){if(u&&u.__esModule)return u;var D={};if(null!=u)for(var e in u)"default"!==e&&Object.prototype.hasOwnProperty.call(u,e)&&C(D,u,e);return F(D,u),D},A=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(t,"__esModule",{value:!0}),t.executeInstallPnpm=t.isPnpmInstalled=t.environmentHandler=t.checkNpmConifg=t.PNPM_VERSION=void 0;const o=r,a=E(e),c=A(D),s=E(u),B=i,d=l,f=ou;t.PNPM_VERSION="7.30.0",t.checkNpmConifg=function(){const u=s.resolve(B.HVIGOR_PROJECT_ROOT_DIR,".npmrc"),D=s.resolve(c.default.homedir(),".npmrc");if((0,f.isFileExists)(u)||(0,f.isFileExists)(D))return;const e=(0,f.getNpmPath)(),t=(0,o.spawnSync)(e,["config","get","prefix"],{cwd:B.HVIGOR_PROJECT_ROOT_DIR});if(0!==t.status||!t.stdout)return void(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.");const r=s.resolve(`${t.stdout}`.replace(/[\r\n]/gi,""),".npmrc");(0,f.isFileExists)(r)||(0,d.logErrorAndExit)("Error: The hvigor depends on the npmrc file. Configure the npmrc file first.")},t.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},t.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},t.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${t.PNPM_VERSION}...`);const u=(0,f.getNpmPath)();!function(){const u=s.resolve(B.HVIGOR_WRAPPER_TOOLS_HOME,B.DEFAULT_PACKAGE_JSON);try{a.existsSync(B.HVIGOR_WRAPPER_TOOLS_HOME)||a.mkdirSync(B.HVIGOR_WRAPPER_TOOLS_HOME,{recursive:!0});const D={dependencies:{}};D.dependencies[B.PNPM]=t.PNPM_VERSION,a.writeFileSync(u,JSON.stringify(D))}catch(D){(0,d.logErrorAndExit)(`Error: EPERM: operation not permitted,create ${u} failed.`)}}(),(0,f.executeCommand)(u,["install","pnpm"],{cwd:B.HVIGOR_WRAPPER_TOOLS_HOME,stdio:["inherit","inherit","inherit"],env:process.env}),(0,d.logInfoPrintConsole)("Pnpm install success.")}}(Gu),function(){Gu.checkNpmConifg(),Gu.environmentHandler(),Gu.isPnpmInstalled()||Gu.executeInstallPnpm();const D=gu();_(u.join(D,i.WORK_SPACE))}();
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/AppScope/app.json5 b/code/BasicFeature/Connectivity/VPN/AppScope/app.json5
index 0b2f74849bd58e1e77c75fc41a5fa249182e51a6..3cdcbddae43b996b292a8ea26fda952286748f5c 100644
--- a/code/BasicFeature/Connectivity/VPN/AppScope/app.json5
+++ b/code/BasicFeature/Connectivity/VPN/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
-* Copyright (c) 2023 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.example.testvpnclient",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+* Copyright (c) 2023 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.example.testvpnclient",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json b/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json
index 095e4c59b5d6afdbb087a71c09b72d93b0c91e11..5ee9d169b2bf40c6ec257eba1af2cfc126431e84 100644
--- a/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/Connectivity/VPN/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "testvpnclient"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "testvpnclient"
+ }
+ ]
+}
diff --git a/code/BasicFeature/Connectivity/VPN/README_zh.md b/code/BasicFeature/Connectivity/VPN/README_zh.md
index a837fea4044512ebb49de8fa2c9004df3efeb83e..c34babfd81c065b15e176b514556a92ce6878e67 100644
--- a/code/BasicFeature/Connectivity/VPN/README_zh.md
+++ b/code/BasicFeature/Connectivity/VPN/README_zh.md
@@ -1,85 +1,85 @@
-# VPN连接
-
-### 介绍
-本示例使用@ohos.net.vpn接口创建VPN 隧道,建立vpn网络,vpn隧道保护,销毁VPN网络以及使用@ohos.net.vpnExtension接口创建三方vpn等功能。
-实现了VPN的进行服务器连接,发送数据的功能
-
-### 效果预览
-| 主页 | vpn启动 | vpn关闭 |
-| ------------------------------ | --------------------------------- | --------------------------------------- |
-|  |  |  |
-
- 使用说明
-1. 进入应用前请先安装[VPNFoundation](./lib/VPNFoundation-1.0.0.hap)。
-2. 进入应用后,主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。
-3. 在主界面,可以点击启用VPN来创建VPN连接。
-4. 在VPN启动界面,可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。
-5. 在VPN启动界面,点击创建对象可以创建VPN隧道,点击隧道保护可以开启隧道保护,点击启动VPN可以进行网络连接。
-6. 在主界面,可以点击停用VPN来断开和关闭VPN连接。
-
-7. 以上演示系统vpn,如果使用三方vpn,点击启动vpnExt按钮,弹窗提示vpn使用许可,同意后三方vpn启动并自动连接,尝试用浏览器等hap包访问百度
-
-| 三方vpn弹窗 |
-| ------------------------------ |
-| |
-
-8 .访问成功后返回主页面,点击关闭vpnExt按钮,断开三方vpn连接
-
-### 工程目录
-
-```
-entry/src/main/ets/
-|---entryability
-| |---EntryAbility.ts // 项目入口,请求相关权限
-|---pages
-| |---Index.ets // 首页
-| |---StartVpn.ets // 打开vpn
-| |---StopVpn.ets // 关闭vpn
-|---model
-| |---Logger.ets // 日志
-|---serviceextability
-| |---MyVpnExtAbility.ts // 三方vpn能力
-
-```
-
-### 具体实现
-
-创建VPN隧道,建立VPN网络,VPN隧道保护,销毁VPN网络,接口封装在StartVpn和StopVpn,源码参考:StartVpn.ets和StopVpn.ets。
-
- * 创建VPN隧道:调用StartVpn.CreateTunnel()来创建VPN隧道;
- * 建立VPN网络:调用StartVpn.SetupVpn()来建立VPN网络;
- * 销毁VPN网络:调用StopVpn.Destroy()来销毁VPN网络;
- * VPN隧道保护:调用StartVpn.Protect()来开启VPN隧道保护;
-
-### 相关权限
-允许系统应用获取网络权限: ohos.permission.INTERNET,允许系统应用获取VPN权限: ohos.permission.MANAGE_VPN。
-
-### 依赖
-
-不涉及
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568。
-
-2.本示例为Stage模型,支持API11版本SDK,SDK版本号(API Version 4.1 Beta1),镜像版本号(4.1 Beta1)
-
-3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
-
-4.本示例在启动前需搭建服务端环境,成功启动相应服务端后再运行客户端,服务端脚本(server_python)需要在Python 3.8.5版本下运行(需与客户端处于同一局域网)。
-
-5.该示例运行测试完成后,再次运行需要重新启动服务端和客户端。
-
-6.本示例使用了system_basic级别的权限(相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465) ) 。
-
-### 下载
-
-如需单独下载本工程,执行如下命令:
-
-```
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/Connectivity/VPN/ > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
+# VPN连接
+
+### 介绍
+本示例使用@ohos.net.vpn接口创建VPN 隧道,建立vpn网络,vpn隧道保护,销毁VPN网络以及使用@ohos.net.vpnExtension接口创建三方vpn等功能。
+实现了VPN的进行服务器连接,发送数据的功能
+
+### 效果预览
+| 主页 | vpn启动 | vpn关闭 |
+| ------------------------------ | --------------------------------- | --------------------------------------- |
+|  |  |  |
+
+ 使用说明
+1. 进入应用前请先安装[VPNFoundation](./lib/VPNFoundation-1.0.0.hap)。
+2. 进入应用后,主界面有启用VPN和停用VPN的选项。分别对应开启和关闭VPN功能。
+3. 在主界面,可以点击启用VPN来创建VPN连接。
+4. 在VPN启动界面,可以配置VPN服务器IP地址/隧道IP地址/使用VPN的应用程序。
+5. 在VPN启动界面,点击创建对象可以创建VPN隧道,点击隧道保护可以开启隧道保护,点击启动VPN可以进行网络连接。
+6. 在主界面,可以点击停用VPN来断开和关闭VPN连接。
+
+7. 以上演示系统vpn,如果使用三方vpn,点击启动vpnExt按钮,弹窗提示vpn使用许可,同意后三方vpn启动并自动连接,尝试用浏览器等hap包访问百度
+
+| 三方vpn弹窗 |
+| ------------------------------ |
+| |
+
+8 .访问成功后返回主页面,点击关闭vpnExt按钮,断开三方vpn连接
+
+### 工程目录
+
+```
+entry/src/main/ets/
+|---entryability
+| |---EntryAbility.ts // 项目入口,请求相关权限
+|---pages
+| |---Index.ets // 首页
+| |---StartVpn.ets // 打开vpn
+| |---StopVpn.ets // 关闭vpn
+|---model
+| |---Logger.ets // 日志
+|---serviceextability
+| |---MyVpnExtAbility.ts // 三方vpn能力
+
+```
+
+### 具体实现
+
+创建VPN隧道,建立VPN网络,VPN隧道保护,销毁VPN网络,接口封装在StartVpn和StopVpn,源码参考:StartVpn.ets和StopVpn.ets。
+
+ * 创建VPN隧道:调用StartVpn.CreateTunnel()来创建VPN隧道;
+ * 建立VPN网络:调用StartVpn.SetupVpn()来建立VPN网络;
+ * 销毁VPN网络:调用StopVpn.Destroy()来销毁VPN网络;
+ * VPN隧道保护:调用StartVpn.Protect()来开启VPN隧道保护;
+
+### 相关权限
+允许系统应用获取网络权限: ohos.permission.INTERNET,允许系统应用获取VPN权限: ohos.permission.MANAGE_VPN。
+
+### 依赖
+
+不涉及
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568。
+
+2.本示例为Stage模型,支持API11版本SDK,SDK版本号(API Version 4.1 Beta1),镜像版本号(4.1 Beta1)
+
+3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
+
+4.本示例在启动前需搭建服务端环境,成功启动相应服务端后再运行客户端,服务端脚本(server_python)需要在Python 3.8.5版本下运行(需与客户端处于同一局域网)。
+
+5.该示例运行测试完成后,再次运行需要重新启动服务端和客户端。
+
+6.本示例使用了system_basic级别的权限(相关权限级别请查看[权限定义列表](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/AccessToken/permissions-for-all.md) ),需要手动配置高级别的权限签名(具体操作可查看[自动化签名方案](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ohos-auto-configuring-signature-information-0000001271659465) ) 。
+
+### 下载
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/Connectivity/VPN/ > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
diff --git "a/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md" "b/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md"
index 9a2a4d043e16a8235bc4e5c8ba2ef3fa274f8fdf..e026087716f6a704cf0928f8cbdc8b06236ba551 100644
--- "a/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md"
+++ "b/code/BasicFeature/Connectivity/VPN/VPN\346\265\213\350\257\225\347\224\250\344\276\213\346\212\245\345\221\212.md"
@@ -1,9 +1,9 @@
-| 用例名称 | 预置条件 | 用例测试功能 | 输入 | 预期输出 | 是否自动 | 测试结果 |
-|------------------| ---------------- |---------------------------|----------------------------|-----------------------------------------------| -------- | -------- |
-| VPN_sample_test001 | 位于主页 | 界面UI展示 | 打开VPNSample。| 展示启用VPN和停用VPN的按钮,以及Toy VPN标题。| 是 | Pass |
-| VPN_sample_test002 | 位于主页 | 选择启用VPN | 打开VPNSample,点击启用VPN按钮。| 1.正常跳转到启动VPN页面。
2.正常显示VPN配置,创建对象、隧道保护以及启动vpn按钮正常显示和可用。| 否 | Pass |
-| VPN_sample_test003 | 位于启动VPN界面 | 创建VPN隧道 | 打开VPNSample,点击启用VPN按钮,点击创建对象按钮。| 和已经配置IP地址和端口的VpnServer发起Tcp建联,返回隧道的Fd。| 否 | Pass |
-| VPN_sample_test004 | 位于启动VPN界面 | 开启隧道保护 | 打开VPNSample,点击启用VPN按钮,点击隧道保护按钮。| 提示开启隧道保护成功。| 否 | Pass |
-| VPN_sample_test005 | 位于启动VPN界面 | 启动VPN连接 | 打开VPNSample,点击启用VPN按钮,点击启动vpn按钮。| 提示通过隧道进行VPN连接。| 否 | Pass |
-| VPN_sample_test006 | 位于主页 | 选择停用VPN | 打开VPNSample,点击停用VPN按钮。| 1.正常跳转到关闭vpn页面。
2.正常显示关闭vpn按钮且按钮可用。| 否 | Pass |
-| VPN_sample_test007 | 位于停用VPN界面 | 选择关闭VPN | 打开VPNSample,点击停用VPN按钮,点击关闭vpn按钮。| 1.正常跳转到关闭vpn页面。
2.提示关闭VPN隧道和连接。| 否 | Pass |
+| 用例名称 | 预置条件 | 用例测试功能 | 输入 | 预期输出 | 是否自动 | 测试结果 |
+|------------------| ---------------- |---------------------------|----------------------------|-----------------------------------------------| -------- | -------- |
+| VPN_sample_test001 | 位于主页 | 界面UI展示 | 打开VPNSample。| 展示启用VPN和停用VPN的按钮,以及Toy VPN标题。| 是 | Pass |
+| VPN_sample_test002 | 位于主页 | 选择启用VPN | 打开VPNSample,点击启用VPN按钮。| 1.正常跳转到启动VPN页面。
2.正常显示VPN配置,创建对象、隧道保护以及启动vpn按钮正常显示和可用。| 否 | Pass |
+| VPN_sample_test003 | 位于启动VPN界面 | 创建VPN隧道 | 打开VPNSample,点击启用VPN按钮,点击创建对象按钮。| 和已经配置IP地址和端口的VpnServer发起Tcp建联,返回隧道的Fd。| 否 | Pass |
+| VPN_sample_test004 | 位于启动VPN界面 | 开启隧道保护 | 打开VPNSample,点击启用VPN按钮,点击隧道保护按钮。| 提示开启隧道保护成功。| 否 | Pass |
+| VPN_sample_test005 | 位于启动VPN界面 | 启动VPN连接 | 打开VPNSample,点击启用VPN按钮,点击启动vpn按钮。| 提示通过隧道进行VPN连接。| 否 | Pass |
+| VPN_sample_test006 | 位于主页 | 选择停用VPN | 打开VPNSample,点击停用VPN按钮。| 1.正常跳转到关闭vpn页面。
2.正常显示关闭vpn按钮且按钮可用。| 否 | Pass |
+| VPN_sample_test007 | 位于停用VPN界面 | 选择关闭VPN | 打开VPNSample,点击停用VPN按钮,点击关闭vpn按钮。| 1.正常跳转到关闭vpn页面。
2.提示关闭VPN隧道和连接。| 否 | Pass |
diff --git a/code/BasicFeature/Connectivity/VPN/build-profile.json5 b/code/BasicFeature/Connectivity/VPN/build-profile.json5
index 1b9ae4c2c2d450784bb89b6c87af8377b44dee5e..47bc7132870bca565aee0987c72f4d21752e00f7 100644
--- a/code/BasicFeature/Connectivity/VPN/build-profile.json5
+++ b/code/BasicFeature/Connectivity/VPN/build-profile.json5
@@ -1,56 +1,56 @@
-/*
-* Copyright (c) 2023 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": {
- "signingConfigs": [],
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- //Specify the version of OpenHarmony application/service to be used during compilation.
- "compileSdkVersion": 11,
- //Specify the minimum version of OpenHarmony that the application/service is compatible with.
- "compatibleSdkVersion": 11,
- //Specify the target version of OpenHarmony for the application/service. If not set, it defaults to compatibleSdkVersion.
- "targetSdkVersion": 11,
- //Specify OpenHarmony as the target platform.
- "runtimeOS": "OpenHarmony",
- }
- ],
- "buildModeSet": [
- {
- "name": "debug",
- },
- {
- "name": "release"
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+* Copyright (c) 2023 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": {
+ "signingConfigs": [],
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ //Specify the version of OpenHarmony application/service to be used during compilation.
+ "compileSdkVersion": 11,
+ //Specify the minimum version of OpenHarmony that the application/service is compatible with.
+ "compatibleSdkVersion": 11,
+ //Specify the target version of OpenHarmony for the application/service. If not set, it defaults to compatibleSdkVersion.
+ "targetSdkVersion": 11,
+ //Specify OpenHarmony as the target platform.
+ "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/BasicFeature/Connectivity/VPN/entry/build-profile.json5 b/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5
index 6968595ec3635360bb720d25a55544b2c0967f39..f2e911029623965af728e5be805963578db3a0b9 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5
+++ b/code/BasicFeature/Connectivity/VPN/entry/build-profile.json5
@@ -1,39 +1,39 @@
-/*
-* Copyright (c) 2023-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": {
- "externalNativeOptions": {
- "path": "./src/main/cpp/CMakeLists.txt",
- "arguments": "",
- "cppFlags": "",
- "abiFilters": [
- "arm64-v8a",
- "x86_64",
- "armeabi-v7a"
- ]
- }
- },
- "targets": [
- {
- "name": "default",
- "runtimeOS": "OpenHarmony"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+* Copyright (c) 2023-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": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "cppFlags": "",
+ "abiFilters": [
+ "arm64-v8a",
+ "x86_64",
+ "armeabi-v7a"
+ ]
+ }
+ },
+ "targets": [
+ {
+ "name": "default",
+ "runtimeOS": "OpenHarmony"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5
index e74c2f98f624894d125534044276d1c9e485852e..f4b9ceda4105bb04e8eca5747eeda97f44e0c556 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5
+++ b/code/BasicFeature/Connectivity/VPN/entry/oh-package.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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": {
- "libvpn_client.so": "file:./src/main/cpp/types/libentry"
- }
+/*
+ * Copyright (c) 2023 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": {
+ "libvpn_client.so": "file:./src/main/cpp/types/libentry"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt
index 0e63d48d35ea069307be04fb84872cb0763877ce..3b34f4f7a20d2b09a7be07bec443b01be119f021 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/CMakeLists.txt
@@ -1,21 +1,21 @@
-# Set the minimum required version of CMake to 3.4.1
-cmake_minimum_required(VERSION 3.4.1)
-
-# set the project name as "XComponent"
-project(XComponent)
-
-# Define the variable NATIVERENDER_ROOT_PATH as the root path of the current source code
-set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
-
-# Add the header file path to the project
-include_directories(
- ${NATIVERENDER_ROOT_PATH}
- ${NATIVERENDER_ROOT_PATH}/include
-)
-
-# Build the shared library vpn_client and add the source code file vpn_client.cpp
-add_library(vpn_client SHARED vpn_client.cpp)
-
-# Link two library files into the vpn_client library
-target_link_libraries(vpn_client PUBLIC libace_napi.z.so libc++.a)
+# Set the minimum required version of CMake to 3.4.1
+cmake_minimum_required(VERSION 3.4.1)
+
+# set the project name as "XComponent"
+project(XComponent)
+
+# Define the variable NATIVERENDER_ROOT_PATH as the root path of the current source code
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+# Add the header file path to the project
+include_directories(
+ ${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include
+)
+
+# Build the shared library vpn_client and add the source code file vpn_client.cpp
+add_library(vpn_client SHARED vpn_client.cpp)
+
+# Link two library files into the vpn_client library
+target_link_libraries(vpn_client PUBLIC libace_napi.z.so libc++.a)
target_link_libraries(vpn_client PUBLIC libhilog_ndk.z.so)
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts
index ac36d80b3f9cee59834a30c08f208fbf7ef28268..f80e777f2b7ec6ccd228d4a6d8bb180b636c036d 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/index.d.ts
@@ -1,20 +1,20 @@
-/*
- * Copyright (c) 2023 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 const tcpConnect: (addr: string, port: number) => number;
-
-export const startVpn: (tunFd: number, tunnelFd: number) => number;
-
+/*
+ * Copyright (c) 2023 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 const tcpConnect: (addr: string, port: number) => number;
+
+export const startVpn: (tunFd: number, tunnelFd: number) => number;
+
export const stopVpn: (tunnelFd: number) => number;
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5
index b959526d1a00b34e57174eedbbdb821dbfb38fac..9429d311a648ed3ad221a617875881e86f6386ad 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -1,6 +1,6 @@
-{
- "name": "libvpn_client.so",
- "types": "./index.d.ts",
- "version": "",
- "description": "Please describe the basic information."
+{
+ "name": "libvpn_client.so",
+ "types": "./index.d.ts",
+ "version": "",
+ "description": "Please describe the basic information."
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp
index efc71e40c3b6e5e053ae76a4f896bd723a66124d..605863aa7ce04dc2eb00c79216d4afc942aa4956 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/cpp/vpn_client.cpp
@@ -1,250 +1,250 @@
-/*
-* Copyright (c) 2023 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.
-*/
-
-#include "napi/native_api.h"
-#include "hilog/log.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#define MAKE_FILE_NAME (strrchr(__FILE__, '/') + 1)
-
-#define NETMANAGER_VPN_LOGE(fmt, ...) \
- OH_LOG_Print(LOG_APP, LOG_ERROR, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
- __LINE__, ##__VA_ARGS__)
-
-#define NETMANAGER_VPN_LOGI(fmt, ...) \
- OH_LOG_Print(LOG_APP, LOG_INFO, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
- __LINE__, ##__VA_ARGS__)
-
-#define NETMANAGER_VPN_LOGD(fmt, ...) \
- OH_LOG_Print(LOG_APP, LOG_DEBUG, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
- __LINE__, ##__VA_ARGS__)
-
-constexpr int BUFFER_SIZE = 2048;
-constexpr int ERRORAGAIN = 11;
-
-struct FdInfo {
- int32_t tunFd = 0;
- int32_t tunnelFd = 0;
- struct sockaddr_in serverAddr;
-};
-
-static FdInfo g_fdInfo;
-static bool g_threadRunF = false;
-static std::thread g_threadt1;
-static std::thread g_threadt2;
-
-static constexpr const int MAX_STRING_LENGTH = 1024;
-static std::string GetStringFromValueUtf8(napi_env env, napi_value value)
-{
- std::string result;
- char str[MAX_STRING_LENGTH] = {0};
- size_t length = 0;
- napi_get_value_string_utf8(env, value, str, MAX_STRING_LENGTH, &length);
- if (length > 0) {
- return result.append(str, length);
- }
- return result;
-}
-
-static void HandleReadTunfd(FdInfo fdInfo)
-{
- uint8_t buffer[BUFFER_SIZE] = {0};
- while (g_threadRunF) {
- if (fdInfo.tunFd <= 0) {
- sleep(1);
- continue;
- }
-
- int ret = read(fdInfo.tunFd, buffer, sizeof(buffer));
- if (ret <= 0) {
- if (errno != ERRORAGAIN) {
- sleep(1);
- }
- continue;
- }
-
- // Read the data from the virtual network interface and send it to the client through a TCP tunnel.
- NETMANAGER_VPN_LOGD("buffer: %{public}s, len: %{public}d", buffer, ret);
- ret = sendto(fdInfo.tunnelFd, buffer, ret, 0,
- reinterpret_cast(&fdInfo.serverAddr), sizeof(fdInfo.serverAddr));
- if (ret <= 0) {
- NETMANAGER_VPN_LOGE("send to server[%{public}s:%{public}d] failed, ret: %{public}d, error: %{public}s",
- inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), ret,
- strerror(errno));
- continue;
- }
- }
-}
-
-static void HandleTcpReceived(FdInfo fdInfo)
-{
- int addrlen = sizeof(struct sockaddr_in);
- uint8_t buffer[BUFFER_SIZE] = {0};
- while (g_threadRunF) {
- if (fdInfo.tunnelFd <= 0) {
- sleep(1);
- continue;
- }
-
- int length = recvfrom(fdInfo.tunnelFd, buffer, sizeof(buffer), 0,
- reinterpret_cast(&fdInfo.serverAddr),
- reinterpret_cast(&addrlen));
- if (length < 0) {
- if (errno != EAGAIN) {
- NETMANAGER_VPN_LOGE("read tun device error: %{public}d %{public}d", errno, fdInfo.tunnelFd);
- }
- continue;
- }
-
- NETMANAGER_VPN_LOGI("from [%{public}s:%{public}d] data: %{public}s, len: %{public}d",
- inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), buffer, length);
- int ret = write(fdInfo.tunFd, buffer, length);
- if (ret <= 0) {
- NETMANAGER_VPN_LOGE("error Write To Tunfd, errno: %{public}d", errno);
- }
- }
-}
-
-static napi_value TcpConnect(napi_env env, napi_callback_info info)
-{
- size_t numArgs = 2;
- size_t argc = numArgs;
- napi_value args[2] = {nullptr};
- napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
-
- int32_t port = 0;
- napi_get_value_int32(env, args[1], &port);
- std::string ipAddr = GetStringFromValueUtf8(env, args[0]);
-
- NETMANAGER_VPN_LOGI("ip: %{public}s port: %{public}d", ipAddr.c_str(), port);
-
- int32_t sockFd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sockFd == -1) {
- NETMANAGER_VPN_LOGE("socket() error");
- return 0;
- }
-
- struct timeval timeout = {1, 0};
- setsockopt(sockFd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeout), sizeof(struct timeval));
-
- memset(&g_fdInfo.serverAddr, 0, sizeof(g_fdInfo.serverAddr));
- g_fdInfo.serverAddr.sin_family = AF_INET;
- g_fdInfo.serverAddr.sin_addr.s_addr = inet_addr(ipAddr.c_str()); // server's IP addr
- g_fdInfo.serverAddr.sin_port = htons(port); // port
-
- NETMANAGER_VPN_LOGI("Connection successful\n");
-
- napi_value tunnelFd;
- napi_create_int32(env, sockFd, &tunnelFd);
- return tunnelFd;
-}
-
-static napi_value StartVpn(napi_env env, napi_callback_info info)
-{
- size_t numArgs = 2;
- size_t argc = numArgs;
- napi_value args[2] = {nullptr};
- napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
-
- napi_get_value_int32(env, args[0], &g_fdInfo.tunFd);
- napi_get_value_int32(env, args[1], &g_fdInfo.tunnelFd);
-
- if (g_threadRunF) {
- g_threadRunF = false;
- g_threadt1.join();
- g_threadt2.join();
- }
-
- g_threadRunF = true;
- std::thread tt1(HandleReadTunfd, g_fdInfo);
- std::thread tt2(HandleTcpReceived, g_fdInfo);
-
- g_threadt1 = std::move(tt1);
- g_threadt2 = std::move(tt2);
-
- NETMANAGER_VPN_LOGI("StartVpn successful\n");
-
- napi_value retValue;
- napi_create_int32(env, 0, &retValue);
- return retValue;
-}
-
-static napi_value StopVpn(napi_env env, napi_callback_info info)
-{
- size_t argc = 1;
- napi_value args[1] = {nullptr};
- napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
-
- int32_t tunnelFd;
- napi_get_value_int32(env, args[0], &tunnelFd);
- if (tunnelFd) {
- close(tunnelFd);
- tunnelFd = 0;
- }
-
- if (g_threadRunF) {
- g_threadRunF = false;
- g_threadt1.join();
- g_threadt2.join();
- }
-
- NETMANAGER_VPN_LOGI("StopVpn successful\n");
-
- napi_value retValue;
- napi_create_int32(env, 0, &retValue);
- return retValue;
-}
-
-EXTERN_C_START
-static napi_value Init(napi_env env, napi_value exports)
-{
- napi_property_descriptor desc[] = {
- {"tcpConnect", nullptr, TcpConnect, nullptr, nullptr, nullptr, napi_default, nullptr},
- {"startVpn", nullptr, StartVpn, nullptr, nullptr, nullptr, napi_default, nullptr},
- {"stopVpn", nullptr, StopVpn, nullptr, nullptr, nullptr, napi_default, nullptr},
- };
- napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
- return exports;
-}
-EXTERN_C_END
-
-static napi_module demoModule = {
- .nm_version = 1,
- .nm_flags = 0,
- .nm_filename = nullptr,
- .nm_register_func = Init,
- .nm_modname = "entry",
- .nm_priv = ((void *)0),
- .reserved = {0},
-};
-
-extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
-{
- NETMANAGER_VPN_LOGI("vpn 15b0 HELLO ~~~~~~~~~~");
- napi_module_register(&demoModule);
-}
+/*
+* Copyright (c) 2023 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.
+*/
+
+#include "napi/native_api.h"
+#include "hilog/log.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+
+#define MAKE_FILE_NAME (strrchr(__FILE__, '/') + 1)
+
+#define NETMANAGER_VPN_LOGE(fmt, ...) \
+ OH_LOG_Print(LOG_APP, LOG_ERROR, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
+ __LINE__, ##__VA_ARGS__)
+
+#define NETMANAGER_VPN_LOGI(fmt, ...) \
+ OH_LOG_Print(LOG_APP, LOG_INFO, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
+ __LINE__, ##__VA_ARGS__)
+
+#define NETMANAGER_VPN_LOGD(fmt, ...) \
+ OH_LOG_Print(LOG_APP, LOG_DEBUG, 0x15b0, "NetMgrVpn", "vpn [%{public}s %{public}d] " fmt, MAKE_FILE_NAME, \
+ __LINE__, ##__VA_ARGS__)
+
+constexpr int BUFFER_SIZE = 2048;
+constexpr int ERRORAGAIN = 11;
+
+struct FdInfo {
+ int32_t tunFd = 0;
+ int32_t tunnelFd = 0;
+ struct sockaddr_in serverAddr;
+};
+
+static FdInfo g_fdInfo;
+static bool g_threadRunF = false;
+static std::thread g_threadt1;
+static std::thread g_threadt2;
+
+static constexpr const int MAX_STRING_LENGTH = 1024;
+static std::string GetStringFromValueUtf8(napi_env env, napi_value value)
+{
+ std::string result;
+ char str[MAX_STRING_LENGTH] = {0};
+ size_t length = 0;
+ napi_get_value_string_utf8(env, value, str, MAX_STRING_LENGTH, &length);
+ if (length > 0) {
+ return result.append(str, length);
+ }
+ return result;
+}
+
+static void HandleReadTunfd(FdInfo fdInfo)
+{
+ uint8_t buffer[BUFFER_SIZE] = {0};
+ while (g_threadRunF) {
+ if (fdInfo.tunFd <= 0) {
+ sleep(1);
+ continue;
+ }
+
+ int ret = read(fdInfo.tunFd, buffer, sizeof(buffer));
+ if (ret <= 0) {
+ if (errno != ERRORAGAIN) {
+ sleep(1);
+ }
+ continue;
+ }
+
+ // Read the data from the virtual network interface and send it to the client through a TCP tunnel.
+ NETMANAGER_VPN_LOGD("buffer: %{public}s, len: %{public}d", buffer, ret);
+ ret = sendto(fdInfo.tunnelFd, buffer, ret, 0,
+ reinterpret_cast(&fdInfo.serverAddr), sizeof(fdInfo.serverAddr));
+ if (ret <= 0) {
+ NETMANAGER_VPN_LOGE("send to server[%{public}s:%{public}d] failed, ret: %{public}d, error: %{public}s",
+ inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), ret,
+ strerror(errno));
+ continue;
+ }
+ }
+}
+
+static void HandleTcpReceived(FdInfo fdInfo)
+{
+ int addrlen = sizeof(struct sockaddr_in);
+ uint8_t buffer[BUFFER_SIZE] = {0};
+ while (g_threadRunF) {
+ if (fdInfo.tunnelFd <= 0) {
+ sleep(1);
+ continue;
+ }
+
+ int length = recvfrom(fdInfo.tunnelFd, buffer, sizeof(buffer), 0,
+ reinterpret_cast(&fdInfo.serverAddr),
+ reinterpret_cast(&addrlen));
+ if (length < 0) {
+ if (errno != EAGAIN) {
+ NETMANAGER_VPN_LOGE("read tun device error: %{public}d %{public}d", errno, fdInfo.tunnelFd);
+ }
+ continue;
+ }
+
+ NETMANAGER_VPN_LOGI("from [%{public}s:%{public}d] data: %{public}s, len: %{public}d",
+ inet_ntoa(fdInfo.serverAddr.sin_addr), ntohs(fdInfo.serverAddr.sin_port), buffer, length);
+ int ret = write(fdInfo.tunFd, buffer, length);
+ if (ret <= 0) {
+ NETMANAGER_VPN_LOGE("error Write To Tunfd, errno: %{public}d", errno);
+ }
+ }
+}
+
+static napi_value TcpConnect(napi_env env, napi_callback_info info)
+{
+ size_t numArgs = 2;
+ size_t argc = numArgs;
+ napi_value args[2] = {nullptr};
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ int32_t port = 0;
+ napi_get_value_int32(env, args[1], &port);
+ std::string ipAddr = GetStringFromValueUtf8(env, args[0]);
+
+ NETMANAGER_VPN_LOGI("ip: %{public}s port: %{public}d", ipAddr.c_str(), port);
+
+ int32_t sockFd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockFd == -1) {
+ NETMANAGER_VPN_LOGE("socket() error");
+ return 0;
+ }
+
+ struct timeval timeout = {1, 0};
+ setsockopt(sockFd, SOL_SOCKET, SO_RCVTIMEO, reinterpret_cast(&timeout), sizeof(struct timeval));
+
+ memset(&g_fdInfo.serverAddr, 0, sizeof(g_fdInfo.serverAddr));
+ g_fdInfo.serverAddr.sin_family = AF_INET;
+ g_fdInfo.serverAddr.sin_addr.s_addr = inet_addr(ipAddr.c_str()); // server's IP addr
+ g_fdInfo.serverAddr.sin_port = htons(port); // port
+
+ NETMANAGER_VPN_LOGI("Connection successful\n");
+
+ napi_value tunnelFd;
+ napi_create_int32(env, sockFd, &tunnelFd);
+ return tunnelFd;
+}
+
+static napi_value StartVpn(napi_env env, napi_callback_info info)
+{
+ size_t numArgs = 2;
+ size_t argc = numArgs;
+ napi_value args[2] = {nullptr};
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ napi_get_value_int32(env, args[0], &g_fdInfo.tunFd);
+ napi_get_value_int32(env, args[1], &g_fdInfo.tunnelFd);
+
+ if (g_threadRunF) {
+ g_threadRunF = false;
+ g_threadt1.join();
+ g_threadt2.join();
+ }
+
+ g_threadRunF = true;
+ std::thread tt1(HandleReadTunfd, g_fdInfo);
+ std::thread tt2(HandleTcpReceived, g_fdInfo);
+
+ g_threadt1 = std::move(tt1);
+ g_threadt2 = std::move(tt2);
+
+ NETMANAGER_VPN_LOGI("StartVpn successful\n");
+
+ napi_value retValue;
+ napi_create_int32(env, 0, &retValue);
+ return retValue;
+}
+
+static napi_value StopVpn(napi_env env, napi_callback_info info)
+{
+ size_t argc = 1;
+ napi_value args[1] = {nullptr};
+ napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
+
+ int32_t tunnelFd;
+ napi_get_value_int32(env, args[0], &tunnelFd);
+ if (tunnelFd) {
+ close(tunnelFd);
+ tunnelFd = 0;
+ }
+
+ if (g_threadRunF) {
+ g_threadRunF = false;
+ g_threadt1.join();
+ g_threadt2.join();
+ }
+
+ NETMANAGER_VPN_LOGI("StopVpn successful\n");
+
+ napi_value retValue;
+ napi_create_int32(env, 0, &retValue);
+ return retValue;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor desc[] = {
+ {"tcpConnect", nullptr, TcpConnect, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"startVpn", nullptr, StartVpn, nullptr, nullptr, nullptr, napi_default, nullptr},
+ {"stopVpn", nullptr, StopVpn, nullptr, nullptr, nullptr, napi_default, nullptr},
+ };
+ napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void *)0),
+ .reserved = {0},
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ NETMANAGER_VPN_LOGI("vpn 15b0 HELLO ~~~~~~~~~~");
+ napi_module_register(&demoModule);
+}
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts
index fe1acdb252fd749ff9cde86ae89b9fbed803610c..6132d1d0d3679b545df7b78931a717d7aad1a59f 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,58 +1,58 @@
-/*
-* Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
-import hilog from '@ohos.hilog';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import Want from '@ohos.app.ability.Want';
-import window from '@ohos.window';
-
-export default class EntryAbility extends UIAbility {
- onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy() {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
- }
-};
+/*
+* Copyright (c) 2023 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 from '@ohos.app.ability.AbilityConstant';
+import hilog from '@ohos.hilog';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import Want from '@ohos.app.ability.Want';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+};
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets
index ec90e1fa3b91cc7b06f83b2e2acabbf9dd7b8b50..1f100b4df59c12b20a93224376b2fbba0a31320c 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/model/Logger.ets
@@ -1,40 +1,40 @@
-/*
-* Copyright (c) 2023 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.
-*/
-
- class Logger {
- private prefix: string
-
- constructor(prefix: string) {
- this.prefix = prefix
- }
-
- log(...args: string[]) {
- console.log(`[${this.prefix}].${args.join(' ')}`)
- }
-
- info(...args: string[]) {
- console.log(`[${this.prefix}].${args.join(' ')}`)
- }
-
- debug(...args: string[]) {
- console.log(`[${this.prefix}].${args.join(' ')}`)
- }
-
- error(...args: string[]) {
- console.log(`[${this.prefix}].${args.join(' ')}`)
- }
- }
-
+/*
+* Copyright (c) 2023 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.
+*/
+
+ class Logger {
+ private prefix: string
+
+ constructor(prefix: string) {
+ this.prefix = prefix
+ }
+
+ log(...args: string[]) {
+ console.log(`[${this.prefix}].${args.join(' ')}`)
+ }
+
+ info(...args: string[]) {
+ console.log(`[${this.prefix}].${args.join(' ')}`)
+ }
+
+ debug(...args: string[]) {
+ console.log(`[${this.prefix}].${args.join(' ')}`)
+ }
+
+ error(...args: string[]) {
+ console.log(`[${this.prefix}].${args.join(' ')}`)
+ }
+ }
+
export default new Logger('[Sample_Wlan]')
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets
index c09c56ce836cfac0e47bda607360b88d62144dc5..6c6879fd53c665654e9aa016486c9f1184019c2e 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/Index.ets
@@ -1,55 +1,55 @@
-/*
-* Copyright (c) 2023 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 '@ohos.hilog';
-import router from '@ohos.router';
-import { BusinessError } from '@ohos.base';
-
-@Entry
-@Component
-struct Index {
- @State message: string = 'Toy VPN';
-
- build() {
- Row() {
- Column() {
- Text(this.message)
- .fontSize(35)
- .fontWeight(FontWeight.Bold)
- .onClick(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
- })
- Button('Start VPN').onClick(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
- router.pushUrl({ url: 'pages/StartVpn' }).then(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
- }).catch((err: BusinessError) => {
- hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
- JSON.stringify(err) ?? '');
- })
- }).width('70%').fontSize(45).margin(16)
- Button('Stop VPN').onClick(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
- router.pushUrl({ url: 'pages/StopVpn' }).then(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
- }).catch((err: BusinessError) => {
- hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
- JSON.stringify(err) ?? '');
- })
- }).width('70%').fontSize(45)
- }.width('100%')
- }.height('100%')
- }
+/*
+* Copyright (c) 2023 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 '@ohos.hilog';
+import router from '@ohos.router';
+import { BusinessError } from '@ohos.base';
+
+@Entry
+@Component
+struct Index {
+ @State message: string = 'Toy VPN';
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(35)
+ .fontWeight(FontWeight.Bold)
+ .onClick(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
+ })
+ Button('Start VPN').onClick(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
+ router.pushUrl({ url: 'pages/StartVpn' }).then(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
+ }).catch((err: BusinessError) => {
+ hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
+ JSON.stringify(err) ?? '');
+ })
+ }).width('70%').fontSize(45).margin(16)
+ Button('Stop VPN').onClick(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in clicking the button.');
+ router.pushUrl({ url: 'pages/StopVpn' }).then(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'Succeeded in jumping to the second page.');
+ }).catch((err: BusinessError) => {
+ hilog.error(0x0000, 'developTag', 'Failed to jump to the second page: %{public}s',
+ JSON.stringify(err) ?? '');
+ })
+ }).width('70%').fontSize(45)
+ }.width('100%')
+ }.height('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets
index 8952dfeaf31250fb4805ba498c0ed161adcab549..8753a423e3537c4d9858462c01582e15e0726c40 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StartVpn.ets
@@ -1,184 +1,184 @@
-/*
-* Copyright (c) 2023 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 '@ohos.hilog';
-import vpn_client from 'libvpn_client.so';
-import common from '@ohos.app.ability.common';
-import vpnext from '@ohos.net.vpnExtension';
-import Want from '@ohos.app.ability.Want';
-import { showToast } from '../components/ShowToast';
-import { BusinessError } from '@kit.BasicServicesKit';
-
-let want: Want = {
- deviceId: "",
- bundleName: "com.example.myvpndemo",
- abilityName: "MyVpnExtAbility",
-};
-
-let g_tunFd = -1;
-let g_tunnelFd = -1;
-
-@Entry
-@Component
-struct StartVpn {
- @State message: string = 'Toy VPN';
- @State vpnServerIp: string = '192.168.31.13';
- @State tunIp: string = '10.0.0.5';
- @State prefix: string = '24';
- @State blockedAppName: string = 'com.example.baidumyapplication';
- private context = getContext(this) as common.VpnExtensionContext;
- private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context);
-
- CreateTunnel() {
- g_tunnelFd = vpn_client.tcpConnect(this.vpnServerIp, 8888);
- if (g_tunnelFd) {
- showToast('CreateTunnel Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'CreateTunnel Success');
- } else {
- showToast('CreateTunnel Fail', 2000);
- hilog.error(0x0000, 'developTag', 'CreateTunnel Fail %{public}s', 'CreateTunnel Fail');
- }
- }
-
- Protect() {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect');
- this.VpnConnection.protect(g_tunnelFd).then(() => {
- showToast('vpn Protect Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect Success');
- }).catch((err: Error) => {
- showToast('vpn Protect Failed: ' + JSON.stringify(err), 2000);
- hilog.error(0x0000, 'developTag', 'vpn Protect Failed %{public}s', JSON.stringify(err) ?? '');
- })
- }
-
- SetupVpn() {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn SetupVpn');
- class Address {
- address: string;
- family: number;
-
- constructor(address: string, family: number) {
- this.address = address;
- this.family = family;
- }
- }
-
- class AddressWithPrefix {
- address: Address;
- prefixLength: number;
-
- constructor(address: Address, prefixLength: number) {
- this.address = address;
- this.prefixLength = prefixLength;
- }
- }
-
- class Config {
- addresses: AddressWithPrefix[];
- mtu: number;
- dnsAddresses: string[];
- trustedApplications: string[];
- blockedApplications: string[];
-
- constructor(
- tunIp: string,
- blockedAppName: string
- ) {
- this.addresses = [
- new AddressWithPrefix(new Address(tunIp, 1), 24)
- ];
- this.mtu = 1400;
- this.dnsAddresses = ["114.114.114.114"];
- this.trustedApplications = [];
- this.blockedApplications = [blockedAppName];
- }
- }
-
- let config = new Config(this.tunIp, this.blockedAppName);
- this.VpnConnection.create(config).then((data) => {
- g_tunFd = data;
- hilog.error(0x0000, 'developTag', 'tunfd: %{public}s', JSON.stringify(data) ?? '');
- vpn_client.startVpn(g_tunFd, g_tunnelFd);
- showToast('vpn start Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn start Success');
- }).catch((err: BusinessError) => {
- showToast('vpn start Fail: ' + JSON.stringify(err), 2000);
- hilog.error(0x0000, 'developTag', 'vpn start Fail %{public}s', JSON.stringify(err) ?? '');
- })
- }
-
- build() {
- Row() {
- Column() {
- Text(this.message)
- .fontSize(35)
- .fontWeight(FontWeight.Bold)
- .onClick(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
- })
-
- Row() {
- //ip address of server
- Text('server ip').fontSize(30).width('40%').textAlign(TextAlign.Center)
- .backgroundColor(0xAFEEEE)
- TextInput({ text: '192.168.31.13' }).onChange((value) => {
- this.vpnServerIp = value;
- }).width('60%').margin(2)
- }.width('90%')
-
- Row() {
- //ip address of tun-vpn on server
- Text('tun ip').fontSize(30).width('40%').textAlign(TextAlign.Center)
- .backgroundColor(0xAFEEEE)
- TextInput({ text: '10.0.0.5' }).onChange((value) => {
- this.tunIp = value;
- }).width('60%').margin(2)
- }.width('90%')
-
- Row() {
- //blocked Hap
- Text('blockedApp').fontSize(30).width('40%').textAlign(TextAlign.Center)
- .backgroundColor(0xAFEEEE)
- TextInput({ text: 'com.example.baidumyapplication' }).onChange((value) => {
- this.blockedAppName = value;
- }).width('60%').margin(2)
- }.width('90%')
-
- Button($r('app.string.btn_create_tunnel')).onClick(() => {
- this.CreateTunnel();
- }).fontSize(50)
- Button($r('app.string.btn_protect')).onClick(() => {
- this.Protect();
- }).fontSize(50)
- Button($r('app.string.btn_start_vpn')).onClick(() => {
- this.SetupVpn();
- }).fontSize(50)
- Button($r('app.string.btn_start_vpnExt')).onClick(() => {
- try {
- vpnext.startVpnExtensionAbility(want).then(() => {
- showToast('start vpnExt Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'start vpnExt Success');
- })
- } catch (err) {
- showToast('start vpnExt Fail: ' + JSON.stringify(err), 2000);
- hilog.error(0x0000, 'developTag', 'start vpnExt Fail %{public}s', JSON.stringify(err) ?? '');
- }
- }).fontSize(50)
- }
- .width('100%')
- }
- .height('100%')
- }
+/*
+* Copyright (c) 2023 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 '@ohos.hilog';
+import vpn_client from 'libvpn_client.so';
+import common from '@ohos.app.ability.common';
+import vpnext from '@ohos.net.vpnExtension';
+import Want from '@ohos.app.ability.Want';
+import { showToast } from '../components/ShowToast';
+import { BusinessError } from '@kit.BasicServicesKit';
+
+let want: Want = {
+ deviceId: "",
+ bundleName: "com.example.myvpndemo",
+ abilityName: "MyVpnExtAbility",
+};
+
+let g_tunFd = -1;
+let g_tunnelFd = -1;
+
+@Entry
+@Component
+struct StartVpn {
+ @State message: string = 'Toy VPN';
+ @State vpnServerIp: string = '192.168.31.13';
+ @State tunIp: string = '10.0.0.5';
+ @State prefix: string = '24';
+ @State blockedAppName: string = 'com.example.baidumyapplication';
+ private context = getContext(this) as common.VpnExtensionContext;
+ private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context);
+
+ CreateTunnel() {
+ g_tunnelFd = vpn_client.tcpConnect(this.vpnServerIp, 8888);
+ if (g_tunnelFd) {
+ showToast('CreateTunnel Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'CreateTunnel Success');
+ } else {
+ showToast('CreateTunnel Fail', 2000);
+ hilog.error(0x0000, 'developTag', 'CreateTunnel Fail %{public}s', 'CreateTunnel Fail');
+ }
+ }
+
+ Protect() {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect');
+ this.VpnConnection.protect(g_tunnelFd).then(() => {
+ showToast('vpn Protect Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Protect Success');
+ }).catch((err: Error) => {
+ showToast('vpn Protect Failed: ' + JSON.stringify(err), 2000);
+ hilog.error(0x0000, 'developTag', 'vpn Protect Failed %{public}s', JSON.stringify(err) ?? '');
+ })
+ }
+
+ SetupVpn() {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn SetupVpn');
+ class Address {
+ address: string;
+ family: number;
+
+ constructor(address: string, family: number) {
+ this.address = address;
+ this.family = family;
+ }
+ }
+
+ class AddressWithPrefix {
+ address: Address;
+ prefixLength: number;
+
+ constructor(address: Address, prefixLength: number) {
+ this.address = address;
+ this.prefixLength = prefixLength;
+ }
+ }
+
+ class Config {
+ addresses: AddressWithPrefix[];
+ mtu: number;
+ dnsAddresses: string[];
+ trustedApplications: string[];
+ blockedApplications: string[];
+
+ constructor(
+ tunIp: string,
+ blockedAppName: string
+ ) {
+ this.addresses = [
+ new AddressWithPrefix(new Address(tunIp, 1), 24)
+ ];
+ this.mtu = 1400;
+ this.dnsAddresses = ["114.114.114.114"];
+ this.trustedApplications = [];
+ this.blockedApplications = [blockedAppName];
+ }
+ }
+
+ let config = new Config(this.tunIp, this.blockedAppName);
+ this.VpnConnection.create(config).then((data) => {
+ g_tunFd = data;
+ hilog.error(0x0000, 'developTag', 'tunfd: %{public}s', JSON.stringify(data) ?? '');
+ vpn_client.startVpn(g_tunFd, g_tunnelFd);
+ showToast('vpn start Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn start Success');
+ }).catch((err: BusinessError) => {
+ showToast('vpn start Fail: ' + JSON.stringify(err), 2000);
+ hilog.error(0x0000, 'developTag', 'vpn start Fail %{public}s', JSON.stringify(err) ?? '');
+ })
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(35)
+ .fontWeight(FontWeight.Bold)
+ .onClick(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
+ })
+
+ Row() {
+ //ip address of server
+ Text('server ip').fontSize(30).width('40%').textAlign(TextAlign.Center)
+ .backgroundColor(0xAFEEEE)
+ TextInput({ text: '192.168.31.13' }).onChange((value) => {
+ this.vpnServerIp = value;
+ }).width('60%').margin(2)
+ }.width('90%')
+
+ Row() {
+ //ip address of tun-vpn on server
+ Text('tun ip').fontSize(30).width('40%').textAlign(TextAlign.Center)
+ .backgroundColor(0xAFEEEE)
+ TextInput({ text: '10.0.0.5' }).onChange((value) => {
+ this.tunIp = value;
+ }).width('60%').margin(2)
+ }.width('90%')
+
+ Row() {
+ //blocked Hap
+ Text('blockedApp').fontSize(30).width('40%').textAlign(TextAlign.Center)
+ .backgroundColor(0xAFEEEE)
+ TextInput({ text: 'com.example.baidumyapplication' }).onChange((value) => {
+ this.blockedAppName = value;
+ }).width('60%').margin(2)
+ }.width('90%')
+
+ Button($r('app.string.btn_create_tunnel')).onClick(() => {
+ this.CreateTunnel();
+ }).fontSize(50)
+ Button($r('app.string.btn_protect')).onClick(() => {
+ this.Protect();
+ }).fontSize(50)
+ Button($r('app.string.btn_start_vpn')).onClick(() => {
+ this.SetupVpn();
+ }).fontSize(50)
+ Button($r('app.string.btn_start_vpnExt')).onClick(() => {
+ try {
+ vpnext.startVpnExtensionAbility(want).then(() => {
+ showToast('start vpnExt Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'start vpnExt Success');
+ })
+ } catch (err) {
+ showToast('start vpnExt Fail: ' + JSON.stringify(err), 2000);
+ hilog.error(0x0000, 'developTag', 'start vpnExt Fail %{public}s', JSON.stringify(err) ?? '');
+ }
+ }).fontSize(50)
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets
index dfae42ccbdfc6664ac42f7964059192ae5df3a68..75b6c7502064b71c4f9942dc27da9e0a5e4ec7b4 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/ets/pages/StopVpn.ets
@@ -1,80 +1,80 @@
-/*
-* Copyright (c) 2023 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 '@ohos.hilog';
-import vpnext from '@ohos.net.vpnExtension';
-import Want from '@ohos.app.ability.Want';
-import common from '@ohos.app.ability.common';
-import vpn_client from "libvpn_client.so";
-import { showToast } from '../components/ShowToast';
-
-let want: Want = {
- deviceId: "",
- bundleName: "com.example.myvpndemo",
- abilityName: "MyVpnExtAbility",
-};
-let g_tunnelFd = -1;
-
-@Entry
-@Component
-struct StopVpn {
- @State message: string = 'VPN';
- @State vpnServerIp: string = '192.168.31.13';
- @State tunIp: string = '10.0.0.5';
- @State routeAddr: string = '192.168.214.0';
- @State prefix: string = '24';
- @State blockedAppName: string = 'com.example.baidumyapplication';
- private context = getContext(this) as common.VpnExtensionContext;
- private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context);
-
- Destroy() {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy');
- vpn_client.stopVpn(g_tunnelFd);
- this.VpnConnection.destroy().then(() => {
- showToast('vpn Destroy Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy Success');
- }).catch((err: Error) => {
- showToast('vpn Destroy Failed: ' + JSON.stringify(err), 2000);
- hilog.error(0x0000, 'developTag', 'vpn Destroy Failed: %{public}s', JSON.stringify(err) ?? '');
- })
- }
-
- build() {
- Row() {
- Column() {
- Text(this.message)
- .fontSize(35)
- .fontWeight(FontWeight.Bold)
- .onClick(() => {
- hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
- })
- Button('stop vpn').onClick(() => {
- this.Destroy();
- }).fontSize(50)
- Button('stop vpnExt').onClick(() => {
- try {
- vpnext.stopVpnExtensionAbility(want).then(() => {
- showToast('stop vpnExt Success', 2000);
- hilog.info(0x0000, 'developTag', '%{public}s', 'stop vpnExt Success');
- })
- } catch (err) {
- showToast('stop vpnExt Fail: ' + JSON.stringify(err), 2000);
- hilog.error(0x0000, 'developTag', 'stop vpnExt Fail %{public}s', JSON.stringify(err) ?? '');
- }
- }).fontSize(50)
- }.width('100%')
- }.height('100%')
- }
+/*
+* Copyright (c) 2023 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 '@ohos.hilog';
+import vpnext from '@ohos.net.vpnExtension';
+import Want from '@ohos.app.ability.Want';
+import common from '@ohos.app.ability.common';
+import vpn_client from "libvpn_client.so";
+import { showToast } from '../components/ShowToast';
+
+let want: Want = {
+ deviceId: "",
+ bundleName: "com.example.myvpndemo",
+ abilityName: "MyVpnExtAbility",
+};
+let g_tunnelFd = -1;
+
+@Entry
+@Component
+struct StopVpn {
+ @State message: string = 'VPN';
+ @State vpnServerIp: string = '192.168.31.13';
+ @State tunIp: string = '10.0.0.5';
+ @State routeAddr: string = '192.168.214.0';
+ @State prefix: string = '24';
+ @State blockedAppName: string = 'com.example.baidumyapplication';
+ private context = getContext(this) as common.VpnExtensionContext;
+ private VpnConnection: vpnext.VpnConnection = vpnext.createVpnConnection(this.context);
+
+ Destroy() {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy');
+ vpn_client.stopVpn(g_tunnelFd);
+ this.VpnConnection.destroy().then(() => {
+ showToast('vpn Destroy Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Destroy Success');
+ }).catch((err: Error) => {
+ showToast('vpn Destroy Failed: ' + JSON.stringify(err), 2000);
+ hilog.error(0x0000, 'developTag', 'vpn Destroy Failed: %{public}s', JSON.stringify(err) ?? '');
+ })
+ }
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(35)
+ .fontWeight(FontWeight.Bold)
+ .onClick(() => {
+ hilog.info(0x0000, 'developTag', '%{public}s', 'vpn Client');
+ })
+ Button('stop vpn').onClick(() => {
+ this.Destroy();
+ }).fontSize(50)
+ Button('stop vpnExt').onClick(() => {
+ try {
+ vpnext.stopVpnExtensionAbility(want).then(() => {
+ showToast('stop vpnExt Success', 2000);
+ hilog.info(0x0000, 'developTag', '%{public}s', 'stop vpnExt Success');
+ })
+ } catch (err) {
+ showToast('stop vpnExt Fail: ' + JSON.stringify(err), 2000);
+ hilog.error(0x0000, 'developTag', 'stop vpnExt Fail %{public}s', JSON.stringify(err) ?? '');
+ }
+ }).fontSize(50)
+ }.width('100%')
+ }.height('100%')
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5
index 7b5d4bddec9d421068794da986e08778508c1b3c..cf0f399062ceca16c71d8dda8671d3a2cd1cba5b 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/module.json5
@@ -1,57 +1,57 @@
-/*
-* Copyright (c) 2023 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": [
- "tablet",
- "default"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:main_pages",
- "requestPermissions": [
- {
- "name": "ohos.permission.INTERNET"
- }
- ],
- "abilities": [
- {
- "name": "EntryAbility",
- "srcEntry": "./ets/entryability/EntryAbility.ts",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- }
- ]
- }
+/*
+* Copyright (c) 2023 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": [
+ "tablet",
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.INTERNET"
+ }
+ ],
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json
index d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json
index 02ef7dfd955f13bab197477942775838504a1170..55e9d9478baba38af63e4701b3b6b3ed8e08f8e3 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/element/string.json
@@ -1,32 +1,32 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "VPN"
- },
- {
- "name": "btn_create_tunnel",
- "value": "创建隧道"
- },
- {
- "name": "btn_protect",
- "value": "隧道保护"
- },
- {
- "name": "btn_start_vpn",
- "value": "启动vpn"
- },
- {
- "name": "btn_start_vpnExt",
- "value": "启动vpnExt"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "VPN"
+ },
+ {
+ "name": "btn_create_tunnel",
+ "value": "创建隧道"
+ },
+ {
+ "name": "btn_protect",
+ "value": "隧道保护"
+ },
+ {
+ "name": "btn_start_vpn",
+ "value": "启动vpn"
+ },
+ {
+ "name": "btn_start_vpnExt",
+ "value": "启动vpnExt"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json
index fc9de9b35aceff555044ef0083e8e311112f2485..65b5903f306bc5bdf078467edf3e8916ed626ccc 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/base/profile/main_pages.json
@@ -1,7 +1,7 @@
-{
- "src": [
- "pages/Index",
- "pages/StartVpn",
- "pages/StopVpn"
- ]
-}
+{
+ "src": [
+ "pages/Index",
+ "pages/StartVpn",
+ "pages/StopVpn"
+ ]
+}
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json
index c50c4c2c0dede563b132f095736f6ce2b96a4dc4..172a8567ec3ce7be6b7e113cd24540568b6f11d5 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/en_US/element/string.json
@@ -1,32 +1,32 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "module description"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "label"
- },
- {
- "name": "btn_create_tunnel",
- "value": "创建隧道"
- },
- {
- "name": "btn_protect",
- "value": "隧道保护"
- },
- {
- "name": "btn_start_vpn",
- "value": "启动vpn"
- },
- {
- "name": "btn_start_vpnExt",
- "value": "启动vpnExt"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "module description"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "btn_create_tunnel",
+ "value": "创建隧道"
+ },
+ {
+ "name": "btn_protect",
+ "value": "隧道保护"
+ },
+ {
+ "name": "btn_start_vpn",
+ "value": "启动vpn"
+ },
+ {
+ "name": "btn_start_vpnExt",
+ "value": "启动vpnExt"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json
index 19a14d7711d6df7a14ec5f90d0d3ca98ab72a959..320848d813c1879ff4a05dd6c95a69fd15aae394 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/main/resources/zh_CN/element/string.json
@@ -1,32 +1,32 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "模块描述"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "label"
- },
- {
- "name": "btn_create_tunnel",
- "value": "创建隧道"
- },
- {
- "name": "btn_protect",
- "value": "隧道保护"
- },
- {
- "name": "btn_start_vpn",
- "value": "启动vpn"
- },
- {
- "name": "btn_start_vpnExt",
- "value": "启动vpnExt"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "模块描述"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "label"
+ },
+ {
+ "name": "btn_create_tunnel",
+ "value": "创建隧道"
+ },
+ {
+ "name": "btn_protect",
+ "value": "隧道保护"
+ },
+ {
+ "name": "btn_start_vpn",
+ "value": "启动vpn"
+ },
+ {
+ "name": "btn_start_vpnExt",
+ "value": "启动vpnExt"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets
index f7b9ddf6591ef2cc2f5ec721386a86f3aee491e2..32b21d38782a72d8d5fa2acee5e98b6e9d7cfe7f 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -1,233 +1,233 @@
-/*
-* Copyright (c) 2024 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 '@ohos.hilog';
-import { describe, it, expect } from '@ohos/hypium'
-import { Driver, ON } from '@ohos.UiTest';
-import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
-
-const TAG = '[Sample_VpnConnect]';
-const DOMAIN = 0xF811;
-
-let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
-async function getResourceString(resource: Resource): Promise {
- let manage = abilityDelegator.getAppContext().resourceManager
- let text = await manage.getStringValue(resource)
- return text
-}
-
-export default function abilityTest() {
- describe('ActsAbilityTest', () => {
- /**
- * 启动Ability
- */
- it('startAbility_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'startAbility_001 start');
- let driver = Driver.create();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- hilog.info(DOMAIN, TAG, 'startAbility_001 end');
- done();
- });
-
- /**
- * 进入首页,标题显示正确
- */
- it('IndexPageEnter_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 start');
- let driver: Driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- await driver.assertComponentExist(ON.text('Toy VPN'));
- let titleComponent = await driver.findComponent(ON.text('Toy VPN'));
- let titleContent = await titleComponent.getText();
- await driver.delayMs(200);
- expect('Toy VPN').assertEqual(titleContent);
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 end');
- done();
- });
-
- /**
- * 在主界面启用VPN
- */
- it('StartVpn_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'StartVpn_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- await driver.assertComponentExist(ON.text('Start VPN'));
- let startVpn = await driver.findComponent(ON.text('Start VPN'));
- await driver.delayMs(200);
- await startVpn.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'StartVpn_001 end');
- done();
- });
-
- /**
- * 在主界面启用VPN后,再创建隧道
- */
- it('CreateTunnel_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'CreateTunnel_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- // 点击启用VPN
- await driver.assertComponentExist(ON.text('Start VPN'));
- let startVpn = await driver.findComponent(ON.text('Start VPN'));
- await driver.delayMs(200);
- await startVpn.click();
- // 点击创建隧道
- await driver.delayMs(200);
- await driver.assertComponentExist(ON.text('创建对象'));
- let createTunnel = await driver.findComponent(ON.text('创建对象'));
- await driver.delayMs(200);
- await createTunnel.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'CreateTunnel_001 end');
- done();
- });
-
- /**
- * 启用VPN后开启隧道保护
- */
- it('StartTunnelProtect_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- // 点击启用VPN
- await driver.assertComponentExist(ON.text('Start VPN'));
- let startVpn = await driver.findComponent(ON.text('Start VPN'));
- await driver.delayMs(200);
- await startVpn.click();
- // 点击开启隧道保护
- await driver.delayMs(200);
- await driver.assertComponentExist(ON.text('隧道保护'));
- let protect = await driver.findComponent(ON.text('隧道保护'));
- await driver.delayMs(200);
- await protect.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 end');
- done();
- });
-
- /**
- * 启用VPN后启动VPN连接
- */
- it('SetupVpn_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'SetupVpn_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- // 点击启用VPN
- await driver.assertComponentExist(ON.text('Start VPN'));
- let startVpn = await driver.findComponent(ON.text('Start VPN'));
- await driver.delayMs(200);
- await startVpn.click();
- // 点击开启vpn
- await driver.delayMs(200);
- await driver.assertComponentExist(ON.text('启动vpn'));
- let setupVpn = await driver.findComponent(ON.text('启动vpn'));
- await setupVpn.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'SetupVpn_001 end');
- done();
- });
-
- /**
- * 停用VPN
- */
- it('StopVpn_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'StopVpn_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- await driver.assertComponentExist(ON.text('Stop VPN'));
- let stopVpn = await driver.findComponent(ON.text('Stop VPN'));
- await stopVpn.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'StopVpn_001 end')
- done();
- });
-
- /**
- * 关闭VPN连接
- */
- it('CloseVpn_001', 0, async (done: Function) => {
- hilog.info(DOMAIN, TAG, 'CloseVpn_001 start');
- let driver = Driver.create();
- await terminateAbility();
- await driver.delayMs(1000);
- await startAbility();
- await driver.delayMs(1000);
- // 点击停用VPN
- await driver.assertComponentExist(ON.text('Stop VPN'));
- let stopVpn = await driver.findComponent(ON.text('Stop VPN'));
- await stopVpn.click();
- // 点击关闭VPN
- await driver.delayMs(200);
- await driver.assertComponentExist(ON.text('关闭vpn'));
- let closeVpn = await driver.findComponent(ON.text('关闭vpn'));
- await closeVpn.click();
- await driver.delayMs(200);
- hilog.info(DOMAIN, TAG, 'CloseVpn_001 end');
- done();
- });
- });
-}
-
-/**
- * 拉起应用
- */
-async function startAbility() {
- try {
- let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
- await abilityDelegator.startAbility({
- bundleName: "com.example.testvpnclient",
- abilityName: "EntryAbility"
- });
- } catch (err) {
- hilog.info(DOMAIN, TAG, 'startAbility err');
- }
-}
-
-/**
- * 关闭应用
- */
-async function terminateAbility() {
- try {
- let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
- let topAbility = await abilityDelegator.getCurrentTopAbility();
- await topAbility.context.terminateSelf();
- } catch (err) {
- hilog.info(DOMAIN, TAG, 'terminateAbility err');
- }
-}
-
+/*
+* Copyright (c) 2024 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 '@ohos.hilog';
+import { describe, it, expect } from '@ohos/hypium'
+import { Driver, ON } from '@ohos.UiTest';
+import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+
+const TAG = '[Sample_VpnConnect]';
+const DOMAIN = 0xF811;
+
+let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+async function getResourceString(resource: Resource): Promise {
+ let manage = abilityDelegator.getAppContext().resourceManager
+ let text = await manage.getStringValue(resource)
+ return text
+}
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ /**
+ * 启动Ability
+ */
+ it('startAbility_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'startAbility_001 start');
+ let driver = Driver.create();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ hilog.info(DOMAIN, TAG, 'startAbility_001 end');
+ done();
+ });
+
+ /**
+ * 进入首页,标题显示正确
+ */
+ it('IndexPageEnter_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 start');
+ let driver: Driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Toy VPN'));
+ let titleComponent = await driver.findComponent(ON.text('Toy VPN'));
+ let titleContent = await titleComponent.getText();
+ await driver.delayMs(200);
+ expect('Toy VPN').assertEqual(titleContent);
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'IndexPageEnter_001 end');
+ done();
+ });
+
+ /**
+ * 在主界面启用VPN
+ */
+ it('StartVpn_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'StartVpn_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Start VPN'));
+ let startVpn = await driver.findComponent(ON.text('Start VPN'));
+ await driver.delayMs(200);
+ await startVpn.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'StartVpn_001 end');
+ done();
+ });
+
+ /**
+ * 在主界面启用VPN后,再创建隧道
+ */
+ it('CreateTunnel_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'CreateTunnel_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ // 点击启用VPN
+ await driver.assertComponentExist(ON.text('Start VPN'));
+ let startVpn = await driver.findComponent(ON.text('Start VPN'));
+ await driver.delayMs(200);
+ await startVpn.click();
+ // 点击创建隧道
+ await driver.delayMs(200);
+ await driver.assertComponentExist(ON.text('创建对象'));
+ let createTunnel = await driver.findComponent(ON.text('创建对象'));
+ await driver.delayMs(200);
+ await createTunnel.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'CreateTunnel_001 end');
+ done();
+ });
+
+ /**
+ * 启用VPN后开启隧道保护
+ */
+ it('StartTunnelProtect_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ // 点击启用VPN
+ await driver.assertComponentExist(ON.text('Start VPN'));
+ let startVpn = await driver.findComponent(ON.text('Start VPN'));
+ await driver.delayMs(200);
+ await startVpn.click();
+ // 点击开启隧道保护
+ await driver.delayMs(200);
+ await driver.assertComponentExist(ON.text('隧道保护'));
+ let protect = await driver.findComponent(ON.text('隧道保护'));
+ await driver.delayMs(200);
+ await protect.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'StartTunnelProtect_001 end');
+ done();
+ });
+
+ /**
+ * 启用VPN后启动VPN连接
+ */
+ it('SetupVpn_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'SetupVpn_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ // 点击启用VPN
+ await driver.assertComponentExist(ON.text('Start VPN'));
+ let startVpn = await driver.findComponent(ON.text('Start VPN'));
+ await driver.delayMs(200);
+ await startVpn.click();
+ // 点击开启vpn
+ await driver.delayMs(200);
+ await driver.assertComponentExist(ON.text('启动vpn'));
+ let setupVpn = await driver.findComponent(ON.text('启动vpn'));
+ await setupVpn.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'SetupVpn_001 end');
+ done();
+ });
+
+ /**
+ * 停用VPN
+ */
+ it('StopVpn_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'StopVpn_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ await driver.assertComponentExist(ON.text('Stop VPN'));
+ let stopVpn = await driver.findComponent(ON.text('Stop VPN'));
+ await stopVpn.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'StopVpn_001 end')
+ done();
+ });
+
+ /**
+ * 关闭VPN连接
+ */
+ it('CloseVpn_001', 0, async (done: Function) => {
+ hilog.info(DOMAIN, TAG, 'CloseVpn_001 start');
+ let driver = Driver.create();
+ await terminateAbility();
+ await driver.delayMs(1000);
+ await startAbility();
+ await driver.delayMs(1000);
+ // 点击停用VPN
+ await driver.assertComponentExist(ON.text('Stop VPN'));
+ let stopVpn = await driver.findComponent(ON.text('Stop VPN'));
+ await stopVpn.click();
+ // 点击关闭VPN
+ await driver.delayMs(200);
+ await driver.assertComponentExist(ON.text('关闭vpn'));
+ let closeVpn = await driver.findComponent(ON.text('关闭vpn'));
+ await closeVpn.click();
+ await driver.delayMs(200);
+ hilog.info(DOMAIN, TAG, 'CloseVpn_001 end');
+ done();
+ });
+ });
+}
+
+/**
+ * 拉起应用
+ */
+async function startAbility() {
+ try {
+ let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ await abilityDelegator.startAbility({
+ bundleName: "com.example.testvpnclient",
+ abilityName: "EntryAbility"
+ });
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, 'startAbility err');
+ }
+}
+
+/**
+ * 关闭应用
+ */
+async function terminateAbility() {
+ try {
+ let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ let topAbility = await abilityDelegator.getCurrentTopAbility();
+ await topAbility.context.terminateSelf();
+ } catch (err) {
+ hilog.info(DOMAIN, TAG, 'terminateAbility err');
+ }
+}
+
diff --git a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5 b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5
index 8a85c47aa89de01d2df7c9f1e4955e89cb03c03e..12caf23cd2f308d179831840ef85132591f578a2 100644
--- a/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/Connectivity/VPN/entry/src/ohosTest/module.json5
@@ -1,52 +1,52 @@
-/*
-* Copyright (c) 2023 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "default",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntry": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "exported": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
-}
+/*
+* Copyright (c) 2023 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5 b/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5
index ccfdcf13408fcd4e571a67a0cfbec84ad120c3b5..f6cf5984545c7c13c4bf8e13b801c223b3af7a43 100644
--- a/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/Connectivity/VPN/hvigor/hvigor-config.json5
@@ -1,33 +1,33 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "hvigorVersion": "3.0.2",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "3.0.2"
- },
- "execution": {
- // "daemon": true, /* Enable daemon compilation. Default: true */
- // "incremental": true, /* Enable incremental compilation. Default: true */
- // "parallel": true, /* Enable parallel compilation. Default: true */
- // "typeCheck": false, /* Enable typeCheck. Default: false */
- },
- "logging": {
- // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
- },
- "debugging": {
- // "stacktrace": false /* Disable stacktrace compilation. Default: false */
- }
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "hvigorVersion": "3.0.2",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "3.0.2"
+ },
+ "execution": {
+ // "daemon": true, /* Enable daemon compilation. Default: true */
+ // "incremental": true, /* Enable incremental compilation. Default: true */
+ // "parallel": true, /* Enable parallel compilation. Default: true */
+ // "typeCheck": false, /* Enable typeCheck. Default: false */
+ },
+ "logging": {
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
+ },
+ "debugging": {
+ // "stacktrace": false /* Disable stacktrace compilation. Default: false */
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/Connectivity/VPN/oh-package.json5 b/code/BasicFeature/Connectivity/VPN/oh-package.json5
index 3c30215fd0f84e0b501cf0a6a8ace8278079971a..427c512f09f4ef18a9a92ae874c543dcd77c44d6 100644
--- a/code/BasicFeature/Connectivity/VPN/oh-package.json5
+++ b/code/BasicFeature/Connectivity/VPN/oh-package.json5
@@ -1,28 +1,28 @@
-/*
-* Copyright (c) 2023 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": "testvpnclient",
- "version": "1.0.0",
- "description": "Please describe the basic information.",
- "main": "",
- "author": "",
- "license": "",
- "dependencies": {
- },
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- }
-}
+/*
+* Copyright (c) 2023 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": "testvpnclient",
+ "version": "1.0.0",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "author": "",
+ "license": "",
+ "dependencies": {
+ },
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/.gitignore b/code/BasicFeature/DFX/AppRecovery/.gitignore
index b031e2b2be48618dee0d1e1643234c0a59200ffe..5a137750855ea0a5006740284db2f4138bff31e8 100644
--- a/code/BasicFeature/DFX/AppRecovery/.gitignore
+++ b/code/BasicFeature/DFX/AppRecovery/.gitignore
@@ -1,12 +1,12 @@
-/node_modules
-/local.properties
-/.idea
-**/build
-/.hvigor
-.cxx
-/.clangd
-/.clang-format
-/.clang-tidy
-/oh-package-lock.json5
-/package-lock.json
-/entry/package-lock.json
+/node_modules
+/local.properties
+/.idea
+**/build
+/.hvigor
+.cxx
+/.clangd
+/.clang-format
+/.clang-tidy
+/oh-package-lock.json5
+/package-lock.json
+/entry/package-lock.json
diff --git a/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5 b/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5
index 66eeccf56c84f8367b7b246ea6b973a6823362ea..bf1a3d1a33161786e49e631c272065feac168b5e 100644
--- a/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5
+++ b/code/BasicFeature/DFX/AppRecovery/AppScope/app.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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.recovery",
- "vendor": "samples",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name",
- "distributedNotificationEnabled": true
- }
-}
+/*
+ * Copyright (c) 2023 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.recovery",
+ "vendor": "samples",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name",
+ "distributedNotificationEnabled": true
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json
index 5d97eb3a833f7cbd9abdd6135fb551609ff74f87..21bb9f49856e57358901250d182285b564c1af51 100644
--- a/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/DFX/AppRecovery/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "AppRecoverySample"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "AppRecoverySample"
+ }
+ ]
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/README_zh.md b/code/BasicFeature/DFX/AppRecovery/README_zh.md
index 02d787035e57c4b903f6ef2cca325a95a46494fc..f90c553c5a4435568c22e9fe321df680a08478fb 100644
--- a/code/BasicFeature/DFX/AppRecovery/README_zh.md
+++ b/code/BasicFeature/DFX/AppRecovery/README_zh.md
@@ -1,128 +1,128 @@
-# 应用故障恢复
-
-### 介绍
-本示例展示了在应用中如何适配故障恢复相关接口。
-
-样例包含以下场景:\
-一.单Ability自动恢复 \
-在EntryAbility的故障触发页面触发故障,自动重启回到故障触发页面。
-
-二.多Ability自动恢复 \
-应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \
-自动重启到SecondAbility的故障触发页面。 \
-从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上点击次数信息。
-
-三.多Ability主动恢复 \
-应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \
-重启时启动RecoveryAbility,让使用者选择具体启动的Ability。
-
-四.Ability后台强制终止恢复 \
-应用中启动了EntryAbility和SecondAbility,并切入后台。\
-系统回收该应用,再次拉起时能够恢复先前的状态。
-
-相关概念: \
-故障:指的是应用处于无法提供服务的状态,如卡死以及崩溃。 \
-系统强制终止:指的是由于系统或者应用的原因,系统强制终止正在运行的应用进程,并回收资源的操作。
-
-### 效果预览
-|首页|故障触发页面|
-|---|---|
-|||
-
-使用说明
-
-一.单Ability自动恢复 \
-点击首页点击``跳转到故障触发页面`` \
-在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \
-以上场景预期:\
-能够回到``故障触发页面``页面,页面上的点击次数与触发保存状态时的一致。
-
-二.多Ability自动恢复 \
-点击首页点击跳转到``故障触发页面`` \
-在``故障触发页面``点击``启动SecondAbility``
-点击首页点击``跳转到故障触发页面`` \
-在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \
-以上场景预期:\
-立即回到SecondAbility的故障触发页面,并恢复页面的点击次数信息。\
-从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,页面上的点击次数与触发保存状态时的一致。
-
-三.多Ability主动恢复 \
-点击首页点击跳转到``故障触发页面`` \
-在``故障触发页面``点击``启动SecondAbility``
-在SecondAbility的故障触发页面点击设置重启Ability。 \
-在SecondAbility的故障触发页面点击``触发JsError``。 \
-以上场景预期:\
-重启时启动RecoveryAbility。
-
-四.Ability后台强制终止恢复 \
-点击首页点击跳转到``故障触发页面`` \
-在``故障触发页面``点击``启动SecondAbility``
-在SecondAbility的故障触发页面点击Counter,点击``保存当前Ability状态``,并切入后台 \
-使用kill命令强制终止当前应用 \
-以上场景预期:\
-从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。\
-从任务管理中将SecondAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。
-
-为避免反复拉起,两次测试的间隔至少为60秒(自动拉起的间隔为60秒)。
-### 工程目录
-```
-entry/src/main/
-├── cpp // 触发Native卡死代码
-│ ├── CMakeLists.txt
-│ ├── hello.cpp
-│ └── types
-│ └── libentry
-│ ├── index.d.ts
-│ └── oh-package.json5
-├── ets
-│ ├── ability
-│ │ ├── EntryAbility.ets // 测试入口Ability
-│ │ ├── RecoveryAbility.ets // 恢复引导Ability
-│ │ └── SecondAbility.ets // 测试第二Ability
-│ ├── app
-│ │ └── MyAbilityStage.ets // 用于初始化appRecovery的配置
-│ ├── common
-│ │ ├── Logger.ts // 日志
-│ │ └── TitleBar.ets // 标题
-│ └── pages
-│ ├── FaultTriggerPage.ets // 故障触发页面
-│ ├── Index.ets // 首页
-│ └── RecoveryPage.ets // 恢复页面
-```
-
-### 具体实现
-* 使能应用恢复功能,源码参考:[MyAbilityStage.ets](entry/src/main/ets/app/MyAbilityStage.ets)
- * 在``onCreate``中 调用[appRecovery](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/dfx/apprecovery-guidelines.md)接口使能功能
-* 配置支持恢复的Ability,源码参考:[module.json5](entry/src/main/module.json5)
- * 在``Ability``的节点中增加``recoverable``的配置,并设置为``true``
-* 实现恢复功能,源码参考:[EntryAbility.ets](entry/src/main/ets/ability/EntryAbility.ets)
- * 在``onSaveState``中保存用于恢复的数据
- * 在``onCreate``的``want``参数中恢复所需要的数据
-
-### 相关权限
-不涉及
-
-### 依赖
-无
-
-### 约束与限制
-
-1.本示例仅支持标准系统上运行,支持设备:RK3568。
-
-2.本示例为Stage模型,支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)
-
-3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
-
-### 下载
-
-给出单独下载本工程的命令,在代码中替换工程目录并以/结尾,如下面示例中的 **code/BasicFeature/DFX/AppRecovery/**,示例如下:
-
-如需单独下载本工程,执行如下命令:
-
-```
-git init
-git config core.sparsecheckout true
-echo code/BasicFeature/DFX/AppRecovery/ > .git/info/sparse-checkout
-git remote add origin https://gitee.com/openharmony/applications_app_samples.git
-git pull origin master
-```
+# 应用故障恢复
+
+### 介绍
+本示例展示了在应用中如何适配故障恢复相关接口。
+
+样例包含以下场景:\
+一.单Ability自动恢复 \
+在EntryAbility的故障触发页面触发故障,自动重启回到故障触发页面。
+
+二.多Ability自动恢复 \
+应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \
+自动重启到SecondAbility的故障触发页面。 \
+从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上点击次数信息。
+
+三.多Ability主动恢复 \
+应用中启动了EntryAbility和SecondAbility,在第二个启动的SecondAbility的故障触发页面触发故障。 \
+重启时启动RecoveryAbility,让使用者选择具体启动的Ability。
+
+四.Ability后台强制终止恢复 \
+应用中启动了EntryAbility和SecondAbility,并切入后台。\
+系统回收该应用,再次拉起时能够恢复先前的状态。
+
+相关概念: \
+故障:指的是应用处于无法提供服务的状态,如卡死以及崩溃。 \
+系统强制终止:指的是由于系统或者应用的原因,系统强制终止正在运行的应用进程,并回收资源的操作。
+
+### 效果预览
+|首页|故障触发页面|
+|---|---|
+|||
+
+使用说明
+
+一.单Ability自动恢复 \
+点击首页点击``跳转到故障触发页面`` \
+在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \
+以上场景预期:\
+能够回到``故障触发页面``页面,页面上的点击次数与触发保存状态时的一致。
+
+二.多Ability自动恢复 \
+点击首页点击跳转到``故障触发页面`` \
+在``故障触发页面``点击``启动SecondAbility``
+点击首页点击``跳转到故障触发页面`` \
+在故障触发页面点击按钮``点击``,再点击``保存当前Ability状态``以及``触发JsError``。 \
+以上场景预期:\
+立即回到SecondAbility的故障触发页面,并恢复页面的点击次数信息。\
+从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,页面上的点击次数与触发保存状态时的一致。
+
+三.多Ability主动恢复 \
+点击首页点击跳转到``故障触发页面`` \
+在``故障触发页面``点击``启动SecondAbility``
+在SecondAbility的故障触发页面点击设置重启Ability。 \
+在SecondAbility的故障触发页面点击``触发JsError``。 \
+以上场景预期:\
+重启时启动RecoveryAbility。
+
+四.Ability后台强制终止恢复 \
+点击首页点击跳转到``故障触发页面`` \
+在``故障触发页面``点击``启动SecondAbility``
+在SecondAbility的故障触发页面点击Counter,点击``保存当前Ability状态``,并切入后台 \
+使用kill命令强制终止当前应用 \
+以上场景预期:\
+从任务管理中将EntryAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。\
+从任务管理中将SecondAbility切回前台,预期能回到故障触发页面,并恢复页面上的点击次数信息。
+
+为避免反复拉起,两次测试的间隔至少为60秒(自动拉起的间隔为60秒)。
+### 工程目录
+```
+entry/src/main/
+├── cpp // 触发Native卡死代码
+│ ├── CMakeLists.txt
+│ ├── hello.cpp
+│ └── types
+│ └── libentry
+│ ├── index.d.ts
+│ └── oh-package.json5
+├── ets
+│ ├── ability
+│ │ ├── EntryAbility.ets // 测试入口Ability
+│ │ ├── RecoveryAbility.ets // 恢复引导Ability
+│ │ └── SecondAbility.ets // 测试第二Ability
+│ ├── app
+│ │ └── MyAbilityStage.ets // 用于初始化appRecovery的配置
+│ ├── common
+│ │ ├── Logger.ts // 日志
+│ │ └── TitleBar.ets // 标题
+│ └── pages
+│ ├── FaultTriggerPage.ets // 故障触发页面
+│ ├── Index.ets // 首页
+│ └── RecoveryPage.ets // 恢复页面
+```
+
+### 具体实现
+* 使能应用恢复功能,源码参考:[MyAbilityStage.ets](entry/src/main/ets/app/MyAbilityStage.ets)
+ * 在``onCreate``中 调用[appRecovery](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/dfx/apprecovery-guidelines.md)接口使能功能
+* 配置支持恢复的Ability,源码参考:[module.json5](entry/src/main/module.json5)
+ * 在``Ability``的节点中增加``recoverable``的配置,并设置为``true``
+* 实现恢复功能,源码参考:[EntryAbility.ets](entry/src/main/ets/ability/EntryAbility.ets)
+ * 在``onSaveState``中保存用于恢复的数据
+ * 在``onCreate``的``want``参数中恢复所需要的数据
+
+### 相关权限
+不涉及
+
+### 依赖
+无
+
+### 约束与限制
+
+1.本示例仅支持标准系统上运行,支持设备:RK3568。
+
+2.本示例为Stage模型,支持API10版本SDK,SDK版本号(API Version 10 Release),镜像版本号(4.0 Release)
+
+3.本示例需要使用DevEco Studio 版本号(4.0 Release)及以上版本才可编译运行。
+
+### 下载
+
+给出单独下载本工程的命令,在代码中替换工程目录并以/结尾,如下面示例中的 **code/BasicFeature/DFX/AppRecovery/**,示例如下:
+
+如需单独下载本工程,执行如下命令:
+
+```
+git init
+git config core.sparsecheckout true
+echo code/BasicFeature/DFX/AppRecovery/ > .git/info/sparse-checkout
+git remote add origin https://gitee.com/openharmony/applications_app_samples.git
+git pull origin master
+```
diff --git a/code/BasicFeature/DFX/AppRecovery/build-profile.json5 b/code/BasicFeature/DFX/AppRecovery/build-profile.json5
index 390b41a9444ff9c8f9fdae6934b65992667fe62f..947c318515daba7da7f38dc0121210ba6d4856c9 100644
--- a/code/BasicFeature/DFX/AppRecovery/build-profile.json5
+++ b/code/BasicFeature/DFX/AppRecovery/build-profile.json5
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2023 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": 10,
- "compatibleSdkVersion": 10,
- "runtimeOS": "OpenHarmony"
- }
- ],
- "signingConfigs": []
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2023 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": 10,
+ "compatibleSdkVersion": 10,
+ "runtimeOS": "OpenHarmony"
+ }
+ ],
+ "signingConfigs": []
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/.gitignore b/code/BasicFeature/DFX/AppRecovery/entry/.gitignore
index 4a65948351bcf95d2be1fa983394377e3aaa3a2e..5a6ba80fa3d9498a23ae8ae7d9518f8743fa8a96 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/.gitignore
+++ b/code/BasicFeature/DFX/AppRecovery/entry/.gitignore
@@ -1,4 +1,4 @@
-/node_modules
-/.preview
-/build
+/node_modules
+/.preview
+/build
/.cxx
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5 b/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5
index 4822212a5538b5bf7eef93d447aa21945d947c26..71efbba6e55b38784800ea4b7b82c6bdcc88492d 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5
+++ b/code/BasicFeature/DFX/AppRecovery/entry/build-profile.json5
@@ -1,38 +1,38 @@
-/*
- * Copyright (c) 2023 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": {
- "externalNativeOptions": {
- "path": "./src/main/cpp/CMakeLists.txt",
- "arguments": "",
- "abiFilters": [
- "armeabi-v7a",
- "arm64-v8a"
- ],
- "cppFlags": "",
- }
- },
- "targets": [
- {
- "name": "default",
- "runtimeOS": "OpenHarmony"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ "externalNativeOptions": {
+ "path": "./src/main/cpp/CMakeLists.txt",
+ "arguments": "",
+ "abiFilters": [
+ "armeabi-v7a",
+ "arm64-v8a"
+ ],
+ "cppFlags": "",
+ }
+ },
+ "targets": [
+ {
+ "name": "default",
+ "runtimeOS": "OpenHarmony"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts b/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts
index c57c77181d0d36beb49c897ff3fc1ad92f7eaa7c..80e4ec5b81689f238c34614b167a0b9e9c83e8d9 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts
+++ b/code/BasicFeature/DFX/AppRecovery/entry/hvigorfile.ts
@@ -1,2 +1,2 @@
-// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
-export { hapTasks } from '@ohos/hvigor-ohos-plugin';
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+export { hapTasks } from '@ohos/hvigor-ohos-plugin';
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5
index 92a9bafefbc1a3c13b108fea78a65392ebe0faff..3e99258f08d36a6ecb88e5d369e1d1857d272148 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5
+++ b/code/BasicFeature/DFX/AppRecovery/entry/oh-package.json5
@@ -1,24 +1,24 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "ISC",
- "devDependencies": {},
- "name": "entry",
- "description": "app recovery sample",
- "repository": {},
- "version": "1.0.0",
- "dependencies": {}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "ISC",
+ "devDependencies": {},
+ "name": "entry",
+ "description": "app recovery sample",
+ "repository": {},
+ "version": "1.0.0",
+ "dependencies": {}
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt
index 8825d3732258b61586a58a0e836d30e23d8d1d11..0304a9904c143dcf8941f600a99a43989fb2057a 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/CMakeLists.txt
@@ -1,24 +1,24 @@
-# Copyright (c) 2023 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.
-#
-# the minimum version of CMake.
-cmake_minimum_required(VERSION 3.4.1)
-project(MyApplication6)
-
-set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
-
-include_directories(${NATIVERENDER_ROOT_PATH}
- ${NATIVERENDER_ROOT_PATH}/include)
-
-add_library(entry SHARED hello.cpp)
+# Copyright (c) 2023 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.
+#
+# the minimum version of CMake.
+cmake_minimum_required(VERSION 3.4.1)
+project(MyApplication6)
+
+set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
+
+include_directories(${NATIVERENDER_ROOT_PATH}
+ ${NATIVERENDER_ROOT_PATH}/include)
+
+add_library(entry SHARED hello.cpp)
target_link_libraries(entry PUBLIC libace_napi.z.so)
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp
index 4b1c45621ccac30286bcc7e84308b5a98e48b658..32c697284e77fdbbb6576cb8aa81096ff7dc13e8 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/hello.cpp
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-#include
-#include "napi/native_api.h"
-
-static napi_value DeadLoop(napi_env env, napi_callback_info info)
-{
- while (true) {
- printf("aaa\n");
- }
- return 0;
-}
-
-EXTERN_C_START
-static napi_value Init(napi_env env, napi_value exports)
-{
- napi_property_descriptor functions[] = {
- { "deadLoop", nullptr, DeadLoop, nullptr, nullptr, nullptr, napi_default, nullptr }
- };
- napi_define_properties(env, exports, sizeof(functions) / sizeof(functions[0]), functions);
- return exports;
-}
-EXTERN_C_END
-
-static napi_module demoModule = {
- .nm_version = 1,
- .nm_flags = 0,
- .nm_filename = nullptr,
- .nm_register_func = Init,
- .nm_modname = "entry",
- .nm_priv = ((void*)0),
- .reserved = { 0 },
-};
-
-extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
-{
- napi_module_register(&demoModule);
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+#include
+#include "napi/native_api.h"
+
+static napi_value DeadLoop(napi_env env, napi_callback_info info)
+{
+ while (true) {
+ printf("aaa\n");
+ }
+ return 0;
+}
+
+EXTERN_C_START
+static napi_value Init(napi_env env, napi_value exports)
+{
+ napi_property_descriptor functions[] = {
+ { "deadLoop", nullptr, DeadLoop, nullptr, nullptr, nullptr, napi_default, nullptr }
+ };
+ napi_define_properties(env, exports, sizeof(functions) / sizeof(functions[0]), functions);
+ return exports;
+}
+EXTERN_C_END
+
+static napi_module demoModule = {
+ .nm_version = 1,
+ .nm_flags = 0,
+ .nm_filename = nullptr,
+ .nm_register_func = Init,
+ .nm_modname = "entry",
+ .nm_priv = ((void*)0),
+ .reserved = { 0 },
+};
+
+extern "C" __attribute__((constructor)) void RegisterEntryModule(void)
+{
+ napi_module_register(&demoModule);
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts
index 50ede76b5da6f59d05d5067da8e55163ecbbf962..7811a521b4a5c6cca88354f96cc6921f2513411a 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/index.d.ts
@@ -1,16 +1,16 @@
-/*
- * Copyright (c) 2023 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.
- */
-
+/*
+ * Copyright (c) 2023 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 const deadLoop: () => number;
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5
index 982d2e7abbd541c31132878bf64c0201d191655d..58bef51c5d4b7b7a530d5f9f1a6d9fc2edcb6874 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/cpp/types/libentry/oh-package.json5
@@ -1,21 +1,21 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "types": "./index.d.ts",
- "name": "libentry.so",
- "description": "",
- "version": ""
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "types": "./index.d.ts",
+ "name": "libentry.so",
+ "description": "",
+ "version": ""
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets
index 5f81cef6f1119f9618b46394b405bfa57abbdd6d..0c92955e9746dd49baf3845d6e069a1ff484f64f 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/EntryAbility.ets
@@ -1,93 +1,93 @@
-/*
- * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
-import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import Want from '@ohos.app.ability.Want';
-import Window from '@ohos.window';
-
-import Logger from '../common/Logger';
-import { CurActiveAbility } from '../common/CurActiveAbility';
-
-const TAG: string = 'EntryAbility';
-
-export default class EntryAbility extends UIAbility {
- isRecoverLaunch: boolean = false;
- storage: LocalStorage = new LocalStorage();
-
- // Read previous saved status from want if we are launched by appRecovery
- restoreLocalStorage(want: Want): void {
- Logger.info(TAG, "RestoreLocalStorage String:${want.parameters['Page1Str']} Counter:${want.parameters['Page2Counter']}");
- if (want.parameters !== undefined) {
- this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string);
- this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number);
- }
-
- }
-
- onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
- Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}');
- this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY);
- this.storage.setOrCreate('CurrentAbilityName', 'EntryAbility');
- this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
- this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
- if (this.isRecoverLaunch) {
- // savedState is in wantParams
- this.restoreLocalStorage(want);
- this.context.restoreWindowStage(this.storage);
- }
- }
-
- onDestroy(): void {
- Logger.info(TAG, 'onDestroy');
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage): void {
- Logger.info(TAG, 'onWindowStageCreate');
- // Share storage between pages and current ability
- windowStage.loadContent('pages/Index', this.storage, (err, data): void => {
- if (err.code) {
- Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}');
- return;
- }
- });
- }
-
- onWindowStageDestroy(): void {
- Logger.info(TAG, 'onWindowStageDestroy');
- }
-
- onForeground(): void {
- Logger.info(TAG, 'onForeground');
- CurActiveAbility.GetInstance().SetGlobalAbility(this);
- }
-
- onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
- Logger.info(TAG, 'onSaveState');
- let string = this.storage.get('FaultTriggerPageString');
- let counter = this.storage.get('FaultTriggerPageCounter');
- wantParam['FaultTriggerPageString'] = string ?? 'Empty';
- wantParam['FaultTriggerPageCounter'] = counter as number;
- Logger.info(TAG, 'SavedText:${string} SavedCounter:${counter}');
- return AbilityConstant.OnSaveResult.ALL_AGREE;
- }
-
- onBackground(): void {
- Logger.info(TAG, 'onBackground');
- // save state when background
- appRecovery.saveAppState(this.context);
- }
-}
+/*
+ * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import Want from '@ohos.app.ability.Want';
+import Window from '@ohos.window';
+
+import Logger from '../common/Logger';
+import { CurActiveAbility } from '../common/CurActiveAbility';
+
+const TAG: string = 'EntryAbility';
+
+export default class EntryAbility extends UIAbility {
+ isRecoverLaunch: boolean = false;
+ storage: LocalStorage = new LocalStorage();
+
+ // Read previous saved status from want if we are launched by appRecovery
+ restoreLocalStorage(want: Want): void {
+ Logger.info(TAG, "RestoreLocalStorage String:${want.parameters['Page1Str']} Counter:${want.parameters['Page2Counter']}");
+ if (want.parameters !== undefined) {
+ this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string);
+ this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number);
+ }
+
+ }
+
+ onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
+ Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}');
+ this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY);
+ this.storage.setOrCreate('CurrentAbilityName', 'EntryAbility');
+ this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
+ this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
+ if (this.isRecoverLaunch) {
+ // savedState is in wantParams
+ this.restoreLocalStorage(want);
+ this.context.restoreWindowStage(this.storage);
+ }
+ }
+
+ onDestroy(): void {
+ Logger.info(TAG, 'onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage): void {
+ Logger.info(TAG, 'onWindowStageCreate');
+ // Share storage between pages and current ability
+ windowStage.loadContent('pages/Index', this.storage, (err, data): void => {
+ if (err.code) {
+ Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}');
+ return;
+ }
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ Logger.info(TAG, 'onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ Logger.info(TAG, 'onForeground');
+ CurActiveAbility.GetInstance().SetGlobalAbility(this);
+ }
+
+ onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
+ Logger.info(TAG, 'onSaveState');
+ let string = this.storage.get('FaultTriggerPageString');
+ let counter = this.storage.get('FaultTriggerPageCounter');
+ wantParam['FaultTriggerPageString'] = string ?? 'Empty';
+ wantParam['FaultTriggerPageCounter'] = counter as number;
+ Logger.info(TAG, 'SavedText:${string} SavedCounter:${counter}');
+ return AbilityConstant.OnSaveResult.ALL_AGREE;
+ }
+
+ onBackground(): void {
+ Logger.info(TAG, 'onBackground');
+ // save state when background
+ appRecovery.saveAppState(this.context);
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets
index da3abb03d5f1b0c5ed5d2bc3d6bfdcce073abc7c..adea24140cd0d8f2f60c3df4fd9957b9eeb64b46 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/RecoveryAbility.ets
@@ -1,71 +1,71 @@
-/*
- * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
-import Window from '@ohos.window'
-import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-import Want from '@ohos.app.ability.Want';
-
-import Logger from '../common/Logger'
-import { CurActiveAbility } from '../common/CurActiveAbility';
-
-const TAG: string = 'SecondAbility';
-
-export default class RecoveryAbility extends UIAbility {
- storage: LocalStorage = new LocalStorage();
-
- onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
- Logger.info(TAG, 'onCreate');
- this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
- this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
- if (want.parameters !== undefined) {
- AppStorage.SetOrCreate('RecoverAbility', want.parameters['RecoverAbility'] as string);
- }
- }
-
- onDestroy(): void {
- Logger.info(TAG, 'onDestroy');
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage):void {
- Logger.info(TAG, 'onWindowStageCreate');
- windowStage.loadContent('pages/RecoveryPage', this.storage, (err, data) => {
- if (err.code) {
- Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}');
- return;
- }
- });
- }
-
- onWindowStageDestroy(): void {
- Logger.info(TAG, 'onWindowStageDestroy');
- }
-
- onForeground(): void {
- Logger.info(TAG, 'onForeground');
- CurActiveAbility.GetInstance().SetGlobalAbility(this);
- }
-
- onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
- // No need to save state
- Logger.info(TAG, 'onSaveState');
- return AbilityConstant.OnSaveResult.ALL_REJECT;
- }
-
- onBackground(): void {
- // Ability has back to background
- Logger.info(TAG, 'onBackground');
- }
-}
+/*
+ * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
+import Window from '@ohos.window'
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+import Want from '@ohos.app.ability.Want';
+
+import Logger from '../common/Logger'
+import { CurActiveAbility } from '../common/CurActiveAbility';
+
+const TAG: string = 'SecondAbility';
+
+export default class RecoveryAbility extends UIAbility {
+ storage: LocalStorage = new LocalStorage();
+
+ onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
+ Logger.info(TAG, 'onCreate');
+ this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
+ this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
+ if (want.parameters !== undefined) {
+ AppStorage.SetOrCreate('RecoverAbility', want.parameters['RecoverAbility'] as string);
+ }
+ }
+
+ onDestroy(): void {
+ Logger.info(TAG, 'onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage):void {
+ Logger.info(TAG, 'onWindowStageCreate');
+ windowStage.loadContent('pages/RecoveryPage', this.storage, (err, data) => {
+ if (err.code) {
+ Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}');
+ return;
+ }
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ Logger.info(TAG, 'onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ Logger.info(TAG, 'onForeground');
+ CurActiveAbility.GetInstance().SetGlobalAbility(this);
+ }
+
+ onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
+ // No need to save state
+ Logger.info(TAG, 'onSaveState');
+ return AbilityConstant.OnSaveResult.ALL_REJECT;
+ }
+
+ onBackground(): void {
+ // Ability has back to background
+ Logger.info(TAG, 'onBackground');
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets
index ed13cc61fb68936224b6b08e0c0c435482cb8b02..2754443218b115e8c5bbb96f93adf47d67f21d27 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/ability/SecondAbility.ets
@@ -1,90 +1,90 @@
-/*
- * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
-import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-import UIAbility from '@ohos.app.ability.UIAbility';
-import Want from '@ohos.app.ability.Want';
-import Window from '@ohos.window';
-
-import Logger from '../common/Logger';
-import { CurActiveAbility } from '../common/CurActiveAbility';
-
-const TAG: string = 'SecondAbility';
-
-export default class SecondAbility extends UIAbility {
- isRecoverLaunch: boolean = false;
- storage: LocalStorage = new LocalStorage();
-
- // Read previous saved status from want if we are launched by appRecovery
- restoreLocalStorage(want: Want) : void {
- if (want.parameters !== undefined) {
- this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string);
- this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number);
- }
- }
-
- onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
- Logger.info(TAG, 'onCreate');
- this.storage.setOrCreate('CurrentAbilityName', 'SecondAbility');
- this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
- this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
- this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY);
- if (this.isRecoverLaunch) {
- // savedState is in wantParams
- this.restoreLocalStorage(want);
- this.context.restoreWindowStage(this.storage);
- }
- }
-
- onDestroy(): void {
- Logger.info(TAG, 'onDestroy');
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage): void {
- Logger.info(TAG, 'onWindowStageCreate');
- // Share storage between pages and current ability
- windowStage.loadContent('pages/Index', this.storage, (err, data) => {
- if (err.code) {
- Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}');
- return;
- }
- });
- }
-
- onWindowStageDestroy(): void {
- Logger.info(TAG, 'onWindowStageDestroy');
- }
-
- onForeground(): void {
- Logger.info(TAG, 'onForeground');
- CurActiveAbility.GetInstance().SetGlobalAbility(this);
- }
-
- onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
- Logger.info(TAG, 'onSaveState');
- let string = this.storage.get('FaultTriggerPageString');
- let counter = this.storage.get('FaultTriggerPageCounter');
- wantParam['FaultTriggerPageString'] = string ?? 'Empty';
- wantParam['FaultTriggerPageCounter'] = counter as number;
- return AbilityConstant.OnSaveResult.ALL_AGREE;
- }
-
- onBackground(): void {
- Logger.info(TAG, 'onBackground');
- // save state when background
- appRecovery.saveAppState(this.context);
- }
-}
+/*
+ * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+import UIAbility from '@ohos.app.ability.UIAbility';
+import Want from '@ohos.app.ability.Want';
+import Window from '@ohos.window';
+
+import Logger from '../common/Logger';
+import { CurActiveAbility } from '../common/CurActiveAbility';
+
+const TAG: string = 'SecondAbility';
+
+export default class SecondAbility extends UIAbility {
+ isRecoverLaunch: boolean = false;
+ storage: LocalStorage = new LocalStorage();
+
+ // Read previous saved status from want if we are launched by appRecovery
+ restoreLocalStorage(want: Want) : void {
+ if (want.parameters !== undefined) {
+ this.storage.setOrCreate('FaultTriggerPageString', want.parameters['FaultTriggerPageString'] as string);
+ this.storage.setOrCreate('FaultTriggerPageCounter', want.parameters['FaultTriggerPageCounter'] as number);
+ }
+ }
+
+ onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
+ Logger.info(TAG, 'onCreate');
+ this.storage.setOrCreate('CurrentAbilityName', 'SecondAbility');
+ this.storage.setOrCreate('launchReason', launchParam.launchReason.toString());
+ this.storage.setOrCreate('lastExitReason', launchParam.lastExitReason.toString());
+ this.isRecoverLaunch = (launchParam.launchReason == AbilityConstant.LaunchReason.APP_RECOVERY);
+ if (this.isRecoverLaunch) {
+ // savedState is in wantParams
+ this.restoreLocalStorage(want);
+ this.context.restoreWindowStage(this.storage);
+ }
+ }
+
+ onDestroy(): void {
+ Logger.info(TAG, 'onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage): void {
+ Logger.info(TAG, 'onWindowStageCreate');
+ // Share storage between pages and current ability
+ windowStage.loadContent('pages/Index', this.storage, (err, data) => {
+ if (err.code) {
+ Logger.info(TAG, 'Failed to load the content. Cause:${JSON.stringify(err)}}');
+ return;
+ }
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ Logger.info(TAG, 'onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ Logger.info(TAG, 'onForeground');
+ CurActiveAbility.GetInstance().SetGlobalAbility(this);
+ }
+
+ onSaveState(reason: AbilityConstant.StateType, wantParam: Record): AbilityConstant.OnSaveResult {
+ Logger.info(TAG, 'onSaveState');
+ let string = this.storage.get('FaultTriggerPageString');
+ let counter = this.storage.get('FaultTriggerPageCounter');
+ wantParam['FaultTriggerPageString'] = string ?? 'Empty';
+ wantParam['FaultTriggerPageCounter'] = counter as number;
+ return AbilityConstant.OnSaveResult.ALL_AGREE;
+ }
+
+ onBackground(): void {
+ Logger.info(TAG, 'onBackground');
+ // save state when background
+ appRecovery.saveAppState(this.context);
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets
index 08c38d397153c200a0ca1e0c18519810670539a2..95880a84314466b675b2e4a8ec809c3e05823a68 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/app/MyAbilityStage.ets
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage';
-import appRecovery from '@ohos.app.ability.appRecovery';
-import Logger from '../common/Logger'
-const TAG: string = 'MyAbilityStage'
-export default class MyAbilityStage extends AbilityStage {
- onCreate() {
- Logger.info(TAG, 'onCreate')
- // global switch for appRecovery function in current package
- appRecovery.enableAppRecovery();
- }
+/*
+ * Copyright (c) 2023 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 AbilityStage from '@ohos.app.ability.AbilityStage';
+import appRecovery from '@ohos.app.ability.appRecovery';
+import Logger from '../common/Logger'
+const TAG: string = 'MyAbilityStage'
+export default class MyAbilityStage extends AbilityStage {
+ onCreate() {
+ Logger.info(TAG, 'onCreate')
+ // global switch for appRecovery function in current package
+ appRecovery.enableAppRecovery();
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts
index 8e98759606288a23c2b8b30e7e437ab2fd4d90a4..253aa9ed5e899128dd86aaf72b526f26ffa0b836 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/CurActiveAbility.ts
@@ -1,36 +1,36 @@
-/**
- * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
-
-export class CurActiveAbility extends UIAbility {
- private static instance: CurActiveAbility;
- private _object : Object;
-
- public static GetInstance(): CurActiveAbility {
- if (!CurActiveAbility.instance) {
- CurActiveAbility.instance = new CurActiveAbility();
- }
- return CurActiveAbility.instance;
- }
-
- SetGlobalAbility(object: Object): void{
- this._object = object;
- }
-
- GetGlobalAbility(): UIAbility {
- return this._object as UIAbility;
- }
+/**
+ * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
+
+export class CurActiveAbility extends UIAbility {
+ private static instance: CurActiveAbility;
+ private _object : Object;
+
+ public static GetInstance(): CurActiveAbility {
+ if (!CurActiveAbility.instance) {
+ CurActiveAbility.instance = new CurActiveAbility();
+ }
+ return CurActiveAbility.instance;
+ }
+
+ SetGlobalAbility(object: Object): void{
+ this._object = object;
+ }
+
+ GetGlobalAbility(): UIAbility {
+ return this._object as UIAbility;
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts
index d25871d66e7b8cb619fad0ef0aa70ba8a654ba5a..789e0158c4dd0900e65e6d570fba7317b6d32183 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/common/ResUtil.ts
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2023 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 resourceManager from '@ohos.resourceManager';
-import Logger from './Logger';
-import { CurActiveAbility } from './CurActiveAbility';
-
-export class ResUtil {
- async getString(id): Promise {
- let resourceMgr = CurActiveAbility.GetInstance().GetGlobalAbility().context.resourceManager;
- return resourceMgr.getStringValue(id);
- }
-}
-
-let resUtil = new ResUtil();
-
-export default resUtil as ResUtil;
+/**
+ * Copyright (c) 2023 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 resourceManager from '@ohos.resourceManager';
+import Logger from './Logger';
+import { CurActiveAbility } from './CurActiveAbility';
+
+export class ResUtil {
+ async getString(id): Promise {
+ let resourceMgr = CurActiveAbility.GetInstance().GetGlobalAbility().context.resourceManager;
+ return resourceMgr.getStringValue(id);
+ }
+}
+
+let resUtil = new ResUtil();
+
+export default resUtil as ResUtil;
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets
index 5d0c57b05cd66bcfccd939f81057604051b041d0..2dda66cb3e1d812337377371f0760f8343eed900 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/FaultTriggerPage.ets
@@ -1,315 +1,315 @@
-/*
- * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
-import testNapi from 'libentry.so';
-import ResUtil from '../common/ResUtil';
-import { CurActiveAbility } from '../common/CurActiveAbility';
-
-@Entry
-@Component
-struct FaultTriggerPage {
- storage = LocalStorage.GetShared();
- @State counter: number = 0;
- @State callerAbility: string = '';
- @State launchReason: string = '';
- @State lastExitReason: string = '';
- @State curAbilitySaveState: string = '';
- @State allAbilitySaveState: string = '';
- @State setRecoveryAbility: string = '';
-
- aboutToAppear() {
- this.counter = this.storage.get('FaultTriggerPageCounter') ?? 0;
- this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'UnknownCallingAbility';
- this.launchReason = this.storage.get('launchReason') ?? 'Unknown';
- this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown';
- ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.curAbilitySaveState = value);
- ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.allAbilitySaveState = value);
- ResUtil.getString($r('app.string.set_config').id).then((value: string) => this.setRecoveryAbility = value);
- }
-
- doHeavyWork() : void {
- let i = 0;
- while (i < 1000000000) {
- i++;
- let j = 0;
- while (j < 1000000000) {
- j++;
- let k = 0;
- while (k < 1000000000) {
- k++;
- }
- }
- }
- }
-
- build() {
- Column() {
- Text(this.callerAbility)
- .fontSize('30fp')
- .fontWeight(FontWeight.Bold)
- .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' })
- .margin({ top: '14vp' })
- .textAlign(TextAlign.Start)
- .height('56vp')
- .width('100%')
- .fontColor($r('app.color.text_grey'));
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.launch_reason')).fontSize('16fp').width('86%');
- Text('0' + this.launchReason)
- .fontSize('14fp')
- .width('14%')
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .textAlign(TextAlign.End);
- }
- }
- }.width('100%').height('48vp').align(Alignment.Center);
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%');
- Text('0' + this.lastExitReason)
- .fontSize('14fp')
- .width('14%')
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .textAlign(TextAlign.End);
- }
- }
- }.width('100%').height('48vp').align(Alignment.Center);
- }
- .alignListItem(ListItemAlign.Center)
- .margin({ left: '12vp', right: '12vp', top: '8vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Row() {
- Text($r('app.string.click_counter')).fontSize('16fp')
- Text(this.counter.toString()).fontSize('16fp')
- }.align(Alignment.Center).width('76.3%');
- Button($r('app.string.counter_name'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- this.counter++;
- this.storage.setOrCreate('FaultTriggerPageCounter', this.counter);
- this.storage.setOrCreate('FaultTriggerPageString', 'TestFaultTriggerPageString');
- })
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- .align(Alignment.Center)
- .height('28vp');
- }.align(Alignment.Center).height('48vp');
- }
- }.align(Alignment.Center).padding({ top: '4vp', bottom: '4vp' }).width('100%');
- }
- .height('56vp')
- .margin({ left: '12vp', right: '12vp', top: '12vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp' });
-
- Text($r('app.string.recover_settings'))
- .fontSize('14fp')
- .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' })
- .textAlign(TextAlign.Start)
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .height('19vp')
- .width('86.7%');
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.save_current_ability_status')).fontSize('16fp').width('76.3%');
- Button(this.curAbilitySaveState)
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- appRecovery.saveAppState(CurActiveAbility.GetInstance().GetGlobalAbility().context);
- ResUtil.getString($r('app.string.save_state_done').id)
- .then((value: string) => this.curAbilitySaveState = value);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').width('100%');
- }
- }.width('100%');
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.save_all_ability_status')).fontSize('16fp').width('76.3%');
- Button(this.allAbilitySaveState)
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- appRecovery.saveAppState();
- ResUtil.getString($r('app.string.save_state_done').id)
- .then((value: string) => this.allAbilitySaveState = value);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').width('100%');
- }
- }.width('100%');
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.set_recovery_ability')).fontSize('16fp').width('76.3%');
- Button(this.setRecoveryAbility)
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- let tmp: Record = {'RecoverAbility': this.callerAbility }
- let want: Record = {
- 'bundleName': 'com.samples.recovery',
- 'abilityName': 'RecoveryAbility',
- 'parameters': tmp,
- };
- appRecovery.setRestartWant(want);
- ResUtil.getString($r('app.string.set_config_done').id).then((value: string) => this.setRecoveryAbility = value);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').width('100%');
- }
- }.width('100%');
-
- if (this.callerAbility === 'EntryAbility') {
- ListItem() {
- Column() {
- Row() {
- Text('SecondAbility').fontSize('16fp').width('76.3%');
- Button($r('app.string.launch_ability'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
- return;
- }
- let want: Record = {
- 'bundleName': 'com.samples.recovery',
- 'abilityName': 'SecondAbility'
- };
- CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').width('100%');
- }
- }.width('100%');
- }
- }
- .margin({ left: '12vp', right: '12vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- .divider(
- { strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }
- );
-
- Text($r('app.string.trigger_fault_items'))
- .fontSize('14fp')
- .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' })
- .textAlign(TextAlign.Start)
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .height('19vp')
- .width('86.7%');
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.trigger_js_error')).fontSize('16fp').width('76.3%');
- Button($r('app.string.trigger'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- throw new Error('Force Crash');
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').align(Alignment.Center).width('100%');
- }
- }.width('100%');
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.trigger_freeze_in_js_code')).fontSize('16fp').width('76.3%');
- Button($r('app.string.trigger'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- this.doHeavyWork();
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').align(Alignment.Center).width('100%');
- }
- }.width('100%');
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.trigger_freeze_in_native_code')).fontSize('16fp').width('76.3%');
- Button($r('app.string.trigger'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- testNapi.add(1, 1);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').align(Alignment.Center).width('100%');
- }
- }.align(Alignment.Center).width('100%');
- }
- .margin({ left: '12vp', right: '12vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
- }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
- .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
- }
-}
+/*
+ * Copyright (c) 2023 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 appRecovery from '@ohos.app.ability.appRecovery';
+import testNapi from 'libentry.so';
+import ResUtil from '../common/ResUtil';
+import { CurActiveAbility } from '../common/CurActiveAbility';
+
+@Entry
+@Component
+struct FaultTriggerPage {
+ storage = LocalStorage.GetShared();
+ @State counter: number = 0;
+ @State callerAbility: string = '';
+ @State launchReason: string = '';
+ @State lastExitReason: string = '';
+ @State curAbilitySaveState: string = '';
+ @State allAbilitySaveState: string = '';
+ @State setRecoveryAbility: string = '';
+
+ aboutToAppear() {
+ this.counter = this.storage.get('FaultTriggerPageCounter') ?? 0;
+ this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'UnknownCallingAbility';
+ this.launchReason = this.storage.get('launchReason') ?? 'Unknown';
+ this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown';
+ ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.curAbilitySaveState = value);
+ ResUtil.getString($r('app.string.save_state').id).then((value: string) => this.allAbilitySaveState = value);
+ ResUtil.getString($r('app.string.set_config').id).then((value: string) => this.setRecoveryAbility = value);
+ }
+
+ doHeavyWork() : void {
+ let i = 0;
+ while (i < 1000000000) {
+ i++;
+ let j = 0;
+ while (j < 1000000000) {
+ j++;
+ let k = 0;
+ while (k < 1000000000) {
+ k++;
+ }
+ }
+ }
+ }
+
+ build() {
+ Column() {
+ Text(this.callerAbility)
+ .fontSize('30fp')
+ .fontWeight(FontWeight.Bold)
+ .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' })
+ .margin({ top: '14vp' })
+ .textAlign(TextAlign.Start)
+ .height('56vp')
+ .width('100%')
+ .fontColor($r('app.color.text_grey'));
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.launch_reason')).fontSize('16fp').width('86%');
+ Text('0' + this.launchReason)
+ .fontSize('14fp')
+ .width('14%')
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .textAlign(TextAlign.End);
+ }
+ }
+ }.width('100%').height('48vp').align(Alignment.Center);
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%');
+ Text('0' + this.lastExitReason)
+ .fontSize('14fp')
+ .width('14%')
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .textAlign(TextAlign.End);
+ }
+ }
+ }.width('100%').height('48vp').align(Alignment.Center);
+ }
+ .alignListItem(ListItemAlign.Center)
+ .margin({ left: '12vp', right: '12vp', top: '8vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Row() {
+ Text($r('app.string.click_counter')).fontSize('16fp')
+ Text(this.counter.toString()).fontSize('16fp')
+ }.align(Alignment.Center).width('76.3%');
+ Button($r('app.string.counter_name'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ this.counter++;
+ this.storage.setOrCreate('FaultTriggerPageCounter', this.counter);
+ this.storage.setOrCreate('FaultTriggerPageString', 'TestFaultTriggerPageString');
+ })
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ .align(Alignment.Center)
+ .height('28vp');
+ }.align(Alignment.Center).height('48vp');
+ }
+ }.align(Alignment.Center).padding({ top: '4vp', bottom: '4vp' }).width('100%');
+ }
+ .height('56vp')
+ .margin({ left: '12vp', right: '12vp', top: '12vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp' });
+
+ Text($r('app.string.recover_settings'))
+ .fontSize('14fp')
+ .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' })
+ .textAlign(TextAlign.Start)
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .height('19vp')
+ .width('86.7%');
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.save_current_ability_status')).fontSize('16fp').width('76.3%');
+ Button(this.curAbilitySaveState)
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ appRecovery.saveAppState(CurActiveAbility.GetInstance().GetGlobalAbility().context);
+ ResUtil.getString($r('app.string.save_state_done').id)
+ .then((value: string) => this.curAbilitySaveState = value);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').width('100%');
+ }
+ }.width('100%');
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.save_all_ability_status')).fontSize('16fp').width('76.3%');
+ Button(this.allAbilitySaveState)
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ appRecovery.saveAppState();
+ ResUtil.getString($r('app.string.save_state_done').id)
+ .then((value: string) => this.allAbilitySaveState = value);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').width('100%');
+ }
+ }.width('100%');
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.set_recovery_ability')).fontSize('16fp').width('76.3%');
+ Button(this.setRecoveryAbility)
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ let tmp: Record = {'RecoverAbility': this.callerAbility }
+ let want: Record = {
+ 'bundleName': 'com.samples.recovery',
+ 'abilityName': 'RecoveryAbility',
+ 'parameters': tmp,
+ };
+ appRecovery.setRestartWant(want);
+ ResUtil.getString($r('app.string.set_config_done').id).then((value: string) => this.setRecoveryAbility = value);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').width('100%');
+ }
+ }.width('100%');
+
+ if (this.callerAbility === 'EntryAbility') {
+ ListItem() {
+ Column() {
+ Row() {
+ Text('SecondAbility').fontSize('16fp').width('76.3%');
+ Button($r('app.string.launch_ability'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
+ return;
+ }
+ let want: Record = {
+ 'bundleName': 'com.samples.recovery',
+ 'abilityName': 'SecondAbility'
+ };
+ CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').width('100%');
+ }
+ }.width('100%');
+ }
+ }
+ .margin({ left: '12vp', right: '12vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ .divider(
+ { strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') }
+ );
+
+ Text($r('app.string.trigger_fault_items'))
+ .fontSize('14fp')
+ .margin({ left: '24vp', right: '24vp', top: '19.5vp', bottom: '9.5vp' })
+ .textAlign(TextAlign.Start)
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .height('19vp')
+ .width('86.7%');
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.trigger_js_error')).fontSize('16fp').width('76.3%');
+ Button($r('app.string.trigger'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ throw new Error('Force Crash');
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').align(Alignment.Center).width('100%');
+ }
+ }.width('100%');
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.trigger_freeze_in_js_code')).fontSize('16fp').width('76.3%');
+ Button($r('app.string.trigger'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ this.doHeavyWork();
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').align(Alignment.Center).width('100%');
+ }
+ }.width('100%');
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.trigger_freeze_in_native_code')).fontSize('16fp').width('76.3%');
+ Button($r('app.string.trigger'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ testNapi.add(1, 1);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').align(Alignment.Center).width('100%');
+ }
+ }.align(Alignment.Center).width('100%');
+ }
+ .margin({ left: '12vp', right: '12vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
+ }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
+ .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets
index 5d0ad7ec9b40c6a496587d8356b6d597f9fa963b..a18cab7c373ff2f73b582f3aac7c695cce0f730d 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/Index.ets
@@ -1,93 +1,93 @@
-/*
- * Copyright (c) 2023 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 router from '@ohos.router';
-
-@Entry
-@Component
-struct FirstPage {
- storage = LocalStorage.GetShared();
- @State launchReason: string = '';
- @State lastExitReason: string = '';
- @State callerAbility: string = '';
-
- aboutToAppear() {
- this.launchReason = this.storage.get('launchReason') ?? 'Unknown';
- this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown';
- this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'Unknown';
- }
-
- build() {
- Column() {
- Text(this.callerAbility)
- .fontSize('30fp')
- .fontWeight(FontWeight.Bold)
- .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' })
- .margin({ top: '14vp' })
- .textAlign(TextAlign.Start)
- .height('56vp')
- .width('100%')
- .fontColor($r('app.color.text_grey'));
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.launch_reason')).fontSize('16fp').width('86%');
- Text('0' + this.launchReason)
- .fontSize('14fp')
- .width('14%')
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .textAlign(TextAlign.End);
- }
- }
- }.width('100%').height('48vp').align(Alignment.Center);
-
- ListItem() {
- Column() {
- Row() {
- Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%');
- Text('0' + this.lastExitReason)
- .fontSize('14fp')
- .width('14%')
- .fontColor($r('app.color.text_grey'))
- .opacity(0.6)
- .textAlign(TextAlign.End);
- }
- }
- }.width('100%').height('48vp').align(Alignment.Center);
- }
- .alignListItem(ListItemAlign.Center)
- .margin({ left: '12vp', right: '12vp', top: '8vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
-
- Button($r('app.string.trigger_fault'))
- .fontSize('16fp')
- .onClick(() => {
- router.pushUrl({ url: 'pages/FaultTriggerPage' });
- })
- .width('88.9%')
- .margin({ top: '480vp', right: '24vp', left: '24vp', bottom: '34vp' })
- .height('40vp')
- .backgroundColor($r('app.color.text_blue_opacity'));
- }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
- .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
- }
-}
+/*
+ * Copyright (c) 2023 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 router from '@ohos.router';
+
+@Entry
+@Component
+struct FirstPage {
+ storage = LocalStorage.GetShared();
+ @State launchReason: string = '';
+ @State lastExitReason: string = '';
+ @State callerAbility: string = '';
+
+ aboutToAppear() {
+ this.launchReason = this.storage.get('launchReason') ?? 'Unknown';
+ this.lastExitReason = this.storage.get('lastExitReason') ?? 'Unknown';
+ this.callerAbility = this.storage.get('CurrentAbilityName') ?? 'Unknown';
+ }
+
+ build() {
+ Column() {
+ Text(this.callerAbility)
+ .fontSize('30fp')
+ .fontWeight(FontWeight.Bold)
+ .padding({ left: '24vp', right: '24vp', top: '7vp', bottom: '8vp' })
+ .margin({ top: '14vp' })
+ .textAlign(TextAlign.Start)
+ .height('56vp')
+ .width('100%')
+ .fontColor($r('app.color.text_grey'));
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.launch_reason')).fontSize('16fp').width('86%');
+ Text('0' + this.launchReason)
+ .fontSize('14fp')
+ .width('14%')
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .textAlign(TextAlign.End);
+ }
+ }
+ }.width('100%').height('48vp').align(Alignment.Center);
+
+ ListItem() {
+ Column() {
+ Row() {
+ Text($r('app.string.last_exit_reason')).fontSize('16fp').width('86%');
+ Text('0' + this.lastExitReason)
+ .fontSize('14fp')
+ .width('14%')
+ .fontColor($r('app.color.text_grey'))
+ .opacity(0.6)
+ .textAlign(TextAlign.End);
+ }
+ }
+ }.width('100%').height('48vp').align(Alignment.Center);
+ }
+ .alignListItem(ListItemAlign.Center)
+ .margin({ left: '12vp', right: '12vp', top: '8vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ .divider({ strokeWidth: '0.5vp', color: $r('app.color.text_grey_opacity') });
+
+ Button($r('app.string.trigger_fault'))
+ .fontSize('16fp')
+ .onClick(() => {
+ router.pushUrl({ url: 'pages/FaultTriggerPage' });
+ })
+ .width('88.9%')
+ .margin({ top: '480vp', right: '24vp', left: '24vp', bottom: '34vp' })
+ .height('40vp')
+ .backgroundColor($r('app.color.text_blue_opacity'));
+ }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
+ .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets
index 9f4bb4093b7f9614986f1a7b9b3dc7ccf6f7b223..fcc2469853263ff1a4794be23fcbb8a2ba795661 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/ets/pages/RecoveryPage.ets
@@ -1,112 +1,112 @@
-/*
- * Copyright (c) 2023 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 { CurActiveAbility } from '../common/CurActiveAbility';
-@Entry
-@Component
-struct Index {
- storage = LocalStorage.GetShared();
- @State launchParam: string = '';
- @State wantParam: string = '';
- fromEntryAbility: boolean = false;
-
- aboutToAppear() {
- this.launchParam = this.storage.get('launchParam') ?? 'UnknownLaunchParam';
- this.wantParam = this.storage.get('wantParam') ?? 'UnknownWantParam';
- let abilityName = AppStorage.Get('RecoverAbility');
- if (abilityName === 'EntryAbility') {
- this.fromEntryAbility = true;
- }
- }
-
- build() {
- Column() {
- Text('RecoveryPage')
- .fontSize('30fp')
- .fontWeight(FontWeight.Bold)
- .padding({ left: '24vp', right: '24vp', top: '4vp', bottom: '4vp' })
- .margin({ top: '14vp' })
- .textAlign(TextAlign.Start)
- .height('56vp')
- .width('100%')
- .fontColor($r('app.color.text_grey'));
-
- if (this.fromEntryAbility === false) {
- List() {
- ListItem() {
- Column() {
- Row() {
- Text('SecondAbility').fontSize('16fp').width('76.3%');
- Button($r('app.string.recover'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
- return;
- }
- let want: Record = {
- 'bundleName': 'com.samples.recovery',
- 'abilityName': 'SecondAbility'
- };
- CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').align(Alignment.Center).width('100%');
- }
- }.width('100%')
- }
- .margin({ left: '12vp', right: '12vp', top: '12vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- }
-
- List() {
- ListItem() {
- Column() {
- Row() {
- Text('EntryAbility').fontSize('16fp').width('76.3%');
- Button($r('app.string.recover'))
- .fontSize('12fp')
- .width('23.7%')
- .fontColor($r('app.color.text_blue_opacity'))
- .onClick(() => {
- if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
- return;
- }
- let want: Record = {
- 'bundleName': 'com.samples.recovery',
- 'abilityName': 'EntryAbility'
- };
- CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
- })
- .height('28vp')
- .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
- }.height('48vp').align(Alignment.Center).width('100%');
- }
- }.width('100%')
- }
- .margin({ left: '12vp', right: '12vp', top: '12vp' })
- .width('93.3%')
- .borderRadius('24vp')
- .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
- .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
- }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
- .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
- }
-}
+/*
+ * Copyright (c) 2023 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 { CurActiveAbility } from '../common/CurActiveAbility';
+@Entry
+@Component
+struct Index {
+ storage = LocalStorage.GetShared();
+ @State launchParam: string = '';
+ @State wantParam: string = '';
+ fromEntryAbility: boolean = false;
+
+ aboutToAppear() {
+ this.launchParam = this.storage.get('launchParam') ?? 'UnknownLaunchParam';
+ this.wantParam = this.storage.get('wantParam') ?? 'UnknownWantParam';
+ let abilityName = AppStorage.Get('RecoverAbility');
+ if (abilityName === 'EntryAbility') {
+ this.fromEntryAbility = true;
+ }
+ }
+
+ build() {
+ Column() {
+ Text('RecoveryPage')
+ .fontSize('30fp')
+ .fontWeight(FontWeight.Bold)
+ .padding({ left: '24vp', right: '24vp', top: '4vp', bottom: '4vp' })
+ .margin({ top: '14vp' })
+ .textAlign(TextAlign.Start)
+ .height('56vp')
+ .width('100%')
+ .fontColor($r('app.color.text_grey'));
+
+ if (this.fromEntryAbility === false) {
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text('SecondAbility').fontSize('16fp').width('76.3%');
+ Button($r('app.string.recover'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
+ return;
+ }
+ let want: Record = {
+ 'bundleName': 'com.samples.recovery',
+ 'abilityName': 'SecondAbility'
+ };
+ CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').align(Alignment.Center).width('100%');
+ }
+ }.width('100%')
+ }
+ .margin({ left: '12vp', right: '12vp', top: '12vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ }
+
+ List() {
+ ListItem() {
+ Column() {
+ Row() {
+ Text('EntryAbility').fontSize('16fp').width('76.3%');
+ Button($r('app.string.recover'))
+ .fontSize('12fp')
+ .width('23.7%')
+ .fontColor($r('app.color.text_blue_opacity'))
+ .onClick(() => {
+ if (CurActiveAbility.GetInstance().GetGlobalAbility() == undefined) {
+ return;
+ }
+ let want: Record = {
+ 'bundleName': 'com.samples.recovery',
+ 'abilityName': 'EntryAbility'
+ };
+ CurActiveAbility.GetInstance().GetGlobalAbility().context.startAbility(want);
+ })
+ .height('28vp')
+ .backgroundColor($r('sys.color.ohos_id_color_sub_background'))
+ }.height('48vp').align(Alignment.Center).width('100%');
+ }
+ }.width('100%')
+ }
+ .margin({ left: '12vp', right: '12vp', top: '12vp' })
+ .width('93.3%')
+ .borderRadius('24vp')
+ .backgroundColor($r('sys.color.ohos_id_color_foreground_contrary'))
+ .padding({ left: '12vp', right: '12vp', top: '4vp', bottom: '4vp' })
+ }.backgroundColor($r('sys.color.ohos_id_color_sub_background')).width('100%').height('100%')
+ .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]);
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5
index a096762082fa635a29e2722dde744167fd5a9630..f63149349ababcfe1bc740ab9722ee0ec675b50a 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/module.json5
@@ -1,74 +1,74 @@
-/*
- * Copyright (c) 2023 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",
- "srcEntry": "./ets/app/MyAbilityStage.ets",
- "mainElement": "EntryAbility",
- "deviceTypes": [
- "default"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:main_pages",
- "abilities": [
- {
- "name": "EntryAbility",
- "srcEntry": "./ets/ability/EntryAbility.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "recoverable": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- },
- {
- "name": "SecondAbility",
- "srcEntry": "./ets/ability/SecondAbility.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TextAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "recoverable": true
- },
- {
- "name": "RecoveryAbility",
- "srcEntry": "./ets/ability/RecoveryAbility.ets",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:RecoveryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true
- }
- ]
- }
+/*
+ * Copyright (c) 2023 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",
+ "srcEntry": "./ets/app/MyAbilityStage.ets",
+ "mainElement": "EntryAbility",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/ability/EntryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "recoverable": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ },
+ {
+ "name": "SecondAbility",
+ "srcEntry": "./ets/ability/SecondAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TextAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "recoverable": true
+ },
+ {
+ "name": "RecoveryAbility",
+ "srcEntry": "./ets/ability/RecoveryAbility.ets",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:RecoveryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json
index 357a66c7ff386daa7e2b2f6b4702e37b0428bc57..c3a092dc687dc003a88618ee73ef21eeb4b98c22 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/color.json
@@ -1,28 +1,28 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- },
- {
- "name": "title_background",
- "value": "#0D9FFB"
- },
- {
- "name": "text_grey",
- "value": "#182431"
- },
- {
- "name": "text_black",
- "value": "#000000"
- },
- {
- "name": "text_grey_opacity",
- "value": "#F3F4F4"
- },
- {
- "name": "text_blue_opacity",
- "value": "#007dFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ },
+ {
+ "name": "title_background",
+ "value": "#0D9FFB"
+ },
+ {
+ "name": "text_grey",
+ "value": "#182431"
+ },
+ {
+ "name": "text_black",
+ "value": "#000000"
+ },
+ {
+ "name": "text_grey_opacity",
+ "value": "#F3F4F4"
+ },
+ {
+ "name": "text_blue_opacity",
+ "value": "#007dFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json
index 63c648fdf061fa4cba40ba28b00e7aa4e54e9525..e0a8911ecb471961e2a6844cc92ca2f3bd81bac6 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/element/string.json
@@ -1,120 +1,120 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "AppRecoverySample"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "EntryAbility"
- },
- {
- "name": "TextAbility_label",
- "value": "TextAbility"
- },
- {
- "name": "RecoveryAbility_label",
- "value": "RecoveryAbility"
- },
- {
- "name": "app_has_recovered",
- "value": "Application has recovered from error"
- },
- {
- "name": "trigger_fault",
- "value": "Fault trigger page"
- },
- {
- "name": "current_ability",
- "value": "Ability:"
- },
- {
- "name": "launch_reason",
- "value": "Launch reason"
- },
- {
- "name": "last_exit_reason",
- "value": "Last exit reason"
- },
- {
- "name": "current_status",
- "value": "Current status:"
- },
- {
- "name": "click_counter",
- "value": "Click Count:"
- },
- {
- "name": "trigger_fault_items",
- "value": "Trigger Faults"
- },
- {
- "name": "trigger_js_error",
- "value": "Trigger JsError"
- },
- {
- "name": "trigger_freeze_in_js_code",
- "value": "Hung In Js Code"
- },
- {
- "name": "trigger_freeze_in_native_code",
- "value": "Hung In Native Code"
- },
- {
- "name": "recover_settings",
- "value": "Recovery settings"
- },
- {
- "name": "save_all_ability_status",
- "value": "Whole abilities status"
- },
- {
- "name": "save_current_ability_status",
- "value": "Current ability status"
- },
- {
- "name": "route_to_second_ability",
- "value": "Route to SecondAbility"
- },
- {
- "name": "set_recovery_ability",
- "value": "Set recovery ability"
- },
- {
- "name": "counter_name",
- "value": "ClickMe"
- },
- {
- "name": "save_state",
- "value": "Save"
- },
- {
- "name": "set_config",
- "value": "Set"
- },
- {
- "name": "save_state_done",
- "value": "Saved"
- },
- {
- "name": "set_config_done",
- "value": "Set"
- },
- {
- "name": "launch_ability",
- "value": "Launch"
- },
- {
- "name": "trigger",
- "value": "Trigger"
- },
- {
- "name": "recover",
- "value": "Recover"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "AppRecoverySample"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "EntryAbility"
+ },
+ {
+ "name": "TextAbility_label",
+ "value": "TextAbility"
+ },
+ {
+ "name": "RecoveryAbility_label",
+ "value": "RecoveryAbility"
+ },
+ {
+ "name": "app_has_recovered",
+ "value": "Application has recovered from error"
+ },
+ {
+ "name": "trigger_fault",
+ "value": "Fault trigger page"
+ },
+ {
+ "name": "current_ability",
+ "value": "Ability:"
+ },
+ {
+ "name": "launch_reason",
+ "value": "Launch reason"
+ },
+ {
+ "name": "last_exit_reason",
+ "value": "Last exit reason"
+ },
+ {
+ "name": "current_status",
+ "value": "Current status:"
+ },
+ {
+ "name": "click_counter",
+ "value": "Click Count:"
+ },
+ {
+ "name": "trigger_fault_items",
+ "value": "Trigger Faults"
+ },
+ {
+ "name": "trigger_js_error",
+ "value": "Trigger JsError"
+ },
+ {
+ "name": "trigger_freeze_in_js_code",
+ "value": "Hung In Js Code"
+ },
+ {
+ "name": "trigger_freeze_in_native_code",
+ "value": "Hung In Native Code"
+ },
+ {
+ "name": "recover_settings",
+ "value": "Recovery settings"
+ },
+ {
+ "name": "save_all_ability_status",
+ "value": "Whole abilities status"
+ },
+ {
+ "name": "save_current_ability_status",
+ "value": "Current ability status"
+ },
+ {
+ "name": "route_to_second_ability",
+ "value": "Route to SecondAbility"
+ },
+ {
+ "name": "set_recovery_ability",
+ "value": "Set recovery ability"
+ },
+ {
+ "name": "counter_name",
+ "value": "ClickMe"
+ },
+ {
+ "name": "save_state",
+ "value": "Save"
+ },
+ {
+ "name": "set_config",
+ "value": "Set"
+ },
+ {
+ "name": "save_state_done",
+ "value": "Saved"
+ },
+ {
+ "name": "set_config_done",
+ "value": "Set"
+ },
+ {
+ "name": "launch_ability",
+ "value": "Launch"
+ },
+ {
+ "name": "trigger",
+ "value": "Trigger"
+ },
+ {
+ "name": "recover",
+ "value": "Recover"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json
index 262d048acf4c6eeffc4ffcba93ffc77000a1a4a5..98e0d65bd89fe79ee4b4f184f35a2ba10a4b5bb6 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/base/profile/main_pages.json
@@ -1,7 +1,7 @@
-{
- "src": [
- "pages/Index",
- "pages/FaultTriggerPage",
- "pages/RecoveryPage"
- ]
-}
+{
+ "src": [
+ "pages/Index",
+ "pages/FaultTriggerPage",
+ "pages/RecoveryPage"
+ ]
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json
index 63c648fdf061fa4cba40ba28b00e7aa4e54e9525..e0a8911ecb471961e2a6844cc92ca2f3bd81bac6 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/en_US/element/string.json
@@ -1,120 +1,120 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "AppRecoverySample"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "EntryAbility"
- },
- {
- "name": "TextAbility_label",
- "value": "TextAbility"
- },
- {
- "name": "RecoveryAbility_label",
- "value": "RecoveryAbility"
- },
- {
- "name": "app_has_recovered",
- "value": "Application has recovered from error"
- },
- {
- "name": "trigger_fault",
- "value": "Fault trigger page"
- },
- {
- "name": "current_ability",
- "value": "Ability:"
- },
- {
- "name": "launch_reason",
- "value": "Launch reason"
- },
- {
- "name": "last_exit_reason",
- "value": "Last exit reason"
- },
- {
- "name": "current_status",
- "value": "Current status:"
- },
- {
- "name": "click_counter",
- "value": "Click Count:"
- },
- {
- "name": "trigger_fault_items",
- "value": "Trigger Faults"
- },
- {
- "name": "trigger_js_error",
- "value": "Trigger JsError"
- },
- {
- "name": "trigger_freeze_in_js_code",
- "value": "Hung In Js Code"
- },
- {
- "name": "trigger_freeze_in_native_code",
- "value": "Hung In Native Code"
- },
- {
- "name": "recover_settings",
- "value": "Recovery settings"
- },
- {
- "name": "save_all_ability_status",
- "value": "Whole abilities status"
- },
- {
- "name": "save_current_ability_status",
- "value": "Current ability status"
- },
- {
- "name": "route_to_second_ability",
- "value": "Route to SecondAbility"
- },
- {
- "name": "set_recovery_ability",
- "value": "Set recovery ability"
- },
- {
- "name": "counter_name",
- "value": "ClickMe"
- },
- {
- "name": "save_state",
- "value": "Save"
- },
- {
- "name": "set_config",
- "value": "Set"
- },
- {
- "name": "save_state_done",
- "value": "Saved"
- },
- {
- "name": "set_config_done",
- "value": "Set"
- },
- {
- "name": "launch_ability",
- "value": "Launch"
- },
- {
- "name": "trigger",
- "value": "Trigger"
- },
- {
- "name": "recover",
- "value": "Recover"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "AppRecoverySample"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "EntryAbility"
+ },
+ {
+ "name": "TextAbility_label",
+ "value": "TextAbility"
+ },
+ {
+ "name": "RecoveryAbility_label",
+ "value": "RecoveryAbility"
+ },
+ {
+ "name": "app_has_recovered",
+ "value": "Application has recovered from error"
+ },
+ {
+ "name": "trigger_fault",
+ "value": "Fault trigger page"
+ },
+ {
+ "name": "current_ability",
+ "value": "Ability:"
+ },
+ {
+ "name": "launch_reason",
+ "value": "Launch reason"
+ },
+ {
+ "name": "last_exit_reason",
+ "value": "Last exit reason"
+ },
+ {
+ "name": "current_status",
+ "value": "Current status:"
+ },
+ {
+ "name": "click_counter",
+ "value": "Click Count:"
+ },
+ {
+ "name": "trigger_fault_items",
+ "value": "Trigger Faults"
+ },
+ {
+ "name": "trigger_js_error",
+ "value": "Trigger JsError"
+ },
+ {
+ "name": "trigger_freeze_in_js_code",
+ "value": "Hung In Js Code"
+ },
+ {
+ "name": "trigger_freeze_in_native_code",
+ "value": "Hung In Native Code"
+ },
+ {
+ "name": "recover_settings",
+ "value": "Recovery settings"
+ },
+ {
+ "name": "save_all_ability_status",
+ "value": "Whole abilities status"
+ },
+ {
+ "name": "save_current_ability_status",
+ "value": "Current ability status"
+ },
+ {
+ "name": "route_to_second_ability",
+ "value": "Route to SecondAbility"
+ },
+ {
+ "name": "set_recovery_ability",
+ "value": "Set recovery ability"
+ },
+ {
+ "name": "counter_name",
+ "value": "ClickMe"
+ },
+ {
+ "name": "save_state",
+ "value": "Save"
+ },
+ {
+ "name": "set_config",
+ "value": "Set"
+ },
+ {
+ "name": "save_state_done",
+ "value": "Saved"
+ },
+ {
+ "name": "set_config_done",
+ "value": "Set"
+ },
+ {
+ "name": "launch_ability",
+ "value": "Launch"
+ },
+ {
+ "name": "trigger",
+ "value": "Trigger"
+ },
+ {
+ "name": "recover",
+ "value": "Recover"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json
index eb713b875bc624f7b49b3c44a176e6f3110e594b..b04853b653f87aea6dae1e247bc1d5042ea80f0e 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/main/resources/zh_CN/element/string.json
@@ -1,120 +1,120 @@
-{
- "string": [
- {
- "name": "module_desc",
- "value": "应用恢复范例"
- },
- {
- "name": "EntryAbility_desc",
- "value": "description"
- },
- {
- "name": "EntryAbility_label",
- "value": "EntryAbility"
- },
- {
- "name": "TextAbility_label",
- "value": "TextAbility"
- },
- {
- "name": "RecoveryAbility_label",
- "value": "RecoveryAbility"
- },
- {
- "name": "app_has_recovered",
- "value": "应用已经从故障中恢复"
- },
- {
- "name": "trigger_fault",
- "value": "跳转到故障触发页面"
- },
- {
- "name": "current_ability",
- "value": "当前页面:"
- },
- {
- "name": "launch_reason",
- "value": "启动原因"
- },
- {
- "name": "last_exit_reason",
- "value": "上次退出原因"
- },
- {
- "name": "current_status",
- "value": "当前状态:"
- },
- {
- "name": "click_counter",
- "value": "按钮点击计数:"
- },
- {
- "name": "trigger_fault_items",
- "value": "触发故障"
- },
- {
- "name": "trigger_js_error",
- "value": "JsError"
- },
- {
- "name": "trigger_freeze_in_js_code",
- "value": "Js代码卡死"
- },
- {
- "name": "trigger_freeze_in_native_code",
- "value": "Native代码卡死"
- },
- {
- "name": "recover_settings",
- "value": "应用恢复设置"
- },
- {
- "name": "save_all_ability_status",
- "value": "所有Ability状态"
- },
- {
- "name": "save_current_ability_status",
- "value": "当前Ability状态"
- },
- {
- "name": "route_to_second_ability",
- "value": "启动SecondAbility"
- },
- {
- "name": "set_recovery_ability",
- "value": "恢复Ability"
- },
- {
- "name": "counter_name",
- "value": "点击"
- },
- {
- "name": "save_state",
- "value": "保存"
- },
- {
- "name": "set_config",
- "value": "设置"
- },
- {
- "name": "save_state_done",
- "value": "已保存"
- },
- {
- "name": "set_config_done",
- "value": "已设置"
- },
- {
- "name": "launch_ability",
- "value": "启动"
- },
- {
- "name": "trigger",
- "value": "触发"
- },
- {
- "name": "recover",
- "value": "恢复"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_desc",
+ "value": "应用恢复范例"
+ },
+ {
+ "name": "EntryAbility_desc",
+ "value": "description"
+ },
+ {
+ "name": "EntryAbility_label",
+ "value": "EntryAbility"
+ },
+ {
+ "name": "TextAbility_label",
+ "value": "TextAbility"
+ },
+ {
+ "name": "RecoveryAbility_label",
+ "value": "RecoveryAbility"
+ },
+ {
+ "name": "app_has_recovered",
+ "value": "应用已经从故障中恢复"
+ },
+ {
+ "name": "trigger_fault",
+ "value": "跳转到故障触发页面"
+ },
+ {
+ "name": "current_ability",
+ "value": "当前页面:"
+ },
+ {
+ "name": "launch_reason",
+ "value": "启动原因"
+ },
+ {
+ "name": "last_exit_reason",
+ "value": "上次退出原因"
+ },
+ {
+ "name": "current_status",
+ "value": "当前状态:"
+ },
+ {
+ "name": "click_counter",
+ "value": "按钮点击计数:"
+ },
+ {
+ "name": "trigger_fault_items",
+ "value": "触发故障"
+ },
+ {
+ "name": "trigger_js_error",
+ "value": "JsError"
+ },
+ {
+ "name": "trigger_freeze_in_js_code",
+ "value": "Js代码卡死"
+ },
+ {
+ "name": "trigger_freeze_in_native_code",
+ "value": "Native代码卡死"
+ },
+ {
+ "name": "recover_settings",
+ "value": "应用恢复设置"
+ },
+ {
+ "name": "save_all_ability_status",
+ "value": "所有Ability状态"
+ },
+ {
+ "name": "save_current_ability_status",
+ "value": "当前Ability状态"
+ },
+ {
+ "name": "route_to_second_ability",
+ "value": "启动SecondAbility"
+ },
+ {
+ "name": "set_recovery_ability",
+ "value": "恢复Ability"
+ },
+ {
+ "name": "counter_name",
+ "value": "点击"
+ },
+ {
+ "name": "save_state",
+ "value": "保存"
+ },
+ {
+ "name": "set_config",
+ "value": "设置"
+ },
+ {
+ "name": "save_state_done",
+ "value": "已保存"
+ },
+ {
+ "name": "set_config_done",
+ "value": "已设置"
+ },
+ {
+ "name": "launch_ability",
+ "value": "启动"
+ },
+ {
+ "name": "trigger",
+ "value": "触发"
+ },
+ {
+ "name": "recover",
+ "value": "恢复"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
index ece6bfbc6e61c6e37d3c9a586a1db68b680088d9..1cdc33bdf42a0e9586430cad2ea0f574dfe97f40 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts
@@ -1,84 +1,84 @@
-/*
- * Copyright (c) 2023 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 TestRunner from '@ohos.application.testRunner';
-import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
-import Logger from '../../../main/ets/common/Logger';
-
-let abilityDelegator = undefined;
-let abilityDelegatorArguments = undefined;
-
-const TAG: string = 'TestRunner';
-const keySet = new Set([
- '-s class', '-s notClass', '-s suite', '-s it',
- '-s level', '-s testType', '-s size', '-s timeout',
- '-s dryRun'
-]);
-
-function translateParamsToString(parameters): string {
- let targetParams = '';
- for (const key in parameters) {
- if (keySet.has(key)) {
- targetParams = '${targetParams} ${key} ${parameters[key]}';
- Logger.info(TAG, 'targetParams:${targetParams}');
- }
- }
- return targetParams.trim();
-}
-
-async function onAbilityCreateCallback(): Promise {
- Logger.info(TAG, 'onAbilityCreateCallback');
-}
-
-async function addAbilityMonitorCallback(err: Error): Promise {
- Logger.info(TAG, 'addAbilityMonitorCallback');
-}
-
-export default class OpenHarmonyTestRunner implements TestRunner {
- constructor() {
- }
-
- onPrepare(): void {
- Logger.info(TAG, 'OpenHarmonyTestRunner onPrepare');
- }
-
- async onRun(): Promise {
- Logger.info(TAG, 'OpenHarmonyTestRunner onRun');
- abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
-
- let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
- let lMonitor = {
- abilityName: testAbilityName,
- onAbilityCreate: onAbilityCreateCallback,
- };
-
- abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
- abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
-
- let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
- cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
- let debug = abilityDelegatorArguments.parameters['-D'];
- if (debug === 'true') {
- cmd += ' -D';
- }
- Logger.info(TAG, 'cmd:${cmd}');
-
- abilityDelegator.executeShellCommand(cmd,
- (err: any, d: any) => {
- Logger.info(TAG, 'OpenHarmonyTestRunner onError');
- });
- Logger.info(TAG, 'OpenHarmonyTestRunner onRun end');
- }
-}
+/*
+ * Copyright (c) 2023 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 TestRunner from '@ohos.application.testRunner';
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
+import Logger from '../../../main/ets/common/Logger';
+
+let abilityDelegator = undefined;
+let abilityDelegatorArguments = undefined;
+
+const TAG: string = 'TestRunner';
+const keySet = new Set([
+ '-s class', '-s notClass', '-s suite', '-s it',
+ '-s level', '-s testType', '-s size', '-s timeout',
+ '-s dryRun'
+]);
+
+function translateParamsToString(parameters): string {
+ let targetParams = '';
+ for (const key in parameters) {
+ if (keySet.has(key)) {
+ targetParams = '${targetParams} ${key} ${parameters[key]}';
+ Logger.info(TAG, 'targetParams:${targetParams}');
+ }
+ }
+ return targetParams.trim();
+}
+
+async function onAbilityCreateCallback(): Promise {
+ Logger.info(TAG, 'onAbilityCreateCallback');
+}
+
+async function addAbilityMonitorCallback(err: Error): Promise {
+ Logger.info(TAG, 'addAbilityMonitorCallback');
+}
+
+export default class OpenHarmonyTestRunner implements TestRunner {
+ constructor() {
+ }
+
+ onPrepare(): void {
+ Logger.info(TAG, 'OpenHarmonyTestRunner onPrepare');
+ }
+
+ async onRun(): Promise {
+ Logger.info(TAG, 'OpenHarmonyTestRunner onRun');
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
+
+ let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
+ let lMonitor = {
+ abilityName: testAbilityName,
+ onAbilityCreate: onAbilityCreateCallback,
+ };
+
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback);
+
+ let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
+ cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters);
+ let debug = abilityDelegatorArguments.parameters['-D'];
+ if (debug === 'true') {
+ cmd += ' -D';
+ }
+ Logger.info(TAG, 'cmd:${cmd}');
+
+ abilityDelegator.executeShellCommand(cmd,
+ (err: any, d: any) => {
+ Logger.info(TAG, 'OpenHarmonyTestRunner onError');
+ });
+ Logger.info(TAG, 'OpenHarmonyTestRunner onRun end');
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets
index 94e6fccffd012581bec78ddf553b387f2e8b10b6..0febaf1ef3fad02d9dff2c89d423c31cb616619b 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/Ability.test.ets
@@ -1,84 +1,84 @@
-/*
- * Copyright (c) 2023 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, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
-import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
-import Logger from '../../../main/ets/common/Logger'
-
-const TAG = '[Sample_AppRecovery]'
-const BUNDLE = 'appRecovery_'
-
-export default function abilityTest() {
- describe('ActsAbilityTest', () => {
- // Defines a test suite. Two parameters are supported: test suite name and test suite function.
- beforeAll(() => {
- // Presets an action, which is performed only once before all test cases of the test suite start.
- // This API supports only one parameter: preset action function.
- });
- beforeEach(() => {
- // Presets an action, which is performed before each unit test case starts.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: preset action function.
- });
- afterEach(() => {
- // Presets a clear action, which is performed after each unit test case ends.
- // The number of execution times is the same as the number of test cases defined by **it**.
- // This API supports only one parameter: clear action function.
- });
- afterAll(() => {
- // Presets a clear action, which is performed after all test cases of the test suite end.
- // This API supports only one parameter: clear action function.
- });
-
- it('AppRecoverySample_StartAbility_001', 0, () => {
- Logger.info(TAG, BUNDLE + 'StartAbility_001 begin');
- let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
- try {
- abilityDelegator.startAbility({
- bundleName: 'com.sample.recovery', abilityName: 'EntryAbility'
- });
- } catch (exception) {
- expect().assertFail();
- }
- Logger.info(TAG, BUNDLE + 'StartAbility_001 end');
- });
-
- it('AppRecoverySample_StartAbility_002', 0, () => {
- Logger.info(TAG, BUNDLE + 'StartAbility_002 begin');
- let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
- try {
- abilityDelegator.startAbility({
- bundleName: 'com.sample.recovery', abilityName: 'SecondAbility'
- });
- } catch (exception) {
- expect().assertFail();
- }
- Logger.info(TAG, BUNDLE + 'StartAbility_002 end');
- });
-
- it('AppRecoverySample_StartAbility_003', 0, () => {
- Logger.info(TAG, BUNDLE + 'StartAbility_003 begin');
- let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
- try {
- abilityDelegator.startAbility({
- bundleName: 'com.sample.recovery', abilityName: 'RecoveryAbility'
- });
- } catch (exception) {
- expect().assertFail();
- }
- Logger.info(TAG, BUNDLE + 'StartAbility_003 end');
- });
- });
-}
+/*
+ * Copyright (c) 2023 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, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
+import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
+import Logger from '../../../main/ets/common/Logger'
+
+const TAG = '[Sample_AppRecovery]'
+const BUNDLE = 'appRecovery_'
+
+export default function abilityTest() {
+ describe('ActsAbilityTest', () => {
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
+ beforeAll(() => {
+ // Presets an action, which is performed only once before all test cases of the test suite start.
+ // This API supports only one parameter: preset action function.
+ });
+ beforeEach(() => {
+ // Presets an action, which is performed before each unit test case starts.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: preset action function.
+ });
+ afterEach(() => {
+ // Presets a clear action, which is performed after each unit test case ends.
+ // The number of execution times is the same as the number of test cases defined by **it**.
+ // This API supports only one parameter: clear action function.
+ });
+ afterAll(() => {
+ // Presets a clear action, which is performed after all test cases of the test suite end.
+ // This API supports only one parameter: clear action function.
+ });
+
+ it('AppRecoverySample_StartAbility_001', 0, () => {
+ Logger.info(TAG, BUNDLE + 'StartAbility_001 begin');
+ let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+ try {
+ abilityDelegator.startAbility({
+ bundleName: 'com.sample.recovery', abilityName: 'EntryAbility'
+ });
+ } catch (exception) {
+ expect().assertFail();
+ }
+ Logger.info(TAG, BUNDLE + 'StartAbility_001 end');
+ });
+
+ it('AppRecoverySample_StartAbility_002', 0, () => {
+ Logger.info(TAG, BUNDLE + 'StartAbility_002 begin');
+ let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+ try {
+ abilityDelegator.startAbility({
+ bundleName: 'com.sample.recovery', abilityName: 'SecondAbility'
+ });
+ } catch (exception) {
+ expect().assertFail();
+ }
+ Logger.info(TAG, BUNDLE + 'StartAbility_002 end');
+ });
+
+ it('AppRecoverySample_StartAbility_003', 0, () => {
+ Logger.info(TAG, BUNDLE + 'StartAbility_003 begin');
+ let abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
+ try {
+ abilityDelegator.startAbility({
+ bundleName: 'com.sample.recovery', abilityName: 'RecoveryAbility'
+ });
+ } catch (exception) {
+ expect().assertFail();
+ }
+ Logger.info(TAG, BUNDLE + 'StartAbility_003 end');
+ });
+ });
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets
index 2a22ae6dc9bdd833b75571bef8c29a0e39dde777..27c07a1a174f6862ea84c4bb5f45bc1789234441 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/test/List.test.ets
@@ -1,20 +1,20 @@
-/*
- * Copyright (c) 2023 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()
+/*
+ * Copyright (c) 2023 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/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets
index 2295bc84968e7802f06e16b6bdf2badd546cf1f3..b71566313bab42773bb2a3ce0705606ae9d74d42 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/TestAbility.ets
@@ -1,59 +1,59 @@
-/*
- * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
-import Window from '@ohos.window';
-import Want from '@ohos.app.ability.Want';
-import AbilityConstant from '@ohos.app.ability.AbilityConstant';
-import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
-import { Hypium } from '@ohos/hypium';
-import testsuite from '../test/List.test';
-import Logger from '../../../main/ets/common/Logger';
-
-const TAG = '[Sample_AppRecovery]'
-
-export default class TestAbility extends UIAbility {
- onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
- Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}');
- let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
- let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
- Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
- }
-
- onDestroy(): void {
- Logger.info(TAG, 'onDestroy');
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage): void {
- Logger.info(TAG, 'onWindowStageCreate');
- windowStage.loadContent('testability/pages/Index', (err, data) => {
- if (err.code) {
- return;
- }
- });
- }
-
- onWindowStageDestroy(): void {
- Logger.info(TAG, 'onWindowStageDestroy');
- }
-
- onForeground(): void {
- Logger.info(TAG, 'onForeground');
- }
-
- onBackground(): void {
- Logger.info(TAG, 'onBackground');
- }
-}
+/*
+ * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
+import Window from '@ohos.window';
+import Want from '@ohos.app.ability.Want';
+import AbilityConstant from '@ohos.app.ability.AbilityConstant';
+import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
+import { Hypium } from '@ohos/hypium';
+import testsuite from '../test/List.test';
+import Logger from '../../../main/ets/common/Logger';
+
+const TAG = '[Sample_AppRecovery]'
+
+export default class TestAbility extends UIAbility {
+ onCreate(want: Want, launchParam:AbilityConstant.LaunchParam): void {
+ Logger.info(TAG, 'onCreate Want:${JSON.stringify(want)} launchParam: ${JSON.stringify(launchParam)}');
+ let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ let abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
+ }
+
+ onDestroy(): void {
+ Logger.info(TAG, 'onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage): void {
+ Logger.info(TAG, 'onWindowStageCreate');
+ windowStage.loadContent('testability/pages/Index', (err, data) => {
+ if (err.code) {
+ return;
+ }
+ });
+ }
+
+ onWindowStageDestroy(): void {
+ Logger.info(TAG, 'onWindowStageDestroy');
+ }
+
+ onForeground(): void {
+ Logger.info(TAG, 'onForeground');
+ }
+
+ onBackground(): void {
+ Logger.info(TAG, 'onBackground');
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets
index 874769e7cb5ed899068327ea6c4bda2284ddb936..98da6018fb63b794221dafbac0088bcf83bf825d 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/ets/testability/pages/Index.ets
@@ -1,49 +1,49 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-@Entry
-@Component
-struct Index {
- aboutToAppear() {
- }
-
- @State message: string = 'Hello World'
-
- build() {
- Row() {
- Column() {
- Text(this.message)
- .fontSize(50)
- .fontWeight(FontWeight.Bold)
- Button() {
- Text('next page')
- .fontSize(20)
- .fontWeight(FontWeight.Bold)
- }
- .type(ButtonType.Capsule)
- .margin({
- top: 20
- })
- .backgroundColor('#0D9FFB')
- .width('35%')
- .height('5%')
- .onClick(() => {
- })
- }
- .width('100%')
- }
- .height('100%')
- }
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+@Entry
+@Component
+struct Index {
+ aboutToAppear() {
+ }
+
+ @State message: string = 'Hello World'
+
+ build() {
+ Row() {
+ Column() {
+ Text(this.message)
+ .fontSize(50)
+ .fontWeight(FontWeight.Bold)
+ Button() {
+ Text('next page')
+ .fontSize(20)
+ .fontWeight(FontWeight.Bold)
+ }
+ .type(ButtonType.Capsule)
+ .margin({
+ top: 20
+ })
+ .backgroundColor('#0D9FFB')
+ .width('35%')
+ .height('5%')
+ .onClick(() => {
+ })
+ }
+ .width('100%')
+ }
+ .height('100%')
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5 b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5
index be787551f087b82ccb3cda239a6c9a503d40a754..b86e44a1f92d479be6f163b5c225b000f27b4b47 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/module.json5
@@ -1,51 +1,51 @@
-/*
- * Copyright (c) 2023 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "default"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntrance": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "visible": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
-}
+/*
+ * Copyright (c) 2023 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "default"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntrance": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "visible": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json
index d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json
index 04e87abb7232eeca56a0e436b32ecc84576d5ead..65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/element/string.json
@@ -1,16 +1,16 @@
-{
- "string": [
- {
- "name": "module_test_desc",
- "value": "test ability description"
- },
- {
- "name": "TestAbility_desc",
- "value": "the test ability"
- },
- {
- "name": "TestAbility_label",
- "value": "test label"
- }
- ]
+{
+ "string": [
+ {
+ "name": "module_test_desc",
+ "value": "test ability description"
+ },
+ {
+ "name": "TestAbility_desc",
+ "value": "the test ability"
+ },
+ {
+ "name": "TestAbility_label",
+ "value": "test label"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json
index c3d813c41aa8ac1b64ccf124bb705adefb381787..b7e7343cacb32ce982a45e76daad86e435e054fe 100644
--- a/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json
+++ b/code/BasicFeature/DFX/AppRecovery/entry/src/ohosTest/resources/base/profile/test_pages.json
@@ -1,5 +1,5 @@
-{
- "src": [
- "testability/pages/Index"
- ]
-}
+{
+ "src": [
+ "testability/pages/Index"
+ ]
+}
diff --git a/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts b/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts
index 1a4d9969c6ab9c5b03543519686d9d713e729402..6478186902c0c1ad7c966a929c7d6b7d8ae7a9f3 100644
--- a/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts
+++ b/code/BasicFeature/DFX/AppRecovery/hvigorfile.ts
@@ -1,2 +1,2 @@
-// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
+// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently.
export { appTasks } from '@ohos/hvigor-ohos-plugin';
\ No newline at end of file
diff --git a/code/BasicFeature/DFX/AppRecovery/oh-package.json5 b/code/BasicFeature/DFX/AppRecovery/oh-package.json5
index 57600fe0a1fabaf59708b8eaeb87e33815dbc144..3dc884c6f82052fd4d5d2a1f1e202fad43cbeb12 100644
--- a/code/BasicFeature/DFX/AppRecovery/oh-package.json5
+++ b/code/BasicFeature/DFX/AppRecovery/oh-package.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "ISC",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "name": "AppRecoverySample",
- "description": "app recovery sample",
- "repository": {},
- "version": "1.0.0",
- "dependencies": {}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "ISC",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "name": "AppRecoverySample",
+ "description": "app recovery sample",
+ "repository": {},
+ "version": "1.0.0",
+ "dependencies": {}
}
\ No newline at end of file
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/.gitignore b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/.gitignore
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5
old mode 100755
new mode 100644
index edc19e4572698a17e57006511172e90fd4473bde..3470aba677de9e4dfce354a98d2b007fa9727be3
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": "ohos.samples.UTDType",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": "ohos.samples.UTDType",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json
old mode 100755
new mode 100644
index 312b4a8ac19334ec4e2b596fb7fcf6231021cc2e..2f400f979454bec995ff417b3f6875fe5f20d799
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "UTDType"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "UTDType"
+ }
+ ]
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/media/app_icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/AppScope/resources/base/media/app_icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/README_zh.md
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5
old mode 100755
new mode 100644
index c38ebad24c2f09453adc769b45e5be152063a258..ce0311a17532780c9b0a98f429f705d32d0f6eee
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/build-profile.json5
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": 11,
- "compatibleSdkVersion": 10,
- "runtimeOS": "OpenHarmony"
- }
- ],
- "signingConfigs": []
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
-}
+/*
+ * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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": 11,
+ "compatibleSdkVersion": 10,
+ "runtimeOS": "OpenHarmony"
+ }
+ ],
+ "signingConfigs": []
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/.gitignore b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/.gitignore
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/build-profile.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/build-profile.json5
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/hvigorfile.js b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/hvigorfile.js
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/oh-package.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/oh-package.json5
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts
old mode 100755
new mode 100644
index db9f5c164eef5f147c46961cf73dbdfd814d29cc..414945cf53013f4ba746d7000f2c32686320ebb9
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,56 +1,56 @@
-/*
- * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 UIAbility from '@ohos.app.ability.UIAbility';
-import hilog from '@ohos.hilog';
-import window from '@ohos.window';
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy() {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
- }
-}
+/*
+ * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 UIAbility from '@ohos.app.ability.UIAbility';
+import hilog from '@ohos.hilog';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/Index.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets
old mode 100755
new mode 100644
index 75723cb5c9c84ffac09b685ea1303313032d7089..509e7ebcd6d1375d6b373726a99a548754788859
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/displayMediaFile.ets
@@ -1,162 +1,162 @@
-/*
- * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 utdDesc from '@ohos.data.uniformTypeDescriptor';
-import router from '@ohos.router';
-import { logger } from '../util/Logger';
-
-const TAG: string = 'DisplayMediaFile';
-
-interface paramsTape {
- src: string,
- selectIconFile: string,
-}
-
-interface FileIconType {
- type: string,
- value: string,
- icon: Resource
-}
-
-const FILE_TYPE_ICON: FileIconType[] = [
- {
- type: "Image",
- value: "general.image",
- icon: $r("app.media.image")
- },
- {
- type: "Audio",
- value: "general.audio",
- icon: $r("app.media.myAudio")
- },
- {
- type: "Video",
- value: "general.video",
- icon: $r("app.media.video")
- }
-]
-
-@Entry
-@Component
-struct selectMediaType {
- @State src: string = (router.getParams() as paramsTape).src;
- @State selectIconFile: string = (router.getParams() as paramsTape).selectIconFile;
- private routerBackUrl: string = 'pages/selectMediaType';
-
- onPageShow() {
- this.src = (router.getParams() as paramsTape).src;
- this.selectIconFile = (router.getParams() as paramsTape).selectIconFile;
- }
-
- getFileIcon(fileName: string): Resource {
- let fileIcon = $r("app.media.file");
- let index = fileName.lastIndexOf('.');
- if (index < 0) {
- return fileIcon;
- } else {
- let fileExtension = fileName.substring(index);
- let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
- let typeObj: utdDesc.TypeDescriptor;
- try {
- typeObj = utdDesc.getTypeDescriptor(utd);
- } catch (e) {
- logger.info(TAG, `invalid file type`);
- return fileIcon;
- }
- FILE_TYPE_ICON.forEach(DataType => {
- if(typeObj.belongsTo(DataType.value)) {
- logger.info(TAG, `file type: ${DataType.type}`);
- fileIcon = DataType.icon;
- }
- })
- return fileIcon;
- }
- }
-
- build() {
- Column() {
- Column() {
- Row() {
- Image($r('app.media.utdType_back'))
- .id('thirdPageBack')
- .width(24)
- .height(24)
- .visibility(Visibility.Visible)
- .objectFit(ImageFit.Fill)
- .alignSelf(ItemAlign.Auto)
- .margin({ left: 24, right: 12 })
- .onClick(() => {
- router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single);
- })
- Text($r('app.string.displayMediaFile_title'))
- .fontStyle(FontStyle.Normal)
- .fontSize(20)
- .textAlign(TextAlign.Start)
- .fontWeight(700)
- }
- .width('100%')
- .height(56)
- }
- .width(280)
- .height(56)
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Center)
-
- Column() {
- List({ space: 2, initialIndex: 0 }) {
- ListItem() {
- Row() {
- Image(this.getFileIcon(this.src))
- .id('imageBack')
- .width(24)
- .height(24)
- .objectFit(ImageFit.Fill)
- .alignSelf(ItemAlign.Auto)
- .margin({ left: 12, right: 12 })
- Text(this.src)
- .fontSize(16)
- .textAlign(TextAlign.Start)
- .fontWeight(500)
- }.width('100%').height('100%')
- }
- }
- .listDirection(Axis.Vertical) // 排列方向
- .scrollBar(BarState.Auto)
- .friction(0.6)
- .margin({ left: 12, right: 12 })
- .borderRadius(24)
- .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
- .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
- logger.info(TAG, 'first' + firstIndex)
- logger.info(TAG, 'last' + lastIndex)
- logger.info(TAG, 'center' + centerIndex)
- })
- .onScroll((scrollOffset: number, scrollState: ScrollState) => {
- logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
- })
- .backgroundColor(0xFFFFFF)
- .alignListItem(ListItemAlign.Center)
- }
- .width('100%')
- .height(64)
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Center)
- }
- .width('100%')
- .height('100%')
- .alignItems(HorizontalAlign.Start)
- .backgroundColor($r('app.color.background_shallow_grey'))
- }
-}
+/*
+ * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 utdDesc from '@ohos.data.uniformTypeDescriptor';
+import router from '@ohos.router';
+import { logger } from '../util/Logger';
+
+const TAG: string = 'DisplayMediaFile';
+
+interface paramsTape {
+ src: string,
+ selectIconFile: string,
+}
+
+interface FileIconType {
+ type: string,
+ value: string,
+ icon: Resource
+}
+
+const FILE_TYPE_ICON: FileIconType[] = [
+ {
+ type: "Image",
+ value: "general.image",
+ icon: $r("app.media.image")
+ },
+ {
+ type: "Audio",
+ value: "general.audio",
+ icon: $r("app.media.myAudio")
+ },
+ {
+ type: "Video",
+ value: "general.video",
+ icon: $r("app.media.video")
+ }
+]
+
+@Entry
+@Component
+struct selectMediaType {
+ @State src: string = (router.getParams() as paramsTape).src;
+ @State selectIconFile: string = (router.getParams() as paramsTape).selectIconFile;
+ private routerBackUrl: string = 'pages/selectMediaType';
+
+ onPageShow() {
+ this.src = (router.getParams() as paramsTape).src;
+ this.selectIconFile = (router.getParams() as paramsTape).selectIconFile;
+ }
+
+ getFileIcon(fileName: string): Resource {
+ let fileIcon = $r("app.media.file");
+ let index = fileName.lastIndexOf('.');
+ if (index < 0) {
+ return fileIcon;
+ } else {
+ let fileExtension = fileName.substring(index);
+ let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
+ let typeObj: utdDesc.TypeDescriptor;
+ try {
+ typeObj = utdDesc.getTypeDescriptor(utd);
+ } catch (e) {
+ logger.info(TAG, `invalid file type`);
+ return fileIcon;
+ }
+ FILE_TYPE_ICON.forEach(DataType => {
+ if(typeObj.belongsTo(DataType.value)) {
+ logger.info(TAG, `file type: ${DataType.type}`);
+ fileIcon = DataType.icon;
+ }
+ })
+ return fileIcon;
+ }
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Row() {
+ Image($r('app.media.utdType_back'))
+ .id('thirdPageBack')
+ .width(24)
+ .height(24)
+ .visibility(Visibility.Visible)
+ .objectFit(ImageFit.Fill)
+ .alignSelf(ItemAlign.Auto)
+ .margin({ left: 24, right: 12 })
+ .onClick(() => {
+ router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single);
+ })
+ Text($r('app.string.displayMediaFile_title'))
+ .fontStyle(FontStyle.Normal)
+ .fontSize(20)
+ .textAlign(TextAlign.Start)
+ .fontWeight(700)
+ }
+ .width('100%')
+ .height(56)
+ }
+ .width(280)
+ .height(56)
+ .alignItems(HorizontalAlign.Start)
+ .justifyContent(FlexAlign.Center)
+
+ Column() {
+ List({ space: 2, initialIndex: 0 }) {
+ ListItem() {
+ Row() {
+ Image(this.getFileIcon(this.src))
+ .id('imageBack')
+ .width(24)
+ .height(24)
+ .objectFit(ImageFit.Fill)
+ .alignSelf(ItemAlign.Auto)
+ .margin({ left: 12, right: 12 })
+ Text(this.src)
+ .fontSize(16)
+ .textAlign(TextAlign.Start)
+ .fontWeight(500)
+ }.width('100%').height('100%')
+ }
+ }
+ .listDirection(Axis.Vertical) // 排列方向
+ .scrollBar(BarState.Auto)
+ .friction(0.6)
+ .margin({ left: 12, right: 12 })
+ .borderRadius(24)
+ .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
+ .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
+ logger.info(TAG, 'first' + firstIndex)
+ logger.info(TAG, 'last' + lastIndex)
+ logger.info(TAG, 'center' + centerIndex)
+ })
+ .onScroll((scrollOffset: number, scrollState: ScrollState) => {
+ logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset)
+ })
+ .backgroundColor(0xFFFFFF)
+ .alignListItem(ListItemAlign.Center)
+ }
+ .width('100%')
+ .height(64)
+ .alignItems(HorizontalAlign.Start)
+ .justifyContent(FlexAlign.Center)
+ }
+ .width('100%')
+ .height('100%')
+ .alignItems(HorizontalAlign.Start)
+ .backgroundColor($r('app.color.background_shallow_grey'))
+ }
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets
old mode 100755
new mode 100644
index 74dddc4837f32f2461a06964244a3d19d6e640b4..b445b259f732671b57e3417ac58a6ba530279f69
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/pages/selectMediaType.ets
@@ -1,264 +1,264 @@
-/*
- * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router';
-import fs from '@ohos.file.fs';
-import common from '@ohos.app.ability.common';
-import utdDesc from '@ohos.data.uniformTypeDescriptor';
-import { BusinessError } from '@ohos.base';
-import { logger } from '../util/Logger';
-
-const TAG: string = 'SelectMediaType';
-// 获取应用文件路径
-let context = getContext(this) as common.UIAbilityContext;
-let baseDir = context.filesDir;
-let filesDir = baseDir + '/udmf_test';
-
-let class2UTD = new Map([
- ["All", "All"],
- ["Images", "general.image"],
- ["Audios", "general.audio"],
- ["Videos", "general.video"]
-]);
-
-class FileInfo {
- filename: string;
- iconFile: string;
-
- constructor(fileName: string, iconFile: string) {
- this.filename = fileName;
- this.iconFile = iconFile;
- }
-}
-
-@Entry
-@Component
-struct selectMediaType {
- @State text: string = "Images";
- @State index: number = 1;
- @State space: number = 12;
- @State arrowPosition: ArrowPosition = ArrowPosition.END;
- @State fileNames: string[] = [];
- @State selectedFilesInfos: FileInfo[] = [];
- private routerBackUrl: string = 'pages/Index';
- private routerNextUrl: string = 'pages/displayMediaFile';
-
- getListFile(): string[] {
- let files = fs.listFileSync(filesDir);
- return files;
- }
-
- UpdateSelectedFiles(): void {
- this.fileNames = this.getListFile();
- for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
- this.selectedFilesInfos.pop();
- }
- this.selectedFilesInfos = [];
- logger.info(TAG, "selectText: " + this.text)
- for (let i = 0; i < this.fileNames.length; i++) {
- let fileName = this.fileNames[i];
- let index = fileName.lastIndexOf('.');
- if (index < 0) {
- logger.info(TAG, `fileNames file: ${fileName}`);
- if (this.text == "All") {
- let fileInfo = new FileInfo(fileName, "");
- this.selectedFilesInfos.push(fileInfo);
- }
- continue;
- } else {
- let fileExtension = fileName.substring(index);
- let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
- logger.info(TAG, `fileNames file: ${fileName}, extension: ${fileExtension}, utd: ${utd}`);
- try {
- if (utd != null) {
- let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd);
- if (class2UTD.get(this.text) == "All") {
- let fileInfo = new FileInfo(fileName, typeObj.iconFile);
- this.selectedFilesInfos.push(fileInfo);
- logger.info(TAG, `All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
- } else {
- let ret = typeObj.belongsTo(class2UTD.get(this.text));
- logger.info(TAG, `typeObj.belongsTo: ${fileName}, utd: ${class2UTD.get(this.text)}, ret: ${ret} iconFile: ${typeObj.iconFile}`);
- if (ret) {
- let fileInfo = new FileInfo(fileName, typeObj.iconFile);
- this.selectedFilesInfos.push(fileInfo);
- }
- }
- } else {
- if (class2UTD.get(this.text) == "All") {
- let fileInfo = new FileInfo(fileName, "");
- this.selectedFilesInfos.push(fileInfo);
- logger.info(TAG, `utd null All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
- }
- }
- }
- catch (e) {
- let error: BusinessError = e as BusinessError;
- logger.error(TAG, `belongsTo throws an exception. code is ${error.code}, message is ${error.message}`);
- }
- }
- }
- logger.info(TAG, `all files ${JSON.stringify(this.selectedFilesInfos)}}`);
- }
-
- aboutToAppear() {
- logger.info(TAG, 'filesDir: ' + filesDir);
- this.UpdateSelectedFiles();
- }
-
- aboutToDisappear() {
- for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
- this.selectedFilesInfos.pop();
- }
- }
-
- build() {
- Column() {
- Column() {
- Row() {
- Image($r('app.media.utdType_back'))
- .id('secondPageBack')
- .width(24)
- .height(24)
- .objectFit(ImageFit.Fill)
- .visibility(Visibility.Visible)
- .alignSelf(ItemAlign.Auto)
- .margin({ left: 24, right: 12 })
- .onClick(() => {
- router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single);
- })
- Text($r('app.string.selectMediaType_title'))
- .fontStyle(FontStyle.Normal)
- .fontSize(20)
- .fontWeight(700)
- .textAlign(TextAlign.Start)
- .id('titleText')
- }
- .width('100%')
- .height(56)
- .alignItems(VerticalAlign.Center)
- }
- .width(280)
- .height(56)
- .alignItems(HorizontalAlign.Start)
-
- Column() {
- Select([{ value: 'All', icon: $r('app.media.ic_select_option_collection') },
- { value: 'Images', icon: $r('app.media.ic_select_option_collection') },
- { value: 'Audios', icon: $r('app.media.ic_select_option_collection') },
- { value: 'Videos', icon: $r('app.media.ic_select_option_collection') }])
- .selected(this.index)
- .value(this.text)
- .id('SelectTypeList')
- .font({ size: 16, weight: 500 })
- .fontColor('#182431')
- .selectedOptionFont({ size: 16, weight: 500 })
- .optionFont({ size: 16, weight: 500 })
- .space(this.space)
- .arrowPosition(this.arrowPosition)
- .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 })
- .backgroundColor($r('app.color.background_shallow_grey'))
- .onSelect((index: number, text?: string | undefined) => {
- this.index = index;
- if (text) {
- this.text = text;
- logger.info(TAG, 'Select type:' + text);
- this.UpdateSelectedFiles();
- }
- })
- }
- .margin({ left: 12, right: 12 })
- .height(48)
- .width(160)
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Center)
-
- Column() {
- List({ space: 2, initialIndex: 0 }) {
- ForEach(this.selectedFilesInfos, (item: FileInfo, no: Number) => {
- ListItem() {
- Row() {
- Column() {
- Text(item.filename)
- .fontSize(16)
- .height(46)
- .textAlign(TextAlign.Start)
- .margin({ left: 12, right: 12 })
- .fontWeight(500)
- .id("textFilename_" + no)
- .visibility(Visibility.Visible)
- .onClick(() => {
- logger.info(TAG, `selected file:` + item.filename + `and clicked`);
- try {
- router.pushUrl({
- url: this.routerNextUrl,
- params: {
- src: item.filename,
- selectIconFile: item.iconFile
- }
- }, router.RouterMode.Single);
- }
- catch (e) {
- let error: BusinessError = e as BusinessError;
- logger.error(TAG, `select file and router exception. code is ${error.code}, message is ${error.message}`);
- }
- })
- Divider()
- .vertical(false)
- .height(2)
- .color($r('app.color.background_shallow_grey'))
- .opacity(0.6)
- .margin({ left: 12, right: 12 })
- }
- .width('100%')
- .height(48)
- .justifyContent(FlexAlign.Center)
- .alignItems(HorizontalAlign.Start)
- }
- .width('100%')
- .height(48)
- .alignItems(VerticalAlign.Center)
- }
- .id("listItem_" + no)
- })
- }
- .listDirection(Axis.Vertical) // 排列方向
- .scrollBar(BarState.Auto)
- .friction(0.6)
- .margin({ left: 12, right: 12 })
- .borderRadius(24)
- .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
- .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
- logger.info(TAG, 'first: ' + firstIndex);
- logger.info(TAG, 'last: ' + lastIndex);
- logger.info(TAG, 'center: ' + centerIndex);
- })
- .onScroll((scrollOffset: number, scrollState: ScrollState) => {
- logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset);
- })
- .backgroundColor(0xFFFFFF)
- }
- .width('100%')
- .height(680)
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Start)
- }
- .width('100%')
- .height('100%')
- .backgroundColor($r('app.color.background_shallow_grey'))
- .alignItems(HorizontalAlign.Start)
- .justifyContent(FlexAlign.Center)
- }
-}
+/*
+ * Copyright (c) 2023-2024 Shenzhen Kaihong Digital Industry Development 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 router from '@ohos.router';
+import fs from '@ohos.file.fs';
+import common from '@ohos.app.ability.common';
+import utdDesc from '@ohos.data.uniformTypeDescriptor';
+import { BusinessError } from '@ohos.base';
+import { logger } from '../util/Logger';
+
+const TAG: string = 'SelectMediaType';
+// 获取应用文件路径
+let context = getContext(this) as common.UIAbilityContext;
+let baseDir = context.filesDir;
+let filesDir = baseDir + '/udmf_test';
+
+let class2UTD = new Map([
+ ["All", "All"],
+ ["Images", "general.image"],
+ ["Audios", "general.audio"],
+ ["Videos", "general.video"]
+]);
+
+class FileInfo {
+ filename: string;
+ iconFile: string;
+
+ constructor(fileName: string, iconFile: string) {
+ this.filename = fileName;
+ this.iconFile = iconFile;
+ }
+}
+
+@Entry
+@Component
+struct selectMediaType {
+ @State text: string = "Images";
+ @State index: number = 1;
+ @State space: number = 12;
+ @State arrowPosition: ArrowPosition = ArrowPosition.END;
+ @State fileNames: string[] = [];
+ @State selectedFilesInfos: FileInfo[] = [];
+ private routerBackUrl: string = 'pages/Index';
+ private routerNextUrl: string = 'pages/displayMediaFile';
+
+ getListFile(): string[] {
+ let files = fs.listFileSync(filesDir);
+ return files;
+ }
+
+ UpdateSelectedFiles(): void {
+ this.fileNames = this.getListFile();
+ for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
+ this.selectedFilesInfos.pop();
+ }
+ this.selectedFilesInfos = [];
+ logger.info(TAG, "selectText: " + this.text)
+ for (let i = 0; i < this.fileNames.length; i++) {
+ let fileName = this.fileNames[i];
+ let index = fileName.lastIndexOf('.');
+ if (index < 0) {
+ logger.info(TAG, `fileNames file: ${fileName}`);
+ if (this.text == "All") {
+ let fileInfo = new FileInfo(fileName, "");
+ this.selectedFilesInfos.push(fileInfo);
+ }
+ continue;
+ } else {
+ let fileExtension = fileName.substring(index);
+ let utd = utdDesc.getUniformDataTypeByFilenameExtension(fileExtension);
+ logger.info(TAG, `fileNames file: ${fileName}, extension: ${fileExtension}, utd: ${utd}`);
+ try {
+ if (utd != null) {
+ let typeObj: utdDesc.TypeDescriptor = utdDesc.getTypeDescriptor(utd);
+ if (class2UTD.get(this.text) == "All") {
+ let fileInfo = new FileInfo(fileName, typeObj.iconFile);
+ this.selectedFilesInfos.push(fileInfo);
+ logger.info(TAG, `All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
+ } else {
+ let ret = typeObj.belongsTo(class2UTD.get(this.text));
+ logger.info(TAG, `typeObj.belongsTo: ${fileName}, utd: ${class2UTD.get(this.text)}, ret: ${ret} iconFile: ${typeObj.iconFile}`);
+ if (ret) {
+ let fileInfo = new FileInfo(fileName, typeObj.iconFile);
+ this.selectedFilesInfos.push(fileInfo);
+ }
+ }
+ } else {
+ if (class2UTD.get(this.text) == "All") {
+ let fileInfo = new FileInfo(fileName, "");
+ this.selectedFilesInfos.push(fileInfo);
+ logger.info(TAG, `utd null All type: ${fileInfo.filename}, utd: ${utd}, iconFile: ${fileInfo.iconFile}`);
+ }
+ }
+ }
+ catch (e) {
+ let error: BusinessError = e as BusinessError;
+ logger.error(TAG, `belongsTo throws an exception. code is ${error.code}, message is ${error.message}`);
+ }
+ }
+ }
+ logger.info(TAG, `all files ${JSON.stringify(this.selectedFilesInfos)}}`);
+ }
+
+ aboutToAppear() {
+ logger.info(TAG, 'filesDir: ' + filesDir);
+ this.UpdateSelectedFiles();
+ }
+
+ aboutToDisappear() {
+ for (let i = this.selectedFilesInfos.length - 1; i >= 0; i--) {
+ this.selectedFilesInfos.pop();
+ }
+ }
+
+ build() {
+ Column() {
+ Column() {
+ Row() {
+ Image($r('app.media.utdType_back'))
+ .id('secondPageBack')
+ .width(24)
+ .height(24)
+ .objectFit(ImageFit.Fill)
+ .visibility(Visibility.Visible)
+ .alignSelf(ItemAlign.Auto)
+ .margin({ left: 24, right: 12 })
+ .onClick(() => {
+ router.pushUrl({ url: this.routerBackUrl }, router.RouterMode.Single);
+ })
+ Text($r('app.string.selectMediaType_title'))
+ .fontStyle(FontStyle.Normal)
+ .fontSize(20)
+ .fontWeight(700)
+ .textAlign(TextAlign.Start)
+ .id('titleText')
+ }
+ .width('100%')
+ .height(56)
+ .alignItems(VerticalAlign.Center)
+ }
+ .width(280)
+ .height(56)
+ .alignItems(HorizontalAlign.Start)
+
+ Column() {
+ Select([{ value: 'All', icon: $r('app.media.ic_select_option_collection') },
+ { value: 'Images', icon: $r('app.media.ic_select_option_collection') },
+ { value: 'Audios', icon: $r('app.media.ic_select_option_collection') },
+ { value: 'Videos', icon: $r('app.media.ic_select_option_collection') }])
+ .selected(this.index)
+ .value(this.text)
+ .id('SelectTypeList')
+ .font({ size: 16, weight: 500 })
+ .fontColor('#182431')
+ .selectedOptionFont({ size: 16, weight: 500 })
+ .optionFont({ size: 16, weight: 500 })
+ .space(this.space)
+ .arrowPosition(this.arrowPosition)
+ .menuAlign(MenuAlignType.START, { dx: 0, dy: 0 })
+ .backgroundColor($r('app.color.background_shallow_grey'))
+ .onSelect((index: number, text?: string | undefined) => {
+ this.index = index;
+ if (text) {
+ this.text = text;
+ logger.info(TAG, 'Select type:' + text);
+ this.UpdateSelectedFiles();
+ }
+ })
+ }
+ .margin({ left: 12, right: 12 })
+ .height(48)
+ .width(160)
+ .alignItems(HorizontalAlign.Start)
+ .justifyContent(FlexAlign.Center)
+
+ Column() {
+ List({ space: 2, initialIndex: 0 }) {
+ ForEach(this.selectedFilesInfos, (item: FileInfo, no: Number) => {
+ ListItem() {
+ Row() {
+ Column() {
+ Text(item.filename)
+ .fontSize(16)
+ .height(46)
+ .textAlign(TextAlign.Start)
+ .margin({ left: 12, right: 12 })
+ .fontWeight(500)
+ .id("textFilename_" + no)
+ .visibility(Visibility.Visible)
+ .onClick(() => {
+ logger.info(TAG, `selected file:` + item.filename + `and clicked`);
+ try {
+ router.pushUrl({
+ url: this.routerNextUrl,
+ params: {
+ src: item.filename,
+ selectIconFile: item.iconFile
+ }
+ }, router.RouterMode.Single);
+ }
+ catch (e) {
+ let error: BusinessError = e as BusinessError;
+ logger.error(TAG, `select file and router exception. code is ${error.code}, message is ${error.message}`);
+ }
+ })
+ Divider()
+ .vertical(false)
+ .height(2)
+ .color($r('app.color.background_shallow_grey'))
+ .opacity(0.6)
+ .margin({ left: 12, right: 12 })
+ }
+ .width('100%')
+ .height(48)
+ .justifyContent(FlexAlign.Center)
+ .alignItems(HorizontalAlign.Start)
+ }
+ .width('100%')
+ .height(48)
+ .alignItems(VerticalAlign.Center)
+ }
+ .id("listItem_" + no)
+ })
+ }
+ .listDirection(Axis.Vertical) // 排列方向
+ .scrollBar(BarState.Auto)
+ .friction(0.6)
+ .margin({ left: 12, right: 12 })
+ .borderRadius(24)
+ .edgeEffect(EdgeEffect.Spring) // 边缘效果设置为Spring
+ .onScrollIndex((firstIndex: number, lastIndex: number, centerIndex: number) => {
+ logger.info(TAG, 'first: ' + firstIndex);
+ logger.info(TAG, 'last: ' + lastIndex);
+ logger.info(TAG, 'center: ' + centerIndex);
+ })
+ .onScroll((scrollOffset: number, scrollState: ScrollState) => {
+ logger.info(TAG, `onScroll scrollState = ScrollState` + scrollState + `, scrollOffset = ` + scrollOffset);
+ })
+ .backgroundColor(0xFFFFFF)
+ }
+ .width('100%')
+ .height(680)
+ .alignItems(HorizontalAlign.Start)
+ .justifyContent(FlexAlign.Start)
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor($r('app.color.background_shallow_grey'))
+ .alignItems(HorizontalAlign.Start)
+ .justifyContent(FlexAlign.Center)
+ }
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/util/Logger.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/ets/util/Logger.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/module.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/module.json5
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/color.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/file.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/file.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/ic_select_option_collection.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/ic_select_option_collection.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/image.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/image.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/myAudio.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/myAudio.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/utdType_back.svg b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/utdType_back.svg
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/video.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/media/video.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/profile/main_pages.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/base/profile/main_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en_US/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/en_US/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh_CN/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/main/resources/zh_CN/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/Application/TestAbilityStage.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/Ability.test.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/Ability.test.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/List.test.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/test/List.test.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/TestAbility.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/TestAbility.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/pages/Index.ets b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testability/pages/Index.ets
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/util/Logger.ts b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/ets/util/Logger.ts
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/module.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/module.json5
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/color.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/color.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/media/icon.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/media/icon.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/profile/test_pages.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/base/profile/test_pages.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/en/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/en/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/zh/element/string.json b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/entry/src/ohosTest/resources/zh/element/string.json
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5
old mode 100755
new mode 100644
index 3e204d93247770d06a95af202bfe2c9f11f5a45e..122677b194bc767301ef00a87a4b93c45562fe31
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-config.json5
@@ -1,6 +1,6 @@
-{
- "hvigorVersion": "3.0.9",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "3.0.9"
- }
+{
+ "hvigorVersion": "3.0.9",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "3.0.9"
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-wrapper.js b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigor/hvigor-wrapper.js
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw.bat b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/hvigorw.bat
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5 b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5
old mode 100755
new mode 100644
index 3762fe6b2a97a0e2cfe64c08744a2c2eb59bd5a2..368c840c89b3a0550d4bcb58ce0a86ad228b487c
--- a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5
+++ b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/oh-package.json5
@@ -1,12 +1,12 @@
-{
- "license": "",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "author": "",
- "name": "myfile",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+{
+ "license": "",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "author": "",
+ "name": "myfile",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/ohosTest.md b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/ohosTest.md
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/display_file.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/display_file.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/first.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/first.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/select_type.png b/code/BasicFeature/DataManagement/UDMF/UniformTypeDescriptor/UTDType/screenshots/select_type.png
old mode 100755
new mode 100644
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5
index e621231c39bfb930dc721877a2707baaeb2803bf..88e81944882a7b5814c3bd2db1076a5d37a9c018 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/app.json5
@@ -1,25 +1,25 @@
-/*
- * Copyright (c) 2023 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.example.sensor",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name"
- }
-}
+/*
+ * Copyright (c) 2023 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.example.sensor",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name"
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json
index 27bc1ff1ff0ecab8166457e5dafe073557ef6deb..3050b880be8741dc98a4a8232fca9fae94652d80 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "Sensor"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "Sensor"
+ }
+ ]
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5
index 7c88aef542571888b8d0231907cdb8cbfde46f9f..6b7e50621e658f015253cc648ca80b70ad5b8c45 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/build-profile.json5
@@ -1,41 +1,41 @@
-/*
- * Copyright (c) 2023 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": {
- "compileSdkVersion": 9,
- "compatibleSdkVersion": 9,
- "products": [
- {
- "name": "default",
- "signingConfig": "default",
- }
- ]
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ "compileSdkVersion": 9,
+ "compatibleSdkVersion": 9,
+ "products": [
+ {
+ "name": "default",
+ "signingConfig": "default",
+ }
+ ]
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5
index 0c8525dfdde040a6d029cd2dc7bbddc5a5ee5353..910cc991f5e6483bbaebf92e26274ddd43db6f82 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/build-profile.json5
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2023 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": {
- },
- "targets": [
- {
- "name": "default",
- "runtimeOS": "OpenHarmony"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ },
+ "targets": [
+ {
+ "name": "default",
+ "runtimeOS": "OpenHarmony"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5
index 80997033c906a6c587247cdaf29a174d9212b479..e7aaaec223615df3fef35b07ed52d2fbbc43a0f9 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/oh-package.json5
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "",
- "devDependencies": {},
- "author": "",
- "name": "entry",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {
- "library": "file:../libs/library.har"
- }
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "",
+ "devDependencies": {},
+ "author": "",
+ "name": "entry",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {
+ "library": "file:../libs/library.har"
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts
index 202b948c9ed4dd76c512c9225e676899cb8907b8..7370b8f3270dfb1cc5824b1d9fe959f82b7ede74 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,56 +1,56 @@
-/*
- * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
-import hilog from '@ohos.hilog';
-import window from '@ohos.window';
-
-export default class EntryAbility extends UIAbility {
- onCreate(want, launchParam) {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
- }
-
- onDestroy() {
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: window.WindowStage) {
- // Main window is created, set main page for this ability
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
- }
-}
+/*
+ * Copyright (c) 2023 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 UIAbility from '@ohos.app.ability.UIAbility';
+import hilog from '@ohos.hilog';
+import window from '@ohos.window';
+
+export default class EntryAbility extends UIAbility {
+ onCreate(want, launchParam) {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
+ }
+
+ onDestroy() {
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: window.WindowStage) {
+ // Main window is created, set main page for this ability
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5
index 4dd6059374f1c75c5562d42f8b09a31082659d40..370d208a19c7f950b63a59f96c9eec8bc2b41c52 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/module.json5
@@ -1,57 +1,57 @@
-/*
- * Copyright (c) 2023 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": [
- "phone",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:main_pages",
- "abilities": [
- {
- "name": "EntryAbility",
- "srcEntry": "./ets/entryability/EntryAbility.ts",
- "description": "$string:EntryAbility_desc",
- "icon": "$media:icon",
- "label": "$string:EntryAbility_label",
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "exported": true,
- "skills": [
- {
- "entities": [
- "entity.system.home"
- ],
- "actions": [
- "action.system.home"
- ]
- }
- ]
- }
- ],
- "requestPermissions": [
- {
- "name": "ohos.permission.VIBRATE",
- }
- ]
- }
+/*
+ * Copyright (c) 2023 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": [
+ "phone",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:main_pages",
+ "abilities": [
+ {
+ "name": "EntryAbility",
+ "srcEntry": "./ets/entryability/EntryAbility.ts",
+ "description": "$string:EntryAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:EntryAbility_label",
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "exported": true,
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ]
+ }
+ ],
+ "requestPermissions": [
+ {
+ "name": "ohos.permission.VIBRATE",
+ }
+ ]
+ }
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json
index d66f9a7d4ac61fb8d215239ab3620b7bcd77bf33..3c712962da3c2751c2b9ddb53559afcbd2b54a02 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/main/resources/base/element/color.json
@@ -1,8 +1,8 @@
-{
- "color": [
- {
- "name": "start_window_background",
- "value": "#FFFFFF"
- }
- ]
+{
+ "color": [
+ {
+ "name": "start_window_background",
+ "value": "#FFFFFF"
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5
index 259be9c7d7cd4d0ee34176d052eafa7c3e3f0b6a..237ccad18bb855c80f49912561d2c6cab46eb810 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/entry/src/ohosTest/module.json5
@@ -1,52 +1,52 @@
-/*
- * Copyright (c) 2023 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",
- "description": "$string:module_test_desc",
- "mainElement": "TestAbility",
- "deviceTypes": [
- "phone",
- "tablet"
- ],
- "deliveryWithInstall": true,
- "installationFree": false,
- "pages": "$profile:test_pages",
- "abilities": [
- {
- "name": "TestAbility",
- "srcEntry": "./ets/testability/TestAbility.ets",
- "description": "$string:TestAbility_desc",
- "icon": "$media:icon",
- "label": "$string:TestAbility_label",
- "exported": true,
- "startWindowIcon": "$media:icon",
- "startWindowBackground": "$color:start_window_background",
- "skills": [
- {
- "actions": [
- "action.system.home"
- ],
- "entities": [
- "entity.system.home"
- ]
- }
- ]
- }
- ]
- }
-}
+/*
+ * Copyright (c) 2023 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",
+ "description": "$string:module_test_desc",
+ "mainElement": "TestAbility",
+ "deviceTypes": [
+ "phone",
+ "tablet"
+ ],
+ "deliveryWithInstall": true,
+ "installationFree": false,
+ "pages": "$profile:test_pages",
+ "abilities": [
+ {
+ "name": "TestAbility",
+ "srcEntry": "./ets/testability/TestAbility.ets",
+ "description": "$string:TestAbility_desc",
+ "icon": "$media:icon",
+ "label": "$string:TestAbility_label",
+ "exported": true,
+ "startWindowIcon": "$media:icon",
+ "startWindowBackground": "$color:start_window_background",
+ "skills": [
+ {
+ "actions": [
+ "action.system.home"
+ ],
+ "entities": [
+ "entity.system.home"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5
index 9fa38552b00172f3bd25c8e973caebb4b8e82de0..0450bec27475c1853a73087292c8a8d946880600 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/hvigor/hvigor-config.json5
@@ -1,6 +1,6 @@
-{
- "hvigorVersion": "2.4.2",
- "dependencies": {
- "@ohos/hvigor-ohos-plugin": "2.4.2"
- }
-}
+{
+ "hvigorVersion": "2.4.2",
+ "dependencies": {
+ "@ohos/hvigor-ohos-plugin": "2.4.2"
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5 b/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5
index 8ce88801dde6f221c4966625d6814e9ad64c094f..4dc65913833eb2c035908863133cdb85e480bd09 100644
--- a/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5
+++ b/code/BasicFeature/DeviceManagement/Sensor/Capi/oh-package.json5
@@ -1,27 +1,27 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "",
- "devDependencies": {
- "@ohos/hypium": "1.0.6"
- },
- "author": "",
- "name": "sensor",
- "description": "Please describe the basic information.",
- "main": "",
- "version": "1.0.0",
- "dependencies": {}
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "",
+ "devDependencies": {
+ "@ohos/hypium": "1.0.6"
+ },
+ "author": "",
+ "name": "sensor",
+ "description": "Please describe the basic information.",
+ "main": "",
+ "version": "1.0.0",
+ "dependencies": {}
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5
index 1f9987259b27c3f6a853c720206b24f814f6350b..6c137fcb314a0d38d009e82b6bae63e7d58f6bf1 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/app.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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.haptic",
- "vendor": "example",
- "versionCode": 1000000,
- "versionName": "1.0.0",
- "icon": "$media:app_icon",
- "label": "$string:app_name",
- "distributedNotificationEnabled": true
- }
-}
+/*
+ * Copyright (c) 2023 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.haptic",
+ "vendor": "example",
+ "versionCode": 1000000,
+ "versionName": "1.0.0",
+ "icon": "$media:app_icon",
+ "label": "$string:app_name",
+ "distributedNotificationEnabled": true
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json
index b2c6a66807cdaa47974eb3a6145740f74c2509ab..13156d6afcf2082181fdd648c62ff835a4a67389 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/AppScope/resources/base/element/string.json
@@ -1,8 +1,8 @@
-{
- "string": [
- {
- "name": "app_name",
- "value": "Haptic Sample"
- }
- ]
-}
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "Haptic Sample"
+ }
+ ]
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5
index 390b41a9444ff9c8f9fdae6934b65992667fe62f..947c318515daba7da7f38dc0121210ba6d4856c9 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/build-profile.json5
@@ -1,43 +1,43 @@
-/*
- * Copyright (c) 2023 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": 10,
- "compatibleSdkVersion": 10,
- "runtimeOS": "OpenHarmony"
- }
- ],
- "signingConfigs": []
- },
- "modules": [
- {
- "name": "entry",
- "srcPath": "./entry",
- "targets": [
- {
- "name": "default",
- "applyToProducts": [
- "default"
- ]
- }
- ]
- }
- ]
+/*
+ * Copyright (c) 2023 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": 10,
+ "compatibleSdkVersion": 10,
+ "runtimeOS": "OpenHarmony"
+ }
+ ],
+ "signingConfigs": []
+ },
+ "modules": [
+ {
+ "name": "entry",
+ "srcPath": "./entry",
+ "targets": [
+ {
+ "name": "default",
+ "applyToProducts": [
+ "default"
+ ]
+ }
+ ]
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5
index 0c8525dfdde040a6d029cd2dc7bbddc5a5ee5353..910cc991f5e6483bbaebf92e26274ddd43db6f82 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/build-profile.json5
@@ -1,29 +1,29 @@
-/*
- * Copyright (c) 2023 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": {
- },
- "targets": [
- {
- "name": "default",
- "runtimeOS": "OpenHarmony"
- },
- {
- "name": "ohosTest",
- }
- ]
+/*
+ * Copyright (c) 2023 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": {
+ },
+ "targets": [
+ {
+ "name": "default",
+ "runtimeOS": "OpenHarmony"
+ },
+ {
+ "name": "ohosTest",
+ }
+ ]
}
\ No newline at end of file
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5 b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5
index 7cee9755d2e97da5568f5cbb4a44896c8c929552..fcff8e1a08dd69ab29d8791a8cb2721d2350ede8 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/oh-package.json5
@@ -1,26 +1,26 @@
-/*
- * Copyright (c) 2023 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.
- */
-
-{
- "license": "ISC",
- "devDependencies": {},
- "name": "entry",
- "description": "example description",
- "repository": {},
- "version": "1.0.0",
- "dependencies": {
- "library": "file:../libs/library.har"
- }
-}
+/*
+ * Copyright (c) 2023 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.
+ */
+
+{
+ "license": "ISC",
+ "devDependencies": {},
+ "name": "entry",
+ "description": "example description",
+ "repository": {},
+ "version": "1.0.0",
+ "dependencies": {
+ "library": "file:../libs/library.har"
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets
index f7469ab6f1068b2612b77f013e6792b8a5840deb..57b8b4aaa44e443d63f54c24cb201149ded4dfdc 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Battle.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageBattleList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct BattleLayout {
- @State battleList: ImageDataSource = new ImageDataSource(getImageBattleList())
- @State status: boolean[] = [false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $battleList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageBattleList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct BattleLayout {
+ @State battleList: ImageDataSource = new ImageDataSource(getImageBattleList())
+ @State status: boolean[] = [false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $battleList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets
index 66c1ee33f0b6da3e3a5220ae9777385429b1b4f4..4e9ebcef1535425cc6b0f566d080e3db8f56e609 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Common.ets
@@ -1,95 +1,95 @@
-/*
- * Copyright (c) 2023 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 { playVibrateCustom, getDynamicStates } from '../module/Util'
-import { ImageDataSource, ImagesData } from '../module/ImageData'
-import AudioPlayer from '../module/AudioPlayer'
-import Logger from '../module/Logger'
-
-const TAG = '[CommonLayout]'
-
-@Component
-export default struct CommonLayout {
- @Link dataList: ImageDataSource
- @Link status: boolean[]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- Column({ space: 10 }) {
- List() {
- LazyForEach(this.dataList, (item: ImagesData) => {
- ListItem() {
- Row() {
- Row() {
- Image(item.src)
- .width(60)
- .height(50)
- .borderRadius(5)
- .autoResize(false)
- }
-
- Stack({ alignContent: Alignment.Start }) {
- Column() {
- Text(item.name)
- .fontSize(15)
- .fontColor(Color.White)
- }
- .alignItems(HorizontalAlign.Start)
- .padding({ left: 20 })
- }
- .layoutWeight(7)
-
- if (item.id !== undefined) {
- Image($r("app.media.music"))
- .width(15)
- .height(15)
- .visibility(this.status[item.id] ? Visibility.Visible : Visibility.Hidden)
- }
- }
- .id("audioHaptic")
- .width("95%")
- .height(70)
- .padding({ top: 5, left: 10, right: 10, bottom: 5 })
- .backgroundColor(this.status[item.id!] ? "#1a3e3f56" : "#4d191a32")
- .onClick(() => {
- this.status = getDynamicStates(this.status, item.id!)
- AudioPlayer.playAudio(item.audioName!)
- if (this.vibrationIntensity === 'H') {
- Logger.info(TAG, "High intensity mode")
- playVibrateCustom(item.vibratorFileH!, this.php)
- } else if (this.vibrationIntensity === 'M') {
- Logger.info(TAG, "Middle intensity mode")
- playVibrateCustom(item.vibratorFileM!, this.php)
- } else if (this.vibrationIntensity === 'L') {
- Logger.info(TAG, "Low intensity mode")
- playVibrateCustom(item.vibratorFileL!, this.php)
- } else {
- Logger.info(TAG, "Vibration mode error")
- }
- if (item.id) {
- Logger.info(TAG, item.id.toString() + ' ' + item.name + ' ' + item.audioName)
- }
- })
- }
- }) // LazyForEach
- }
- .listDirection(Axis.Vertical)
- .divider({ strokeWidth: 3, color: "#00f3f3f3", startMargin: 0, endMargin: 0 })
- .height('50%')
- .width('100%')
- }
- }
-}
+/*
+ * Copyright (c) 2023 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 { playVibrateCustom, getDynamicStates } from '../module/Util'
+import { ImageDataSource, ImagesData } from '../module/ImageData'
+import AudioPlayer from '../module/AudioPlayer'
+import Logger from '../module/Logger'
+
+const TAG = '[CommonLayout]'
+
+@Component
+export default struct CommonLayout {
+ @Link dataList: ImageDataSource
+ @Link status: boolean[]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ Column({ space: 10 }) {
+ List() {
+ LazyForEach(this.dataList, (item: ImagesData) => {
+ ListItem() {
+ Row() {
+ Row() {
+ Image(item.src)
+ .width(60)
+ .height(50)
+ .borderRadius(5)
+ .autoResize(false)
+ }
+
+ Stack({ alignContent: Alignment.Start }) {
+ Column() {
+ Text(item.name)
+ .fontSize(15)
+ .fontColor(Color.White)
+ }
+ .alignItems(HorizontalAlign.Start)
+ .padding({ left: 20 })
+ }
+ .layoutWeight(7)
+
+ if (item.id !== undefined) {
+ Image($r("app.media.music"))
+ .width(15)
+ .height(15)
+ .visibility(this.status[item.id] ? Visibility.Visible : Visibility.Hidden)
+ }
+ }
+ .id("audioHaptic")
+ .width("95%")
+ .height(70)
+ .padding({ top: 5, left: 10, right: 10, bottom: 5 })
+ .backgroundColor(this.status[item.id!] ? "#1a3e3f56" : "#4d191a32")
+ .onClick(() => {
+ this.status = getDynamicStates(this.status, item.id!)
+ AudioPlayer.playAudio(item.audioName!)
+ if (this.vibrationIntensity === 'H') {
+ Logger.info(TAG, "High intensity mode")
+ playVibrateCustom(item.vibratorFileH!, this.php)
+ } else if (this.vibrationIntensity === 'M') {
+ Logger.info(TAG, "Middle intensity mode")
+ playVibrateCustom(item.vibratorFileM!, this.php)
+ } else if (this.vibrationIntensity === 'L') {
+ Logger.info(TAG, "Low intensity mode")
+ playVibrateCustom(item.vibratorFileL!, this.php)
+ } else {
+ Logger.info(TAG, "Vibration mode error")
+ }
+ if (item.id) {
+ Logger.info(TAG, item.id.toString() + ' ' + item.name + ' ' + item.audioName)
+ }
+ })
+ }
+ }) // LazyForEach
+ }
+ .listDirection(Axis.Vertical)
+ .divider({ strokeWidth: 3, color: "#00f3f3f3", startMargin: 0, endMargin: 0 })
+ .height('50%')
+ .width('100%')
+ }
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets
index 68cebf3f046fa7b2e73d28c7031f887872742a5c..7ef5240367f61e4b073acbd815e046f2da7a22b8 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Environment.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageEnvironmentList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct EnvironmentLayout {
- @State environmentList: ImageDataSource = new ImageDataSource(getImageEnvironmentList())
- @State status: boolean[] = [false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $environmentList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageEnvironmentList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct EnvironmentLayout {
+ @State environmentList: ImageDataSource = new ImageDataSource(getImageEnvironmentList())
+ @State status: boolean[] = [false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $environmentList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets
index 2de2cb07c83cffd3aff35c4af2184ff1a31c0090..7543a256b9901806bc1458b8c0fb5cdfbf03068e 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Exercise.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageExerciseList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct ExerciseLayout {
- @State exerciseList: ImageDataSource = new ImageDataSource(getImageExerciseList())
- @State status: boolean[] = [false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $exerciseList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageExerciseList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct ExerciseLayout {
+ @State exerciseList: ImageDataSource = new ImageDataSource(getImageExerciseList())
+ @State status: boolean[] = [false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $exerciseList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets
index 56b4e443b9db1b0cf6febbd5558d82328f923cd3..db58ec43d351d23be8713d07d989dd697abd1a55 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Footstep.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageFootstepList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct FootstepLayout {
- @State footstepList: ImageDataSource = new ImageDataSource(getImageFootstepList())
- @State status: boolean[] = [false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $footstepList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageFootstepList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct FootstepLayout {
+ @State footstepList: ImageDataSource = new ImageDataSource(getImageFootstepList())
+ @State status: boolean[] = [false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $footstepList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets
index 263509737366a3dbdb221445983a387d280c560f..0f4cf857f2eda4d23fab8cafc65f1c17379c4016 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Instrument.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageInstrumentsList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct InstrumentLayout {
- @State instrumentList: ImageDataSource = new ImageDataSource(getImageInstrumentsList())
- @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $instrumentList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageInstrumentsList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct InstrumentLayout {
+ @State instrumentList: ImageDataSource = new ImageDataSource(getImageInstrumentsList())
+ @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $instrumentList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets
index 9936c87b1c9ab38c1d7ccf4d2c2e6e16a39bee78..0f11126a628b388f2908aa4057215f6f7decaa00 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Interaction.ets
@@ -1,216 +1,216 @@
-/*
- * Copyright (c) 2023 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 { playVibrateCustom } from '../module/Util'
-
-@Component
-export default struct InteractionLayout {
- @State status: boolean[] = [false, false, false, false]
- @State stateSlideLeftRight: AnimationStatus = AnimationStatus.Initial
- @State stateSlideUp: AnimationStatus = AnimationStatus.Initial
- @State stateSwitchApp: AnimationStatus = AnimationStatus.Initial
- @State stateUpSlideStop: AnimationStatus = AnimationStatus.Initial
- @State iterations: number = 1
- @Link php: string
-
- build() {
- Column() {
- List({ space: 20 }) {
- ListItem() {
- Row({ space: 30 }) {
- Column({ space: 10 }) {
- Row() {
- ImageAnimator()
- .images([
- { src: $r("app.media.Slide_LeftRight1") },
- { src: $r("app.media.Slide_LeftRight2") },
- { src: $r("app.media.Slide_LeftRight3") },
- { src: $r("app.media.Slide_LeftRight4") },
- { src: $r("app.media.Slide_LeftRight5") },
- { src: $r("app.media.Slide_LeftRight6") },
- { src: $r("app.media.Slide_LeftRight7") },
- { src: $r("app.media.Slide_LeftRight8") },
- { src: $r("app.media.Slide_LeftRight9") },
- { src: $r("app.media.Slide_LeftRight10") },
- { src: $r("app.media.Slide_LeftRight11") },
- { src: $r("app.media.Slide_LeftRight12") },
- ])
- .borderRadius(10)
- .duration(3000)
- .state(this.stateSlideLeftRight)
- .fillMode(FillMode.None)
- .iterations(this.iterations)
- .width("100%")
- .height("100%")
- .onFinish(() => {
- this.stateSlideLeftRight = AnimationStatus.Initial
- })
- }
- .width('30%')
- .borderRadius(20)
- .backgroundColor("#66191a32")
- .height("60%")
- .onClick(() => {
- this.stateSlideLeftRight = AnimationStatus.Running
- playVibrateCustom("Slide_LeftRight.json", this.php)
- })
-
- Text($r("app.string.interaction_slide_left_right"))
- .fontColor(Color.White)
- .fontSize(18)
- }
-
- Column({ space: 10 }) {
- Row() {
- ImageAnimator()
- .images([
- { src: $r("app.media.slide_up1") },
- { src: $r("app.media.slide_up2") },
- { src: $r("app.media.slide_up3") },
- { src: $r("app.media.slide_up4") },
- { src: $r("app.media.slide_up5") },
- { src: $r("app.media.slide_up6") },
- { src: $r("app.media.slide_up7") },
- { src: $r("app.media.slide_up8") },
- { src: $r("app.media.slide_up9") },
- ])
- .borderRadius(10)
- .duration(2250)
- .state(this.stateSlideUp)
- .fillMode(FillMode.None)
- .iterations(this.iterations)
- .width("100%")
- .height("100%")
- .onFinish(() => {
- this.stateSlideUp = AnimationStatus.Initial
- })
- }
- .width('30%')
- .borderRadius(20)
- .backgroundColor("#66191a32")
- .height("60%")
- .onClick(() => {
- this.stateSlideUp = AnimationStatus.Running
- playVibrateCustom("Slide_Up.json", this.php)
- })
-
- Text($r("app.string.interaction_slide_up"))
- .fontColor(Color.White)
- .fontSize(18)
- }
- }
- .justifyContent(FlexAlign.Center)
- }
- .margin({ left: "1%" })
- .width("100%")
-
- ListItem() {
- Row({ space: 30 }) {
- Column({ space: 10 }) {
- Row() {
- ImageAnimator()
- .images([
- { src: $r("app.media.Switch_App1") },
- { src: $r("app.media.Switch_App2") },
- { src: $r("app.media.Switch_App3") },
- { src: $r("app.media.Switch_App4") },
- { src: $r("app.media.Switch_App5") },
- { src: $r("app.media.Switch_App6") },
- { src: $r("app.media.Switch_App7") },
- { src: $r("app.media.Switch_App8") },
- { src: $r("app.media.Switch_App9") },
- { src: $r("app.media.Switch_App10") },
- { src: $r("app.media.Switch_App11") },
- { src: $r("app.media.Switch_App12") },
- { src: $r("app.media.Switch_App13") },
- { src: $r("app.media.Switch_App14") },
- ])
- .borderRadius(10)
- .duration(3500)
- .state(this.stateSwitchApp)
- .fillMode(FillMode.None)
- .iterations(this.iterations)
- .width("100%")
- .height("100%")
- .onFinish(() => {
- this.stateSwitchApp = AnimationStatus.Initial
- })
- }
- .width('30%')
- .borderRadius(20)
- .backgroundColor("#66191a32")
- .height("60%")
- .onClick(() => {
- this.stateSwitchApp = AnimationStatus.Running
- playVibrateCustom("Switch_App.json", this.php)
- })
-
- Text($r("app.string.interaction_switch_app"))
- .fontColor(Color.White)
- .fontSize(18)
- }
-
- Column({ space: 10 }) {
- Row() {
- ImageAnimator()
- .images([
- { src: $r("app.media.Upslide_Stop1") },
- { src: $r("app.media.Upslide_Stop2") },
- { src: $r("app.media.Upslide_Stop3") },
- { src: $r("app.media.Upslide_Stop4") },
- { src: $r("app.media.Upslide_Stop5") },
- { src: $r("app.media.Upslide_Stop6") },
- { src: $r("app.media.Upslide_Stop7") },
- { src: $r("app.media.Upslide_Stop8") },
- { src: $r("app.media.Upslide_Stop9") },
- { src: $r("app.media.Upslide_Stop10") },
- { src: $r("app.media.Upslide_Stop11") },
- { src: $r("app.media.Upslide_Stop12") },
- ])
- .borderRadius(10)
- .duration(3000)
- .state(this.stateUpSlideStop)
- .fillMode(FillMode.None)
- .iterations(this.iterations)
- .width("100%")
- .height("100%")
- .onFinish(() => {
- this.stateUpSlideStop = AnimationStatus.Initial
- })
- }
- .width('30%')
- .borderRadius(20)
- .backgroundColor("#66191a32")
- .height("60%")
- .onClick(() => {
- this.stateUpSlideStop = AnimationStatus.Running
- playVibrateCustom("UpSlide_Stop.json", this.php)
- })
-
- Text($r("app.string.interaction_slide_stop"))
- .fontColor(Color.White)
- .fontSize(18)
- }
- }
- .justifyContent(FlexAlign.Center)
- }
- .margin({ left: "1%" })
- .width("100%")
- }
- .height('50%')
- .width("100%")
- }
- }
-}
+/*
+ * Copyright (c) 2023 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 { playVibrateCustom } from '../module/Util'
+
+@Component
+export default struct InteractionLayout {
+ @State status: boolean[] = [false, false, false, false]
+ @State stateSlideLeftRight: AnimationStatus = AnimationStatus.Initial
+ @State stateSlideUp: AnimationStatus = AnimationStatus.Initial
+ @State stateSwitchApp: AnimationStatus = AnimationStatus.Initial
+ @State stateUpSlideStop: AnimationStatus = AnimationStatus.Initial
+ @State iterations: number = 1
+ @Link php: string
+
+ build() {
+ Column() {
+ List({ space: 20 }) {
+ ListItem() {
+ Row({ space: 30 }) {
+ Column({ space: 10 }) {
+ Row() {
+ ImageAnimator()
+ .images([
+ { src: $r("app.media.Slide_LeftRight1") },
+ { src: $r("app.media.Slide_LeftRight2") },
+ { src: $r("app.media.Slide_LeftRight3") },
+ { src: $r("app.media.Slide_LeftRight4") },
+ { src: $r("app.media.Slide_LeftRight5") },
+ { src: $r("app.media.Slide_LeftRight6") },
+ { src: $r("app.media.Slide_LeftRight7") },
+ { src: $r("app.media.Slide_LeftRight8") },
+ { src: $r("app.media.Slide_LeftRight9") },
+ { src: $r("app.media.Slide_LeftRight10") },
+ { src: $r("app.media.Slide_LeftRight11") },
+ { src: $r("app.media.Slide_LeftRight12") },
+ ])
+ .borderRadius(10)
+ .duration(3000)
+ .state(this.stateSlideLeftRight)
+ .fillMode(FillMode.None)
+ .iterations(this.iterations)
+ .width("100%")
+ .height("100%")
+ .onFinish(() => {
+ this.stateSlideLeftRight = AnimationStatus.Initial
+ })
+ }
+ .width('30%')
+ .borderRadius(20)
+ .backgroundColor("#66191a32")
+ .height("60%")
+ .onClick(() => {
+ this.stateSlideLeftRight = AnimationStatus.Running
+ playVibrateCustom("Slide_LeftRight.json", this.php)
+ })
+
+ Text($r("app.string.interaction_slide_left_right"))
+ .fontColor(Color.White)
+ .fontSize(18)
+ }
+
+ Column({ space: 10 }) {
+ Row() {
+ ImageAnimator()
+ .images([
+ { src: $r("app.media.slide_up1") },
+ { src: $r("app.media.slide_up2") },
+ { src: $r("app.media.slide_up3") },
+ { src: $r("app.media.slide_up4") },
+ { src: $r("app.media.slide_up5") },
+ { src: $r("app.media.slide_up6") },
+ { src: $r("app.media.slide_up7") },
+ { src: $r("app.media.slide_up8") },
+ { src: $r("app.media.slide_up9") },
+ ])
+ .borderRadius(10)
+ .duration(2250)
+ .state(this.stateSlideUp)
+ .fillMode(FillMode.None)
+ .iterations(this.iterations)
+ .width("100%")
+ .height("100%")
+ .onFinish(() => {
+ this.stateSlideUp = AnimationStatus.Initial
+ })
+ }
+ .width('30%')
+ .borderRadius(20)
+ .backgroundColor("#66191a32")
+ .height("60%")
+ .onClick(() => {
+ this.stateSlideUp = AnimationStatus.Running
+ playVibrateCustom("Slide_Up.json", this.php)
+ })
+
+ Text($r("app.string.interaction_slide_up"))
+ .fontColor(Color.White)
+ .fontSize(18)
+ }
+ }
+ .justifyContent(FlexAlign.Center)
+ }
+ .margin({ left: "1%" })
+ .width("100%")
+
+ ListItem() {
+ Row({ space: 30 }) {
+ Column({ space: 10 }) {
+ Row() {
+ ImageAnimator()
+ .images([
+ { src: $r("app.media.Switch_App1") },
+ { src: $r("app.media.Switch_App2") },
+ { src: $r("app.media.Switch_App3") },
+ { src: $r("app.media.Switch_App4") },
+ { src: $r("app.media.Switch_App5") },
+ { src: $r("app.media.Switch_App6") },
+ { src: $r("app.media.Switch_App7") },
+ { src: $r("app.media.Switch_App8") },
+ { src: $r("app.media.Switch_App9") },
+ { src: $r("app.media.Switch_App10") },
+ { src: $r("app.media.Switch_App11") },
+ { src: $r("app.media.Switch_App12") },
+ { src: $r("app.media.Switch_App13") },
+ { src: $r("app.media.Switch_App14") },
+ ])
+ .borderRadius(10)
+ .duration(3500)
+ .state(this.stateSwitchApp)
+ .fillMode(FillMode.None)
+ .iterations(this.iterations)
+ .width("100%")
+ .height("100%")
+ .onFinish(() => {
+ this.stateSwitchApp = AnimationStatus.Initial
+ })
+ }
+ .width('30%')
+ .borderRadius(20)
+ .backgroundColor("#66191a32")
+ .height("60%")
+ .onClick(() => {
+ this.stateSwitchApp = AnimationStatus.Running
+ playVibrateCustom("Switch_App.json", this.php)
+ })
+
+ Text($r("app.string.interaction_switch_app"))
+ .fontColor(Color.White)
+ .fontSize(18)
+ }
+
+ Column({ space: 10 }) {
+ Row() {
+ ImageAnimator()
+ .images([
+ { src: $r("app.media.Upslide_Stop1") },
+ { src: $r("app.media.Upslide_Stop2") },
+ { src: $r("app.media.Upslide_Stop3") },
+ { src: $r("app.media.Upslide_Stop4") },
+ { src: $r("app.media.Upslide_Stop5") },
+ { src: $r("app.media.Upslide_Stop6") },
+ { src: $r("app.media.Upslide_Stop7") },
+ { src: $r("app.media.Upslide_Stop8") },
+ { src: $r("app.media.Upslide_Stop9") },
+ { src: $r("app.media.Upslide_Stop10") },
+ { src: $r("app.media.Upslide_Stop11") },
+ { src: $r("app.media.Upslide_Stop12") },
+ ])
+ .borderRadius(10)
+ .duration(3000)
+ .state(this.stateUpSlideStop)
+ .fillMode(FillMode.None)
+ .iterations(this.iterations)
+ .width("100%")
+ .height("100%")
+ .onFinish(() => {
+ this.stateUpSlideStop = AnimationStatus.Initial
+ })
+ }
+ .width('30%')
+ .borderRadius(20)
+ .backgroundColor("#66191a32")
+ .height("60%")
+ .onClick(() => {
+ this.stateUpSlideStop = AnimationStatus.Running
+ playVibrateCustom("UpSlide_Stop.json", this.php)
+ })
+
+ Text($r("app.string.interaction_slide_stop"))
+ .fontColor(Color.White)
+ .fontSize(18)
+ }
+ }
+ .justifyContent(FlexAlign.Center)
+ }
+ .margin({ left: "1%" })
+ .width("100%")
+ }
+ .height('50%')
+ .width("100%")
+ }
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets
index b6107a202df17e256d8bbdfebd457377ec0ff63d..abdc75438ba481c59a40568275ab9d0addc4a339 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Racing.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageRacingList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct RacingLayout {
- @State carList: ImageDataSource = new ImageDataSource(getImageRacingList())
- @State status: boolean[] = [false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $carList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageRacingList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct RacingLayout {
+ @State carList: ImageDataSource = new ImageDataSource(getImageRacingList())
+ @State status: boolean[] = [false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $carList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets
index 9221a66af13a5f19a6794136236c52dcd5d31c1c..fbd517c398968172db75a6974396d3914f4db520 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Realistic.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageRealisticList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct RealisticLayout {
- @State realisticList: ImageDataSource = new ImageDataSource(getImageRealisticList())
- @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $realisticList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageRealisticList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct RealisticLayout {
+ @State realisticList: ImageDataSource = new ImageDataSource(getImageRealisticList())
+ @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $realisticList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets
index 524769f6e64f6eceac881c2ec59f45d36291832b..ccf7589d02dea457a098d9ed3da0d6653a78d704 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/Shooting.ets
@@ -1,34 +1,34 @@
-/*
- * Copyright (c) 2023 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 { getImageShootList, ImageDataSource } from '../module/ImageData'
-import CommonLayout from './Common'
-
-@Component
-export default struct ShootLayout {
- @State shootList: ImageDataSource = new ImageDataSource(getImageShootList())
- @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false]
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- CommonLayout({
- dataList: $shootList,
- status: $status,
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- }
-}
+/*
+ * Copyright (c) 2023 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 { getImageShootList, ImageDataSource } from '../module/ImageData'
+import CommonLayout from './Common'
+
+@Component
+export default struct ShootLayout {
+ @State shootList: ImageDataSource = new ImageDataSource(getImageShootList())
+ @State status: boolean[] = [false, false, false, false, false, false, false, false, false, false, false, false, false]
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ CommonLayout({
+ dataList: $shootList,
+ status: $status,
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets
index 2e0e970b7cd3a59a1e1385fe1314a5338064b87a..8bf3176ad31c08662c8dda94d7bc90dc05ddbacd 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/component/VideoPreview.ets
@@ -1,58 +1,58 @@
-/*
- * Copyright (c) 2023 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 router from '@ohos.router'
-
-@Component
-export default struct VideoListLayout {
- @State playDis: boolean = false
- @Link php: string
-
- build() {
- Scroll() {
- Row({ space: 10 }) {
- Stack() {
- Image($r("app.media.HapticVideoPreview"))
- .width("100%")
- .height("100%")
- .borderRadius(10)
- Image($r("app.media.player2"))
- .width("30%")
- .height("30%")
- .visibility(this.playDis ? Visibility.Hidden : Visibility.Visible)
- }
- .id("videoPreview")
- .width("95%")
- .height("30%")
- .onClick(() => {
- this.playDis = true
- router.pushUrl({
- url: "module/VideoPlayModule",
- params: {
- vibrateFileName: "HapticVideo.json",
- videoName: 'HapticVideo',
- videoSrc: $r("app.media.HapticVideo"),
- previewUri: $r("app.media.HapticVideoPreview"),
- pages: "Index",
- php: this.php
- }
- })
- })
- .padding({ left: 10 })
- }
- }
- .scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
- }
-}
+/*
+ * Copyright (c) 2023 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 router from '@ohos.router'
+
+@Component
+export default struct VideoListLayout {
+ @State playDis: boolean = false
+ @Link php: string
+
+ build() {
+ Scroll() {
+ Row({ space: 10 }) {
+ Stack() {
+ Image($r("app.media.HapticVideoPreview"))
+ .width("100%")
+ .height("100%")
+ .borderRadius(10)
+ Image($r("app.media.player2"))
+ .width("30%")
+ .height("30%")
+ .visibility(this.playDis ? Visibility.Hidden : Visibility.Visible)
+ }
+ .id("videoPreview")
+ .width("95%")
+ .height("30%")
+ .onClick(() => {
+ this.playDis = true
+ router.pushUrl({
+ url: "module/VideoPlayModule",
+ params: {
+ vibrateFileName: "HapticVideo.json",
+ videoName: 'HapticVideo',
+ videoSrc: $r("app.media.HapticVideo"),
+ previewUri: $r("app.media.HapticVideoPreview"),
+ pages: "Index",
+ php: this.php
+ }
+ })
+ })
+ .padding({ left: 10 })
+ }
+ }
+ .scrollable(ScrollDirection.Horizontal).scrollBar(BarState.Off)
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts
index d30b8cd46bc9fd93e70e6b01935bd1398a0f2cf4..63f68c7013aa83921a7327e05086450f8ae90c00 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/entryability/EntryAbility.ts
@@ -1,74 +1,74 @@
-/*
- * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility';
-import type Window from '@ohos.window';
-import vibrator from '@ohos.vibrator';
-import Logger from '../module/Logger';
-
-const TAG = '[EntryAbility]';
-
-export default class EntryAbility extends Ability {
- onCreate(want, launchParam) {
- Logger.info(TAG, 'Ability onCreate, want param: %{public}s, launchParam: %{public}s',
- JSON.stringify(want) ?? '', JSON.stringify(launchParam) ?? '');
-
- vibrator.isSupportEffect('haptic.clock.timer', (error, data) => {
- if (data) {
- vibrator.startVibration({
- type: 'preset',
- effectId: 'haptic.clock.timer',
- count: 1,
- }, {
- usage: 'notification'
- });
- } else {
- Logger.info(TAG, 'Failed to vibrate onCreate');
- }
- });
- }
-
- onDestroy() {
- Logger.info(TAG, 'Ability onDestroy');
- }
-
- onWindowStageCreate(windowStage: Window.WindowStage) {
- // Main window is created, set main page for this ability
- Logger.info(TAG, 'Ability onWindowStageCreate');
-
- windowStage.loadContent('pages/Index', (err, data) => {
- if (err.code) {
- Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
- return;
- }
- Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
- });
- }
-
- onWindowStageDestroy() {
- // Main window is destroyed, release UI related resources
- Logger.info(TAG, '%{public}s', 'Ability onWindowStageDestroy');
- }
-
- onForeground() {
- // Ability has brought to foreground
- Logger.info(TAG, '%{public}s', 'Ability onForeground');
- }
-
- onBackground() {
- // Ability has back to background
- Logger.info(TAG, '%{public}s', 'Ability onBackground');
- }
-}
+/*
+ * Copyright (c) 2023 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 Ability from '@ohos.app.ability.UIAbility';
+import type Window from '@ohos.window';
+import vibrator from '@ohos.vibrator';
+import Logger from '../module/Logger';
+
+const TAG = '[EntryAbility]';
+
+export default class EntryAbility extends Ability {
+ onCreate(want, launchParam) {
+ Logger.info(TAG, 'Ability onCreate, want param: %{public}s, launchParam: %{public}s',
+ JSON.stringify(want) ?? '', JSON.stringify(launchParam) ?? '');
+
+ vibrator.isSupportEffect('haptic.clock.timer', (error, data) => {
+ if (data) {
+ vibrator.startVibration({
+ type: 'preset',
+ effectId: 'haptic.clock.timer',
+ count: 1,
+ }, {
+ usage: 'notification'
+ });
+ } else {
+ Logger.info(TAG, 'Failed to vibrate onCreate');
+ }
+ });
+ }
+
+ onDestroy() {
+ Logger.info(TAG, 'Ability onDestroy');
+ }
+
+ onWindowStageCreate(windowStage: Window.WindowStage) {
+ // Main window is created, set main page for this ability
+ Logger.info(TAG, 'Ability onWindowStageCreate');
+
+ windowStage.loadContent('pages/Index', (err, data) => {
+ if (err.code) {
+ Logger.error(TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
+ return;
+ }
+ Logger.info(TAG, 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
+ });
+ }
+
+ onWindowStageDestroy() {
+ // Main window is destroyed, release UI related resources
+ Logger.info(TAG, '%{public}s', 'Ability onWindowStageDestroy');
+ }
+
+ onForeground() {
+ // Ability has brought to foreground
+ Logger.info(TAG, '%{public}s', 'Ability onForeground');
+ }
+
+ onBackground() {
+ // Ability has back to background
+ Logger.info(TAG, '%{public}s', 'Ability onBackground');
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets
index d54b9e410a276e823f7a7b21c561f4d9a7a82d68..dfb985fa149f3709ce064510724761904b8c8d03 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/DisplayModule.ets
@@ -1,191 +1,191 @@
-/*
- * Copyright (c) 2023 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 router from '@ohos.router'
-import VideoListLayout from '../component/VideoPreview'
-import RacingLayout from '../component/Racing'
-import BattleLayout from '../component/Battle'
-import ShootLayout from '../component/Shooting'
-import InstrumentLayout from '../component/Instrument'
-import RealisticLayout from '../component/Realistic'
-import FootstepLayout from '../component/Footstep'
-import EnvironmentLayout from '../component/Environment'
-import ExerciseLayout from '../component/Exercise'
-import InteractionLayout from '../component/Interaction'
-import Logger from './Logger'
-import TabBar from './TabBar'
-
-const TAG = '[DisplayModule]'
-
-export enum TabIndex {
- RACING = 0,
- BATTLE,
- SHOOT,
- INSTRUMENT,
- REALISTIC,
- FOOTSTEP,
- ENVIRONMENT,
- EXERCISE,
- INTERACTION,
-}
-
-@Component
-export default struct DisplayModule {
- @State titleArr: Resource[] = [
- $r("app.string.display_racing"), $r("app.string.display_battle"), $r("app.string.display_shoot"),
- $r("app.string.display_instrument"), $r("app.string.display_realistic"), $r("app.string.display_footstep"),
- $r("app.string.display_environment"), $r("app.string.display_exercise"), $r("app.string.display_interaction")
- ]
- @State currentIndex: number = 0
- private swiperController: SwiperController = new SwiperController()
- private tabHeight = 50
- @State playDis: boolean = false
- @Link vibrationIntensity: string
- @Link php: string
- private controller: TabsController = new TabsController();
-
- build() {
- Column({ space: 10 }) {
- Row() {
- Text($r("app.string.display_haptic_video"))
- .width('50%')
- .fontSize(24)
- .fontColor('#ffffffff')
- .fontWeight(FontWeight.Normal)
- .textAlign(TextAlign.Start)
- .layoutWeight(7)
- .padding({ left: 10 })
- Button($r("app.string.display_show_more"))
- .id('showMore')
- .backgroundColor("#00d613ca")
- .layoutWeight(3)
- .height(35)
- .fontColor('#919191')
- .onClick(() => {
- Logger.info(TAG, 'Show more pressed')
- router.pushUrl({
- url: 'module/VideoListModule',
- params: {php: this.php}
- })
- })
- }
- .padding({ top: 5 })
-
- VideoListLayout({php: $php})
-
- Text($r("app.string.display_haptic_library"))
- .width('100%')
- .fontSize(24)
- .fontColor('#ffffffff')
- .fontWeight(FontWeight.Normal)
- .textAlign(TextAlign.Start)
- .padding({ left: 10 })
-
- Row() {
- TabBar({
- titleArr: $titleArr,
- currentIndex: $currentIndex,
- tabSelected: (position: number, title: string) => {
- this.currentIndex = position
- Logger.info(TAG, 'onTabSelected position = ' + position + ', title = ' + title)
- this.swiperController.showNext()
- },
- })
- }
- .width('100%')
- .height(this.tabHeight)
- .zIndex(10)
-
- Scroll() {
- Column() {
- Swiper(this.swiperController) {
- ForEach(this.titleArr, (item: string) => {
- Column() {
- if (this.currentIndex === TabIndex.RACING) {
- RacingLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.BATTLE) {
- BattleLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.SHOOT) {
- ShootLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.INSTRUMENT) {
- InstrumentLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.REALISTIC) {
- RealisticLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.FOOTSTEP) {
- FootstepLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.ENVIRONMENT) {
- EnvironmentLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.EXERCISE) {
- ExerciseLayout({
- vibrationIntensity: $vibrationIntensity,
- php: $php
- })
- } else if (this.currentIndex === TabIndex.INTERACTION) {
- InteractionLayout({
- php: $php
- })
- } else {
- Text('Please Waiting!')
- .fontSize(48)
- .fontColor(Color.Black)
- .width("100%")
- .height("100%")
- }
- }
- }, (item: string) => item)
- }
- .index(0)
- .autoPlay(false)
- .indicator(false)
- .loop(false)
- .vertical(false)
- .itemSpace(0)
- .index(this.currentIndex)
- .flexGrow(1)
- .width('100%')
- .onChange((index: number) => {
- Logger.info(TAG, index.toString())
- this.currentIndex = index
- })
- }
- }
- .scrollBar(BarState.Off)
- }
- .width('100%')
- .height('100%')
- .backgroundColor('#f2191a32')
- }
-}
+/*
+ * Copyright (c) 2023 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 router from '@ohos.router'
+import VideoListLayout from '../component/VideoPreview'
+import RacingLayout from '../component/Racing'
+import BattleLayout from '../component/Battle'
+import ShootLayout from '../component/Shooting'
+import InstrumentLayout from '../component/Instrument'
+import RealisticLayout from '../component/Realistic'
+import FootstepLayout from '../component/Footstep'
+import EnvironmentLayout from '../component/Environment'
+import ExerciseLayout from '../component/Exercise'
+import InteractionLayout from '../component/Interaction'
+import Logger from './Logger'
+import TabBar from './TabBar'
+
+const TAG = '[DisplayModule]'
+
+export enum TabIndex {
+ RACING = 0,
+ BATTLE,
+ SHOOT,
+ INSTRUMENT,
+ REALISTIC,
+ FOOTSTEP,
+ ENVIRONMENT,
+ EXERCISE,
+ INTERACTION,
+}
+
+@Component
+export default struct DisplayModule {
+ @State titleArr: Resource[] = [
+ $r("app.string.display_racing"), $r("app.string.display_battle"), $r("app.string.display_shoot"),
+ $r("app.string.display_instrument"), $r("app.string.display_realistic"), $r("app.string.display_footstep"),
+ $r("app.string.display_environment"), $r("app.string.display_exercise"), $r("app.string.display_interaction")
+ ]
+ @State currentIndex: number = 0
+ private swiperController: SwiperController = new SwiperController()
+ private tabHeight = 50
+ @State playDis: boolean = false
+ @Link vibrationIntensity: string
+ @Link php: string
+ private controller: TabsController = new TabsController();
+
+ build() {
+ Column({ space: 10 }) {
+ Row() {
+ Text($r("app.string.display_haptic_video"))
+ .width('50%')
+ .fontSize(24)
+ .fontColor('#ffffffff')
+ .fontWeight(FontWeight.Normal)
+ .textAlign(TextAlign.Start)
+ .layoutWeight(7)
+ .padding({ left: 10 })
+ Button($r("app.string.display_show_more"))
+ .id('showMore')
+ .backgroundColor("#00d613ca")
+ .layoutWeight(3)
+ .height(35)
+ .fontColor('#919191')
+ .onClick(() => {
+ Logger.info(TAG, 'Show more pressed')
+ router.pushUrl({
+ url: 'module/VideoListModule',
+ params: {php: this.php}
+ })
+ })
+ }
+ .padding({ top: 5 })
+
+ VideoListLayout({php: $php})
+
+ Text($r("app.string.display_haptic_library"))
+ .width('100%')
+ .fontSize(24)
+ .fontColor('#ffffffff')
+ .fontWeight(FontWeight.Normal)
+ .textAlign(TextAlign.Start)
+ .padding({ left: 10 })
+
+ Row() {
+ TabBar({
+ titleArr: $titleArr,
+ currentIndex: $currentIndex,
+ tabSelected: (position: number, title: string) => {
+ this.currentIndex = position
+ Logger.info(TAG, 'onTabSelected position = ' + position + ', title = ' + title)
+ this.swiperController.showNext()
+ },
+ })
+ }
+ .width('100%')
+ .height(this.tabHeight)
+ .zIndex(10)
+
+ Scroll() {
+ Column() {
+ Swiper(this.swiperController) {
+ ForEach(this.titleArr, (item: string) => {
+ Column() {
+ if (this.currentIndex === TabIndex.RACING) {
+ RacingLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.BATTLE) {
+ BattleLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.SHOOT) {
+ ShootLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.INSTRUMENT) {
+ InstrumentLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.REALISTIC) {
+ RealisticLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.FOOTSTEP) {
+ FootstepLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.ENVIRONMENT) {
+ EnvironmentLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.EXERCISE) {
+ ExerciseLayout({
+ vibrationIntensity: $vibrationIntensity,
+ php: $php
+ })
+ } else if (this.currentIndex === TabIndex.INTERACTION) {
+ InteractionLayout({
+ php: $php
+ })
+ } else {
+ Text('Please Waiting!')
+ .fontSize(48)
+ .fontColor(Color.Black)
+ .width("100%")
+ .height("100%")
+ }
+ }
+ }, (item: string) => item)
+ }
+ .index(0)
+ .autoPlay(false)
+ .indicator(false)
+ .loop(false)
+ .vertical(false)
+ .itemSpace(0)
+ .index(this.currentIndex)
+ .flexGrow(1)
+ .width('100%')
+ .onChange((index: number) => {
+ Logger.info(TAG, index.toString())
+ this.currentIndex = index
+ })
+ }
+ }
+ .scrollBar(BarState.Off)
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor('#f2191a32')
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets
index 2c1d532df3e4610b18adb3bf698837be5143fdf2..5b205c8d05672fb34dbff9fd931affa1acceddcb 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/ImageData.ets
@@ -1,730 +1,730 @@
-/*
- * Copyright (c) 2023 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 class ImagesData {
- id ?: number
- src ?: Resource
- name ?: Resource
- vibratorFileL ?: string
- vibratorFileM ?: string
- vibratorFileH ?: string
- audioName ?: string
-}
-
-export function getImageRacingList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Racing1"),
- name: $r("app.string.display_racing_car_crash"),
- vibratorFileL: "CarCrash_l.json",
- vibratorFileM: "CarCrash_m.json",
- vibratorFileH: "CarCrash_h.json",
- audioName: "CarCrash.wav"
- },
- {
- id: 1,
- src: $r("app.media.Racing2"),
- name: $r("app.string.display_racing_ignite"),
- vibratorFileL: "CarIgnite_l.json",
- vibratorFileM: "CarIgnite_m.json",
- vibratorFileH: "CarIgnite_h.json",
- audioName: "CarIgnite.wav"
- },
- {
- id: 2,
- src: $r("app.media.Racing3"),
- name: $r("app.string.display_racing_skid"),
- vibratorFileL: "CarSkid_l.json",
- vibratorFileM: "CarSkid_m.json",
- vibratorFileH: "CarSkid_h.json",
- audioName: "CarSkid.wav"
- },
- {
- id: 3,
- src: $r("app.media.Racing4"),
- name: $r("app.string.display_racing_drifting_jet"),
- vibratorFileL: "DriftingJet_l.json",
- vibratorFileM: "DriftingJet_m.json",
- vibratorFileH: "DriftingJet_h.json",
- audioName: "DriftingJet.wav"
- },
- {
- id: 4,
- src: $r("app.media.Racing5"),
- name: $r("app.string.display_racing_jet_n2o"),
- vibratorFileL: "JetN2O_l.json",
- vibratorFileM: "JetN2O_m.json",
- vibratorFileH: "JetN2O_h.json",
- audioName: "JetN2O.wav"
- },
- {
- id: 5,
- src: $r("app.media.Racing6"),
- name: $r("app.string.display_racing_start"),
- vibratorFileL: "RacingStart_l.json",
- vibratorFileM: "RacingStart_m.json",
- vibratorFileH: "RacingStart_h.json",
- audioName: "RacingStart.wav"
- },
- {
- id: 6,
- src: $r("app.media.Racing8"),
- name: $r("app.string.display_racing_speed_up"),
- vibratorFileL: "SpeedUp_l.json",
- vibratorFileM: "SpeedUp_m.json",
- vibratorFileH: "SpeedUp_h.json",
- audioName: "SpeedUp.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageBattleList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Battle7"),
- name: $r("app.string.display_battle_tumble"),
- vibratorFileL: "Tumble_l.json",
- vibratorFileM: "Tumble_m.json",
- vibratorFileH: "Tumble_h.json",
- audioName: "Tumble.wav"
- },
- {
- id: 1,
- src: $r("app.media.Battle2"),
- name: $r("app.string.display_battle_punch"),
- vibratorFileL: "Punch_l.json",
- vibratorFileM: "Punch_m.json",
- vibratorFileH: "Punch_h.json",
- audioName: "Punch.wav"
- },
- {
- id: 2,
- src: $r("app.media.Battle3"),
- name: $r("app.string.display_battle_kick"),
- vibratorFileL: "Kick_l.json",
- vibratorFileM: "Kick_m.json",
- vibratorFileH: "Kick_h.json",
- audioName: "Kick.wav"
- },
- {
- id: 3,
- src: $r("app.media.Battle4"),
- name: $r("app.string.display_battle_hurt"),
- vibratorFileL: "Hurt_l.json",
- vibratorFileM: "Hurt_m.json",
- vibratorFileH: "Hurt_h.json",
- audioName: "Hurt.wav"
- },
- {
- id: 4,
- src: $r("app.media.Battle5"),
- name: $r("app.string.display_battle_blast"),
- vibratorFileL: "Blast_l.json",
- vibratorFileM: "Blast_m.json",
- vibratorFileH: "Blast_h.json",
- audioName: "Blast.wav"
- },
- {
- id: 5,
- src: $r("app.media.Battle6"),
- name: $r("app.string.display_battle_bomb"),
- vibratorFileL: "Bomb_l.json",
- vibratorFileM: "Bomb_m.json",
- vibratorFileH: "Bomb_h.json",
- audioName: "Bomb.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageShootList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.AK47"),
- name: $r("app.string.display_shoot_AK47"),
- vibratorFileL: "AK47_l.json",
- vibratorFileM: "AK47_m.json",
- vibratorFileH: "AK47_h.json",
- audioName: "AK47.wav"
- },
- {
- id: 1,
- src: $r("app.media.HK416"),
- name: $r("app.string.display_shoot_HK416"),
- vibratorFileL: "HK416_l.json",
- vibratorFileM: "HK416_m.json",
- vibratorFileH: "HK416_h.json",
- audioName: "HK416.wav"
- },
- {
- id: 2,
- src: $r("app.media.M4"),
- name: $r("app.string.display_shoot_M4"),
- vibratorFileL: "M4_l.json",
- vibratorFileM: "M4_m.json",
- vibratorFileH: "M4_h.json",
- audioName: "M4.wav"
- },
- {
- id: 3,
- src: $r("app.media.MP5"),
- name: $r("app.string.display_shoot_MP5"),
- vibratorFileL: "MP5_l.json",
- vibratorFileM: "MP5_m.json",
- vibratorFileH: "MP5_h.json",
- audioName: "MP5.wav"
- },
- {
- id: 4,
- src: $r("app.media.CZ75"),
- name: $r("app.string.display_shoot_CZ75"),
- vibratorFileL: "CZ75_l.json",
- vibratorFileM: "CZ75_m.json",
- vibratorFileH: "CZ75_h.json",
- audioName: "CZ75.wav"
- },
- {
- id: 5,
- src: $r("app.media.Winchester"),
- name: $r("app.string.display_shoot_winchester"),
- vibratorFileL: "Winchester_l.json",
- vibratorFileM: "Winchester_m.json",
- vibratorFileH: "Winchester_h.json",
- audioName: "Winchester.wav"
- },
- {
- id: 6,
- src: $r("app.media.Rifle"),
- name: $r("app.string.display_shoot_rifle"),
- vibratorFileL: "Rifle_l.json",
- vibratorFileM: "Rifle_m.json",
- vibratorFileH: "Rifle_h.json",
- audioName: "Rifle.wav"
- },
- {
- id: 7,
- src: $r("app.media.AssaultRifle"),
- name: $r("app.string.display_shoot_assault_rifle"),
- vibratorFileL: "AssaultRifle_l.json",
- vibratorFileM: "AssaultRifle_m.json",
- vibratorFileH: "AssaultRifle_h.json",
- audioName: "AssaultRifle.wav"
- },
- {
- id: 8,
- src: $r("app.media.HitSand"),
- name: $r("app.string.display_shoot_hit_sand"),
- vibratorFileL: "HitSand_l.json",
- vibratorFileM: "HitSand_m.json",
- vibratorFileH: "HitSand_h.json",
- audioName: "HitSand.wav"
- },
- {
- id: 9,
- src: $r("app.media.HitWater"),
- name: $r("app.string.display_shoot_hit_water"),
- vibratorFileL: "HitWater_l.json",
- vibratorFileM: "HitWater_m.json",
- vibratorFileH: "HitWater_h.json",
- audioName: "HitWater.wav"
- },
- {
- id: 10,
- src: $r("app.media.HitMetal"),
- name: $r("app.string.display_shoot_hit_metal"),
- vibratorFileL: "HitMetal_l.json",
- vibratorFileM: "HitMetal_m.json",
- vibratorFileH: "HitMetal_h.json",
- audioName: "HitMetal.wav"
- },
- {
- id: 11,
- src: $r("app.media.HitWood"),
- name: $r("app.string.display_shoot_hit_wood"),
- vibratorFileL: "HitWood_l.json",
- vibratorFileM: "HitWood_m.json",
- vibratorFileH: "HitWood_h.json",
- audioName: "HitWood.wav"
- },
- {
- id: 12,
- src: $r("app.media.HitGlass"),
- name: $r("app.string.display_shoot_hit_glass"),
- vibratorFileL: "HitGlass_l.json",
- vibratorFileM: "HitGlass_m.json",
- vibratorFileH: "HitGlass_h.json",
- audioName: "HitGlass.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageInstrumentsList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Cymbals"),
- name: $r("app.string.display_instrument_cymbals"),
- vibratorFileL: "Cymbals_l.json",
- vibratorFileM: "Cymbals_m.json",
- vibratorFileH: "Cymbals_h.json",
- audioName: "Cymbals.wav"
- },
- {
- id: 1,
- src: $r("app.media.Cymbals2"),
- name: $r("app.string.display_instrument_cymbals2"),
- vibratorFileL: "Cymbals2_l.json",
- vibratorFileM: "Cymbals2_m.json",
- vibratorFileH: "Cymbals2_h.json",
- audioName: "Cymbals2.wav"
- },
- {
- id: 2,
- src: $r("app.media.KickDrum"),
- name: $r("app.string.display_instrument_kick_drum"),
- vibratorFileL: "KickDrum_l.json",
- vibratorFileM: "KickDrum_m.json",
- vibratorFileH: "KickDrum_h.json",
- audioName: "KickDrum.wav"
- },
- {
- id: 3,
- src: $r("app.media.KickDrum2"),
- name: $r("app.string.display_instrument_kick_drum2"),
- vibratorFileL: "KickDrum2_l.json",
- vibratorFileM: "KickDrum2_m.json",
- vibratorFileH: "KickDrum2_h.json",
- audioName: "KickDrum2.wav"
- },
- {
- id: 4,
- src: $r("app.media.Guitar"),
- name: $r("app.string.display_instrument_guitar"),
- vibratorFileL: "Guitar_l.json",
- vibratorFileM: "Guitar_m.json",
- vibratorFileH: "Guitar_h.json",
- audioName: "Guitar.wav"
- },
- {
- id: 5,
- src: $r("app.media.Tambourine"),
- name: $r("app.string.display_instrument_tambourine"),
- vibratorFileL: "Tambourine_l.json",
- vibratorFileM: "Tambourine_m.json",
- vibratorFileH: "Tambourine_h.json",
- audioName: "Tambourine.wav"
- },
- {
- id: 6,
- src: $r("app.media.Bell"),
- name: $r("app.string.display_instrument_bell"),
- vibratorFileL: "bell_l.json",
- vibratorFileM: "bell_m.json",
- vibratorFileH: "bell_h.json",
- audioName: "bell.wav"
- },
- {
- id: 7,
- src: $r("app.media.Claves"),
- name: $r("app.string.display_instrument_claves"),
- vibratorFileL: "Claves_l.json",
- vibratorFileM: "Claves_m.json",
- vibratorFileH: "Claves_h.json",
- audioName: "Claves.wav"
- },
- {
- id: 8,
- src: $r("app.media.Gong"),
- name: $r("app.string.display_instrument_gong"),
- vibratorFileL: "Gong_l.json",
- vibratorFileM: "Gong_m.json",
- vibratorFileH: "Gong_h.json",
- audioName: "Gong.wav"
- },
- {
- id: 9,
- src: $r("app.media.Triangle"),
- name: $r("app.string.display_instrument_triangle"),
- vibratorFileL: "triangle_l.json",
- vibratorFileM: "triangle_m.json",
- vibratorFileH: "triangle_h.json",
- audioName: "triangle.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageRealisticList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Ice"),
- name: $r("app.string.display_realistic_ice"),
- vibratorFileL: "ice_l.json",
- vibratorFileM: "ice_m.json",
- vibratorFileH: "ice_h.json",
- audioName: "ice.wav"
- },
- {
- id: 1,
- src: $r("app.media.Keyboard"),
- name: $r("app.string.display_realistic_keyboard"),
- vibratorFileL: "Keyboard_l.json",
- vibratorFileM: "Keyboard_m.json",
- vibratorFileH: "Keyboard_h.json",
- audioName: "Keyboard.wav"
- },
- {
- id: 2,
- src: $r("app.media.Typewriter"),
- name: $r("app.string.display_realistic_typewriter"),
- vibratorFileL: "Typewriter_l.json",
- vibratorFileM: "Typewriter_m.json",
- vibratorFileH: "Typewriter_h.json",
- audioName: "Typewriter.wav"
- },
- {
- id: 3,
- src: $r("app.media.CoinDrop"),
- name: $r("app.string.display_realistic_coin_drop"),
- vibratorFileL: "CoinDrop_l.json",
- vibratorFileM: "CoinDrop_m.json",
- vibratorFileH: "CoinDrop_h.json",
- audioName: "CoinDrop.wav"
- },
- {
- id: 4,
- src: $r("app.media.Timer"),
- name: $r("app.string.display_realistic_timer"),
- vibratorFileL: "timer_l.json",
- vibratorFileM: "timer_m.json",
- vibratorFileH: "timer_h.json",
- audioName: "timer.wav"
- },
- {
- id: 5,
- src: $r("app.media.Walk"),
- name: $r("app.string.display_realistic_walk"),
- vibratorFileL: "Walk_l.json",
- vibratorFileM: "Walk_m.json",
- vibratorFileH: "Walk_h.json",
- audioName: "Walk.wav"
- },
- {
- id: 6,
- src: $r("app.media.camerashutter"),
- name: $r("app.string.display_realistic_camerashutter"),
- vibratorFileL: "camerashutter_l.json",
- vibratorFileM: "camerashutter_m.json",
- vibratorFileH: "camerashutter_h.json",
- audioName: "camerashutter.wav"
- },
- {
- id: 7,
- src: $r("app.media.camerashutter2"),
- name: $r("app.string.display_realistic_camerashutter2"),
- vibratorFileL: "camerashutter2_l.json",
- vibratorFileM: "camerashutter2_m.json",
- vibratorFileH: "camerashutter2_h.json",
- audioName: "camerashutter2.wav"
- },
- {
- id: 8,
- src: $r("app.media.Clock"),
- name: $r("app.string.display_realistic_clock"),
- vibratorFileL: "clock_l.json",
- vibratorFileM: "clock_m.json",
- vibratorFileH: "clock_h.json",
- audioName: "clock.wav"
- },
- {
- id: 9,
- src: $r("app.media.Water"),
- name: $r("app.string.display_realistic_water"),
- vibratorFileL: "Water_l.json",
- vibratorFileM: "Water_m.json",
- vibratorFileH: "Water_h.json",
- audioName: "Water.wav"
- },
- {
- id: 10,
- src: $r("app.media.heartbeat"),
- name: $r("app.string.display_realistic_heartbeat"),
- vibratorFileL: "heartbeat_l.json",
- vibratorFileM: "heartbeat_m.json",
- vibratorFileH: "heartbeat_h.json",
- audioName: "heartbeat.wav"
- },
- {
- id: 11,
- src: $r("app.media.Firework"),
- name: $r("app.string.display_realistic_firework"),
- vibratorFileL: "Firework_l.json",
- vibratorFileM: "Firework_m.json",
- vibratorFileH: "Firework_h.json",
- audioName: "Firework.wav"
- },
- {
- id: 12,
- src: $r("app.media.Picker"),
- name: $r("app.string.display_realistic_picker"),
- vibratorFileL: "Picker_l.json",
- vibratorFileM: "Picker_m.json",
- vibratorFileH: "Picker_h.json",
- audioName: "Picker.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageFootstepList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Footstep1"),
- name: $r("app.string.display_footstep_on_carpet"),
- vibratorFileL: "OnCarpet_l.json",
- vibratorFileM: "OnCarpet_m.json",
- vibratorFileH: "OnCarpet_h.json",
- audioName: "OnCarpet.wav"
- },
- {
- id: 1,
- src: $r("app.media.Footstep2"),
- name: $r("app.string.display_footstep_on_concrete"),
- vibratorFileL: "OnConcrete_l.json",
- vibratorFileM: "OnConcrete_m.json",
- vibratorFileH: "OnConcrete_h.json",
- audioName: "OnConcrete.wav"
- },
- {
- id: 2,
- src: $r("app.media.Footstep3"),
- name: $r("app.string.display_footstep_on_grass"),
- vibratorFileL: "OnGrass_l.json",
- vibratorFileM: "OnGrass_m.json",
- vibratorFileH: "OnGrass_h.json",
- audioName: "OnGrass.wav"
- },
- {
- id: 3,
- src: $r("app.media.Footstep4"),
- name: $r("app.string.display_footstep_on_board"),
- vibratorFileL: "OnWood_l.json",
- vibratorFileM: "OnWood_m.json",
- vibratorFileH: "OnWood_h.json",
- audioName: "OnWood.wav"
- },
- {
- id: 4,
- src: $r("app.media.Footstep5"),
- name: $r("app.string.display_footstep_on_gravel"),
- vibratorFileL: "OnGravel_l.json",
- vibratorFileM: "OnGravel_m.json",
- vibratorFileH: "OnGravel_h.json",
- audioName: "OnGravel.wav"
- },
- {
- id: 5,
- src: $r("app.media.Footstep6"),
- name: $r("app.string.display_footstep_on_mud"),
- vibratorFileL: "OnMud_l.json",
- vibratorFileM: "OnMud_m.json",
- vibratorFileH: "OnMud_h.json",
- audioName: "OnMud.wav"
- },
- {
- id: 6,
- src: $r("app.media.Footstep7"),
- name: $r("app.string.display_footstep_on_snow"),
- vibratorFileL: "OnSnow_l.json",
- vibratorFileM: "OnSnow_m.json",
- vibratorFileH: "OnSnow_h.json",
- audioName: "OnSnow.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageEnvironmentList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Rain"),
- name: $r("app.string.display_environment_rain"),
- vibratorFileL: "Rain_l.json",
- vibratorFileM: "Rain_m.json",
- vibratorFileH: "Rain_h.json",
- audioName: "Rain.wav"
- },
- {
- id: 1,
- src: $r("app.media.Snowdrift"),
- name: $r("app.string.display_environment_snowdrift"),
- vibratorFileL: "Snowdrift_l.json",
- vibratorFileM: "Snowdrift_m.json",
- vibratorFileH: "Snowdrift_h.json",
- audioName: "Snowdrift.wav"
- },
- {
- id: 2,
- src: $r("app.media.Campfire"),
- name: $r("app.string.display_environment_campfire"),
- vibratorFileL: "Campfire_l.json",
- vibratorFileM: "Campfire_m.json",
- vibratorFileH: "Campfire_h.json",
- audioName: "Campfire.wav"
- },
- {
- id: 3,
- src: $r("app.media.Creek"),
- name: $r("app.string.display_environment_creek"),
- vibratorFileL: "Creek_l.json",
- vibratorFileM: "Creek_m.json",
- vibratorFileH: "Creek_h.json",
- audioName: "Creek.wav"
- },
- {
- id: 4,
- src: $r("app.media.Wave"),
- name: $r("app.string.display_environment_wave"),
- vibratorFileL: "Wave_l.json",
- vibratorFileM: "Wave_m.json",
- vibratorFileH: "Wave_h.json",
- audioName: "Wave.wav"
- },
- {
- id: 5,
- src: $r("app.media.Wind"),
- name: $r("app.string.display_environment_wind"),
- vibratorFileL: "Wind_l.json",
- vibratorFileM: "Wind_m.json",
- vibratorFileH: "Wind_h.json",
- audioName: "Wind.wav"
- },
- {
- id: 6,
- src: $r("app.media.Thunder"),
- name: $r("app.string.display_environment_thunder"),
- vibratorFileL: "Thunder_l.json",
- vibratorFileM: "Thunder_m.json",
- vibratorFileH: "Thunder_h.json",
- audioName: "Thunder.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export function getImageExerciseList(): Array {
- let ImagesDataArray: Array = [
- {
- id: 0,
- src: $r("app.media.Badminton"),
- name: $r("app.string.display_exercise_badminton"),
- vibratorFileL: "Badminton_l.json",
- vibratorFileM: "Badminton_m.json",
- vibratorFileH: "Badminton_h.json",
- audioName: "Badminton.wav"
- },
- {
- id: 1,
- src: $r("app.media.Baseball"),
- name: $r("app.string.display_exercise_baseball"),
- vibratorFileL: "Baseball_l.json",
- vibratorFileM: "Baseball_m.json",
- vibratorFileH: "Baseball_h.json",
- audioName: "Baseball.wav"
- },
- {
- id: 2,
- src: $r("app.media.Basketball"),
- name: $r("app.string.display_exercise_basketball"),
- vibratorFileL: "Basketball_l.json",
- vibratorFileM: "Basketball_m.json",
- vibratorFileH: "Basketball_h.json",
- audioName: "Basketball.wav"
- },
- {
- id: 3,
- src: $r("app.media.Skating"),
- name: $r("app.string.display_exercise_skating"),
- vibratorFileL: "Skating_l.json",
- vibratorFileM: "Skating_m.json",
- vibratorFileH: "Skating_h.json",
- audioName: "Skating.wav"
- },
- {
- id: 4,
- src: $r("app.media.Skiing"),
- name: $r("app.string.display_exercise_skiing"),
- vibratorFileL: "Skiing_l.json",
- vibratorFileM: "Skiing_m.json",
- vibratorFileH: "Skiing_h.json",
- audioName: "Skiing.wav"
- },
- {
- id: 5,
- src: $r("app.media.TableTennis"),
- name: $r("app.string.display_exercise_tabletennis"),
- vibratorFileL: "TableTennis_l.json",
- vibratorFileM: "TableTennis_m.json",
- vibratorFileH: "TableTennis_h.json",
- audioName: "TableTennis.wav"
- },
- {
- id: 6,
- src: $r("app.media.Diving"),
- name: $r("app.string.display_exercise_diving"),
- vibratorFileL: "Diving_l.json",
- vibratorFileM: "Diving_m.json",
- vibratorFileH: "Diving_h.json",
- audioName: "Diving.wav"
- },
- ]
- return ImagesDataArray;
-}
-
-export abstract class BaseDataSource implements IDataSource {
- private mDataSource: T[] = [];
-
- constructor(dataList: T[]) {
- this.mDataSource = dataList;
- }
-
- totalCount(): number {
- return this.mDataSource === null ? 0 : this.mDataSource.length
- }
-
- getData(index: number): T | null {
- return index >= 0 && index < this.totalCount() ? this.mDataSource[index] : null;
- }
-
- registerDataChangeListener(listener: DataChangeListener) {
- }
-
- unregisterDataChangeListener(listener: DataChangeListener) {
- }
-}
-
-export class ImageDataSource extends BaseDataSource {
- constructor(students: ImagesData[]) {
- super(students)
- }
-}
+/*
+ * Copyright (c) 2023 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 class ImagesData {
+ id ?: number
+ src ?: Resource
+ name ?: Resource
+ vibratorFileL ?: string
+ vibratorFileM ?: string
+ vibratorFileH ?: string
+ audioName ?: string
+}
+
+export function getImageRacingList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Racing1"),
+ name: $r("app.string.display_racing_car_crash"),
+ vibratorFileL: "CarCrash_l.json",
+ vibratorFileM: "CarCrash_m.json",
+ vibratorFileH: "CarCrash_h.json",
+ audioName: "CarCrash.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Racing2"),
+ name: $r("app.string.display_racing_ignite"),
+ vibratorFileL: "CarIgnite_l.json",
+ vibratorFileM: "CarIgnite_m.json",
+ vibratorFileH: "CarIgnite_h.json",
+ audioName: "CarIgnite.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Racing3"),
+ name: $r("app.string.display_racing_skid"),
+ vibratorFileL: "CarSkid_l.json",
+ vibratorFileM: "CarSkid_m.json",
+ vibratorFileH: "CarSkid_h.json",
+ audioName: "CarSkid.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.Racing4"),
+ name: $r("app.string.display_racing_drifting_jet"),
+ vibratorFileL: "DriftingJet_l.json",
+ vibratorFileM: "DriftingJet_m.json",
+ vibratorFileH: "DriftingJet_h.json",
+ audioName: "DriftingJet.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Racing5"),
+ name: $r("app.string.display_racing_jet_n2o"),
+ vibratorFileL: "JetN2O_l.json",
+ vibratorFileM: "JetN2O_m.json",
+ vibratorFileH: "JetN2O_h.json",
+ audioName: "JetN2O.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Racing6"),
+ name: $r("app.string.display_racing_start"),
+ vibratorFileL: "RacingStart_l.json",
+ vibratorFileM: "RacingStart_m.json",
+ vibratorFileH: "RacingStart_h.json",
+ audioName: "RacingStart.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Racing8"),
+ name: $r("app.string.display_racing_speed_up"),
+ vibratorFileL: "SpeedUp_l.json",
+ vibratorFileM: "SpeedUp_m.json",
+ vibratorFileH: "SpeedUp_h.json",
+ audioName: "SpeedUp.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageBattleList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Battle7"),
+ name: $r("app.string.display_battle_tumble"),
+ vibratorFileL: "Tumble_l.json",
+ vibratorFileM: "Tumble_m.json",
+ vibratorFileH: "Tumble_h.json",
+ audioName: "Tumble.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Battle2"),
+ name: $r("app.string.display_battle_punch"),
+ vibratorFileL: "Punch_l.json",
+ vibratorFileM: "Punch_m.json",
+ vibratorFileH: "Punch_h.json",
+ audioName: "Punch.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Battle3"),
+ name: $r("app.string.display_battle_kick"),
+ vibratorFileL: "Kick_l.json",
+ vibratorFileM: "Kick_m.json",
+ vibratorFileH: "Kick_h.json",
+ audioName: "Kick.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.Battle4"),
+ name: $r("app.string.display_battle_hurt"),
+ vibratorFileL: "Hurt_l.json",
+ vibratorFileM: "Hurt_m.json",
+ vibratorFileH: "Hurt_h.json",
+ audioName: "Hurt.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Battle5"),
+ name: $r("app.string.display_battle_blast"),
+ vibratorFileL: "Blast_l.json",
+ vibratorFileM: "Blast_m.json",
+ vibratorFileH: "Blast_h.json",
+ audioName: "Blast.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Battle6"),
+ name: $r("app.string.display_battle_bomb"),
+ vibratorFileL: "Bomb_l.json",
+ vibratorFileM: "Bomb_m.json",
+ vibratorFileH: "Bomb_h.json",
+ audioName: "Bomb.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageShootList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.AK47"),
+ name: $r("app.string.display_shoot_AK47"),
+ vibratorFileL: "AK47_l.json",
+ vibratorFileM: "AK47_m.json",
+ vibratorFileH: "AK47_h.json",
+ audioName: "AK47.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.HK416"),
+ name: $r("app.string.display_shoot_HK416"),
+ vibratorFileL: "HK416_l.json",
+ vibratorFileM: "HK416_m.json",
+ vibratorFileH: "HK416_h.json",
+ audioName: "HK416.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.M4"),
+ name: $r("app.string.display_shoot_M4"),
+ vibratorFileL: "M4_l.json",
+ vibratorFileM: "M4_m.json",
+ vibratorFileH: "M4_h.json",
+ audioName: "M4.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.MP5"),
+ name: $r("app.string.display_shoot_MP5"),
+ vibratorFileL: "MP5_l.json",
+ vibratorFileM: "MP5_m.json",
+ vibratorFileH: "MP5_h.json",
+ audioName: "MP5.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.CZ75"),
+ name: $r("app.string.display_shoot_CZ75"),
+ vibratorFileL: "CZ75_l.json",
+ vibratorFileM: "CZ75_m.json",
+ vibratorFileH: "CZ75_h.json",
+ audioName: "CZ75.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Winchester"),
+ name: $r("app.string.display_shoot_winchester"),
+ vibratorFileL: "Winchester_l.json",
+ vibratorFileM: "Winchester_m.json",
+ vibratorFileH: "Winchester_h.json",
+ audioName: "Winchester.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Rifle"),
+ name: $r("app.string.display_shoot_rifle"),
+ vibratorFileL: "Rifle_l.json",
+ vibratorFileM: "Rifle_m.json",
+ vibratorFileH: "Rifle_h.json",
+ audioName: "Rifle.wav"
+ },
+ {
+ id: 7,
+ src: $r("app.media.AssaultRifle"),
+ name: $r("app.string.display_shoot_assault_rifle"),
+ vibratorFileL: "AssaultRifle_l.json",
+ vibratorFileM: "AssaultRifle_m.json",
+ vibratorFileH: "AssaultRifle_h.json",
+ audioName: "AssaultRifle.wav"
+ },
+ {
+ id: 8,
+ src: $r("app.media.HitSand"),
+ name: $r("app.string.display_shoot_hit_sand"),
+ vibratorFileL: "HitSand_l.json",
+ vibratorFileM: "HitSand_m.json",
+ vibratorFileH: "HitSand_h.json",
+ audioName: "HitSand.wav"
+ },
+ {
+ id: 9,
+ src: $r("app.media.HitWater"),
+ name: $r("app.string.display_shoot_hit_water"),
+ vibratorFileL: "HitWater_l.json",
+ vibratorFileM: "HitWater_m.json",
+ vibratorFileH: "HitWater_h.json",
+ audioName: "HitWater.wav"
+ },
+ {
+ id: 10,
+ src: $r("app.media.HitMetal"),
+ name: $r("app.string.display_shoot_hit_metal"),
+ vibratorFileL: "HitMetal_l.json",
+ vibratorFileM: "HitMetal_m.json",
+ vibratorFileH: "HitMetal_h.json",
+ audioName: "HitMetal.wav"
+ },
+ {
+ id: 11,
+ src: $r("app.media.HitWood"),
+ name: $r("app.string.display_shoot_hit_wood"),
+ vibratorFileL: "HitWood_l.json",
+ vibratorFileM: "HitWood_m.json",
+ vibratorFileH: "HitWood_h.json",
+ audioName: "HitWood.wav"
+ },
+ {
+ id: 12,
+ src: $r("app.media.HitGlass"),
+ name: $r("app.string.display_shoot_hit_glass"),
+ vibratorFileL: "HitGlass_l.json",
+ vibratorFileM: "HitGlass_m.json",
+ vibratorFileH: "HitGlass_h.json",
+ audioName: "HitGlass.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageInstrumentsList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Cymbals"),
+ name: $r("app.string.display_instrument_cymbals"),
+ vibratorFileL: "Cymbals_l.json",
+ vibratorFileM: "Cymbals_m.json",
+ vibratorFileH: "Cymbals_h.json",
+ audioName: "Cymbals.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Cymbals2"),
+ name: $r("app.string.display_instrument_cymbals2"),
+ vibratorFileL: "Cymbals2_l.json",
+ vibratorFileM: "Cymbals2_m.json",
+ vibratorFileH: "Cymbals2_h.json",
+ audioName: "Cymbals2.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.KickDrum"),
+ name: $r("app.string.display_instrument_kick_drum"),
+ vibratorFileL: "KickDrum_l.json",
+ vibratorFileM: "KickDrum_m.json",
+ vibratorFileH: "KickDrum_h.json",
+ audioName: "KickDrum.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.KickDrum2"),
+ name: $r("app.string.display_instrument_kick_drum2"),
+ vibratorFileL: "KickDrum2_l.json",
+ vibratorFileM: "KickDrum2_m.json",
+ vibratorFileH: "KickDrum2_h.json",
+ audioName: "KickDrum2.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Guitar"),
+ name: $r("app.string.display_instrument_guitar"),
+ vibratorFileL: "Guitar_l.json",
+ vibratorFileM: "Guitar_m.json",
+ vibratorFileH: "Guitar_h.json",
+ audioName: "Guitar.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Tambourine"),
+ name: $r("app.string.display_instrument_tambourine"),
+ vibratorFileL: "Tambourine_l.json",
+ vibratorFileM: "Tambourine_m.json",
+ vibratorFileH: "Tambourine_h.json",
+ audioName: "Tambourine.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Bell"),
+ name: $r("app.string.display_instrument_bell"),
+ vibratorFileL: "bell_l.json",
+ vibratorFileM: "bell_m.json",
+ vibratorFileH: "bell_h.json",
+ audioName: "bell.wav"
+ },
+ {
+ id: 7,
+ src: $r("app.media.Claves"),
+ name: $r("app.string.display_instrument_claves"),
+ vibratorFileL: "Claves_l.json",
+ vibratorFileM: "Claves_m.json",
+ vibratorFileH: "Claves_h.json",
+ audioName: "Claves.wav"
+ },
+ {
+ id: 8,
+ src: $r("app.media.Gong"),
+ name: $r("app.string.display_instrument_gong"),
+ vibratorFileL: "Gong_l.json",
+ vibratorFileM: "Gong_m.json",
+ vibratorFileH: "Gong_h.json",
+ audioName: "Gong.wav"
+ },
+ {
+ id: 9,
+ src: $r("app.media.Triangle"),
+ name: $r("app.string.display_instrument_triangle"),
+ vibratorFileL: "triangle_l.json",
+ vibratorFileM: "triangle_m.json",
+ vibratorFileH: "triangle_h.json",
+ audioName: "triangle.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageRealisticList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Ice"),
+ name: $r("app.string.display_realistic_ice"),
+ vibratorFileL: "ice_l.json",
+ vibratorFileM: "ice_m.json",
+ vibratorFileH: "ice_h.json",
+ audioName: "ice.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Keyboard"),
+ name: $r("app.string.display_realistic_keyboard"),
+ vibratorFileL: "Keyboard_l.json",
+ vibratorFileM: "Keyboard_m.json",
+ vibratorFileH: "Keyboard_h.json",
+ audioName: "Keyboard.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Typewriter"),
+ name: $r("app.string.display_realistic_typewriter"),
+ vibratorFileL: "Typewriter_l.json",
+ vibratorFileM: "Typewriter_m.json",
+ vibratorFileH: "Typewriter_h.json",
+ audioName: "Typewriter.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.CoinDrop"),
+ name: $r("app.string.display_realistic_coin_drop"),
+ vibratorFileL: "CoinDrop_l.json",
+ vibratorFileM: "CoinDrop_m.json",
+ vibratorFileH: "CoinDrop_h.json",
+ audioName: "CoinDrop.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Timer"),
+ name: $r("app.string.display_realistic_timer"),
+ vibratorFileL: "timer_l.json",
+ vibratorFileM: "timer_m.json",
+ vibratorFileH: "timer_h.json",
+ audioName: "timer.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Walk"),
+ name: $r("app.string.display_realistic_walk"),
+ vibratorFileL: "Walk_l.json",
+ vibratorFileM: "Walk_m.json",
+ vibratorFileH: "Walk_h.json",
+ audioName: "Walk.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.camerashutter"),
+ name: $r("app.string.display_realistic_camerashutter"),
+ vibratorFileL: "camerashutter_l.json",
+ vibratorFileM: "camerashutter_m.json",
+ vibratorFileH: "camerashutter_h.json",
+ audioName: "camerashutter.wav"
+ },
+ {
+ id: 7,
+ src: $r("app.media.camerashutter2"),
+ name: $r("app.string.display_realistic_camerashutter2"),
+ vibratorFileL: "camerashutter2_l.json",
+ vibratorFileM: "camerashutter2_m.json",
+ vibratorFileH: "camerashutter2_h.json",
+ audioName: "camerashutter2.wav"
+ },
+ {
+ id: 8,
+ src: $r("app.media.Clock"),
+ name: $r("app.string.display_realistic_clock"),
+ vibratorFileL: "clock_l.json",
+ vibratorFileM: "clock_m.json",
+ vibratorFileH: "clock_h.json",
+ audioName: "clock.wav"
+ },
+ {
+ id: 9,
+ src: $r("app.media.Water"),
+ name: $r("app.string.display_realistic_water"),
+ vibratorFileL: "Water_l.json",
+ vibratorFileM: "Water_m.json",
+ vibratorFileH: "Water_h.json",
+ audioName: "Water.wav"
+ },
+ {
+ id: 10,
+ src: $r("app.media.heartbeat"),
+ name: $r("app.string.display_realistic_heartbeat"),
+ vibratorFileL: "heartbeat_l.json",
+ vibratorFileM: "heartbeat_m.json",
+ vibratorFileH: "heartbeat_h.json",
+ audioName: "heartbeat.wav"
+ },
+ {
+ id: 11,
+ src: $r("app.media.Firework"),
+ name: $r("app.string.display_realistic_firework"),
+ vibratorFileL: "Firework_l.json",
+ vibratorFileM: "Firework_m.json",
+ vibratorFileH: "Firework_h.json",
+ audioName: "Firework.wav"
+ },
+ {
+ id: 12,
+ src: $r("app.media.Picker"),
+ name: $r("app.string.display_realistic_picker"),
+ vibratorFileL: "Picker_l.json",
+ vibratorFileM: "Picker_m.json",
+ vibratorFileH: "Picker_h.json",
+ audioName: "Picker.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageFootstepList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Footstep1"),
+ name: $r("app.string.display_footstep_on_carpet"),
+ vibratorFileL: "OnCarpet_l.json",
+ vibratorFileM: "OnCarpet_m.json",
+ vibratorFileH: "OnCarpet_h.json",
+ audioName: "OnCarpet.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Footstep2"),
+ name: $r("app.string.display_footstep_on_concrete"),
+ vibratorFileL: "OnConcrete_l.json",
+ vibratorFileM: "OnConcrete_m.json",
+ vibratorFileH: "OnConcrete_h.json",
+ audioName: "OnConcrete.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Footstep3"),
+ name: $r("app.string.display_footstep_on_grass"),
+ vibratorFileL: "OnGrass_l.json",
+ vibratorFileM: "OnGrass_m.json",
+ vibratorFileH: "OnGrass_h.json",
+ audioName: "OnGrass.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.Footstep4"),
+ name: $r("app.string.display_footstep_on_board"),
+ vibratorFileL: "OnWood_l.json",
+ vibratorFileM: "OnWood_m.json",
+ vibratorFileH: "OnWood_h.json",
+ audioName: "OnWood.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Footstep5"),
+ name: $r("app.string.display_footstep_on_gravel"),
+ vibratorFileL: "OnGravel_l.json",
+ vibratorFileM: "OnGravel_m.json",
+ vibratorFileH: "OnGravel_h.json",
+ audioName: "OnGravel.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Footstep6"),
+ name: $r("app.string.display_footstep_on_mud"),
+ vibratorFileL: "OnMud_l.json",
+ vibratorFileM: "OnMud_m.json",
+ vibratorFileH: "OnMud_h.json",
+ audioName: "OnMud.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Footstep7"),
+ name: $r("app.string.display_footstep_on_snow"),
+ vibratorFileL: "OnSnow_l.json",
+ vibratorFileM: "OnSnow_m.json",
+ vibratorFileH: "OnSnow_h.json",
+ audioName: "OnSnow.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageEnvironmentList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Rain"),
+ name: $r("app.string.display_environment_rain"),
+ vibratorFileL: "Rain_l.json",
+ vibratorFileM: "Rain_m.json",
+ vibratorFileH: "Rain_h.json",
+ audioName: "Rain.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Snowdrift"),
+ name: $r("app.string.display_environment_snowdrift"),
+ vibratorFileL: "Snowdrift_l.json",
+ vibratorFileM: "Snowdrift_m.json",
+ vibratorFileH: "Snowdrift_h.json",
+ audioName: "Snowdrift.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Campfire"),
+ name: $r("app.string.display_environment_campfire"),
+ vibratorFileL: "Campfire_l.json",
+ vibratorFileM: "Campfire_m.json",
+ vibratorFileH: "Campfire_h.json",
+ audioName: "Campfire.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.Creek"),
+ name: $r("app.string.display_environment_creek"),
+ vibratorFileL: "Creek_l.json",
+ vibratorFileM: "Creek_m.json",
+ vibratorFileH: "Creek_h.json",
+ audioName: "Creek.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Wave"),
+ name: $r("app.string.display_environment_wave"),
+ vibratorFileL: "Wave_l.json",
+ vibratorFileM: "Wave_m.json",
+ vibratorFileH: "Wave_h.json",
+ audioName: "Wave.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.Wind"),
+ name: $r("app.string.display_environment_wind"),
+ vibratorFileL: "Wind_l.json",
+ vibratorFileM: "Wind_m.json",
+ vibratorFileH: "Wind_h.json",
+ audioName: "Wind.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Thunder"),
+ name: $r("app.string.display_environment_thunder"),
+ vibratorFileL: "Thunder_l.json",
+ vibratorFileM: "Thunder_m.json",
+ vibratorFileH: "Thunder_h.json",
+ audioName: "Thunder.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export function getImageExerciseList(): Array {
+ let ImagesDataArray: Array = [
+ {
+ id: 0,
+ src: $r("app.media.Badminton"),
+ name: $r("app.string.display_exercise_badminton"),
+ vibratorFileL: "Badminton_l.json",
+ vibratorFileM: "Badminton_m.json",
+ vibratorFileH: "Badminton_h.json",
+ audioName: "Badminton.wav"
+ },
+ {
+ id: 1,
+ src: $r("app.media.Baseball"),
+ name: $r("app.string.display_exercise_baseball"),
+ vibratorFileL: "Baseball_l.json",
+ vibratorFileM: "Baseball_m.json",
+ vibratorFileH: "Baseball_h.json",
+ audioName: "Baseball.wav"
+ },
+ {
+ id: 2,
+ src: $r("app.media.Basketball"),
+ name: $r("app.string.display_exercise_basketball"),
+ vibratorFileL: "Basketball_l.json",
+ vibratorFileM: "Basketball_m.json",
+ vibratorFileH: "Basketball_h.json",
+ audioName: "Basketball.wav"
+ },
+ {
+ id: 3,
+ src: $r("app.media.Skating"),
+ name: $r("app.string.display_exercise_skating"),
+ vibratorFileL: "Skating_l.json",
+ vibratorFileM: "Skating_m.json",
+ vibratorFileH: "Skating_h.json",
+ audioName: "Skating.wav"
+ },
+ {
+ id: 4,
+ src: $r("app.media.Skiing"),
+ name: $r("app.string.display_exercise_skiing"),
+ vibratorFileL: "Skiing_l.json",
+ vibratorFileM: "Skiing_m.json",
+ vibratorFileH: "Skiing_h.json",
+ audioName: "Skiing.wav"
+ },
+ {
+ id: 5,
+ src: $r("app.media.TableTennis"),
+ name: $r("app.string.display_exercise_tabletennis"),
+ vibratorFileL: "TableTennis_l.json",
+ vibratorFileM: "TableTennis_m.json",
+ vibratorFileH: "TableTennis_h.json",
+ audioName: "TableTennis.wav"
+ },
+ {
+ id: 6,
+ src: $r("app.media.Diving"),
+ name: $r("app.string.display_exercise_diving"),
+ vibratorFileL: "Diving_l.json",
+ vibratorFileM: "Diving_m.json",
+ vibratorFileH: "Diving_h.json",
+ audioName: "Diving.wav"
+ },
+ ]
+ return ImagesDataArray;
+}
+
+export abstract class BaseDataSource implements IDataSource {
+ private mDataSource: T[] = [];
+
+ constructor(dataList: T[]) {
+ this.mDataSource = dataList;
+ }
+
+ totalCount(): number {
+ return this.mDataSource === null ? 0 : this.mDataSource.length
+ }
+
+ getData(index: number): T | null {
+ return index >= 0 && index < this.totalCount() ? this.mDataSource[index] : null;
+ }
+
+ registerDataChangeListener(listener: DataChangeListener) {
+ }
+
+ unregisterDataChangeListener(listener: DataChangeListener) {
+ }
+}
+
+export class ImageDataSource extends BaseDataSource {
+ constructor(students: ImagesData[]) {
+ super(students)
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets
index 972601945dd29857f307b96251c36bdcd4ce8270..99f666bf13981d42f3296004cc02e0c2762b21d1 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/MyInfoModule.ets
@@ -1,228 +1,228 @@
-/*
- * Copyright (c) 2023 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 Logger from './Logger'
-
-const TAG = '[MyInfoModule]'
-
-@Component
-export default struct MyInfoModule {
- @State selectContent: Resource = $r("app.string.my_low_mode")
- @State selectContent1: Resource = $r("app.string.my_ets")
-
- @Link vibrationIntensity: string
- @Link php: string
-
- build() {
- Column({ space: 30 }) {
- Column({ space: 10 }) {
- Row({ space: 10 }) {
- Image($r("app.media.set"))
- .height(20)
- .width(20)
- Text($r("app.string.my_settings"))
- .fontColor(Color.White)
- .fontSize(20)
- Text(this.selectContent)
- .fontSize(16)
- .fontColor("#ffcbc2c2")
- }
- .id('intensitySelect')
- .height("100%")
- .width("80%")
- .onClick(() => {
- ActionSheet.show({
- title: $r("app.string.my_settings"),
- message: $r("app.string.my_select_msg"),
- autoCancel: true,
- confirm: {
- value: $r("app.string.cancel"),
- action: () => {
- Logger.info(TAG, 'Get Alert Dialog handled')
- }
- },
- cancel: () => {
- Logger.info(TAG, 'actionSheet canceled')
- },
- alignment: DialogAlignment.Bottom,
- offset: { dx: 0, dy: -10 },
- sheets: [
- {
- icon: $r("app.media.app_icon"),
- title: $r("app.string.my_high_mode"),
- action: () => {
- this.selectContent = $r("app.string.my_high_mode")
- this.vibrationIntensity = 'H'
- Logger.info(TAG, 'Vibration intensity is high')
- }
- },
- {
- icon: $r("app.media.app_icon"),
- title: $r("app.string.my_middle_mode"),
- action: () => {
- this.selectContent = $r("app.string.my_middle_mode")
- this.vibrationIntensity = 'M'
- Logger.info(TAG, 'Vibration intensity is middle')
- }
- },
- {
- icon: $r("app.media.app_icon"),
- title: $r("app.string.my_low_mode"),
- action: () => {
- this.selectContent = $r("app.string.my_low_mode")
- this.vibrationIntensity = 'L'
- Logger.info(TAG, 'Vibration intensity is low')
- }
- }
- ]
- })
- })
- .width("80%")
-
- Row() {
- }
- .height(1)
- .width("85%")
- .backgroundColor('#ff404048')
- }
-
- Column({ space: 10 }) {
- Row({ space: 10 }) {
- Image($r("app.media.select"))
- .height(20)
- .width(20)
- Text($r("app.string.my_php"))
- .fontColor(Color.White)
- .fontSize(20)
- Text(this.selectContent1)
- .fontSize(16)
- .fontColor("#ffcbc2c2")
- }
- .id('phpSelect1')
- .height("100%")
- .width("80%")
- .onClick(() => {
- ActionSheet.show({
- title: $r("app.string.my_php_select"),
- message: $r("app.string.my_linguistic_type"),
- autoCancel: true,
- confirm: {
- value: $r("app.string.cancel"),
- action: () => {
- Logger.info(TAG, 'Get Alert Dialog handled')
- }
- },
- cancel: () => {
- Logger.info(TAG, 'actionSheet canceled')
- },
- alignment: DialogAlignment.Bottom,
- offset: { dx: 0, dy: -10 },
- sheets: [
- {
- icon: $r("app.media.app_icon"),
- title: $r("app.string.my_ets"),
- action: () => {
- this.selectContent1 = $r("app.string.my_ets")
- this.php = 'ets'
- }
- },
- {
- icon: $r("app.media.app_icon"),
- title: $r("app.string.my_capi"),
- action: () => {
- this.selectContent1 = $r("app.string.my_capi")
- this.php = 'capi'
- }
- }
- ]
- })
- })
- .width("80%")
-
- Row() {
- }
- .height(1)
- .width("85%")
- .backgroundColor('#ff404048')
- }
-
- Column({ space: 10 }) {
- Row({ space: 10 }) {
- Image($r("app.media.Verison"))
- .width(20)
- .height(20)
- Text($r("app.string.my_version"))
- .fontColor(Color.White)
- .fontSize(20)
- .backgroundColor('#cc191a32')
- Text('v1.0')
- .fontSize(20)
- .fontColor("#ff706666")
- }
- .width("80%")
-
- Row() {
- }
- .height(1)
- .width("85%")
- .backgroundColor("#ff404048")
- }
-
- Column({ space: 10 }) {
- Row({ space: 10 }) {
- Image($r("app.media.bangzhu"))
- .width(20)
- .height(20)
- Text($r("app.string.my_help"))
- .fontColor(Color.White)
- .fontSize(20)
- .backgroundColor('#cc191a32')
- Text('Please Waiting!')
- .fontSize(20)
- .fontColor("#ff706666")
- }
- .width("80%")
-
- Row() {
- }
- .height(1)
- .width("85%")
- .backgroundColor("#ff404048")
- }
-
- Column({ space: 10 }) {
- Row({ space: 10 }) {
- Image($r("app.media.xinxi"))
- .width(20)
- .height(20)
- Text($r("app.string.my_develop"))
- .fontColor(Color.White)
- .fontSize(20)
- .backgroundColor('#cc191a32')
- Text('Please Waiting!')
- .fontSize(20)
- .fontColor("#ff706666")
- }
- .width("80%")
-
- Row() {
- }
- .height(1)
- .width("85%")
- .backgroundColor("#ff404048")
- }
- }
- }
-}
+/*
+ * Copyright (c) 2023 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 Logger from './Logger'
+
+const TAG = '[MyInfoModule]'
+
+@Component
+export default struct MyInfoModule {
+ @State selectContent: Resource = $r("app.string.my_low_mode")
+ @State selectContent1: Resource = $r("app.string.my_ets")
+
+ @Link vibrationIntensity: string
+ @Link php: string
+
+ build() {
+ Column({ space: 30 }) {
+ Column({ space: 10 }) {
+ Row({ space: 10 }) {
+ Image($r("app.media.set"))
+ .height(20)
+ .width(20)
+ Text($r("app.string.my_settings"))
+ .fontColor(Color.White)
+ .fontSize(20)
+ Text(this.selectContent)
+ .fontSize(16)
+ .fontColor("#ffcbc2c2")
+ }
+ .id('intensitySelect')
+ .height("100%")
+ .width("80%")
+ .onClick(() => {
+ ActionSheet.show({
+ title: $r("app.string.my_settings"),
+ message: $r("app.string.my_select_msg"),
+ autoCancel: true,
+ confirm: {
+ value: $r("app.string.cancel"),
+ action: () => {
+ Logger.info(TAG, 'Get Alert Dialog handled')
+ }
+ },
+ cancel: () => {
+ Logger.info(TAG, 'actionSheet canceled')
+ },
+ alignment: DialogAlignment.Bottom,
+ offset: { dx: 0, dy: -10 },
+ sheets: [
+ {
+ icon: $r("app.media.app_icon"),
+ title: $r("app.string.my_high_mode"),
+ action: () => {
+ this.selectContent = $r("app.string.my_high_mode")
+ this.vibrationIntensity = 'H'
+ Logger.info(TAG, 'Vibration intensity is high')
+ }
+ },
+ {
+ icon: $r("app.media.app_icon"),
+ title: $r("app.string.my_middle_mode"),
+ action: () => {
+ this.selectContent = $r("app.string.my_middle_mode")
+ this.vibrationIntensity = 'M'
+ Logger.info(TAG, 'Vibration intensity is middle')
+ }
+ },
+ {
+ icon: $r("app.media.app_icon"),
+ title: $r("app.string.my_low_mode"),
+ action: () => {
+ this.selectContent = $r("app.string.my_low_mode")
+ this.vibrationIntensity = 'L'
+ Logger.info(TAG, 'Vibration intensity is low')
+ }
+ }
+ ]
+ })
+ })
+ .width("80%")
+
+ Row() {
+ }
+ .height(1)
+ .width("85%")
+ .backgroundColor('#ff404048')
+ }
+
+ Column({ space: 10 }) {
+ Row({ space: 10 }) {
+ Image($r("app.media.select"))
+ .height(20)
+ .width(20)
+ Text($r("app.string.my_php"))
+ .fontColor(Color.White)
+ .fontSize(20)
+ Text(this.selectContent1)
+ .fontSize(16)
+ .fontColor("#ffcbc2c2")
+ }
+ .id('phpSelect1')
+ .height("100%")
+ .width("80%")
+ .onClick(() => {
+ ActionSheet.show({
+ title: $r("app.string.my_php_select"),
+ message: $r("app.string.my_linguistic_type"),
+ autoCancel: true,
+ confirm: {
+ value: $r("app.string.cancel"),
+ action: () => {
+ Logger.info(TAG, 'Get Alert Dialog handled')
+ }
+ },
+ cancel: () => {
+ Logger.info(TAG, 'actionSheet canceled')
+ },
+ alignment: DialogAlignment.Bottom,
+ offset: { dx: 0, dy: -10 },
+ sheets: [
+ {
+ icon: $r("app.media.app_icon"),
+ title: $r("app.string.my_ets"),
+ action: () => {
+ this.selectContent1 = $r("app.string.my_ets")
+ this.php = 'ets'
+ }
+ },
+ {
+ icon: $r("app.media.app_icon"),
+ title: $r("app.string.my_capi"),
+ action: () => {
+ this.selectContent1 = $r("app.string.my_capi")
+ this.php = 'capi'
+ }
+ }
+ ]
+ })
+ })
+ .width("80%")
+
+ Row() {
+ }
+ .height(1)
+ .width("85%")
+ .backgroundColor('#ff404048')
+ }
+
+ Column({ space: 10 }) {
+ Row({ space: 10 }) {
+ Image($r("app.media.Verison"))
+ .width(20)
+ .height(20)
+ Text($r("app.string.my_version"))
+ .fontColor(Color.White)
+ .fontSize(20)
+ .backgroundColor('#cc191a32')
+ Text('v1.0')
+ .fontSize(20)
+ .fontColor("#ff706666")
+ }
+ .width("80%")
+
+ Row() {
+ }
+ .height(1)
+ .width("85%")
+ .backgroundColor("#ff404048")
+ }
+
+ Column({ space: 10 }) {
+ Row({ space: 10 }) {
+ Image($r("app.media.bangzhu"))
+ .width(20)
+ .height(20)
+ Text($r("app.string.my_help"))
+ .fontColor(Color.White)
+ .fontSize(20)
+ .backgroundColor('#cc191a32')
+ Text('Please Waiting!')
+ .fontSize(20)
+ .fontColor("#ff706666")
+ }
+ .width("80%")
+
+ Row() {
+ }
+ .height(1)
+ .width("85%")
+ .backgroundColor("#ff404048")
+ }
+
+ Column({ space: 10 }) {
+ Row({ space: 10 }) {
+ Image($r("app.media.xinxi"))
+ .width(20)
+ .height(20)
+ Text($r("app.string.my_develop"))
+ .fontColor(Color.White)
+ .fontSize(20)
+ .backgroundColor('#cc191a32')
+ Text('Please Waiting!')
+ .fontSize(20)
+ .fontColor("#ff706666")
+ }
+ .width("80%")
+
+ Row() {
+ }
+ .height(1)
+ .width("85%")
+ .backgroundColor("#ff404048")
+ }
+ }
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets
index 4665acd8382d9cc60893bd377ac6e572e02e2393..3bb7067170a7f0fbbb12194597a12c0705fec522 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/TabBar.ets
@@ -1,86 +1,86 @@
-/*
- * Copyright (c) 2023 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 Logger from './Logger'
-
-const TAG = '[TabBar]'
-
-export class TabModel {
- index ?: number
- content ?: Resource
- left ?: number
- width ?: number
-}
-
-@Component
-export default struct TabBar {
- private fontSizeNormal = 18
- private tabMargin = 15
- private titleLength = 3
- @Link titleArr: Resource[]
- @Link currentIndex: number
- private left: number = 0
- private tabSelected: (position: number, title: string) => void = (position: number, title: string) => {
- Logger.info(TAG, 'tabSelected position = ' + position + ', title = ' + title)
- }
- @State private tabDataArr: TabModel[] = []
- private scroller: Scroller = new Scroller()
-
- aboutToAppear() {
- this.tabDataArr = this.titleArr.map((title: Resource, index: number) => {
- let tabModel = new TabModel()
- tabModel.index = index
- tabModel.content = title
- tabModel.left = this.left
- let width = this.titleLength * this.fontSizeNormal + this.tabMargin * 2
- tabModel.width = width
- tabModel.left = this.left
- this.left += width
- return tabModel
- })
- }
-
- build() {
- Scroll(this.scroller) {
- Flex({ direction: FlexDirection.Row }) {
- ForEach(this.tabDataArr, (item: TabModel) => {
- Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
- Text(item.content)
- .fontSize(this.currentIndex === item.index ? this.fontSizeNormal + 3 : this.fontSizeNormal)
- .fontColor(this.currentIndex === item.index ? "#2AEFCC" : Color.White)
- .fontWeight(this.currentIndex === item.index ? FontWeight.Bold : FontWeight.Normal)
- .textAlign(TextAlign.Center)
- Column()
- .height(3)
- .width(item.width! - this.tabMargin * 2)
- .margin({ top: 10 })
- .backgroundColor("#2AEFCC")
- .visibility(this.currentIndex === item.index ? Visibility.Visible : Visibility.Hidden)
- }
- .width(item.width!)
- .height('100%')
- .backgroundColor("#00002222")
- .onClick(() => {
- if (item.index !== undefined) {
- this.currentIndex = item.index
- }
- })
- }, (item: TabModel) => item.index!.toString())
- }
- }
- .scrollable(ScrollDirection.Horizontal)
- .scrollBar(BarState.Off)
- }
-}
+/*
+ * Copyright (c) 2023 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 Logger from './Logger'
+
+const TAG = '[TabBar]'
+
+export class TabModel {
+ index ?: number
+ content ?: Resource
+ left ?: number
+ width ?: number
+}
+
+@Component
+export default struct TabBar {
+ private fontSizeNormal = 18
+ private tabMargin = 15
+ private titleLength = 3
+ @Link titleArr: Resource[]
+ @Link currentIndex: number
+ private left: number = 0
+ private tabSelected: (position: number, title: string) => void = (position: number, title: string) => {
+ Logger.info(TAG, 'tabSelected position = ' + position + ', title = ' + title)
+ }
+ @State private tabDataArr: TabModel[] = []
+ private scroller: Scroller = new Scroller()
+
+ aboutToAppear() {
+ this.tabDataArr = this.titleArr.map((title: Resource, index: number) => {
+ let tabModel = new TabModel()
+ tabModel.index = index
+ tabModel.content = title
+ tabModel.left = this.left
+ let width = this.titleLength * this.fontSizeNormal + this.tabMargin * 2
+ tabModel.width = width
+ tabModel.left = this.left
+ this.left += width
+ return tabModel
+ })
+ }
+
+ build() {
+ Scroll(this.scroller) {
+ Flex({ direction: FlexDirection.Row }) {
+ ForEach(this.tabDataArr, (item: TabModel) => {
+ Flex({ direction: FlexDirection.Column, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
+ Text(item.content)
+ .fontSize(this.currentIndex === item.index ? this.fontSizeNormal + 3 : this.fontSizeNormal)
+ .fontColor(this.currentIndex === item.index ? "#2AEFCC" : Color.White)
+ .fontWeight(this.currentIndex === item.index ? FontWeight.Bold : FontWeight.Normal)
+ .textAlign(TextAlign.Center)
+ Column()
+ .height(3)
+ .width(item.width! - this.tabMargin * 2)
+ .margin({ top: 10 })
+ .backgroundColor("#2AEFCC")
+ .visibility(this.currentIndex === item.index ? Visibility.Visible : Visibility.Hidden)
+ }
+ .width(item.width!)
+ .height('100%')
+ .backgroundColor("#00002222")
+ .onClick(() => {
+ if (item.index !== undefined) {
+ this.currentIndex = item.index
+ }
+ })
+ }, (item: TabModel) => item.index!.toString())
+ }
+ }
+ .scrollable(ScrollDirection.Horizontal)
+ .scrollBar(BarState.Off)
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets
index addcbc56982b9238cabc11ce23a942ddf88a8044..33bad70bb0fe5aef8a557aa195b897b6bb1b104c 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/Util.ets
@@ -1,118 +1,118 @@
-/*
- * Copyright (c) 2023 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 vibrator from '@ohos.vibrator'
-import Window from '@ohos.window'
-import Logger from './Logger'
-import resourceManager from '@ohos.resourceManager'
-import { BusinessError } from '@ohos.base'
-import { StartCustom } from 'library';
-
-const TAG = '[Util]'
-
-export function getDynamicStates(dis: boolean[], id: number): boolean[] {
- for (let i = 0; i < dis.length; i++) {
- i === id ? dis[i] = true : dis[i] = false
- Logger.info(TAG, dis[i].toString())
- }
- return dis
-}
-
-export async function playVibrateCustom(fileName: string, mode: string) {
- let rawFd: resourceManager.RawFileDescriptor | undefined = undefined
- await getContext().resourceManager.getRawFd(fileName).then(value => {
- rawFd = value
- Logger.info(TAG, "rawFd of vibration:" + " fd:" + rawFd.fd + ", offset:" + rawFd.offset + ", length: " + rawFd.length)
- })
- if (mode === "ets") {
- try {
- vibrator.startVibration({
- type: "file",
- hapticFd: { fd: rawFd!.fd, offset: rawFd!.offset, length: rawFd!.length }
- }, {
- usage: "unknown"
- }, (error: BusinessError) => {
- if (error) {
- Logger.info(TAG, 'startVibration failed, type is file, in callback');
- } else {
- Logger.info(TAG, 'startVibration successful, type is file, in callback');
- }
- });
- } catch (error) {
- let err: BusinessError = error as BusinessError;
- Logger.info(TAG, 'startVibration failed, type is file, in catch, err code:' + err.code + ' err msg:' + err.message)
- }
- } else if (mode === "capi"){
- let ret: number
- ret = StartCustom(rawFd!.fd, rawFd!.offset, rawFd!.length)
- console.info('StartCustom ret', ret);
- }
-}
-
-export function changeOrientationInternal(lastWindow: Window.Window, portrait: boolean): void {
- if (portrait) {
- lastWindow.setPreferredOrientation(Window.Orientation.LANDSCAPE).then(() => {
- Logger.info(TAG, "setPreferredOrientation success")
- }).catch((error: BusinessError) => {
- Logger.info(TAG, "setPreferredOrientation failure" + JSON.stringify(error))
- })
- } else {
- lastWindow.setPreferredOrientation(Window.Orientation.PORTRAIT).then(() => {
- Logger.info(TAG, "setPreferredOrientation success")
- }).catch((error: BusinessError) => {
- Logger.info(TAG, "setPreferredOrientation failure: " + JSON.stringify(error))
- })
- }
-}
-
-export function changeOrientation(portrait: boolean): void {
- Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
- changeOrientationInternal(lastWindow, portrait)
- }).catch((error: BusinessError) => {
- Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
- })
-}
-
-export function hideTitleBar(): void {
- Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
- if (lastWindow) {
- lastWindow.setWindowSystemBarEnable([], (err: BusinessError) => {
- if (err) {
- Logger.info(TAG, "hideTitleBar failed")
- } else {
- Logger.info(TAG, "hideTitleBar successful")
- }
- })
- }
- }).catch((error: BusinessError) => {
- Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
- })
-}
-
-export function showTitleBar(): void {
- Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
- if (lastWindow) {
- lastWindow.setWindowSystemBarEnable(['status', 'navigation'], (err: BusinessError) => {
- if (err) {
- Logger.info(TAG, "showTitleBar failed")
- } else {
- Logger.info(TAG, "showTitleBar successful")
- }
- })
- }
- }).catch((error: BusinessError) => {
- Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
- })
-}
+/*
+ * Copyright (c) 2023 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 vibrator from '@ohos.vibrator'
+import Window from '@ohos.window'
+import Logger from './Logger'
+import resourceManager from '@ohos.resourceManager'
+import { BusinessError } from '@ohos.base'
+import { StartCustom } from 'library';
+
+const TAG = '[Util]'
+
+export function getDynamicStates(dis: boolean[], id: number): boolean[] {
+ for (let i = 0; i < dis.length; i++) {
+ i === id ? dis[i] = true : dis[i] = false
+ Logger.info(TAG, dis[i].toString())
+ }
+ return dis
+}
+
+export async function playVibrateCustom(fileName: string, mode: string) {
+ let rawFd: resourceManager.RawFileDescriptor | undefined = undefined
+ await getContext().resourceManager.getRawFd(fileName).then(value => {
+ rawFd = value
+ Logger.info(TAG, "rawFd of vibration:" + " fd:" + rawFd.fd + ", offset:" + rawFd.offset + ", length: " + rawFd.length)
+ })
+ if (mode === "ets") {
+ try {
+ vibrator.startVibration({
+ type: "file",
+ hapticFd: { fd: rawFd!.fd, offset: rawFd!.offset, length: rawFd!.length }
+ }, {
+ usage: "unknown"
+ }, (error: BusinessError) => {
+ if (error) {
+ Logger.info(TAG, 'startVibration failed, type is file, in callback');
+ } else {
+ Logger.info(TAG, 'startVibration successful, type is file, in callback');
+ }
+ });
+ } catch (error) {
+ let err: BusinessError = error as BusinessError;
+ Logger.info(TAG, 'startVibration failed, type is file, in catch, err code:' + err.code + ' err msg:' + err.message)
+ }
+ } else if (mode === "capi"){
+ let ret: number
+ ret = StartCustom(rawFd!.fd, rawFd!.offset, rawFd!.length)
+ console.info('StartCustom ret', ret);
+ }
+}
+
+export function changeOrientationInternal(lastWindow: Window.Window, portrait: boolean): void {
+ if (portrait) {
+ lastWindow.setPreferredOrientation(Window.Orientation.LANDSCAPE).then(() => {
+ Logger.info(TAG, "setPreferredOrientation success")
+ }).catch((error: BusinessError) => {
+ Logger.info(TAG, "setPreferredOrientation failure" + JSON.stringify(error))
+ })
+ } else {
+ lastWindow.setPreferredOrientation(Window.Orientation.PORTRAIT).then(() => {
+ Logger.info(TAG, "setPreferredOrientation success")
+ }).catch((error: BusinessError) => {
+ Logger.info(TAG, "setPreferredOrientation failure: " + JSON.stringify(error))
+ })
+ }
+}
+
+export function changeOrientation(portrait: boolean): void {
+ Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
+ changeOrientationInternal(lastWindow, portrait)
+ }).catch((error: BusinessError) => {
+ Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
+ })
+}
+
+export function hideTitleBar(): void {
+ Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
+ if (lastWindow) {
+ lastWindow.setWindowSystemBarEnable([], (err: BusinessError) => {
+ if (err) {
+ Logger.info(TAG, "hideTitleBar failed")
+ } else {
+ Logger.info(TAG, "hideTitleBar successful")
+ }
+ })
+ }
+ }).catch((error: BusinessError) => {
+ Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
+ })
+}
+
+export function showTitleBar(): void {
+ Window.getLastWindow(getContext()).then((lastWindow: Window.Window) => {
+ if (lastWindow) {
+ lastWindow.setWindowSystemBarEnable(['status', 'navigation'], (err: BusinessError) => {
+ if (err) {
+ Logger.info(TAG, "showTitleBar failed")
+ } else {
+ Logger.info(TAG, "showTitleBar successful")
+ }
+ })
+ }
+ }).catch((error: BusinessError) => {
+ Logger.info(TAG, "getLastWindow error: " + JSON.stringify(error))
+ })
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets
index a20194e7833eeca82f418591be912bafa6cd94f5..fb6d6f85c2d06785771a28599b810c09d74804b5 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoListModule.ets
@@ -1,94 +1,94 @@
-/*
- * Copyright (c) 2023 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 router from '@ohos.router'
-
-@Entry
-@Component
-struct VideoListModule {
- private php: string = (router.getParams() as Record)['php']
- build() {
- Column({ space: 20 }) {
- Row() {
- Button({ type: ButtonType.Normal }) {
- Text("<")
- .fontColor(Color.White)
- .fontSize(28)
- }
- .backgroundColor('#00191a32')
- .padding({ left: 5 })
- .layoutWeight(1)
- .onClick(() => {
- router.pushUrl({
- url: 'pages/Index'
- })
- })
-
- Text($r("app.string.back"))
- .fontColor(Color.White)
- .fontSize(24)
- .layoutWeight(7)
- .padding({ right: 10 })
- }
- .padding({ top: 5 })
-
- Column({ space: 20 }) {
- List({ space: 10 }) {
- ListItem() {
- Row() {
- Image($r("app.media.HapticVideoPreview"))
- .width("50%")
- .height(100)
- .borderRadius(10)
- Column() {
- Text($r("app.string.video_list_haptic_video"))
- .fontSize(18)
- .fontColor(Color.White)
- Text($r("app.string.video_list_haptic_video_msg"))
- .fontSize(16)
- .fontColor("#ff837979")
- }
- .alignItems(HorizontalAlign.Start)
- .padding({ left: 5 })
- .height(100)
- }
- .width("95%")
- .padding({ left: 10 })
- .backgroundColor("#00002222")
- .onClick(() => {
- router.pushUrl({
- url: "module/VideoPlayModule",
- params: {
- vibrateFileName: "HapticVideo.json",
- videoName: 'HapticVideo',
- videoSrc: $r("app.media.HapticVideo"),
- previewUri: $r("app.media.HapticVideoPreview"),
- pages: "VideoListPage",
- php: this.php
- }
- })
- })
- }
- }
- .listDirection(Axis.Vertical)
- .divider({ strokeWidth: 10, color: "#00f3f3f3", startMargin: 20, endMargin: 20 })
- .height("60%")
- }
- }
- .width('100%')
- .height('100%')
- .backgroundColor('#f2191a32')
- }
-}
+/*
+ * Copyright (c) 2023 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 router from '@ohos.router'
+
+@Entry
+@Component
+struct VideoListModule {
+ private php: string = (router.getParams() as Record)['php']
+ build() {
+ Column({ space: 20 }) {
+ Row() {
+ Button({ type: ButtonType.Normal }) {
+ Text("<")
+ .fontColor(Color.White)
+ .fontSize(28)
+ }
+ .backgroundColor('#00191a32')
+ .padding({ left: 5 })
+ .layoutWeight(1)
+ .onClick(() => {
+ router.pushUrl({
+ url: 'pages/Index'
+ })
+ })
+
+ Text($r("app.string.back"))
+ .fontColor(Color.White)
+ .fontSize(24)
+ .layoutWeight(7)
+ .padding({ right: 10 })
+ }
+ .padding({ top: 5 })
+
+ Column({ space: 20 }) {
+ List({ space: 10 }) {
+ ListItem() {
+ Row() {
+ Image($r("app.media.HapticVideoPreview"))
+ .width("50%")
+ .height(100)
+ .borderRadius(10)
+ Column() {
+ Text($r("app.string.video_list_haptic_video"))
+ .fontSize(18)
+ .fontColor(Color.White)
+ Text($r("app.string.video_list_haptic_video_msg"))
+ .fontSize(16)
+ .fontColor("#ff837979")
+ }
+ .alignItems(HorizontalAlign.Start)
+ .padding({ left: 5 })
+ .height(100)
+ }
+ .width("95%")
+ .padding({ left: 10 })
+ .backgroundColor("#00002222")
+ .onClick(() => {
+ router.pushUrl({
+ url: "module/VideoPlayModule",
+ params: {
+ vibrateFileName: "HapticVideo.json",
+ videoName: 'HapticVideo',
+ videoSrc: $r("app.media.HapticVideo"),
+ previewUri: $r("app.media.HapticVideoPreview"),
+ pages: "VideoListPage",
+ php: this.php
+ }
+ })
+ })
+ }
+ }
+ .listDirection(Axis.Vertical)
+ .divider({ strokeWidth: 10, color: "#00f3f3f3", startMargin: 20, endMargin: 20 })
+ .height("60%")
+ }
+ }
+ .width('100%')
+ .height('100%')
+ .backgroundColor('#f2191a32')
+ }
+}
diff --git a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets
index df913bb18f68a691c9034027162a20309f61c8b9..adadb757878602f7b8df5ef886ddc2def7dfeea4 100644
--- a/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets
+++ b/code/BasicFeature/DeviceManagement/Vibrator/CustomHaptic/entry/src/main/ets/module/VideoPlayModule.ets
@@ -1,73 +1,73 @@
-/*
- * Copyright (c) 2023 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 vibrator from '@ohos.vibrator';
-import router from '@ohos.router'
-import { changeOrientation, showTitleBar, playVibrateCustom, hideTitleBar } from './Util'
-
-@Entry
-@Component
-struct VideoPlayModule {
- @State videoName: string = (router.getParams() as Record