diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..996b06c972abaf3b850289cdfa4b1199933d3aa1 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.exceptionhandling", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..da3d04310137e468e6d5252f69162d14f1aa0fd3 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ExceptionHandling" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/AppScope/resources/base/media/app_icon.png differ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..338e5b0bc22082e0ffcc7121c2ed3897a3ddccb0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,78 @@ + Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +Apache License, Version 2.0 +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: +1.You must give any other recipients of the Work or Derivative Works a copy of this License; and +2.You must cause any modified files to carry prominent notices stating that You changed the files; and +3.You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and +4.If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 04c33f2bad42c9659e76163f5686f3c7d71cf054..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# ExceptionHandling - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index b96e95237b520ef2e68c15fc6dc4b4e790c95144..f3c63a61e121524cca54f361d51609f7558eb77e 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,54 @@ -# ExceptionHandling +# 应用异常处理 -#### 介绍 -{**以下是 Gitee 平台说明,您可以替换此简介** -Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +### 介绍 -#### 软件架构 -软件架构说明 +本示例介绍了通过应用事件打点hiAppEvent获取上一次应用异常信息的方法,主要分为应用崩溃、应用卡死两种。 +### 效果图预览 +| 默认页面 | 构建异常事件 | 捕获异常事件 | +|---------------------------------------|---------------------------------------|---------------------------------------| +| ![](screenshots/device/Preview_1.png) | ![](screenshots/device/Preview_2.png) | ![](screenshots/device/Preview_3.png) | -#### 安装教程 +**使用说明** -1. xxxx -2. xxxx -3. xxxx +1. 点击构建应用崩溃事件,3s之后应用退出,然后打开应用进入应用异常页面,隔1min左右后,显示上次异常退出信息。 +2. 点击构建应用卡死事件,需手动退出,然后打开应用进入应用异常页面,隔1min左右后,显示上次异常退出信息。 -#### 使用说明 +### 实现思路 -1. xxxx -2. xxxx -3. xxxx +1. 构建应用异常。源码参考[Index.ets](./entry/src/main/ets/pages/Index.ets) +2. 应用退出后,进入本页面,等待订阅消息通知,待收到订阅消息后,通过EventSubscription.ets中的onReceive函数,接收到异常信息数据,并通过AppStorage.setOrCreate('appEventGroups',异常信息数据)双向绑定异常信息,源码参考代码可参考[EventSubscription.ets](./entry/src/main/ets/model/EventSubscription.ets) +3. @StorageLink('appEventGroups')接收订阅事件函数传递的事件组信息,调用getFaultMessage函数对信息进行处理,将处理后的信息通过 this.faultDataSource.pushData(message) 添加到懒加载数据源中,并通过this.faultDataSource.persistenceStorage()执行持久化存储,最后通过使用LazyForEach将数据信息加载到页面上。具体源码参考[Index.ets](./entry/src/main/ets/pages/Index.ets) +4. 以上代码中有引用懒加载数据类和持久化存储类,源码可参考[DataSource.ets](./entry/src/main/ets/model/DataSource.ets)和[PreferencesManager.ets](./entry/src/main/ets/model/PreferencesManager.ets)。 -#### 参与贡献 +### 工程结构&模块类型 -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request + ``` + ├───entry/src/main/ets + │ ├───entryability + │ │ └──EntryAbility.ets // Ability的生命周期回调内容 + │ ├───log + │ │ └──Logger.ets // 日志工具 + │ ├───model + │ │ ├───DataSource.ets // 模型层-懒加载数据源 + │ │ ├───EventSubscription.ets // 数据模型层-订阅应用事件 + │ │ ├───MockData.ets // 数据模型层-模拟数据 + │ │ └──PreferencesManager.ets // 数据模型层-持久化存储 + │ └───pages + │ └──Index.ets // 视图层-应用异常页面 + └───entry/src/main/resources // 应用静态资源目录 + ``` +### 模块依赖 -#### 特技 +**不涉及** -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 -5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +### 约束与限制 + +1.本示例仅支持标准系统上运行,支持设备:华为手机。 + +2.HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 + +3.DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 + +4.HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK 及以上。 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c033ce4278fb0641d84107c3c134047ac487368e --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,35 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.0(12)", + "runtimeOS": "HarmonyOS", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/entry/build-profile.json5 b/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b695582d3680556f4cce2ec518f65720a9413ca3 --- /dev/null +++ b/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "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/entry/hvigorfile.ts b/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/entry/obfuscation-rules.txt b/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..69c4d6a8a5531548e4886fa766090c5c157a87d9 --- /dev/null +++ b/entry/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..c50b13107f839327575767cff8ba185ed6e50ce3 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,35 @@ +/* + * 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, UIAbility, Want } from '@kit.AbilityKit'; +import { window } from '@kit.ArkUI'; +import { eventSubscription } from '../model/EventSubscription'; +import { Logger } from '../log/Logger'; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + eventSubscription(); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + Logger.error('Failed to load the content. Cause: ' + err.code + ', message =' + err.message); + return; + } + }); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/log/Logger.ets b/entry/src/main/ets/log/Logger.ets new file mode 100644 index 0000000000000000000000000000000000000000..6aa6715ae93cc31974301beb6b18895b306f21b3 --- /dev/null +++ b/entry/src/main/ets/log/Logger.ets @@ -0,0 +1,47 @@ +/* + * 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 '@kit.PerformanceAnalysisKit'; + +// Log printing class +class LoggerTools { + private domain: number; + private prefix: string; + private format: string = '%{public}s, %{public}s'; + + constructor(prefix: string) { + this.prefix = prefix; + this.domain = 0xFF00; + this.format.toUpperCase(); + } + + 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 LoggerTools('[ExceptionHandling]') \ No newline at end of file diff --git a/entry/src/main/ets/model/DataSource.ets b/entry/src/main/ets/model/DataSource.ets new file mode 100644 index 0000000000000000000000000000000000000000..0320e6ebf2469f760bf00a12ab97eab89a332243 --- /dev/null +++ b/entry/src/main/ets/model/DataSource.ets @@ -0,0 +1,111 @@ +/* + * 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 { PreferencesManager } from './PreferencesManager'; + +// Basic implementation of IDataSource to handle data listener +class BasicDataSource implements IDataSource { + // Data change listener + private listeners: DataChangeListener[] = []; + // Data sources that require data iteration + private originDataArray: string[] = []; + + // Obtain the length of data + public totalCount(): number { + return 0; + } + + // Get specified data items + public getData(index: number): string { + return this.originDataArray[index]; + } + + // This method is called on the framework side to add a listener listener + // to the LazyForEach component's data source for listening + registerDataChangeListener(listener: DataChangeListener): void { + if (this.listeners.indexOf(listener) < 0) { + console.info('add listener'); + this.listeners.push(listener); + } + } + + // This method is called on the framework side to remove listener listening + // at the data source for the corresponding LazyForEach component + unregisterDataChangeListener(listener: DataChangeListener): void { + const pos = this.listeners.indexOf(listener); + if (pos >= 0) { + console.info('remove listener'); + this.listeners.splice(pos, 1); + } + } + + // Notify LazyForEach component to overload all child components + notifyDataReload(): void { + this.listeners.forEach(listener => { + listener.onDataReloaded(); + }) + } + + // Notify LazyForEach component to add sub components at + // the index corresponding to the index + notifyDataAdd(index: number): void { + this.listeners.forEach(listener => { + listener.onDataAdd(index); + }) + } + + // Notify the LazyForEach component that there is a change in data at + // the index corresponding to the index, and that the subcomponent needs to be rebuilt + notifyDataChange(index: number): void { + this.listeners.forEach(listener => { + listener.onDataChange(index); + }) + } + + // Notify LazyForEach component to delete the subcomponent at the index corresponding to the index + notifyDataDelete(index: number): void { + this.listeners.forEach(listener => { + listener.onDataDelete(index); + }) + } +} + +export class FaultDataSource extends BasicDataSource { + // Lazy loading data + private faultMessage: Array = []; + + // Knowledge point: Obtaining the data length of lazy loading data sources + totalCount(): number { + return this.faultMessage.length; + } + + // Get specified data items + getData(index: number): string { + return this.faultMessage[index]; + } + + // Knowledge point: Storing data into lazy loading data sources + pushData(data: string): void { + this.faultMessage.unshift(data); + // Add data to the array header + this.notifyDataAdd(0); + AppStorage.setOrCreate('faultDataSourceLength', this.totalCount()); + } + + // Knowledge point: Persisting storage exception information collection + persistenceStorage(): void { + PreferencesManager.putFaultMessage(this.faultMessage); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/EventSubscription.ets b/entry/src/main/ets/model/EventSubscription.ets new file mode 100644 index 0000000000000000000000000000000000000000..54bd72ee585b668c9e058e60c3a79461690a6d2d --- /dev/null +++ b/entry/src/main/ets/model/EventSubscription.ets @@ -0,0 +1,46 @@ +/* + * 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 { hiAppEvent } from '@kit.PerformanceAnalysisKit'; +import { Logger } from '../log/Logger'; + +const TAG: string = 'eventSubscription'; + +export function eventSubscription(): void { + // Add application event observer method, which can be used to subscribe to application events + hiAppEvent.addWatcher({ + // Developers can customize observer names, which the system will use to identify different observers + name: 'mst', + // Developers can subscribe to system events of interest, where they have subscribed to crash events + appEventFilters: [ + { + domain: hiAppEvent.domain.OS, + names: [hiAppEvent.event.APP_CRASH, hiAppEvent.event.APP_FREEZE] + } + ], + // Knowledge point: Obtain event group information. + // Developers can implement subscription callback functions themselves, + // and crash and freeze events will be called back to developers the next time the application starts + onReceive: async (domain: string, appEventGroups: Array) => { + Logger.info(TAG, `HiAppEvent onReceive: domain=${domain}`); + // Obtain event group information and perform bidirectional data binding with + // @StorageLink('faultMessage') faultMessage in the ApplicationException file + // Performance concerns: If developers have synchronized code that requires time-consuming operations, + // it is recommended to start worker or taskpool threads to handle it. + // But if developers use storage and preferences, they can simply call them. + AppStorage.setOrCreate('appEventGroups', appEventGroups); + } + }); +} \ No newline at end of file diff --git a/entry/src/main/ets/model/MockData.ets b/entry/src/main/ets/model/MockData.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c9f6829d5b0b64493396be442780d43f744a5d6 --- /dev/null +++ b/entry/src/main/ets/model/MockData.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + +// Mock button text data +export const BUTTON_TEXT: Array = [ + $r('app.string.application_exception_crash_event'), + $r('app.string.application_exception_freeze_event') +]; \ No newline at end of file diff --git a/entry/src/main/ets/model/PreferencesManager.ets b/entry/src/main/ets/model/PreferencesManager.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d998c5df99d224da039aaf093bdd0b28912e0f3 --- /dev/null +++ b/entry/src/main/ets/model/PreferencesManager.ets @@ -0,0 +1,124 @@ +/* + * 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 { preferences as dataPreferences } from '@kit.ArkData'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { FaultDataSource } from '../model/DataSource'; +import { Logger } from '../log/Logger'; + +// Knowledge point: Initialize Preferences instances for persistent storage of +// exception information and the ability to retrieve persistent data +let dataPreferencesManager: dataPreferences.Preferences = {} as dataPreferences.Preferences; + +export class PreferencesManager { + // Get Preferences instance + public static async getPreferences(faultDataSource: FaultDataSource): Promise { + Logger.info('getPreferences start.'); + try { + let val: dataPreferences.Preferences = await (dataPreferences.getPreferences(AppStorage.get('context'), + 'myStore') as Promise); + dataPreferencesManager = val; + Logger.info('Succeeded in getting preferences.'); + // Get abnormal information + await PreferencesManager.getFaultMessage(faultDataSource); + await PreferencesManager.getFaultSign(); + } catch (err) { + Logger.error('Failed to get preferences'); + } + } + + /** + * Storing abnormal data information + * @Param faultMessage exception information set + */ + public static async putFaultMessage(faultMessage: Array): Promise { + Logger.info(`putMessage start`); + try { + // Knowledge point: Storing data through the dataPreferencesManager.put method + dataPreferencesManager.put('faultMessage', JSON.stringify(faultMessage), async (err: BusinessError) => { + if (err) { + Logger.error(`Failed to put value of 'faultMessage'. code =` + err.code + ', message =' + err.message); + return; + } + Logger.info('Succeeded in putting value of faultMessage.'); + dataPreferencesManager.flush(); + }) + } catch (err) { + Logger.error(`Failed to put value of 'catch err'. code =` + err.code + ', message =' + err.message); + } + } + + /** + * Get abnormal data information + * @Param faultMessage exception information set + */ + public static async getFaultMessage(faultDataSource: FaultDataSource): Promise { + Logger.info(`getFaultMessage start`); + try { + // Knowledge point: Obtaining abnormal information data through the dataPreferencesManager.get method + const data: dataPreferences.ValueType = await dataPreferencesManager.get('faultMessage', []); + if (typeof data === 'string') { + const faultData: Array = JSON.parse(data); + // Add abnormal data to lazy loading data source + faultData.forEach((item: string) => { + faultDataSource.pushData(item); + }) + // Bidirectional data binding lazy loading data source length, updating data source length + AppStorage.setOrCreate('faultDataSourceLength', faultDataSource.totalCount()); + Logger.info('Succeeded in getting value of faultMessage.'); + } + } catch (err) { + Logger.error(`Failed to get value of 'catch err'. code =` + err.code + ', message =' + err.message); + } + } + + /** + * Storage data sign + */ + public static async putFaultSign(): Promise { + Logger.info(`putMessage start`); + try { + // Knowledge point: Storing data through the dataPreferencesManager.put method + dataPreferencesManager.put('faultSign', JSON.stringify(true), async (err: BusinessError) => { + if (err) { + Logger.error(`Failed to put value of 'faultSign'. code =` + err.code + ', message =' + err.message); + return; + } + Logger.info('Succeeded in putting value of faultSign.'); + dataPreferencesManager.flush(); + }) + } catch (err) { + Logger.error(`putFaultSign Failed to put value of 'catch err'. code =` + err.code + ', message =' + err.message); + } + } + + /** + * Get abnormal data information + */ + public static async getFaultSign(): Promise { + Logger.info(`getFaultMessage start`); + let faultSign: boolean = false; + try { + // Knowledge point: Obtain exception identifiers through the dataPreferencesManager.get method + const data: dataPreferences.ValueType = await dataPreferencesManager.get('faultSign', faultSign); + if (typeof data === 'string') { + faultSign = JSON.parse(data); + AppStorage.setOrCreate('faultSign', faultSign); + } + } catch (err) { + Logger.error(`getFaultSign Failed to get value of 'catch err'. code =` + err.code + ', message =' + err.message); + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3c3526707b836a96fee540cc9fb16840ab2babfe --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,224 @@ +/* + * 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 { hiAppEvent } from '@kit.PerformanceAnalysisKit'; +import { PreferencesManager } from '../model/PreferencesManager'; +import { BUTTON_TEXT } from '../model/MockData'; +import { FaultDataSource } from '../model/DataSource'; +import { Logger } from '../log/Logger'; + + +const TAG: string = 'FaultLogger'; // Abnormal Application Page Tag +const DELAY_TIME: number = 3000; + +@Entry +@Component +struct ApplicationExceptionView { + // Initialize the index of the clicked exception event + @Provide eventIndex: number = -1; + + build() { + Column() { + // Scenario description component + FunctionDescription({ + title: $r('app.string.application_exception_application_fault_title'), + content: $r('app.string.application_exception_application_fault_description') + }) + // Abnormal information display component + FaultArea() + // Constructing Abnormal Components + FaultConstruction() + } + .padding($r('app.string.ohos_id_card_padding_start')) + .backgroundColor($r('app.color.ohos_id_color_sub_background')) + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + .height($r('app.string.ohos_global_state_dialog_hundred_percent')) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP,SafeAreaEdge.BOTTOM]) + } +} + +@Component +struct FaultArea { + // Perform bidirectional data binding on the array length of lazy loading data sources + @StorageLink('faultDataSourceLength') faultDataSourceLength: number = 0; + // Bidirectional data binding event group, bound to AppStorage. setOrCreate, + // this variable changes and triggers the getFaultMessage function + @StorageLink('appEventGroups') @Watch('getFaultMessage') appEventGroups: Array = []; + // Abnormal trigger sign + @StorageLink('faultSign') faultSign: boolean = false; + // The index of the clicked abnormal event + @Consume eventIndex: number; + // Data source for lazy loading + @State faultDataSource: FaultDataSource = new FaultDataSource(); + private scroller: Scroller = new Scroller(); + + async aboutToAppear() { + Logger.info(TAG, `aboutToAppear start`); + // Get Preferences instance + await PreferencesManager.getPreferences(this.faultDataSource); + // First, retrieve data from the persistent storage, + // then add the previous application exception information to the list header, + // and update the persistent storage + this.getFaultMessage(); + // Reset appEventGroups in AppStorage to avoid adding duplicate data + AppStorage.setOrCreate('appEventGroups', []); + } + + // Obtain application exception information + async getFaultMessage() { + Logger.info(TAG, `getAppEventGroups start`); + if (this.appEventGroups && this.appEventGroups.length > 0) { + // Traverse event groups + this.appEventGroups.forEach((eventGroup: hiAppEvent.AppEventGroup) => { + // Traverse the collection of event objects + eventGroup.appEventInfos.forEach(async (eventInfo: hiAppEvent.AppEventInfo) => { + let message: string = ''; + message += `HiAppEvent eventInfo.domain=${eventInfo.domain}\n` + + `HiAppEvent eventInfo.name=${eventInfo.name}\n` + + `HiAppEvent eventInfo.eventType=${eventInfo.eventType}\n` + + `HiAppEvent eventInfo.params.time=${eventInfo.params['time']}\n` + + `HiAppEvent eventInfo.params.crash_type=${eventInfo.params['crash_type']}\n` + + `HiAppEvent eventInfo.params.foreground=${eventInfo.params['foreground']}\n` + + `HiAppEvent eventInfo.params.bundle_version=${eventInfo.params['bundle_version']}\n` + + `HiAppEvent eventInfo.params.bundle_name=${eventInfo.params['bundle_name']}\n` + + `HiAppEvent eventInfo.params.exception=${JSON.stringify(eventInfo.params['exception'])}\n` + + `HiAppEvent eventInfo.params.hilog.size=${eventInfo.params['hilog'].length}\n`; + // Knowledge point: Storing exception information in the array faultMessage + this.faultDataSource.pushData(message); + }) + }) + } + // Knowledge point: Persisting storage exception information collection + this.faultDataSource.persistenceStorage(); + } + + build() { + List({ scroller:this.scroller }) { + // Add a judgment, if the number of information in the set of abnormal information is greater than 0, traverse the abnormal information + if (this.faultDataSourceLength > 0) { + LazyForEach(this.faultDataSource, (message: string) => { + ListItem() { + Text(message) + .textAlign(TextAlign.Start) + } + }, (item: string) => item) + } else { + ListItem() { + // Respond to specified information based on the index of the clicked event + Text(this.eventIndex === 0 ? $r('app.string.application_exception_crash_event_message') : + (this.eventIndex === 1 ? $r('app.string.application_exception_freeze_event_message') : + (this.faultSign ? $r('app.string.application_exception_data_delay_toast') : + $r('app.string.application_exception_no_message')))) + } + } + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + .height($r('app.string.ohos_id_elements_list_high')) + .borderRadius($r('app.string.ohos_id_corner_radius_default_m')) + .padding($r('app.string.ohos_id_card_padding_start')) + .margin({ top: $r('app.string.ohos_id_elements_margin_vertical_l') }) + .backgroundColor(Color.White) + } +} + +@Component +struct FaultConstruction { + // The index of the clicked abnormal event + @Consume eventIndex: number; + // Perform bidirectional data binding on the array length of lazy loading data sources + @StorageLink('faultDataSourceLength') faultDataSourceLength: number = 0; + // Abnormal trigger sign + @StorageLink('faultSign') faultSign: boolean = false; + + handleOperate(index: number) { + switch (index) { + case 0: + // Note: This is a deliberately constructed bug + // Construct an APP-CRASH scenario in the button click function to trigger an application crash event + const result: object = JSON.parse(''); + break; + case 1: + // Note: This is a deliberately constructed bug + // Construct an APP-FREEZE scenario in the button click function, + // trigger the application freeze event, and execute an infinite loop after 500ms + while (true) { + } + default: + break; + } + } + + build() { + Stack() { + Column(){ + ForEach(BUTTON_TEXT, (item: string, index: number) => { + Button(item) + .type(ButtonType.Capsule) + .size({ width: $r('app.string.ohos_global_state_dialog_hundred_percent') }) + .borderRadius($r('app.string.ohos_id_corner_radius_default_m')) + .margin({ top: $r('app.string.ohos_id_button_margin_top') }) + .onClick(() => { + // Abnormal trigger sign + this.faultSign = true; + PreferencesManager.putFaultSign(); + // When clicking on an exception, clear the page information data + // and display the exception description information. + // To control the display of page information data, + // this variable needs to be set to 0 + this.faultDataSourceLength = 0; + // Update the index of clicked abnormal events + this.eventIndex = index; + // Execute system crash operation after 3s + setTimeout(() => { + this.handleOperate(index); + }, DELAY_TIME); + }) + }, (item: string) => JSON.stringify(item)) + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + .margin({ bottom: $r('app.string.ohos_id_button_margin_bottom')}) + .align(Alignment.Bottom) + .flexGrow(1) + } +} + +@Component +struct FunctionDescription { + private title: ResourceStr = ''; + private content: ResourceStr = ''; + + build() { + Column() { + Row() { + Text(this.title) + .fontSize($r('app.string.ohos_id_text_size_headline')) + .fontWeight(FontWeight.Medium) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxLines(1) + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + .margin({ bottom: $r('app.string.ohos_id_elements_margin_vertical_m') }) + Row() { + Text(this.content) + .wordBreak(WordBreak.NORMAL) + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + } + .width($r('app.string.ohos_global_state_dialog_hundred_percent')) + .padding($r('app.string.ohos_id_card_padding_start')) + } +} \ No newline at end of file diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b8ecc36aae5ad1f7508322140162cedb35285047 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,40 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "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: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/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..b4ca8bc7b8bb3804355abde71cc7038529d23c5f --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,16 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "ohos_id_color_sub_background", + "value": "#F1F3F5" + }, + { + "name": "ohos_id_color_foreground", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9ebd2cbc476c4b4d12f7449f72b2aa23110270cd --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,120 @@ +{ + "string": [ + { + "name": "application_exception_crash_event", + "value": "构建应用崩溃事件" + }, + { + "name": "application_exception_freeze_event", + "value": "构建应用卡死事件" + }, + { + "name": "application_exception_application_fault_title", + "value": "应用异常信息获取" + }, + { + "name": "application_exception_application_fault_description", + "value": "点击构建异常事件,3s之后触发系统异常事件,需要重新启动应用并进入本页面,由于规格原因需等待1min左右才能获取异常数据" + }, + { + "name": "application_exception_crash_event_message", + "value": "3s之后触发系统崩溃事件,需要重新启动应用并进入本页面获取上次异常退出原因" + }, + { + "name": "application_exception_freeze_event_message", + "value": "3s之后触发系统卡死事件,需要重新启动应用并进入本页面获取上次异常退出原因" + }, + { + "name": "application_exception_no_message", + "value": "暂无信息" + }, + { + "name": "application_exception_data_delay_toast", + "value": "由于规格原因,当前异常事件接收有延迟,数据大约在1min左右会进行更新" + }, + { + "name": "ohos_id_text_size_headline", + "value": "20" + }, + { + "name": "ohos_id_text_font_family_medium", + "value": "medium" + }, + { + "name": "ohos_id_text_size_body1", + "value": "14" + }, + { + "name": "ohos_id_text_size_body2", + "value": "14" + }, + { + "name": "ohos_id_text_size_body3", + "value": "12" + }, + { + "name": "ohos_id_text_size_caption", + "value": "10" + }, + { + "name": "ohos_id_corner_radius_default_l", + "value": "16" + }, + { + "name": "ohos_id_corner_radius_default_m", + "value": "12" + }, + { + "name": "ohos_id_corner_radius_subtab", + "value": "4" + }, + { + "name": "ohos_id_card_margin_start", + "value": "12" + }, + { + "name": "ohos_id_card_padding_start", + "value": "12" + }, + { + "name": "ohos_id_button_margin_top", + "value": "12" + }, + { + "name": "ohos_id_button_margin_bottom", + "value": "4" + }, + { + "name": "ohos_id_elements_margin_vertical_m", + "value": "6" + }, + { + "name": "ohos_id_elements_margin_vertical_l", + "value": "16" + }, + { + "name": "ohos_id_elements_list_high", + "value": "300" + }, + { + "name": "ohos_global_state_dialog_sixty_percent", + "value": "60%" + }, + { + "name": "ohos_global_state_dialog_hundred_percent", + "value": "100%" + }, + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "异常处理" + } + ] +} diff --git a/entry/src/main/resources/base/media/background.png b/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/entry/src/main/resources/base/media/background.png differ diff --git a/entry/src/main/resources/base/media/foreground.png b/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/entry/src/main/resources/base/media/foreground.png differ diff --git a/entry/src/main/resources/base/media/layered_image.json b/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/startIcon.png b/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/entry/src/main/resources/base/media/startIcon.png differ diff --git a/entry/src/main/resources/base/profile/backup_config.json b/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/entry/src/main/resources/en_US/element/string.json b/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fdcec0d5d336b0afbf96a5d66591e2334b2cd068 --- /dev/null +++ b/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "application_exception_crash_event", + "value": "Click to build application crash event" + }, + { + "name": "application_exception_freeze_event", + "value": "Click to build application stuck event" + }, + { + "name": "application_exception_application_fault_title", + "value": "Application fault message" + }, + { + "name": "application_exception_application_fault_description", + "value": "Click to build an abnormal event. After 3 seconds, the system abnormal event will be triggered. You need to restart the application and enter this page to obtain the reason for the last abnormal exit" + }, + { + "name": "application_exception_crash_event_message", + "value": "After 3 seconds, the system crash event will be triggered, and the application needs to be restarted to enter this page to obtain the last login exception information" + }, + { + "name": "application_exception_freeze_event_message", + "value": "After 3 seconds, if the system freezes, the application needs to be restarted and this page should be accessed to obtain the last login exception information" + }, + { + "name": "application_exception_no_message", + "value": "no_message" + }, + { + "name": "application_exception_data_delay_toast", + "value": "数据大约在1-3min会进行更新" + } + ] +} diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..04fac022b141786b4729ff57cbd79fe821bea61b --- /dev/null +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "application_exception_crash_event", + "value": "构建应用崩溃事件" + }, + { + "name": "application_exception_freeze_event", + "value": "构建应用卡死事件" + }, + { + "name": "application_exception_application_fault_title", + "value": "应用异常信息获取" + }, + { + "name": "application_exception_application_fault_description", + "value": "点击构建异常事件,3s之后触发系统异常事件,需要重新启动应用并进入本页面,由于规格原因需等待1min左右才能获取异常数据" + }, + { + "name": "application_exception_crash_event_message", + "value": "3s之后触发系统崩溃事件,需要重新启动应用并进入本页面获取上次异常退出原因" + }, + { + "name": "application_exception_freeze_event_message", + "value": "3s之后触发系统卡死事件,需要重新启动应用并进入本页面获取上次异常退出原因" + }, + { + "name": "application_exception_no_message", + "value": "暂无信息" + }, + { + "name": "application_exception_data_delay_toast", + "value": "由于规格原因,当前异常事件接收有延迟,数据大约在1min左右会进行更新" + } + ] +} diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..06b2783670a348f95533b352c1ceda909a842bbc --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "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/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ebdda7e54d1c41e952f1c7f6993c6d15ea3d146d --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "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/screenshots/device/Preview_1.png b/screenshots/device/Preview_1.png new file mode 100644 index 0000000000000000000000000000000000000000..090dd6e4c753e6d4d35f2891054c13ef3f346a28 Binary files /dev/null and b/screenshots/device/Preview_1.png differ diff --git a/screenshots/device/Preview_2.png b/screenshots/device/Preview_2.png new file mode 100644 index 0000000000000000000000000000000000000000..e2f6f4ef795128d884613a55047f725dac132772 Binary files /dev/null and b/screenshots/device/Preview_2.png differ diff --git a/screenshots/device/Preview_3.png b/screenshots/device/Preview_3.png new file mode 100644 index 0000000000000000000000000000000000000000..4265b6c532a83634ceac7e7682d57235c793ce57 Binary files /dev/null and b/screenshots/device/Preview_3.png differ