From 92d35d9f1beeb891514c889fc295be9ef4abb377 Mon Sep 17 00:00:00 2001 From: jerryzcx Date: Tue, 23 Sep 2025 15:17:39 +0800 Subject: [PATCH 1/2] fix readme etc. --- ApiUsingStandards/README.md | 26 ++++++++++-- ApiUsingStandards/entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- ApiUsingStandards/oh-package.json5 | 2 - AppAspectProgrammingDesign/README.md | 29 +++++++++++-- .../entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- ClickResponseOptimization/README.md | 41 +++++++++++++++++-- .../entry/obfuscation-rules.txt | 6 ++- .../main/resources/base/element/string.json | 2 +- .../main/resources/zh_CN/element/string.json | 2 +- ComponentReuse/README.md | 16 ++++---- ComponentReuse/README_EN.md | 2 +- .../entry/src/main/ets/model/ColorData.ets | 8 +++- .../src/main/ets/model/FriendMomentData.ets | 6 ++- .../main/ets/view/PageListSlideToHistory.ets | 2 +- .../src/main/ets/view/UpdaterComponent.ets | 2 +- .../entry/src/main/ets/view/WithFuncParam.ets | 3 +- .../entry/src/main/ets/view/WithReuseId.ets | 2 +- .../main/resources/en_US/element/string.json | 2 +- HapAndHarDependHar/README.md | 25 +++++++++-- .../entry/obfuscation-rules.txt | 6 ++- .../main/resources/base/element/string.json | 2 +- .../har_common/obfuscation-rules.txt | 6 ++- .../har_library/obfuscation-rules.txt | 6 ++- JSCrash/README.md | 2 +- JSCrash/entry/src/main/ets/pages/Index.ets | 4 -- JSCrash/entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- LibuvDevelopment/README.md | 17 +++++++- LibuvDevelopment/entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- NodeAPIDevelopment/README.md | 24 +++++++++-- .../entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- Privacy/README.md | 18 +++++++- Privacy/privacy/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- RationalUseOfFrontEndResources/README.md | 12 +++--- .../{ets/pages => cpp}/VideoSceneEncoding.cpp | 6 ++- .../entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- .../DevEcoStaticCheck/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- StabilityCodingSpecification/README.md | 19 ++++++++- ThreadIssueDetection/README.md | 18 +++++++- .../entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- customPlugin/README.md | 28 ++++++------- customPlugin/entry/src/main/module.json5 | 4 +- .../main/resources/base/element/string.json | 2 +- 51 files changed, 284 insertions(+), 120 deletions(-) rename RationalUseOfFrontEndResources/entry/src/main/{ets/pages => cpp}/VideoSceneEncoding.cpp (74%) diff --git a/ApiUsingStandards/README.md b/ApiUsingStandards/README.md index 758e3646..d3beb85e 100644 --- a/ApiUsingStandards/README.md +++ b/ApiUsingStandards/README.md @@ -4,9 +4,29 @@ 本示例是《易错API的使用规范》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ └──pages +│ ├──animate1.ets // 示例页面 +│ ├──animate2.ets // 示例页面 +│ ├──AVImageGenerator.ets // 示例页面 +│ ├──camera.ets // 示例页面 +│ ├──Index.ets // 示例页面 +│ ├──playStateCallback.ets // 示例页面 +│ └──StyleExample.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/ApiUsingStandards/entry/src/main/module.json5 b/ApiUsingStandards/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/ApiUsingStandards/entry/src/main/module.json5 +++ b/ApiUsingStandards/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/ApiUsingStandards/entry/src/main/resources/base/element/string.json b/ApiUsingStandards/entry/src/main/resources/base/element/string.json index f9459551..9ce98bfb 100644 --- a/ApiUsingStandards/entry/src/main/resources/base/element/string.json +++ b/ApiUsingStandards/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ApiUsingStandards" } ] } \ No newline at end of file diff --git a/ApiUsingStandards/oh-package.json5 b/ApiUsingStandards/oh-package.json5 index 75e4e229..60ef03cd 100644 --- a/ApiUsingStandards/oh-package.json5 +++ b/ApiUsingStandards/oh-package.json5 @@ -4,7 +4,5 @@ "dependencies": { }, "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" } } diff --git a/AppAspectProgrammingDesign/README.md b/AppAspectProgrammingDesign/README.md index eab3f84f..7c20508f 100644 --- a/AppAspectProgrammingDesign/README.md +++ b/AppAspectProgrammingDesign/README.md @@ -4,9 +4,32 @@ 本示例是《应用切面编程设计》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 +│ └──pages +│ ├──Index.ets // 示例页面 +│ ├──Index1.ets // 示例页面 +│ ├──Index2.ets // 示例页面 +│ ├──Index3.ets // 示例页面 +│ ├──Index4.ets // 示例页面 +│ ├──Index5.ets // 示例页面 +│ ├──Index6.ets // 示例页面 +│ ├──Index7.ets // 示例页面 +│ ├──Index8.ets // 示例页面 +│ ├──Index9.ets // 示例页面 +│ └──Index10.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/AppAspectProgrammingDesign/entry/src/main/module.json5 b/AppAspectProgrammingDesign/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/AppAspectProgrammingDesign/entry/src/main/module.json5 +++ b/AppAspectProgrammingDesign/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json b/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json index f9459551..162ff06f 100644 --- a/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json +++ b/AppAspectProgrammingDesign/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "AppAspectProgrammingDesign" } ] } \ No newline at end of file diff --git a/ClickResponseOptimization/README.md b/ClickResponseOptimization/README.md index ee2a083b..38e03fd7 100644 --- a/ClickResponseOptimization/README.md +++ b/ClickResponseOptimization/README.md @@ -4,9 +4,44 @@ 本示例是《点击响应时延分析》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──common/constants +│ │ ├──AppConstant.ets // app常量 +│ │ ├──ChatConstants.ets // chat常量 +│ │ ├──WorldCommonConstants.ets // 公共常量 +│ │ └──WorldConstants.ets // 公共常量 +│ ├──common/db +│ │ ├──AccountData.ets // account数据 +│ │ ├──AccountTable.ets // account表 +│ │ └──Rdb.ets // rdb工具类 +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──model +│ │ └──ChatModel.ets // chat数据模型 +│ ├──pages +│ │ ├──CameraOptPage.ets // 示例页面 +│ │ ├──CameraPage.ets // 示例页面 +│ │ ├──CityListPage.ets // 示例页面 +│ │ ├──ConcurrentOptPage.ets // 示例页面 +│ │ ├──Index.ets // 首页 +│ │ ├──PanGestureDistanceOptPage.ets // 示例页面 +│ │ ├──PanGestureDistancePage.ets // 示例页面 +│ │ ├──ProfilePage.ets // 示例页面 +│ │ └──VisionOptPage.ets // 示例页面 +│ └──view +│ ├──ArticleSkeletonView.ets // 骨架屏view +│ ├──LoadingView.ets // 加载view +│ └──OptChatItemView.ets // 优化后的chat view +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/ClickResponseOptimization/entry/obfuscation-rules.txt b/ClickResponseOptimization/entry/obfuscation-rules.txt index 985b2aeb..a1dfa0bd 100644 --- a/ClickResponseOptimization/entry/obfuscation-rules.txt +++ b/ClickResponseOptimization/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ClickResponseOptimization/entry/src/main/resources/base/element/string.json b/ClickResponseOptimization/entry/src/main/resources/base/element/string.json index f9459551..c622bd7c 100644 --- a/ClickResponseOptimization/entry/src/main/resources/base/element/string.json +++ b/ClickResponseOptimization/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ClickResponseOptimization" } ] } \ No newline at end of file diff --git a/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json b/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json index 597ecf95..c999478a 100644 --- a/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json +++ b/ClickResponseOptimization/entry/src/main/resources/zh_CN/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "点击响应优化" } ] } \ No newline at end of file diff --git a/ComponentReuse/README.md b/ComponentReuse/README.md index b523843f..bfd29ada 100644 --- a/ComponentReuse/README.md +++ b/ComponentReuse/README.md @@ -16,14 +16,14 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 |-----------------------------------------|-----------------------------------------| | ![image](screenshots/device/mode_3.gif) | ![image](screenshots/device/mode_4.gif) | -#### 使用说明 +### 使用说明 -1. 点击“减少组件复用的嵌套层级”按钮,进入二级页面“附近的人”, 滑动列表。 -2. 点击“精准控制组件刷新范围”按钮,进入二级页面“附近的人”, 滑动列表。 -3. 点击“使用reuseId标记不同的组件”按钮,进入二级页面“附近的人”, 滑动列表。 -4. 点击“复用组件创建时的@State变量入参”按钮,进入二级页面“附近的人”, 滑动列表。 +1. 点击“减少组件复用的嵌套层级”按钮,进入二级页面, 滑动列表。 +2. 点击“精准控制组件刷新范围”按钮,进入二级页面, 滑动列表。 +3. 点击“使用reuseId标记不同的组件”按钮,进入二级页面, 滑动列表。 +4. 点击“复用组件创建时的@State变量入参”按钮,进入二级页面, 滑动列表。 -## 工程目录 +### 工程目录 ``` ├──entry/src/main/ets @@ -39,7 +39,7 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 │ │ ├──BasicDataSource.ets // 数据适配器基类 │ │ ├──ColorData.ets // 二级页面“文字列表”的数据适配器 │ │ └──FriendMomentData.ets // 二级页面“附近的人”/“图文列表”/“网名列表”的数据适配器 -│ ├──pages.ets +│ ├──pages │ │ ├──ImproveReuseHitRate.ets // 提升复用命中率 │ │ ├──Index.ets // 首页 │ │ ├──ReuseNested.ets // 复用嵌套 @@ -57,7 +57,7 @@ HarmonyOS应用框架提供了组件复用能力:可复用组件树上移除 不涉及 -## 约束与限制 +### 约束与限制 * 本示例仅支持标准系统上运行,支持设备:华为手机。 * HarmonyOS系统:HarmonyOS 5.0.5 Release及以上。 diff --git a/ComponentReuse/README_EN.md b/ComponentReuse/README_EN.md index 07403082..b7d2c2d7 100644 --- a/ComponentReuse/README_EN.md +++ b/ComponentReuse/README_EN.md @@ -39,7 +39,7 @@ The practices describe how to use the component reuse mechanism to improve the a │ │ ├──BasicDataSource.ets // Basic data adapter │ │ ├──ColorData.ets // Data adapter of Text list on the level-2 page │ │ └──FriendMomentData.ets // Data adapter of Nearby people, Image-text list, and Username list on the level-2 page -│ ├──pages.ets +│ ├──pages │ │ ├──ImproveReuseHitRate.ets // Improve reuse HitRate │ │ ├──Index.ets // Home page │ │ ├──ReuseNested.ets // Reuse nested diff --git a/ComponentReuse/entry/src/main/ets/model/ColorData.ets b/ComponentReuse/entry/src/main/ets/model/ColorData.ets index 2477328f..8740e9a0 100644 --- a/ComponentReuse/entry/src/main/ets/model/ColorData.ets +++ b/ComponentReuse/entry/src/main/ets/model/ColorData.ets @@ -17,6 +17,12 @@ import { BasicDataSource, ColorModel } from './BasicDataSource'; export class ColorData extends BasicDataSource { textColorData: Array = []; + private context: Context | undefined = undefined; + + constructor(context?: Context) { + super(); + this.context = context; + } public totalCount(): number { return this.textColorData.length; @@ -42,7 +48,7 @@ export class ColorData extends BasicDataSource { let colorModel: ColorModel = new ColorModel('', '', Color.White); colorModel.id = Math.floor(this.totalCount() / 10) + i.toString(); colorModel.text = - getContext().resourceManager.getStringSync($r('app.string.update_component_title'), parseInt(colorModel.id) + 1); + this.context!.resourceManager.getStringSync($r('app.string.update_component_title'), parseInt(colorModel.id) + 1); colorModel.color = color[i]; this.pushData(colorModel); } diff --git a/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets b/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets index d7cdbaef..c6af2a7d 100644 --- a/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets +++ b/ComponentReuse/entry/src/main/ets/model/FriendMomentData.ets @@ -20,9 +20,11 @@ import { Constants } from '../common/Constants'; export class FriendMomentsData extends BasicDataSource { private friendMoments: Array = []; private mode: string | undefined = ''; + private context: Context | undefined = undefined; - constructor(mode?: string) { + constructor(context?: Context,mode?: string) { super(); + this.context = context; this.mode = mode; } @@ -43,7 +45,7 @@ export class FriendMomentsData extends BasicDataSource { } public async getFriendMomentFromRawFile(): Promise { - const resourceManager = getContext().resourceManager; + const resourceManager = this.context!.resourceManager; const res = await resourceManager.getRawFileContent('mockFriendMomentOneModelData.json'); const textDecoder = util.TextDecoder.create(); const friendMomentArray = (JSON.parse(textDecoder.decodeToString(res)) as FriendMomentsData).friendMoments; diff --git a/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets b/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets index cc35bc15..fe641679 100644 --- a/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets +++ b/ComponentReuse/entry/src/main/ets/view/PageListSlideToHistory.ets @@ -25,7 +25,7 @@ export struct PageListSlideToHistory { private readonly ANIMATION_DURATION: number = 500; private readonly DEFAULT_VISIBLE_BTN_INDEX: number = 3; // Show jump history button when scroll more than 3 item private readonly LIST_CACHE_COUNT: number = 3; - private momentData: FriendMomentsData = new FriendMomentsData(); + private momentData: FriendMomentsData = new FriendMomentsData(this.getUIContext().getHostContext()); private listScroller: ListScroller = new ListScroller(); private historyOffset: number = 0; private isHistoricalRecord: boolean = false; diff --git a/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets b/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets index 8dc2597a..b8843afb 100644 --- a/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets +++ b/ComponentReuse/entry/src/main/ets/view/UpdaterComponent.ets @@ -39,7 +39,7 @@ export class MyTextUpdater extends AttributeUpdater { // [StartExclude opt_updater] @Component export struct UpdaterComponent { - private colorData: ColorData = new ColorData(); + private colorData: ColorData = new ColorData(this.getUIContext().getHostContext()); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; diff --git a/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets b/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets index 963ea7b6..2c8ff2a9 100644 --- a/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets +++ b/ComponentReuse/entry/src/main/ets/view/WithFuncParam.ets @@ -24,7 +24,8 @@ import { FriendMomentsData } from '../model/FriendMomentData'; struct WithFuncParam { @State sum: number = 0; // [StartExclude opt_funcParam] - private momentData: FriendMomentsData = new FriendMomentsData(Constants.NAV_DESTINATION_ITEM_3); + private momentData: FriendMomentsData = + new FriendMomentsData(this.getUIContext().getHostContext(), Constants.NAV_DESTINATION_ITEM_3); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; // [EndExclude opt_funcParam] diff --git a/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets b/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets index 462b1a7a..c702345d 100644 --- a/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets +++ b/ComponentReuse/entry/src/main/ets/view/WithReuseId.ets @@ -23,7 +23,7 @@ import { FriendMomentsData } from '../model/FriendMomentData' @Component struct WithReuseId { // [StartExclude opt_reuseId] - private momentData: FriendMomentsData = new FriendMomentsData(); + private momentData: FriendMomentsData = new FriendMomentsData(this.getUIContext().getHostContext()); private readonly LIST_CACHE_COUNT: number = 5; private readonly LIST_SPACE: number = 18; diff --git a/ComponentReuse/entry/src/main/resources/en_US/element/string.json b/ComponentReuse/entry/src/main/resources/en_US/element/string.json index 1c04e82d..02cb0a9a 100644 --- a/ComponentReuse/entry/src/main/resources/en_US/element/string.json +++ b/ComponentReuse/entry/src/main/resources/en_US/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ComponentReuse" }, { "name": "nav_destination_item0", diff --git a/HapAndHarDependHar/README.md b/HapAndHarDependHar/README.md index 25571c31..9223b93b 100644 --- a/HapAndHarDependHar/README.md +++ b/HapAndHarDependHar/README.md @@ -4,14 +4,31 @@ 本示例是《模块化设计》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 +### 使用说明 + +进入首面,加载示例逻辑。 + +### 工程目录 +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // Ability入口类 +│ └──pages +│ └──Index.ets // 首页 +├──har_common/src/main/ets +│ ├──components +│ │ └──MainPage.ets // common模块中MainPage +│ └──utils +│ └──Utils.ets // 工具类 +└──har_library/src/main/ets + └──components/mainpage + └──MainPage.ets // library模块中MainPage +``` ### 具体实现 -1. 分别包括三个模块:主业务模块entry,公共模块har_commont,库模块har_library +1. 分别包括三个模块:主业务模块entry,公共模块har_common,库模块har_library ### 相关权限 diff --git a/HapAndHarDependHar/entry/obfuscation-rules.txt b/HapAndHarDependHar/entry/obfuscation-rules.txt index 985b2aeb..a1dfa0bd 100644 --- a/HapAndHarDependHar/entry/obfuscation-rules.txt +++ b/HapAndHarDependHar/entry/obfuscation-rules.txt @@ -15,4 +15,8 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/HapAndHarDependHar/entry/src/main/resources/base/element/string.json b/HapAndHarDependHar/entry/src/main/resources/base/element/string.json index f9459551..47d750c2 100644 --- a/HapAndHarDependHar/entry/src/main/resources/base/element/string.json +++ b/HapAndHarDependHar/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "HapAndHarDependHar" } ] } \ No newline at end of file diff --git a/HapAndHarDependHar/har_common/obfuscation-rules.txt b/HapAndHarDependHar/har_common/obfuscation-rules.txt index 985b2aeb..a1dfa0bd 100644 --- a/HapAndHarDependHar/har_common/obfuscation-rules.txt +++ b/HapAndHarDependHar/har_common/obfuscation-rules.txt @@ -15,4 +15,8 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/HapAndHarDependHar/har_library/obfuscation-rules.txt b/HapAndHarDependHar/har_library/obfuscation-rules.txt index 985b2aeb..a1dfa0bd 100644 --- a/HapAndHarDependHar/har_library/obfuscation-rules.txt +++ b/HapAndHarDependHar/har_library/obfuscation-rules.txt @@ -15,4 +15,8 @@ # Keep options: # -keep-property-name: specifies property names that you want to keep -# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file +# -keep-global-name: specifies names that you want to keep in the global scope +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/JSCrash/README.md b/JSCrash/README.md index 87b927c8..e6014128 100644 --- a/JSCrash/README.md +++ b/JSCrash/README.md @@ -43,7 +43,7 @@ ### 约束与限制 -1. 本示例仅支持标准系统上运行,支持设备:华为手机、华为PC/2in1设备、华为平板。 +1. 本示例仅支持标准系统上运行,支持设备:华为手机。 2. HarmonyOS系统:HarmonyOS NEXT 5.0.5 Release及以上。 diff --git a/JSCrash/entry/src/main/ets/pages/Index.ets b/JSCrash/entry/src/main/ets/pages/Index.ets index 841fa4da..35886cde 100644 --- a/JSCrash/entry/src/main/ets/pages/Index.ets +++ b/JSCrash/entry/src/main/ets/pages/Index.ets @@ -18,10 +18,6 @@ struct Index { middle: { anchor: '__container__', align: HorizontalAlign.Center } }) .onClick(() => { - // [Start xiaoming] - let test:string = "{name:'xiaoming' age:10}"; - let result:object = JSON.parse(test); - // [End xiaoming] this.message = 'Welcome'; }) } diff --git a/JSCrash/entry/src/main/module.json5 b/JSCrash/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/JSCrash/entry/src/main/module.json5 +++ b/JSCrash/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/JSCrash/entry/src/main/resources/base/element/string.json b/JSCrash/entry/src/main/resources/base/element/string.json index f9459551..fe7f30a5 100644 --- a/JSCrash/entry/src/main/resources/base/element/string.json +++ b/JSCrash/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "JSCrash" } ] } \ No newline at end of file diff --git a/LibuvDevelopment/README.md b/LibuvDevelopment/README.md index ea10fe83..03fad0ef 100644 --- a/LibuvDevelopment/README.md +++ b/LibuvDevelopment/README.md @@ -4,11 +4,24 @@ 本示例是《libuv使用规范及案例》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -进入首面,点击按钮,分别进入示例页面。 +进入首面,加载示例逻辑。 +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ └──pages +│ └──Index.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` + ### 具体实现 1. 主要介绍libuv使用规范及案例,提供代码示例。 diff --git a/LibuvDevelopment/entry/src/main/module.json5 b/LibuvDevelopment/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/LibuvDevelopment/entry/src/main/module.json5 +++ b/LibuvDevelopment/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/LibuvDevelopment/entry/src/main/resources/base/element/string.json b/LibuvDevelopment/entry/src/main/resources/base/element/string.json index f9459551..5d298c92 100644 --- a/LibuvDevelopment/entry/src/main/resources/base/element/string.json +++ b/LibuvDevelopment/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "LibuvDevelopment" } ] } \ No newline at end of file diff --git a/NodeAPIDevelopment/README.md b/NodeAPIDevelopment/README.md index b586a1d1..854f1da4 100644 --- a/NodeAPIDevelopment/README.md +++ b/NodeAPIDevelopment/README.md @@ -4,10 +4,26 @@ 本示例是《Node-API开发规范》最佳实践中的代码示例片段。 -##### 使用说明 - -进入首面,点击按钮,分别进入示例页面。 - +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 数据备份类 +│ ├──pages +│ │ ├──Index.ets // 示首页 +│ │ └──Test.ets // 示例页面 +│ └──view +│ └──Worker.ets // worker示例 +└──entry/src/main/resources // 应用资源目录 +``` ### 具体实现 diff --git a/NodeAPIDevelopment/entry/src/main/module.json5 b/NodeAPIDevelopment/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/NodeAPIDevelopment/entry/src/main/module.json5 +++ b/NodeAPIDevelopment/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json b/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json index f9459551..cd60dc68 100644 --- a/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json +++ b/NodeAPIDevelopment/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "NodeAPIDevelopment" } ] } \ No newline at end of file diff --git a/Privacy/README.md b/Privacy/README.md index 870130d6..2db609eb 100644 --- a/Privacy/README.md +++ b/Privacy/README.md @@ -4,9 +4,23 @@ 本示例是应用安全编码实践、应用资产保护设计、应用代码混淆、网络连接安全配置四篇最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -本示例为最佳实践示例代码,开发者可以查阅官网最佳实践下应用安全编码实践、应用资产保护设计、应用代码混淆、网络连接安全配置四篇最佳实践学习。 +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──privacy/src/main/ets +│ ├──privacyability +│ │ └──PrivacyAbility.ets // 入口类 +│ ├──privacybackupability +│ │ └──PrivacyBackupAbility.ets // 数据备份类 +│ └──pages +│ └──Index.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` ### 相关权限 diff --git a/Privacy/privacy/src/main/module.json5 b/Privacy/privacy/src/main/module.json5 index 2f1ce9ad..1e9e3104 100644 --- a/Privacy/privacy/src/main/module.json5 +++ b/Privacy/privacy/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "PrivacyAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/Privacy/privacy/src/main/resources/base/element/string.json b/Privacy/privacy/src/main/resources/base/element/string.json index 4aeaabf1..b4d2fd4b 100644 --- a/Privacy/privacy/src/main/resources/base/element/string.json +++ b/Privacy/privacy/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "PrivacyAbility_label", - "value": "label" + "value": "Privacy" } ] } \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/README.md b/RationalUseOfFrontEndResources/README.md index 5d08e95f..0a8292b8 100644 --- a/RationalUseOfFrontEndResources/README.md +++ b/RationalUseOfFrontEndResources/README.md @@ -5,18 +5,16 @@ APM(Application Performance Management)是一种用于监控和管理应用程序性能的解决方案。它通过收集、分析和报告应用程序的性能数据,帮助开发和运维团队快速定位并解决应用程序问题,提高应用程序的可靠性和性能。HarmonyOS 提供了完善的 HiAppEvent 机制,帮助开发者上报稳定性、性能等应用事件,开发者可以利用它构建自身的 APM 系统。 低功耗是指设备在执行各种任务时,通过应用一系列技术和策略来减少能耗,从而延长电池寿命和设备使用时间。手机等移动设备因其便携、移动的特性,续航时间的长短直接影响用户对品牌的体验和满意度。 -### 工程结构&模块类型 +### 工程结构 ``` ├──entry/src/main/ets/ -│ ├──mock -│ │ └──GoodsMock.ets // 模拟数据类 │ ├──entryability -│ │ └──EntryAbility.ets // 配置类 -│ └──model -│ │ └──GoodsModel.ets // 类型声明 +│ │ └──EntryAbility.ets // 程序入口类 +│ └──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份类 │ └──pages -│ └──Index.ets // 程序入口类 +│ └──Index.ets // 入口页面 │ └──MonitorCrash.ets // 崩溃监测实践文章配套代码 │ └──MusicPlayRule.ets // 音乐播放场景低功耗规则文章配套代码 │ └──NavigationAndPositioningRule.ets // 导航定位场景低功耗规则文章配套代码 diff --git a/RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp similarity index 74% rename from RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp rename to RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp index 7321b301..3fd414e2 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/ets/pages/VideoSceneEncoding.cpp +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp @@ -1,4 +1,6 @@ - +#include +#include +#include /** * 视频场景编解码低功耗规则 */ @@ -13,5 +15,5 @@ const char *name = OH_AVCapability_GetName(capability); // Hard solution: Create H264 decoder. When there are multiple optional decoders, the system will create the most suitable decoder OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_AVC); // Hard solution: Create H265 decoder -OH_AVCodec *videoDec = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_HEVC); +OH_AVCodec *videoDecH = OH_VideoDecoder_CreateByMime(OH_AVCODEC_MIMETYPE_VIDEO_HEVC); // [End VideoSceneEncoding] \ No newline at end of file diff --git a/RationalUseOfFrontEndResources/entry/src/main/module.json5 b/RationalUseOfFrontEndResources/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/module.json5 +++ b/RationalUseOfFrontEndResources/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json b/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json index f9459551..370c3604 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json +++ b/RationalUseOfFrontEndResources/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "RationalUseOfFrontEndResources" } ] } \ No newline at end of file diff --git a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 index 5d96966c..f2f3e7bf 100644 --- a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 +++ b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "DevEcoStaticCheckAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json index 18f3a211..3500f95b 100644 --- a/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json +++ b/StabilityCodingSpecification/DevEcoStaticCheck/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "DevEcoStaticCheckAbility_label", - "value": "label" + "value": "DevEcoStaticCheck" } ] } \ No newline at end of file diff --git a/StabilityCodingSpecification/README.md b/StabilityCodingSpecification/README.md index 82c5f3fd..1dca25d7 100644 --- a/StabilityCodingSpecification/README.md +++ b/StabilityCodingSpecification/README.md @@ -4,9 +4,24 @@ 本示例是《NDK开发ArkTS侧编码规范》《使用DevEco Studio静态检测编码规范》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 + +进入首面,加载示例逻辑。 + + +### 工程目录 + +``` +├──DevEcoStaticCheck/src/main/ets +│ ├──devecostaticcheckability +│ │ └──DevEcoStaticCheckAbility.ets // 入口类 +│ └──pages +│ ├──Index.ets // 示例页面 +│ ├──Index2.ets // 示例页面 +│ └──Index3.ets // 示例页面 +└──entry/src/main/resources // 应用资源目录 +``` -进入首面,点击按钮,分别进入示例页面。 ### 具体实现 diff --git a/ThreadIssueDetection/README.md b/ThreadIssueDetection/README.md index ea8f771c..761f0b00 100644 --- a/ThreadIssueDetection/README.md +++ b/ThreadIssueDetection/README.md @@ -4,11 +4,25 @@ 本示例是《使用TSan检测线程问题》最佳实践中的代码示例片段。 -##### 使用说明 +### 使用说明 -进入首面,点击按钮,分别进入示例页面。 +进入首面,加载示例逻辑。 +### 工程目录 + +``` +├──entry/src/main/ets +│ ├──entryability +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 +│ └──pages +│ ├──UseTSANToDetectThreadingIssues.ets // 示例页面 +│ └──Index.ets // 首页 +└──entry/src/main/resources // 应用资源目录 +``` + ### 具体实现 1. 主要介绍如何使用TSan检测线程,提供代码示例。 diff --git a/ThreadIssueDetection/entry/src/main/module.json5 b/ThreadIssueDetection/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/ThreadIssueDetection/entry/src/main/module.json5 +++ b/ThreadIssueDetection/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/ThreadIssueDetection/entry/src/main/resources/base/element/string.json b/ThreadIssueDetection/entry/src/main/resources/base/element/string.json index f9459551..a1f956d8 100644 --- a/ThreadIssueDetection/entry/src/main/resources/base/element/string.json +++ b/ThreadIssueDetection/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "ThreadIssueDetection" } ] } \ No newline at end of file diff --git a/customPlugin/README.md b/customPlugin/README.md index f921614f..5944414b 100644 --- a/customPlugin/README.md +++ b/customPlugin/README.md @@ -3,32 +3,30 @@ ### 介绍 在进行编译构建的过程中,开发者可以通过定制hvigor插件,扩展构建逻辑,实现个性化的打包流程。 -定制hvigor插件,通常有以下目的: -满足自定义任务需求。 -每个项目可能有独特的构建需求和流程,定制插件可以根据项目的具体要求来扩展hvigor构建的功能。 +### 使用说明 -加强构建任务可维护性。 -定制插件可以将某些复杂的构建逻辑封装在同一个地方,使得项目的构建配置更加清晰和易于维护。可以自动化执行某些特定任务,减少手动干预,确保构建过程的一致可靠。 +编译工程,得到hvigor插件逻辑的编译产物。 -提升团队协作效率。 -在团队开发中,定制插件可以确保所有团队成员使用相同的构建流程和标准,减少因个人配置差异导致的问题,从而提升团队协作的效率。 - -### 工程结构&模块类型 +### 工程结构 ``` ├──entry/src/main/ets/ -│ ├──mock -│ │ └──GoodsMock.ets // 模拟数据类 │ ├──entryability -│ │ └──EntryAbility.ets // 配置类 -│ └──model -│ │ └──GoodsModel.ets // 类型声明 +│ │ └──EntryAbility.ets // 入口类 +│ ├──entrybackupability +│ │ └──EntryBackupAbility.ets // 备份恢复类 │ └──pages -│ └──Index.ets // 程序入口类 +│ └──Index.ets // 示例页面 +├──library/src/main/ets +│ └──components +│ └──MainPage.ets // library模块中MainPage └──entry/src/main/resource // 应用静态资源目录 ``` +### 相关权限 + +不涉及。 ### 约束与限制 diff --git a/customPlugin/entry/src/main/module.json5 b/customPlugin/entry/src/main/module.json5 index a1cea8b6..ad219d73 100644 --- a/customPlugin/entry/src/main/module.json5 +++ b/customPlugin/entry/src/main/module.json5 @@ -5,9 +5,7 @@ "description": "$string:module_desc", "mainElement": "EntryAbility", "deviceTypes": [ - "phone", - "tablet", - "2in1" + "phone" ], "deliveryWithInstall": true, "installationFree": false, diff --git a/customPlugin/entry/src/main/resources/base/element/string.json b/customPlugin/entry/src/main/resources/base/element/string.json index f9459551..71113f81 100644 --- a/customPlugin/entry/src/main/resources/base/element/string.json +++ b/customPlugin/entry/src/main/resources/base/element/string.json @@ -10,7 +10,7 @@ }, { "name": "EntryAbility_label", - "value": "label" + "value": "customPlugin" } ] } \ No newline at end of file -- Gitee From 0abb2ce3976d068704fd5e61208f36fa86a57d7c Mon Sep 17 00:00:00 2001 From: jerryzcx Date: Tue, 23 Sep 2025 15:32:52 +0800 Subject: [PATCH 2/2] fix conflict --- .../entry/src/main/cpp/VideoSceneEncoding.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp index 3fd414e2..4229226b 100644 --- a/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp +++ b/RationalUseOfFrontEndResources/entry/src/main/cpp/VideoSceneEncoding.cpp @@ -1,3 +1,18 @@ +/* + * 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. + */ + #include #include #include -- Gitee