From 876c6d17ef5a7884ddd3a0ca2da4b84023f7b05f Mon Sep 17 00:00:00 2001 From: hwx869784 <“zhouxj1111@thundersoft.com”> Date: Wed, 20 Mar 2024 15:37:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=89=E5=85=A8=E9=9A=90=E7=A7=81=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 11 + AppScope/app.json5 | 10 + AppScope/resources/base/element/string.json | 8 + AppScope/resources/base/media/app_icon.png | Bin 0 -> 6790 bytes build-profile.json5 | 68 +++ bundle.json | 166 ++++++ entry/.gitignore | 6 + entry/build-profile.json5 | 14 + entry/hvigorfile.ts | 6 + entry/oh-package.json5 | 10 + entry/src/main/ets/common/base/BaseIntent.ets | 18 + entry/src/main/ets/common/base/BaseModel.ets | 17 + entry/src/main/ets/common/base/BaseState.ets | 18 + .../main/ets/common/base/BaseViewModel.ets | 65 +++ .../main/ets/common/baseUtile/ConfigData.ets | 92 ++++ .../ets/common/bean/AccessTableTypedef.ets | 20 + .../main/ets/common/bean/BundleInfoBean.ets | 37 ++ .../ets/common/bean/DefaultMenuConfig.ets | 20 + entry/src/main/ets/common/bean/MenuConfig.ets | 64 +++ entry/src/main/ets/common/bean/MenuInfo.ets | 45 ++ .../ets/common/components/ComponentConfig.ets | 37 ++ .../common/components/TitleBarComponent.ets | 84 +++ .../ets/common/components/headComponent.ets | 69 +++ .../main/ets/common/constants/ComConstant.ets | 85 +++ .../common/constants/DataShareConstant.ets | 83 +++ .../common/constants/HiSysEventConstant.ets | 46 ++ .../ets/common/constants/RouterConstant.ets | 47 ++ .../main/ets/common/utils/AutoMenuManager.ets | 378 ++++++++++++++ .../common/utils/GetSelfBundleInfoUtils.ets | 56 ++ .../main/ets/common/utils/HiSysEventUtil.ets | 175 +++++++ entry/src/main/ets/common/utils/Logger.ets | 47 ++ .../src/main/ets/common/utils/RawFileUtil.ets | 72 +++ .../src/main/ets/common/utils/RdbManager.ets | 101 ++++ .../main/ets/common/utils/ResourceUtil.ets | 77 +++ .../src/main/ets/common/utils/StringUtil.ets | 35 ++ .../main/ets/entryability/EntryAbility.ets | 57 ++ .../ets/main/auto_menu/AutoMenuIntent.ets | 57 ++ .../main/ets/main/auto_menu/AutoMenuModel.ets | 234 +++++++++ .../ets/main/auto_menu/AutoMenuViewModel.ets | 63 +++ .../ets/main/auto_menu/AutoMenuViewState.ets | 25 + .../ets/model/bundleInfo/BundleInfoModel.ets | 274 ++++++++++ .../locationServicesImpl/ListenerBean.ets | 22 + .../locationServicesImpl/LocationService.ets | 80 +++ .../LocationViewModel.ets | 54 ++ entry/src/main/ets/pages/Index.ets | 175 +++++++ entry/src/main/ets/pages/UiExtensionPage.ets | 60 +++ entry/src/main/ets/pages/locationServices.ets | 89 ++++ .../privacy/PrivacyProtectionListView.ets | 116 +++++ entry/src/main/module.json5 | 54 ++ .../main/resources/base/element/color.json | 25 + .../main/resources/base/element/float.json | 262 ++++++++++ .../main/resources/base/element/string.json | 487 ++++++++++++++++++ .../src/main/resources/base/media/ic_back.svg | 13 + .../base/media/ic_settings_arrow.svg | 28 + entry/src/main/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/main_pages.json | 7 + .../main/resources/en_US/element/string.json | 487 ++++++++++++++++++ .../main/resources/rawfile/advice_config.json | 30 ++ .../resources/rawfile/default_policy.json | 47 ++ .../resources/rawfile/menu_list_rule.json | 23 + .../main/resources/rawfile/ordering_rule.json | 21 + .../rawfile/searchConfig/searchPage.json | 24 + .../main/resources/zh_CN/element/string.json | 486 +++++++++++++++++ entry/src/ohosTest/Test.json | 37 ++ entry/src/ohosTest/ets/test/Ability.test.ets | 50 ++ entry/src/ohosTest/ets/test/List.test.ets | 28 + entry/src/ohosTest/ets/test/Model.test.ets | 133 +++++ .../ets/test/bean/BundleInfoBean.test.ets | 37 ++ .../LocationService.test.ets | 76 +++ .../LocationViewModel.test.ets | 73 +++ .../ohosTest/ets/test/common/Common.test.ets | 100 ++++ .../ets/test/model/CheckedStateParameter.ets | 33 ++ .../ohosTest/ets/testability/TestAbility.ets | 65 +++ .../ohosTest/ets/testability/pages/Index.ets | 52 ++ .../ets/testrunner/OpenHarmonyTestRunner.ts | 61 +++ entry/src/ohosTest/module.json5 | 36 ++ .../resources/base/element/color.json | 8 + .../resources/base/element/string.json | 16 + .../ohosTest/resources/base/media/ic_back.svg | 13 + .../base/media/ic_settings_arrow.svg | 28 + .../ohosTest/resources/base/media/icon.png | Bin 0 -> 6790 bytes .../resources/base/profile/test_pages.json | 5 + hisysevent.yaml | 183 +++++++ hiview.gni | 73 +++ hiviewdfx.yaml | 101 ++++ hvigor/hvigor-config.json5 | 18 + hvigor/hvigor-wrapper.js | 1 + hvigorfile.ts | 6 + hvigorw | 48 ++ hvigorw.bat | 64 +++ kernel_vendor.yaml | 415 +++++++++++++++ oh-package-lock.json5 | 13 + oh-package.json5 | 12 + ...enter_com.ohos.security_privacy_center.cer | 29 ++ ...enter_com.ohos.security_privacy_center.p12 | Bin 0 -> 1128 bytes ...enter_com.ohos.security_privacy_center.p7b | Bin 0 -> 3586 bytes .../ac/040c8a764ec74ae8a17c35d56c582fb5 | 1 + .../ce/15f1a3b4a475490992130e06e197fc89 | Bin 0 -> 48 bytes .../fd/0/1717ff0face041069eaaa1269a4e883e | 1 + .../fd/1/d6127b65e5824dcfbec9a12b0fa742a2 | 1 + .../fd/2/7d6d6df6c70b416c9f0a043cbab47b94 | 1 + 101 files changed, 7205 insertions(+) create mode 100644 .gitignore create mode 100644 AppScope/app.json5 create mode 100644 AppScope/resources/base/element/string.json create mode 100644 AppScope/resources/base/media/app_icon.png create mode 100644 build-profile.json5 create mode 100644 bundle.json create mode 100644 entry/.gitignore create mode 100644 entry/build-profile.json5 create mode 100644 entry/hvigorfile.ts create mode 100644 entry/oh-package.json5 create mode 100644 entry/src/main/ets/common/base/BaseIntent.ets create mode 100644 entry/src/main/ets/common/base/BaseModel.ets create mode 100644 entry/src/main/ets/common/base/BaseState.ets create mode 100644 entry/src/main/ets/common/base/BaseViewModel.ets create mode 100644 entry/src/main/ets/common/baseUtile/ConfigData.ets create mode 100644 entry/src/main/ets/common/bean/AccessTableTypedef.ets create mode 100644 entry/src/main/ets/common/bean/BundleInfoBean.ets create mode 100644 entry/src/main/ets/common/bean/DefaultMenuConfig.ets create mode 100644 entry/src/main/ets/common/bean/MenuConfig.ets create mode 100644 entry/src/main/ets/common/bean/MenuInfo.ets create mode 100644 entry/src/main/ets/common/components/ComponentConfig.ets create mode 100644 entry/src/main/ets/common/components/TitleBarComponent.ets create mode 100644 entry/src/main/ets/common/components/headComponent.ets create mode 100644 entry/src/main/ets/common/constants/ComConstant.ets create mode 100644 entry/src/main/ets/common/constants/DataShareConstant.ets create mode 100644 entry/src/main/ets/common/constants/HiSysEventConstant.ets create mode 100644 entry/src/main/ets/common/constants/RouterConstant.ets create mode 100644 entry/src/main/ets/common/utils/AutoMenuManager.ets create mode 100644 entry/src/main/ets/common/utils/GetSelfBundleInfoUtils.ets create mode 100644 entry/src/main/ets/common/utils/HiSysEventUtil.ets create mode 100644 entry/src/main/ets/common/utils/Logger.ets create mode 100644 entry/src/main/ets/common/utils/RawFileUtil.ets create mode 100644 entry/src/main/ets/common/utils/RdbManager.ets create mode 100644 entry/src/main/ets/common/utils/ResourceUtil.ets create mode 100644 entry/src/main/ets/common/utils/StringUtil.ets create mode 100644 entry/src/main/ets/entryability/EntryAbility.ets create mode 100644 entry/src/main/ets/main/auto_menu/AutoMenuIntent.ets create mode 100644 entry/src/main/ets/main/auto_menu/AutoMenuModel.ets create mode 100644 entry/src/main/ets/main/auto_menu/AutoMenuViewModel.ets create mode 100644 entry/src/main/ets/main/auto_menu/AutoMenuViewState.ets create mode 100644 entry/src/main/ets/model/bundleInfo/BundleInfoModel.ets create mode 100644 entry/src/main/ets/model/locationServicesImpl/ListenerBean.ets create mode 100644 entry/src/main/ets/model/locationServicesImpl/LocationService.ets create mode 100644 entry/src/main/ets/model/locationServicesImpl/LocationViewModel.ets create mode 100644 entry/src/main/ets/pages/Index.ets create mode 100644 entry/src/main/ets/pages/UiExtensionPage.ets create mode 100644 entry/src/main/ets/pages/locationServices.ets create mode 100644 entry/src/main/ets/view/privacy/PrivacyProtectionListView.ets create mode 100644 entry/src/main/module.json5 create mode 100644 entry/src/main/resources/base/element/color.json create mode 100644 entry/src/main/resources/base/element/float.json create mode 100644 entry/src/main/resources/base/element/string.json create mode 100644 entry/src/main/resources/base/media/ic_back.svg create mode 100644 entry/src/main/resources/base/media/ic_settings_arrow.svg create mode 100644 entry/src/main/resources/base/media/icon.png create mode 100644 entry/src/main/resources/base/profile/main_pages.json create mode 100644 entry/src/main/resources/en_US/element/string.json create mode 100644 entry/src/main/resources/rawfile/advice_config.json create mode 100644 entry/src/main/resources/rawfile/default_policy.json create mode 100644 entry/src/main/resources/rawfile/menu_list_rule.json create mode 100644 entry/src/main/resources/rawfile/ordering_rule.json create mode 100644 entry/src/main/resources/rawfile/searchConfig/searchPage.json create mode 100644 entry/src/main/resources/zh_CN/element/string.json create mode 100644 entry/src/ohosTest/Test.json create mode 100644 entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 entry/src/ohosTest/ets/test/List.test.ets create mode 100644 entry/src/ohosTest/ets/test/Model.test.ets create mode 100644 entry/src/ohosTest/ets/test/bean/BundleInfoBean.test.ets create mode 100644 entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationService.test.ets create mode 100644 entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationViewModel.test.ets create mode 100644 entry/src/ohosTest/ets/test/common/Common.test.ets create mode 100644 entry/src/ohosTest/ets/test/model/CheckedStateParameter.ets create mode 100644 entry/src/ohosTest/ets/testability/TestAbility.ets create mode 100644 entry/src/ohosTest/ets/testability/pages/Index.ets create mode 100644 entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts create mode 100644 entry/src/ohosTest/module.json5 create mode 100644 entry/src/ohosTest/resources/base/element/color.json create mode 100644 entry/src/ohosTest/resources/base/element/string.json create mode 100644 entry/src/ohosTest/resources/base/media/ic_back.svg create mode 100644 entry/src/ohosTest/resources/base/media/ic_settings_arrow.svg create mode 100644 entry/src/ohosTest/resources/base/media/icon.png create mode 100644 entry/src/ohosTest/resources/base/profile/test_pages.json create mode 100644 hisysevent.yaml create mode 100644 hiview.gni create mode 100644 hiviewdfx.yaml create mode 100644 hvigor/hvigor-config.json5 create mode 100644 hvigor/hvigor-wrapper.js create mode 100644 hvigorfile.ts create mode 100644 hvigorw create mode 100644 hvigorw.bat create mode 100644 kernel_vendor.yaml create mode 100644 oh-package-lock.json5 create mode 100644 oh-package.json5 create mode 100644 signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.cer create mode 100644 signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p12 create mode 100644 signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p7b create mode 100644 signature/material/ac/040c8a764ec74ae8a17c35d56c582fb5 create mode 100644 signature/material/ce/15f1a3b4a475490992130e06e197fc89 create mode 100644 signature/material/fd/0/1717ff0face041069eaaa1269a4e883e create mode 100644 signature/material/fd/1/d6127b65e5824dcfbec9a12b0fa742a2 create mode 100644 signature/material/fd/2/7d6d6df6c70b416c9f0a043cbab47b94 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbabf77 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000..56143f3 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.ohos.security_privacy_center", + "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 0000000..48f2534 --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "security_privacy_center" + } + ] +} diff --git a/AppScope/resources/base/media/app_icon.png b/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6Rh_-|%Yy2li*tHO>_vcnuZ7OR_xkAIuIU&x z-|8Y0wj|6|a6_I(v91y%k_kNw6pnkNdxjqG8!%Vz_d%c_!X+6-;1`GC9_FpjoHev5fEV7RhJ>r=mh-jp$fqbqRJ=obwdgLDVP5+s zy1=_DWG0Y-Jb3t^WXmkr(d9~08k-|#Ly zaNOmT(^9tIb&eb4%CzIT zAm3CUtWSr1t4?h1kk#NBi{U|pJsl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;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + private _model?: M; + private _viewState?: S; + + public getViewState(): S { + if (this._viewState === null || this._viewState === undefined) { + this._viewState = this.initViewState(); + } + return this._viewState; + } + + public async processIntent(intent: BaseIntent): Promise { + Logger.info(TAG, 'start processIntent: ' + intent.getIntentTag()); + if (this._model === null || this._model === undefined) { + this._model = this.initModel(); + } + if (this._viewState === null || this._viewState === undefined) { + this._viewState = this.initViewState(); + } + if (this._model !== null && this._viewState !== null) { + try { + return await this.processIntentWithModel(intent, this._model, this._viewState); + } catch (err) { + Logger.error(TAG, 'error when process intent.' + intent.getIntentTag()); + } + } + return ProcessResult.FAIL; + } + + protected abstract initModel(): M; + + protected abstract initViewState(): S; + + protected abstract processIntentWithModel(intent: BaseIntent, model: M, viewState: S): Promise; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/baseUtile/ConfigData.ets b/entry/src/main/ets/common/baseUtile/ConfigData.ets new file mode 100644 index 0000000..8e83fc3 --- /dev/null +++ b/entry/src/main/ets/common/baseUtile/ConfigData.ets @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2022-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 settings from '@ohos.settings'; + +export class ConfigData { + FILE_URI = '/data/accounts/account_0/applications/com.ohos.settings' + + '/com.ohos.settings/assets/phone/resources/rawfile/'; + PREFERENCES_PATH = '/data/accounts/account_0/appdata/com.ohos.settings/sharedPreference/SettingPreferences'; + BRIGHTNESS_SAVE_VALUE_KEY = 'BrightnessSaveValue'; + SENT_EVENT_BROADCAST_BRIGHTNESS_VALUE = 'BRIGHTNESS_VALUE'; + SENT_EVENT_BROADCAST_VOLUME_VALUE = 'VOLUME_VALUE'; + SENT_EVENT_WIFI_CONNECT_NAME = 'WIFI_CONNECT_NAME'; + SENT_EVENT_AUDIO_RINGER_MODE = 'AUDIO_RINGER_MODE'; + SENT_EVENT_AUDIO_VOLUME_VALUE = 'AUDIO_VOLUME_VALUE'; + BRIGHTNESS_DEFAULT_VALUE = 50; + DEFAULT_BUNDLE_NAME = 'com.ohos.settings'; + DATE_AND_TIME_YEAR = 'DATE_AND_TIME_YEAR'; + DATE_AND_TIME_MONTH = 'DATE_AND_TIME_MONTH'; + DATE_AND_TIME_DAY = 'DATE_AND_TIME_DAY'; + TAG = 'Settings '; + // page request + PAGE_REQUEST_CODE_KEY = 'pageRequestCode'; + PAGE_RESULT_KEY = 'pageResult'; + PAGE_RESULT_OK = -1; + PAGE_RESULT_NG = 0; + // password request code + PAGE_REQUEST_CODE_PASSWORD_CREATE = 20001; + PAGE_REQUEST_CODE_PASSWORD_CHANGE = 20003; + PAGE_REQUEST_CODE_PASSWORD_DISABLE = 20004; + WH_100_100 = '100%'; + WH_25_100 = '25%'; + WH_30_100 = '30%'; + WH_33_100 = '33%'; + WH_35_100 = '35%'; + WH_40_100 = '40%'; + WH_45_100 = '45%'; + WH_50_100 = '50%'; + WH_55_100 = '55%'; + WH_83_100 = '83%'; + WH_90_100 = '90%'; + GRID_CONTAINER_GUTTER_24 = 24; + GRID_CONTAINER_MARGIN_24 = 24; + LAYOUT_WEIGHT_1 = 1; + value_20 = 20; + font_20 = 20; + MAX_LINES_1 = 1; + MAX_LINES_2 = 2; + MAX_LINES_3 = 3; + DURATION_TIME = 200; + FUNCTION_TYPE_HDC = 4; + TIME_FORMAT_24 = "24"; + TIME_FORMAT_12 = "12"; + TIME_FORMAT_KEY = settings.date.TIME_FORMAT; + SETTINGSDATA_DEVICE_NAME = settings.general.DEVICE_NAME; + SETTINGSDATA_BRIGHTNESS = settings.display.SCREEN_BRIGHTNESS_STATUS; + SLIDER_CHANG_MODE_MOVING = 1; + SLIDER_CHANG_MODE_END = 2; + //Language And Region + ADDLANGUAGES = 'addedLanguages'; + CURRENTREGION = 'currentRegion'; + //Key of StoragePath + STORAGEPATHKEY = 'storagePath'; + //StartAbility + FACEAUTH_BUNDLE_NAME = 'com.ohos.settings.faceauth'; + FACEAUTH_ABILITY_NAME = 'com.ohos.settings.faceauth.enrollmentstartview'; + PERMISSION_MANAGER_BUNDLE_NAME = 'com.ohos.permissionmanager'; + PERMISSION_MANAGER_ABILITY_NAME = 'com.ohos.permissionmanager.MainAbility'; + MOBILE_DATA_BUNDLE_NAME = 'com.ohos.callui'; + MOBILE_DATA_ABILITY_NAME = 'com.ohos.mobiledatasettings.MainAbility'; + softWareUpDatesBundleName = 'com.ohos.updateapp'; + softWareUpDatesAbilityName = 'com.ohos.updateapp.MainAbility'; + SECURITY_BUNDLE_NAME = 'com.ohos.certmanager'; + SECURITY_ABILITY_NAME = 'MainAbility'; + DEVICE_NAME = 'OpenHarmony 2.0 Canary'; +} + +let configData = new ConfigData(); + +export default configData as ConfigData; \ No newline at end of file diff --git a/entry/src/main/ets/common/bean/AccessTableTypedef.ets b/entry/src/main/ets/common/bean/AccessTableTypedef.ets new file mode 100644 index 0000000..93c30a7 --- /dev/null +++ b/entry/src/main/ets/common/bean/AccessTableTypedef.ets @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022-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 interface AccessTableTypedef { + tableName: string; + sqlCreate: string; + columns: string[]; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/bean/BundleInfoBean.ets b/entry/src/main/ets/common/bean/BundleInfoBean.ets new file mode 100644 index 0000000..67f464c --- /dev/null +++ b/entry/src/main/ets/common/bean/BundleInfoBean.ets @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2022-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 interface ResourceObj { + bundleName: string, + moduleName: string, + id: number +} + +export interface BundleInfoBean { + bundleName: string; + icon: ResourceStr | PixelMap; + iconId: number; + label: string; + labelId: number; + permissionName: string; + permissionLabel: string; + checkedState: string; + checkedStateLabel: Resource | string; + zhTag: string; + indexTag: string; + language: string; + labelResource: Resource | ResourceObj; + iconResource: Resource | ResourceObj; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/bean/DefaultMenuConfig.ets b/entry/src/main/ets/common/bean/DefaultMenuConfig.ets new file mode 100644 index 0000000..83b9f2d --- /dev/null +++ b/entry/src/main/ets/common/bean/DefaultMenuConfig.ets @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022-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 default interface DefaultMenuConfig { + businessId: string; + bundleName: string; + priority: number; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/bean/MenuConfig.ets b/entry/src/main/ets/common/bean/MenuConfig.ets new file mode 100644 index 0000000..b69cbc3 --- /dev/null +++ b/entry/src/main/ets/common/bean/MenuConfig.ets @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2022-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. + */ + +/** + * 接入应用metadata配置的security_privacy.json文件对应属性,详细内容可查询 + * https://wiki.huawei.com/domains/2308/wiki/9312/WIKI202308301913971 + */ +export interface MenuConfig { + businessId: string, + + // card|list(card代表卡片方式接入,list代表列表方式接入) + displayedMode: string; + + // 卡片式菜单显示时的图标 + iconResource: string; + + // 入口菜单显示的主标题字串的资源名 + mainTitleResource: string; + + // 入口菜单显示的副标题字串的资源名 + subTitleResource: string; + + /** + * uri路径,该ability继承自DataShareExtensionAbility,接入方可覆写其query函数,通过query函数返回的结果集告知安全隐私中心,是否需要展示该菜单 + * query结果集为KEY_VALUE形式 + * key: SHOW_RESULT + * Value: + * 0x55,展示 + * 0xaa,不展示 + */ + showControlAbilityUri: string; + displayUserConfig: string; + + /** + * 0: 表示被拉起的ability为UiAbility + * 1: 表示被拉起的ability为UiextensionAbility + */ + dstAbilityMode: number; + + /** + * 跳转的目的ability + * dstAbilityMode为0时,该ability为UiAbility + * dstAbilityMode为1时,该ability需继承自UIExtensionAbility,接入方在此ability中加载自身页面 + */ + dstAbilityName: string; + + // 跳转的目的bundle名 + dstBundleName: string; + + // 应用的包名 + bundleName: string; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/bean/MenuInfo.ets b/entry/src/main/ets/common/bean/MenuInfo.ets new file mode 100644 index 0000000..d47daf9 --- /dev/null +++ b/entry/src/main/ets/common/bean/MenuInfo.ets @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2022-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 default interface MenuInfo { + businessId: string; + intent: string; + + // 用户id + userId: number; + + //图标背景颜色 + iconBackgroundColorResource: string; + + // 优先级 + priority: number; + + //是否展示(0: 不支持, 1:支持) + isSupport: number; + + //是否可点击(0:不可点击, 1: 可点击) + isClickable: number; + displayedMode: string; + iconResource: string; + mainTitleResource: string; + subTitleResource: string; + showControlAbilityUri: string; + dstAbilityMode: number; + dstAbilityName: string; + dstBundleName: string; + bundleName: string; + titleString: string; + subTitleString: string; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/components/ComponentConfig.ets b/entry/src/main/ets/common/components/ComponentConfig.ets new file mode 100644 index 0000000..729808b --- /dev/null +++ b/entry/src/main/ets/common/components/ComponentConfig.ets @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2022-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 ComponentConfig { + WH_100_100 = '100%'; + WH_30_100 = '30%'; + WH_33_100 = '33%'; + WH_35_100 = '35%'; + WH_40_100 = '40%'; + WH_45_100 = '45%'; + WH_50_100 = '50%'; + WH_55_100 = '55%'; + WH_83_100 = '83%'; + WH_90_100 = '90%'; + value_20 = 20; + font_20 = 20; + MAX_LINES_1 = 1; + MAX_LINES_2 = 2; + MAX_LINES_3 = 3; + DURATION_TIME = 200; +} + +let componentConfig = new ComponentConfig(); + +export default componentConfig as ComponentConfig; \ No newline at end of file diff --git a/entry/src/main/ets/common/components/TitleBarComponent.ets b/entry/src/main/ets/common/components/TitleBarComponent.ets new file mode 100644 index 0000000..eccc5df --- /dev/null +++ b/entry/src/main/ets/common/components/TitleBarComponent.ets @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2022-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 common from '@ohos.app.ability.common'; +import Constants from '../constants/ComConstant'; + +@Component +export default struct TitleBar { + private context = getContext(this) as common.UIAbilityContext; + @Prop title: string = ''; + @State isBackOnTouch: boolean = false; + @Prop isSplitMode: boolean = false; + onBackClick?: () => void; + + build() { + // 分栏模式下首页不显示返回按钮 + Column() { + Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { + Row() { + Image($r('app.media.ic_back')) + .fillColor($r('sys.color.ohos_id_color_primary')) + .objectFit(ImageFit.Contain) + .height(Constants.TITLE_BAR_IMAGE_HEIGHT) + .width(Constants.TITLE_BAR_IMAGE_WIDTH) + .draggable(false) + } + .width(Constants.CLICK_SHADOW_LENGTH) + .height(Constants.CLICK_SHADOW_LENGTH) + .borderRadius($r('sys.float.ohos_id_corner_radius_clicked')) + .flexShrink(0) + .alignItems(VerticalAlign.Center) + .justifyContent(FlexAlign.Center) + .visibility(this.isSplitMode ? Visibility.None : Visibility.Visible) + .backgroundColor(this.isBackOnTouch ? $r('sys.color.ohos_id_color_click_effect') : '') + .hoverEffect(HoverEffect.Highlight) + .onTouch(event => { + if (event === undefined) { + return; + } + if (event.type === TouchType.Down) { + this.isBackOnTouch = true; + } + if (event.type === TouchType.Up) { + this.isBackOnTouch = false; + } + }) + .onClick(() => { + let length = router.getLength(); + Number(length) === 1 ? this.context.terminateSelf() : router.back(); + }) + + Text(JSON.parse(this.title)) + .align(Alignment.Start) + .fontColor($r('sys.color.ohos_id_color_titlebar_text')) + .maxLines(Constants.MAXIMUM_HEADER_LINES) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .maxFontSize(this.isSplitMode ? $r('sys.float.ohos_id_text_size_headline7') : $r('sys.float.ohos_id_text_size_headline8')) + .minFontSize(14) + .heightAdaptivePolicy(TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST) + .flexGrow(Constants.FLEX_GROW) + .fontWeight(FontWeight.Medium) + .margin({ left: this.isSplitMode ? 12 : 4 }) + } + } + .height(Constants.TITLE_BAR_HEIGHT) + .constraintSize({ minHeight: Constants.TITLE_BAR_MIN_HEIGHT }) + .alignItems(HorizontalAlign.Start) + .justifyContent(FlexAlign.Center) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + } +} diff --git a/entry/src/main/ets/common/components/headComponent.ets b/entry/src/main/ets/common/components/headComponent.ets new file mode 100644 index 0000000..2fc80f7 --- /dev/null +++ b/entry/src/main/ets/common/components/headComponent.ets @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2022-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 '@system.router'; +import ComponentConfig from './ComponentConfig'; +import router from '@ohos.router'; + +/** + * head custom component + */ +@Component +export default struct HeadComponent { + @State isTouch: boolean = false; + private isActive: boolean = true; + private icBackIsVisibility: boolean = true; + private headName: string | Resource = ''; + + build() { + Row() { + Stack({ alignContent: Alignment.Center }) { + Image($r('app.media.ic_back')) + .width($r('app.float.width_height_m')) + .height($r('app.float.width_height_m')) + .fillColor($r("sys.color.ohos_id_color_primary")) + } + .margin({ right: $r('app.float.wh_value_16') }) + .backgroundColor(this.isTouch ? $r('app.color.color_E3E3E3_grey') : $r('app.color.color_00000000_transparent')) + .visibility(this.icBackIsVisibility ? Visibility.Visible : Visibility.None) + .onClick(() => { + router.back(); + }) + .onTouch((event?: TouchEvent | undefined) => { + if (event?.type === TouchType.Down) { + this.isTouch = true; + } + if (event?.type === TouchType.Up) { + this.isTouch = false; + } + }); + + Text(this.headName) + .fontSize($r('app.float.head_font_24')) + .lineHeight($r('app.float.wh_value_33')) + .fontFamily('HarmonyHeiTi-Bold') + .fontWeight(FontWeight.Bold) + .fontColor($r('app.color.font_color_182431')) + .maxLines(ComponentConfig.MAX_LINES_1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + .textAlign(TextAlign.Start) + .margin({ top: $r('app.float.wh_value_13'), bottom: $r('app.float.wh_value_15') }); + } + .width(ComponentConfig.WH_100_100) + .padding({ left: $r('app.float.wh_value_12') }) + .height($r('app.float.wh_value_56')) + .alignItems(VerticalAlign.Center) + .align(Alignment.Start) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/constants/ComConstant.ets b/entry/src/main/ets/common/constants/ComConstant.ets new file mode 100644 index 0000000..05b3c8a --- /dev/null +++ b/entry/src/main/ets/common/constants/ComConstant.ets @@ -0,0 +1,85 @@ +/** + * Copyright (c) 2022-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 default class Constants { + //TITLE_BAR + static TITLE_BAR_HEIGHT = 56; + static TITLE_BAR_MIN_HEIGHT = 56; + static TITLE_BAR_IMAGE_HEIGHT = 24; + static TITLE_BAR_IMAGE_WIDTH = 24; + static TITLE_BAR_MARGIN_RIGHT = 4; + //public property style + static FLEX_GROW = 1; + static MAXIMUM_HEADER_LINES = 2; + static DEFAULT_MARGIN_START = 12; + static DEFAULT_MARGIN_END = 12; + static CLICK_SHADOW_LENGTH = 48; + static CONSTRAIN_MIN_HEIGHT = 48; + //sliding style + static SLIDING_THRESHOLD = 160 + //duration style + static DURATION_TIME = 300 + static DURATION_TIME_250 = 250 + // with height style + static WIDTH_HEIGHT_FULL_SCREEN = '100%' + static NO_RESULT_HEIGHT = '80%' + // padding style + static BOOK_MARK_PADDING_BOTTOM = 50 + //lineHeight style + static LINE_HEIGHT_S = 13 + static LINE_HEIGHT_M = 19 + static LINE_HEIGHT_L = 21 + // bar max width + static GRID_ROW_XS = 4 + static GRID_ROW_SM = 6 + static GRID_ROW_MD = 8 + static GRID_ROW_XS_LG = 10 + //PermissionListView style + static OPACITY = 0.2 + static STROKE_WIDTH_HALF = 0.5 + static FONT_FAMILY_HARMONY_HEI_TI = 'HarmonyHeiTi' + //grid useSizeType + static GUTTER = 0; + //line point + static START_POINT = -4 + static END_POINT = 30 + //breakpoints size + static XS_BREAKPOINTS_NUMBER = 320; + static MD_BREAKPOINTS_NUMBER = 520; + static LG_BREAKPOINTS_NUMBER = 840; + static XS_BREAKPOINTS = '320vp'; + static MD_BREAKPOINTS = '520vp'; + static LG_BREAKPOINTS = '840vp'; + // store key + static INIT_APP_INFO_LIST = 'initAppInfoList'; + static IGNORE_LOCK_SCREEN_PASSWORD_ADVICE_COUNT = 'ignoreLockScreenPasswordAdviceCount'; + static IGNORE_ADVICE_MAX_COUNT = 2; + // segmentation button width + static BUTTON_BACKGROUND_WIDTH_ONE = 102; + static BUTTON_BACKGROUND_WIDTH_TWO = 140; + static SEGMENTATION_BUTTON_WIDTH = 448; + // column row space + static DEFAULT_SPACE = 12; + // domain + static DOMAIN = 0x0000; + static STORAGE_KEY_SESSION = 'session'; + //device type + static DEVICE_TYPE_PC = '2in1'; + static DEVICE_TYPE_TABLET = 'tablet'; + static STORAGE_KEY_CURRENT_PAGE_ROUTE = 'currentPageRoute'; + //last %d days + static BAR_CHART_DAYS = 3; + static ACCESS_RECORD_DAYS = 7; +} \ No newline at end of file diff --git a/entry/src/main/ets/common/constants/DataShareConstant.ets b/entry/src/main/ets/common/constants/DataShareConstant.ets new file mode 100644 index 0000000..a4478b7 --- /dev/null +++ b/entry/src/main/ets/common/constants/DataShareConstant.ets @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2022-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 relationalStore from '@ohos.data.relationalStore'; +import { AccessTableTypedef } from '../bean/AccessTableTypedef'; + +/** + * Rdb database config + */ +export default class DataShareConstants { + static readonly STORE_CONFIG: relationalStore.StoreConfig = { + name: 'access.db', + securityLevel: relationalStore.SecurityLevel.S1 + }; + /** + * Access table config + */ + public static readonly ACCESS_TABLE: AccessTableTypedef = { + tableName: 'functionAccessTable', + sqlCreate: `CREATE TABLE IF NOT EXISTS functionAccessTable(intent TEXT PRIMARY KEY, + userId INTEGER, + iconBackgroundColorResource TEXT, + priority INTEGER, + isSupport INTEGER, isClickable INTEGER, + displayedMode TEXT, + iconResource TEXT, + mainTitleResource TEXT, + subTitleResource TEXT, + showControlAbilityuri TEXT, + dstAbilityMode INTEGER, + dstAbilityName TEXT, + dstBundleName TEXT, + bundleName TEXT + )`, + columns: ['intent', 'userId', 'iconBackgroundColorResource', + 'priority', 'isSupport', 'isClickable', 'displayedMode', 'iconResource', + 'mainTitleResource', 'subTitleResource', 'showControlAbility', + 'dstAbilityMode', 'dstAbilityName', 'dstBundleName', 'bundleName' + ] + }; + /** + * Access table config + */ + public static readonly ANTO_MENU_TABLE_V2: AccessTableTypedef = { + tableName: 'auto_menu_table', + sqlCreate: `CREATE TABLE IF NOT EXISTS auto_menu_table( + businessId TEXT PRIMARY KEY, + intent TEXT, + userId INTEGER, + iconBackgroundColorResource TEXT, + priority INTEGER, + isSupport INTEGER, + isClickable INTEGER, + displayedMode TEXT, + iconResource TEXT, + mainTitleResource TEXT, + subTitleResource TEXT, + showControlAbilityUri TEXT, + dstAbilityMode INTEGER, + dstAbilityName TEXT, + dstBundleName TEXT, + bundleName TEXT + )`, + columns: ['businessId', 'intent', 'userId', 'iconBackgroundColorResource', + 'priority', 'isSupport', 'isClickable', 'displayedMode', 'iconResource', + 'mainTitleResource', 'subTitleResource', 'showControlAbilityUri', + 'dstAbilityMode', 'dstAbilityName', 'dstBundleName', 'bundleName' + + ] + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/constants/HiSysEventConstant.ets b/entry/src/main/ets/common/constants/HiSysEventConstant.ets new file mode 100644 index 0000000..c1e3cf3 --- /dev/null +++ b/entry/src/main/ets/common/constants/HiSysEventConstant.ets @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2022-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 default class HiSysEventConstant { + static BUNDLE_NAME = 'com.ohos.security_privacy_center'; + static EVENT_DOMAIN = 'PRIVACY_UE'; + static ACCESS_CLICK_EVENT_NAME = 'SECU_PRIV_ENTRANCE'; + static APP_PAGE_PERMISSION_EVENT_NAME = 'APP_PAGE_PERMISSION'; + static APP_PAGE_EVENT_NAME = 'APP_PAGE'; + static APP_PAGE_MORE_EVENT_NAME = 'APP_PAGE_MORE'; + static DATA_PRIVACY_CLICK_EVENT_NAME = 'SECU_DATA_PRIV_ITEM'; + static MAIN_ADVICE_EVENT_NAME = 'MAIN_ADVICE'; //设置-隐私与安全-保护建议打点事件 + static MAIN_BAR_CHART_EVENT_NAME = 'MAIN_BAR_CHART'; //设置-隐私与安全-隐私权限卡片切换打点事件 + static MAIN_BAR_CHART_ITEM_EVENT_NAME = 'MAIN_BAR_CHART_ITEM'; //设置-隐私与安全-点击柱状图应用打点事件 + static MAIN_PERMISSION_LIST_EVENT_NAME = 'MAIN_PERMISSION_LIST'; // 设置-隐私与安全-隐私权限列表打点事件 + static MAIN_PERMISSION_LIST_MORE_EVENT_NAME = 'MAIN_PERMISSION_LIST_MORE'; // 设置-隐私与安全-隐私权限列表点击更多打点事件 + static PERMISSION_PAGE_SEARCH_EVENT_NAME = 'PERMISSION_PAGE_SEARCH'; //设置-隐私与安全-权限-搜索打点事件 + static PERMISSION_PAGE_ACCURACY_EVENT_NAME = 'PERMISSION_PAGE_ACCURACY'; //设置-隐私与安全-权限-位置提高精确度打点事件 + static PERMISSION_PAGE_LOCATION_EVENT_NAME = 'PERMISSION_PAGE_LOCATION'; //设置-隐私与安全-权限-访问我的位置信息开关 + static PERMISSION_PAGE_RECORD_EVENT_NAME = 'PERMISSION_PAGE_RECORD'; //设置-隐私与安全-权限-访问记录打点事件 + static PERMISSION_PAGE_OAID_EVENT_NAME = 'PERMISSION_PAGE_OAID'; //设置-隐私与安全-权限-广告标识 + static PERMISSION_PAGE_SYSTEM_SERVICES_EVENT_NAME = 'PERMISSION_PAGE_SYSTEM_SERVICES'; //设置-隐私与安全-权限-系统服务 + static PERMISSION_PAGE_APP_LIST_EVENT_NAME = 'PERMISSION_PAGE_APP_LIST'; //设置-隐私与安全-权限管理-应用列表打点事件 //最近访问记录 + static RECORD_PAGE_APP_LIST_EVENT_NAME = 'RECORD_PAGE_APP_LIST';//设置-隐私与安全-权限维度访问记录打点事件 + static PORTRAIT_PERMISSION_EVENT_NAME = 'PORTRAIT_PERMISSION';//设置-隐私与安全-应用画像-应用权限管理打点事件 + static BUNDLE_NAME_MAP = new Map([ + ['com.huawei.hmos.passwordvault','pass_vault'], + ['com.huawei.hmos.advsecmode','advsecmode'], + ['com.huawei.hmos.adsservice','hwads'], + ['com.ohos.certmanager','data_privacy'], + ['com.ohos.permissionmanager','data_privacy'], + ['com.ohos.security_privacy_center','data_privacy'] + ]); +} \ No newline at end of file diff --git a/entry/src/main/ets/common/constants/RouterConstant.ets b/entry/src/main/ets/common/constants/RouterConstant.ets new file mode 100644 index 0000000..32c44f7 --- /dev/null +++ b/entry/src/main/ets/common/constants/RouterConstant.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022-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 default class RouterConstant { + // 首页 + static INDEX_URL = 'pages/Index' + // 权限管理 + static PERMISSION_MANAGEMENT_URL = 'pages/PermissionManagementPage' + // 权限访问记录 + static PERMISSION_ACCESS_RECORD_URL = 'pages/PermissionAccessRecordPage' + // 应用权限访问记录 + static PERMISSION_CONTROL_AND_RECORD_URL = 'pages/PermissionControlAndRecordPage' + // 外部模块条换路径对应表 + static OUTSIDE_ROUTE_PAGE_MAP = new Map([ + ['location_manager_settings', 'pages/PermissionManagementPage'] + ]) +} + +/** + * 页面进入方式,需和设置保持一致 + * 当设置传入backMode为1时,点返回跳转到拉起页面 + */ +export enum PageRouteMode { + /** + * 内部跳转 + */ + INSIDE, + /** + * 外部跳转 + */ + OUTSIDE +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/AutoMenuManager.ets b/entry/src/main/ets/common/utils/AutoMenuManager.ets new file mode 100644 index 0000000..1add06b --- /dev/null +++ b/entry/src/main/ets/common/utils/AutoMenuManager.ets @@ -0,0 +1,378 @@ +/** + * Copyright (c) 2022-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 '../utils/Logger'; +import dataShare from '@ohos.data.dataShare'; +import { MenuConfig } from '../bean/MenuConfig'; +import DataShareResultSet from '@ohos.data.DataShareResultSet'; +import { StringUtil } from './StringUtil'; +import resourceUtil from './ResourceUtil'; +import { RawFileUtil } from './RawFileUtil'; +import DefaultMenuConfig from '../bean/DefaultMenuConfig'; +import { HashMap } from '@kit.ArkTS'; +import common from '@ohos.app.ability.common'; +import bundleManager from '@ohos.bundle.bundleManager'; +import BundleInfoModel from '../../model/bundleInfo/BundleInfoModel'; +import abilityAccessCtrl from '@ohos.abilityAccessCtrl'; +import resourceManager from '@ohos.resourceManager'; +import dataSharePredicates from '@ohos.data.dataSharePredicates'; + +const TAG = "AutoMenu"; +const DST_ABILITY_MODE = 1; +//this mode is jump page +const DST_PAGE_MODE = 2; +const BUNDLE_NAME = 'com.huawei.hmos.security.privacycenter'; +//UIAbility access method +const DST_UIABILITY_MODE = 0; + +//数据库唯一标识符 +const DISPLAY_ONLY_PRIMARY_USER = 'ONLY_PRIMARY_USER'; +const DISPLAY_ONLY_SUB_USER = 'ONLY_SUB_USER'; +const MAIN_USER_ID = 100; + +const CHECK_ACCESS_TOKEN_PERMISSION = 'ohos.permission.ACCESS_SECURITY_PRIVACY_CENTER'; +const PRIVACY_CENTER = 'metadata.access.privacy.center'; +const ORDERING_RULE_FILE = 'menu_list_rule.json'; +const DISPLAY_MODEL_CARD = 'card'; +const DISPLAY_MODEL_LIST = 'list'; + +export class AutoMenuManager { + // 默认的配置信息,key is bundle name, value is config + private _defaultMenuConfigMap: HashMap = new HashMap(); + // key is bundle name, value is id. + private _defaultBusinessIdMap: HashMap = new HashMap(); + private _predicates: dataSharePredicates.DataSharePredicates = new dataSharePredicates.DataSharePredicates(); + private _shareArray = ['*']; + private static _INSTANCE: AutoMenuManager; + + /** + * To get single instance + * @returns The single instance + */ + public static getInstance(): AutoMenuManager { + if (!AutoMenuManager._INSTANCE) { + AutoMenuManager._INSTANCE = new AutoMenuManager(); + } + return AutoMenuManager._INSTANCE; + } + + /** + * To get all config in system + * @param context The context + * @param userId The user id + * @returns The all menu config + */ + async getMenuConfigFromBms(context: Context, userId: number): Promise { + // 获取所有配置信息,内部会检查权限 + let allPkgConfigList: MenuConfig[] = await this._readConfigFromBms(context); + // 适配businessId + for (let index = 0; index < allPkgConfigList.length; index++) { + const item = allPkgConfigList[index]; + if (item.businessId === null || item.businessId === undefined || item.businessId.length === 0) { + item.businessId = await this._getDefaultBusinessId(context, item.bundleName); + } + } + Logger.info(TAG, 'getMenuConfigFromBms allPkgConfigList: ' + JSON.stringify(allPkgConfigList)); + // 过滤不合法的配置信息 + let verifiedPkgConfigList: MenuConfig[] = []; + for (let index = 0; index < allPkgConfigList.length; index++) { + const menuConfig = allPkgConfigList[index]; + let isVerifyPass: boolean = await this._verifyMenuConfig(context, menuConfig, userId); + if (isVerifyPass) { + verifiedPkgConfigList.push(menuConfig); + } else { + Logger.error(TAG, 'Not verify pass. ' + menuConfig.businessId); + } + } + Logger.info(TAG, 'getMenuConfigFromBms result: ' + JSON.stringify(verifiedPkgConfigList)); + return verifiedPkgConfigList; + } + + /** + * To judge this menu is support or not + * @param context The context + * @param item The menu id + * @returns True is support + */ + async isSupportMenu(context: Context, item: MenuConfig): Promise { + let isSupport: number = 0; + const uri = item.showControlAbilityUri; + if (uri === undefined) { + isSupport = 1; + } else { + let value: string = await this._verificationUri(context, item.showControlAbilityUri); + if (value === '0x55') { + isSupport = 1; + } else if (value === '0xaa') { + isSupport = 0; + } + } + return isSupport; + } + + /** + * To get menu priority + * @param context The context + * @param menuConfig The menu config + * @returns The menu priority + */ + async getMenuPriority(context: Context, menuConfig: MenuConfig): Promise { + if (this._defaultBusinessIdMap.length === 0) { + await this._initDefaultMenuConfig(context); + } + try { + let defaultMenuConfig: DefaultMenuConfig = this._defaultMenuConfigMap.get(menuConfig.businessId); + if (defaultMenuConfig === undefined) { + return 0; + } + return defaultMenuConfig.priority; + } catch (err) { + Logger.info(TAG, 'get menu priority error.') + } + return 0; + } + + private async _getDefaultBusinessId(context: Context, bundleName: string): Promise { + if (this._defaultBusinessIdMap.length === 0) { + await this._initDefaultMenuConfig(context); + } + try { + return this._defaultBusinessIdMap.get(bundleName) + } catch (err) { + Logger.info(TAG, 'get menu priority error.') + } + return ''; + } + + private async _initDefaultMenuConfig(context: Context) { + try { + let jsonStr: string = await RawFileUtil.getRawFileByContext(context, ORDERING_RULE_FILE); + let defaultMenuConfigList: DefaultMenuConfig[] = JSON.parse(jsonStr); + for (let index = 0; index < defaultMenuConfigList.length; index++) { + const item = defaultMenuConfigList[index]; + this._defaultMenuConfigMap.set(item.businessId, item); + this._defaultBusinessIdMap.set(item.bundleName, item.businessId); + } + } catch (e) { + Logger.error(TAG, 'error when parse advice config.') + } + } + + // 查询有功能接入的Ability信息 + private async _readConfigFromBms(context: Context): Promise { + let abilityInfoList: bundleManager.ExtensionAbilityInfo[] = []; + let uiAbilityInfoList: bundleManager.AbilityInfo[] = []; + try { + abilityInfoList = await BundleInfoModel.queryExtensionAbilityInfoOther() + } catch (err) { + Logger.error(TAG, 'queryExtensionAbilityInfoOther error.') + } + // 查询通过uiAbility方式接入的信息 + try { + uiAbilityInfoList = await BundleInfoModel.queryAbilityInfoOther() + } catch (err) { + Logger.error(TAG, 'queryAbilityInfoOther error.') + } + if (abilityInfoList.length === 0 && uiAbilityInfoList.length === 0) { + return []; + } + // 检查功能接入的Ability权限 + let atManage: abilityAccessCtrl.AtManager = abilityAccessCtrl.createAtManager(); + let pkgConfigList: MenuConfig[] = []; + for (let index = 0; index < abilityInfoList.length; index++) { + const abilityInfo = abilityInfoList[index]; + try { + let data: abilityAccessCtrl.GrantStatus = await atManage.checkAccessToken( + abilityInfo.applicationInfo.accessTokenId, CHECK_ACCESS_TOKEN_PERMISSION); + if (data !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + continue; + } + let singlePkgConfigList: MenuConfig[] = await this._readConfigFromSingleAbilityInfo(context, abilityInfo); + pkgConfigList = pkgConfigList.concat(singlePkgConfigList); + } catch (err) { + Logger.info(TAG, 'checkAccessToken error: ' + abilityInfo.bundleName); + } + } + // 检查功能通过uiAbility方式接入的Ability权限 + for (let index = 0; index < uiAbilityInfoList.length; index++) { + const uiAbilityInfo = uiAbilityInfoList[index]; + try { + let data: abilityAccessCtrl.GrantStatus = await atManage.checkAccessToken( + uiAbilityInfo.applicationInfo.accessTokenId, CHECK_ACCESS_TOKEN_PERMISSION); + if (data !== abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) { + continue; + } + let singlePkgConfigList: MenuConfig[] = await this._readConfigFromSingleAbilityInfo(context, uiAbilityInfo); + pkgConfigList = pkgConfigList.concat(singlePkgConfigList); + } catch (err) { + Logger.info(TAG, 'uiAbilityInfoList checkAccessToken error: ' + uiAbilityInfo.bundleName); + } + } + return pkgConfigList; + } + + // 读取接入方式配置信息转换为对应的数据类 + private async _readConfigFromSingleAbilityInfo(context: Context, + abilityInfo: bundleManager.ExtensionAbilityInfo | bundleManager.AbilityInfo): Promise { + // 获取metaData数据 + let singleAbilityMenuConfigList: MenuConfig[] = []; + for (let index = 0; index < abilityInfo.metadata.length; index++) { + const metaData = abilityInfo.metadata[index]; + if (metaData.name !== PRIVACY_CENTER) { + continue; + } + let bundleName = abilityInfo.bundleName; + let fileName = metaData.value; + // 根据metaData获取json文件 + let content: string = await this._getFileByMetaData(context, bundleName, fileName); + if (StringUtil.isEmpty(content)) { + continue; + } + let menuConfig: MenuConfig = JSON.parse(content); + menuConfig.bundleName = bundleName; + singleAbilityMenuConfigList.push(menuConfig); + } + Logger.info(TAG, 'readConfigFromSingleAbilityInfo: ' + JSON.stringify(singleAbilityMenuConfigList)); + return singleAbilityMenuConfigList; + } + + // 根据包名查询metaData的json数据 + private async _getFileByMetaData(context: Context, bundleName: string, fileName: string): Promise { + let resourceManager = resourceUtil.getBundleResourceManager(bundleName, context) as resourceManager.ResourceManager; + return await RawFileUtil.getStringByFile(resourceManager, fileName); + } + + private async _verifyMenuConfig(context: Context, menuConfig: MenuConfig, userId: number): Promise { + // 根据卡片或列表模式进行分类验证,目前暂只支持列表方式 + try { + if (menuConfig.displayedMode === DISPLAY_MODEL_CARD + || menuConfig.displayedMode === DISPLAY_MODEL_LIST) { + return await this._verificationListContent(context, userId, menuConfig); + } + } catch (err) { + Logger.error(TAG, 'verifyMenuConfig error.'); + } + return false; + } + + // 校验showControlAbilityUri + private async _verificationUri(context: Context, uri: string): Promise { + try { + let data: dataShare.DataShareHelper = await dataShare.createDataShareHelper(context, uri, { isProxy: false }); + if (data !== undefined) { + let resultSet: DataShareResultSet = await data.query(uri, this._predicates, this._shareArray); + resultSet.goToFirstRow(); + let showResult = resultSet.getString(resultSet.getColumnIndex('SHOW_RESULT')); + if (StringUtil.isEmpty(showResult)) { + return ''; + } + if (showResult === '0x55' || showResult === '0xaa') { + Logger.info(TAG, 'verificationUri showResult: ' + showResult); + return showResult; + } else { + Logger.info(TAG, 'showResult: ' + showResult); + return ''; + } + } + } catch (err) { + Logger.error(TAG, 'verificationUri createDataShareHelper error: ' + JSON.stringify(err)); + } + return ''; + } + + private async _verificationListContent(context: common.Context, userId: number, menuConfig: MenuConfig): Promise { + if (menuConfig === undefined || menuConfig === null) { + return false; + } + if (this._isValidAccessMode(menuConfig.dstAbilityMode, menuConfig.dstBundleName)) { + Logger.error(TAG, 'verificationListContent dstAbilityMode error.') + return false; + } + if (StringUtil.isEmpty(menuConfig.dstBundleName)) { + Logger.error(TAG, 'verificationListContent dstBundleName error.'); + return false; + } + if (StringUtil.isEmpty(menuConfig.dstAbilityName)) { + Logger.error(TAG, 'verificationListContent dstAbilityName error.'); + return false; + } + let _isValidResourceWithList: boolean = await this._isValidResourceWithList(context, menuConfig); + if (!_isValidResourceWithList) { + return false; + } + // 校验主子用户配置,可选字段 + if (menuConfig.displayUserConfig !== undefined) { + let displayUserConfigRes = this._verificationPrimaryUser(menuConfig.displayUserConfig, userId); + Logger.info(TAG, `displayUserConfigRes value is: ${displayUserConfigRes}`); + if (displayUserConfigRes === false) { + return displayUserConfigRes; + } + } + // 校验uri,可选字段 + let showControlAbilityUri = menuConfig.showControlAbilityUri; + if (showControlAbilityUri !== undefined) { + let _verificationUriResult: string = await this._verificationUri(context, showControlAbilityUri); + Logger.info(TAG, 'verificationListContent verificationUri: ' + showControlAbilityUri); + Logger.info(TAG, 'verificationListContent verificationUri value: ' + _verificationUriResult); + if ('' === _verificationUriResult) { + Logger.error(TAG, 'verificationListContent verificationUri error.') + return false; + } else { + return true; + } + } + return true; + } + + private async _isValidResourceWithList(context: common.Context, menuConfig: MenuConfig): Promise { + let resourceManager = resourceUtil.getBundleResourceManager(menuConfig.bundleName, context); + if (resourceManager === null || resourceManager === undefined) { + return false; + } + if (StringUtil.isEmpty(menuConfig.mainTitleResource)) { + return false; + } + // 标题 + let titleResList = menuConfig.mainTitleResource.split(':'); + if (titleResList.length < 2) { + Logger.error(TAG, 'titleResList length is error.') + return false; + } + // 校验title + let value: string = await resourceManager?.getStringByName(titleResList[1]); + if (value === '') { + Logger.error(TAG, 'titlePromise is error.') + return false; + } + return true; + } + + // Whether the access mode is valid + private _isValidAccessMode(dstAbilityMode: number, dstBundleName: string): boolean { + return!(dstAbilityMode === DST_PAGE_MODE && dstBundleName === BUNDLE_NAME) && + dstAbilityMode !== DST_ABILITY_MODE && dstAbilityMode !== DST_UIABILITY_MODE + } + + // 校验子用户 + private _verificationPrimaryUser(displayUserConfig: string, userId: number): boolean { + let isPrimaryUser: boolean = userId === MAIN_USER_ID; + Logger.info(TAG, `verificationSubUser, displayUser: ${displayUserConfig}, isPrimaryUser: ${isPrimaryUser}`); + if ((isPrimaryUser && displayUserConfig === DISPLAY_ONLY_PRIMARY_USER) || (!isPrimaryUser && displayUserConfig === DISPLAY_ONLY_SUB_USER)) { + return true; + } else { + return false; + } + } +} diff --git a/entry/src/main/ets/common/utils/GetSelfBundleInfoUtils.ets b/entry/src/main/ets/common/utils/GetSelfBundleInfoUtils.ets new file mode 100644 index 0000000..37cf150 --- /dev/null +++ b/entry/src/main/ets/common/utils/GetSelfBundleInfoUtils.ets @@ -0,0 +1,56 @@ +/** + * Copyright (c) 2022-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 bundleManager from '@ohos.bundle.bundleManager'; +import HiSysEventConstant from '../constants/HiSysEventConstant'; +import Logger from './Logger'; +import { BusinessError } from '@ohos.base'; + +const TAG = 'SPS'; + +class GetSelfBundleInfoUtils { + private versionName: string = ''; + + /** + * Obtains the version name of SecurityPrivacyCenter + * + * @returns Promise versionName + */ + getVersionName(): Promise { + return new Promise(async (resolve) => { + if (this.versionName !== '') { + Logger.info(TAG, `get versionName from object variable : ${this.versionName}`); + resolve(this.versionName) + } else { + try { + await bundleManager.getBundleInfo(HiSysEventConstant.BUNDLE_NAME, + bundleManager.BundleFlag.GET_BUNDLE_INFO_DEFAULT).then((data) => { + this.versionName = data.versionName; + Logger.info(TAG, `get versionName from BMS : ${this.versionName}`); + resolve(this.versionName); + }).catch((err: BusinessError) => { + Logger.error(TAG, `getBundleInfo failed, BusinessError: ${err.message}`); + }) + } catch (err) { + Logger.error(TAG, `getBundleInfo failed: ${err.message}`) + } + } + }) + } +} + +let getSelfBundleInfoUtils = new GetSelfBundleInfoUtils(); + +export default getSelfBundleInfoUtils as GetSelfBundleInfoUtils; \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/HiSysEventUtil.ets b/entry/src/main/ets/common/utils/HiSysEventUtil.ets new file mode 100644 index 0000000..c63453f --- /dev/null +++ b/entry/src/main/ets/common/utils/HiSysEventUtil.ets @@ -0,0 +1,175 @@ +/** + * Copyright (c) 2022-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 hiSysEvent from '@ohos.hiSysEvent'; +import { BusinessError } from '@ohos.base'; +import { StringUtil } from './StringUtil'; +import Logger from './Logger'; +import HiSysEventConstant from '../constants/HiSysEventConstant'; +import GetSelfBundleInfoUtils from './GetSelfBundleInfoUtils'; + +const TAG = 'HiSysEventUtil'; + +export default class HiSysEventUtil { + private constructor() { + } + + /** + * 湖内应用跳转更多权限页面时的点击事件 + * + * @params bundleName 湖内应用包名 + * @params appVersion 湖内应用版本号 + * @returns Promise + */ + static async reportAppPermJumpMorePerm(bundleName: string, appVersion: string): Promise { + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'BUNDLE_NAME': bundleName, + 'APP_VERSION': appVersion, + }; + + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, HiSysEventConstant.APP_PAGE_MORE_EVENT_NAME, + hiSysEvent.EventType.BEHAVIOR, eventParams); + } + + /** + * 复杂权限组[位置信息-精确位置]跳转到二级页面操作权限状态时的点击事件 + * + * @params bundleName 应用包名 + * @params appVersion 应用版本号 + * @returns Promise + */ + static async reportAppPermissionJumpPage(bundleName: string, appVersion: string, operationPermissionGroup: string): Promise { + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'BUNDLE_NAME': bundleName, + 'APP_VERSION': appVersion, + 'OPERATION': operationPermissionGroup + }; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, HiSysEventConstant.APP_PAGE_EVENT_NAME, hiSysEvent.EventType.BEHAVIOR, eventParams) + } + + static reportUpdateAppPermissionGroupState(bundleName: string, appVersion: string, permissionGroup: string, + newCheckedState: string, newFlagMask: number, newFlagValue: number): Promise { + return HiSysEventUtil.reportUpdatePermissionGroupState(HiSysEventConstant.APP_PAGE_PERMISSION_EVENT_NAME, bundleName, + appVersion, permissionGroup, newCheckedState, newFlagMask, newFlagValue); + } + + private static async reportUpdatePermissionGroupState(eventName: string, bundleName: string, appVersion: string, + permissionGroup: string, newCheckedState: string, + newFlagMask: number, newFlagValue: number): Promise { + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'BUNDLE_NAME': bundleName, + 'APP_VERSION': appVersion, + 'PERMISSION_GROUP': permissionGroup, + 'NEW_CHECKED_STATE': newCheckedState, + 'NEW_FLAG_MASK': newFlagMask, + 'NEW_FLAG_VALUE': newFlagValue, + }; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, eventName, hiSysEvent.EventType.BEHAVIOR, eventParams); + } + + /** + * 接入框架接入应用点击事件打点 + * + * @params { clickedBundleName } 所点击的应用包名 + */ + static async reportAccessClick(clickedBundleName: string): Promise { + Logger.info(TAG,"reportAccessClick start.") + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'CLICK_ITEM': clickedBundleName, + }; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, HiSysEventConstant.ACCESS_CLICK_EVENT_NAME, hiSysEvent.EventType.BEHAVIOR, eventParams); + } + + /** + * 访问我的位置信息点击打点事件 + */ + static async reportLocationClick(clickedBundleName: string, checkedState: number) { + if (StringUtil.isEmpty(clickedBundleName)) { + Logger.info(TAG, 'clickedBundleName is empty'); + return + } + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'CLICK_ITEM': checkedState, + }; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, HiSysEventConstant.ACCESS_CLICK_EVENT_NAME, hiSysEvent.EventType.BEHAVIOR, eventParams); + } + + /** + * Report data privacy center user click event + * + * @param clickItem click item info + */ + static async reportDataPrivacyClick(clickItem: string): Promise { + if (StringUtil.isEmpty(clickItem)) { + Logger.info(TAG, 'clickItem is empty'); + return; + } + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + let eventParams: Record = { + 'PNAMEID': HiSysEventConstant.BUNDLE_NAME, + 'PVERSIONID': versionName, + 'CLICK_ITEM': clickItem, + }; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, HiSysEventConstant.DATA_PRIVACY_CLICK_EVENT_NAME, hiSysEvent.EventType.BEHAVIOR, eventParams) + } + + /** + * 界面点击操作打点 + * + * @param eventName 事件名 + * @param params 参数 + */ + static async reportClick(eventName: string, params: Record): Promise { + let versionName: string = await GetSelfBundleInfoUtils.getVersionName(); + params['PNAMEID'] = HiSysEventConstant.BUNDLE_NAME; + params['PVERSIONID'] = versionName; + let eventParams: Record = params; + HiSysEventUtil.report(HiSysEventConstant.EVENT_DOMAIN, eventName, hiSysEvent.EventType.BEHAVIOR, eventParams) + } + + private static report(domain: string, name: string, eventType: hiSysEvent.EventType, params: Object): void { + Logger.info(TAG, `start to report domain: ${domain},eventName: ${name},eventType: ${eventType}, reportData: ${params}`) + const sysEventInfo: hiSysEvent.SysEventInfo = { + domain: domain, + name: name, + eventType: eventType, + params: params + }; + hiSysEvent.write(sysEventInfo).then( + () => { + Logger.info(TAG, `HiSysEventUtil reportHiSysEvent ${sysEventInfo.name} success.`) + } + ).catch( + (err: BusinessError) => { + Logger.error(TAG, `error code: ${err.code}, error msg: ${err.message}`) + } + ) + } +} diff --git a/entry/src/main/ets/common/utils/Logger.ets b/entry/src/main/ets/common/utils/Logger.ets new file mode 100644 index 0000000..14a2833 --- /dev/null +++ b/entry/src/main/ets/common/utils/Logger.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022-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 preTag: string; + private format: string = "%{public}s"; + + constructor() { + this.preTag = 'PrivacyCenter_'; + this.domain = 0x5616; + } + + debug(tag: string, logInfo: string) { + hilog.debug(this.domain, this.preTag + tag, this.format, logInfo); + } + + info(tag: string, logInfo: string) { + hilog.info(this.domain, this.preTag + tag, this.format, logInfo); + } + + warn(tag: string, logInfo: string) { + hilog.warn(this.domain, this.preTag + tag, this.format, logInfo); + } + + error(tag: string, logInfo: string) { + hilog.error(this.domain, this.preTag + tag, this.format, logInfo); + } +} + +export default new Logger() \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/RawFileUtil.ets b/entry/src/main/ets/common/utils/RawFileUtil.ets new file mode 100644 index 0000000..e02026f --- /dev/null +++ b/entry/src/main/ets/common/utils/RawFileUtil.ets @@ -0,0 +1,72 @@ +/** + * Copyright (c) 2022-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 util from '@ohos.util'; +import resmgr from '@ohos.resourceManager'; +import Logger from './Logger'; + +const TAG: string = 'RawFileUtil'; +const UNICODE: string = 'utf-8'; + +/** + * RawFile工具类 + */ +export class RawFileUtil { + /** + * 获取指定的JSON文件的对象 + * + * @param resourceManager 资源管理器 + * @param fileName 文件名 + * @returns string格式的文件内容 + */ + public static async getStringByFile(resourceManager: resmgr.ResourceManager, fileName: string): Promise { + Logger.info(TAG, `getFileContent. fileName: ${fileName}`); + if (resourceManager === null || fileName === null) { + Logger.error(TAG, `getFileContent failed.resourceManager or fileName is null.fileName:${fileName}`); + return ''; + } + try { + let value: Uint8Array = await resourceManager.getRawFileContent(fileName); + let content = util.TextDecoder.create(UNICODE).decodeWithStream(value); + return content; + } catch (jsonError) { + Logger.error(TAG, `JSON parse error: ${jsonError?.code} ${jsonError?.message}`); + } + return ''; + } + + /** + * 获取指定的JSON文件的对象 + * + * @param context 上下文 + * @param fileName 文件名 + * @return string格式的文件内容 + */ + public static async getRawFileByContext(context: Context, fileName: string): Promise { + Logger.info(TAG, `getFileContent. fileName: ${fileName}`); + if (context === null || fileName === null) { + Logger.error(TAG, `getFileContent failed.resourceManager or fileName is null.fileName:${fileName}`); + return ''; + } + try { + let value: Uint8Array = await context.resourceManager.getRawFileContent(fileName); + let content = util.TextDecoder.create('utf-8').decodeWithStream(value); + return content; + } catch (jsonError) { + Logger.error(TAG, `JSON parse error: ${jsonError?.code} ${jsonError?.message}`); + } + return ''; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/RdbManager.ets b/entry/src/main/ets/common/utils/RdbManager.ets new file mode 100644 index 0000000..f2ac374 --- /dev/null +++ b/entry/src/main/ets/common/utils/RdbManager.ets @@ -0,0 +1,101 @@ +/** + * Copyright (c) 2022-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 relationalStore from '@ohos.data.relationalStore'; +import Logger from '../utils/Logger'; +import DataShareConstants from '../constants/DataShareConstant'; + +const TAG = 'RdbManager'; +const OPT_ERROR = -1; + +export class RdbManager { + private _rdbStore: relationalStore.RdbStore | undefined = undefined; + + private constructor() { + } + + private static instance: RdbManager; + + /** + * To get single instance + * @returns The single instance + */ + public static getInstance(): RdbManager { + if (!RdbManager.instance) { + RdbManager.instance = new RdbManager(); + } + return RdbManager.instance; + } + + async getRdbStore(context: Context): Promise { + if (this._rdbStore) { + return this._rdbStore; + } + try { + this._rdbStore = await relationalStore.getRdbStore(context, DataShareConstants.STORE_CONFIG); + if (this._rdbStore === undefined) { + return this._rdbStore; + } + await this._rdbStore.executeSql(DataShareConstants.ANTO_MENU_TABLE_V2.sqlCreate); + Logger.info(TAG, 'getRdbStore() finished.') + } catch (error) { + Logger.info(TAG, 'getRdbStore() error.') + } + return this._rdbStore; + } + + async insert(context: Context, table: string, values: relationalStore.ValuesBucket): Promise { + try { + let rdbStore: relationalStore.RdbStore | undefined = await this.getRdbStore(context); + if (rdbStore === undefined) { + return OPT_ERROR; + } + const result: number = await rdbStore.insert(table, values); + return result; + } catch (err) { + Logger.error(TAG, 'insert error.') + } + return OPT_ERROR; + } + + + async delete(context: Context, predicates: relationalStore.RdbPredicates): Promise { + try { + let rdbStore: relationalStore.RdbStore | undefined = await this.getRdbStore(context); + if (rdbStore === undefined) { + return OPT_ERROR; + } + const result: number = await rdbStore.delete(predicates); + return result; + } catch (err) { + Logger.error(TAG, 'delete error.') + } + return OPT_ERROR; + } + + async query(context: Context, predicates: relationalStore.RdbPredicates, columns?: Array): Promise { + try { + let rdbStore: relationalStore.RdbStore | undefined = await this.getRdbStore(context); + if (rdbStore === undefined) { + return undefined; + } + const result: relationalStore.ResultSet = await rdbStore.query(predicates, columns); + return result; + } catch (err) { + Logger.error(TAG, 'query error.') + } + return undefined; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/ResourceUtil.ets b/entry/src/main/ets/common/utils/ResourceUtil.ets new file mode 100644 index 0000000..f212665 --- /dev/null +++ b/entry/src/main/ets/common/utils/ResourceUtil.ets @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2022-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 common from '@ohos.app.ability.common'; +import { StringUtil } from './StringUtil'; +import Logger from './Logger'; + +const TAG = 'ResourceUtil' + +class ResourceUtil { + /** + * Obtains the resource name + * 获取资源文件 + * @param resource Resource file + * @returns Resource File Name + */ + + getResourceString(context: object, resource: Resource, params?: Array): string { + let resourceString: string = ''; + try { + if (params && params.length) { + resourceString = getContext(context).resourceManager.getStringSync(resource.id, ...params); + } else { + resourceString = getContext(context).resourceManager.getStringSync(resource.id); + } + } catch (error) { + Logger.error(TAG, `getResourceString error = ${JSON.stringify(error)}`) + } + return resourceString + } + + /** + * 获取指定包名资源管理器 + * @params bundleName 应用包名 + * @params context 上下文 + */ + + getBundleResourceManager(bundleName: string, context: common.Context | null): resourceManager.ResourceManager | null { + if (context === null || StringUtil.isEmpty(bundleName)) { + Logger.error(TAG, 'getBundleResourceManager error'); + return null; + } + try { + let bundleContext = context.createBundleContext(bundleName); + if (bundleContext === null || bundleContext === undefined) { + Logger.error(TAG, 'get bundleContext failed') + return null; + } + return bundleContext.resourceManager; + } catch (error) { + Logger.error(TAG, `get bundleContext faild, error message : ${JSON.stringify(error)}}`) + return null; + } + } + + getFloatNumber(resource: Resource): number { + let context = getContext(this) as common.UIAbilityContext; + return px2vp(context.resourceManager.getNumber(resource.id)) + } +} + +let resourceUtil = new ResourceUtil(); + +export default resourceUtil as ResourceUtil; \ No newline at end of file diff --git a/entry/src/main/ets/common/utils/StringUtil.ets b/entry/src/main/ets/common/utils/StringUtil.ets new file mode 100644 index 0000000..03376fd --- /dev/null +++ b/entry/src/main/ets/common/utils/StringUtil.ets @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2022-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 StringUtil { + /** + * 判断字符是否是空字符串 + * @Param stringValue 字符串 + */ + public static isEmpty(stringValue: string | null | undefined): boolean { + return stringValue === undefined || stringValue === null || stringValue.length === 0; + } + + /** + * 判断字符转是否是非空字符串 + * @params stringValue 字符串 + */ + public static isNotEmpty(stringValue: string | null | undefined): boolean { + return stringValue !== undefined && stringValue !== null && stringValue.length !== 0; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000..aff8942 --- /dev/null +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2022-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/entry/src/main/ets/main/auto_menu/AutoMenuIntent.ets b/entry/src/main/ets/main/auto_menu/AutoMenuIntent.ets new file mode 100644 index 0000000..f0e3eab --- /dev/null +++ b/entry/src/main/ets/main/auto_menu/AutoMenuIntent.ets @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2022-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 { BaseIntent } from '../../common/base/BaseIntent'; +import MenuInfo from '../../common/bean/MenuInfo'; +import { Context } from '@kit.AbilityKit'; + +export class AutoMenuInitIntent extends BaseIntent { + public context: Context; + + constructor(context: Context) { + super(); + this.context = context; + } + + getIntentTag(): string { + return 'MenuListInitIntent'; + } +} + +export class AutoMenuRefreshIntent extends BaseIntent { + public context: Context; + + constructor(context: Context) { + super(); + this.context = context; + } + + getIntentTag(): string { + return 'MenuListRefreshIntent'; + } +} + +export class AutoMenuClickIntent extends BaseIntent { + public menuInfo: MenuInfo; + + constructor(menuInfo: MenuInfo) { + super(); + this.menuInfo = menuInfo; + } + + getIntentTag(): string { + return 'MenuClickGoIntent'; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/main/auto_menu/AutoMenuModel.ets b/entry/src/main/ets/main/auto_menu/AutoMenuModel.ets new file mode 100644 index 0000000..1ae3eac --- /dev/null +++ b/entry/src/main/ets/main/auto_menu/AutoMenuModel.ets @@ -0,0 +1,234 @@ +/** + * Copyright (c) 2022-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 { BaseModel } from '../../common/base/BaseModel'; +import { MenuConfig } from '../../common/bean/MenuConfig'; +import { AutoMenuManager } from '../../common/utils/AutoMenuManager'; +import resourceUtil from '../../common/utils/ResourceUtil'; +import osAccount from '@ohos.account.osAccount'; +import { RdbManager } from '../../common/utils/RdbManager'; +import relationalStore from '@ohos.data.relationalStore'; +import DataShareConstants from '../../common/constants/DataShareConstant'; +import MenuInfo from '../../common/bean/MenuInfo'; +import router from '@ohos.router'; +import { BusinessError } from '@ohos.base'; +import HiSysEventUtil from '../../common/utils/HiSysEventUtil'; +import { Context } from '@kit.AbilityKit'; +import Logger from '../../common/utils/Logger'; +import common from '@ohos.app.ability.common'; + +const TAG = 'AutoMenu'; +// 该ability模式需继承自UIExtensionAbility +const DST_ABILITY_MODE = 1; +// this mode is jump page +const DST_PAGE_MODE = 2; +//UIAbility access method +const DST_UIABILITY_MODE = 0; + +export class AutoMenuModel extends BaseModel { + async getMenuInfoListFromRdb(context: Context): Promise { + Logger.info(TAG, 'getMenuInfoListFromRdb start.'); + let menuInfoList: MenuInfo[] = []; + let predicates = new relationalStore.RdbPredicates(DataShareConstants.ANTO_MENU_TABLE_V2.tableName); + let resultSet: relationalStore.ResultSet | undefined = await RdbManager.getInstance().query(context, predicates); + if (resultSet === undefined) { + Logger.info(TAG, 'getMenuInfoListFromRdb menuInfo undefined'); + return menuInfoList; + } + let count: number = resultSet.rowCount; + if (count === 0 || typeof count === 'string' || count === -1) { + Logger.info(TAG, 'getMenuInfoListFromRdb no result!'); + return menuInfoList; + } + resultSet.goToFirstRow(); + for (let i = 0; i < count; i++) { + const bundleName: string = resultSet.getString(resultSet.getColumnIndex('bundleName')); + const mainTitleResource: string = resultSet.getString(resultSet.getColumnIndex('mainTitleResource')); + const subTitleResource: string = resultSet.getString(resultSet.getColumnIndex('subTitleResource')); + const templeData: MenuInfo = { + businessId: resultSet.getString(resultSet.getColumnIndex('businessId')), + intent: resultSet.getString(resultSet.getColumnIndex('intent')), + userId: resultSet.getDouble(resultSet.getColumnIndex('userId')), + iconBackgroundColorResource: resultSet.getString(resultSet.getColumnIndex('iconBackgroundColorResource')), + priority: resultSet.getDouble(resultSet.getColumnIndex('priority')), + isSupport: resultSet.getDouble(resultSet.getColumnIndex('isSupport')), + isClickable: resultSet.getDouble(resultSet.getColumnIndex('isClickable')), + displayedMode: resultSet.getString(resultSet.getColumnIndex('displayedMode')), + iconResource: resultSet.getString(resultSet.getColumnIndex('iconResource')), + mainTitleResource: mainTitleResource, + subTitleResource: resultSet.getString(resultSet.getColumnIndex('subTitleResource')), + showControlAbilityUri: resultSet.getString(resultSet.getColumnIndex('showControlAbilityUri')), + dstAbilityMode: resultSet.getDouble(resultSet.getColumnIndex('dstAbilityMode')), + dstAbilityName: resultSet.getString(resultSet.getColumnIndex('dstAbilityName')), + dstBundleName: resultSet.getString(resultSet.getColumnIndex('dstBundleName')), + bundleName: bundleName, + titleString: await this._getConfigResString(context, bundleName, mainTitleResource), + subTitleString: await this._getConfigResString(context, bundleName, subTitleResource) + }; + menuInfoList[i] = templeData; + resultSet.goToNextRow(); + } + Logger.info(TAG, 'getMenuInfoListFromRdb: ' + JSON.stringify(menuInfoList)); + return menuInfoList; + } + + async getMenuInfoListFromBms(context: Context): Promise { + let userId: number = await this._getUserId(); + // 步骤一,获取配置数据 + let menuConfigs: MenuConfig[] = await AutoMenuManager.getInstance().getMenuConfigFromBms(context, userId); + Logger.info(TAG, 'getMenuInfoList menuConfigList: ' + JSON.stringify(menuConfigs)); + // 步骤二,转换为实际需要展示的数据 + let menuInfoList: MenuInfo[] = await this._convertMenuConfigToMenuInfo(context, menuConfigs, userId); + Logger.info(TAG, 'getMenuInfoList menuInfoList: ' + JSON.stringify(menuInfoList)); + // 步骤三,排序 + menuInfoList.sort((left: MenuInfo, right: MenuInfo) => { + if (left.priority !== right.priority) { + return right.priority - left.priority; + } else { + return left.bundleName.localeCompare(right.bundleName); + } + }) + // 步骤四,写入数据库缓存 + this._refreshDb(context, menuInfoList); + return menuInfoList; + } + + handleMenuClick(menuInfo: MenuInfo) { + // 通过UIAbility方式接入框架 + if (menuInfo.dstAbilityMode === DST_UIABILITY_MODE) { + let context = getContext() as common.UIAbilityContext; + context.startAbility({ + bundleName: menuInfo.dstBundleName, + abilityName: menuInfo.dstAbilityName + }).then((data) => { + Logger.info(TAG,`${menuInfo.dstBundleName} start successful.data: ${JSON.stringify(data)}`) + }).catch((err: BusinessError) => { + Logger.error(TAG,`${menuInfo.dstBundleName} start failed. Cause: ${JSON.stringify(err)}`) + }) + } + // jump page + if (menuInfo.dstAbilityMode === DST_PAGE_MODE) { + router.pushUrl({ + url: menuInfo.dstAbilityName + }, router.RouterMode.Single).then(() => { + Logger.info(TAG, 'Succeeded in jumping to the dst page.') + }).catch((err: BusinessError) => { + Logger.error(TAG, `Failed to jump to the second page.Code is ${err.code},message is ${err.message}`); + }) + } + // 跳转UIExtensionAbility + HiSysEventUtil.reportAccessClick(menuInfo.dstBundleName) + if (menuInfo.dstAbilityMode === DST_ABILITY_MODE) { + router.pushUrl({ + url: 'pages/UiExtensionPage', + params: { + 'dstBundleName': menuInfo.dstBundleName, + 'dstAbilityName': menuInfo.dstAbilityName + } + }, router.RouterMode.Single).then(() => { + Logger.info(TAG, 'Succeeded in jumping to the second page.') + }).catch((err: BusinessError) => { + Logger.error(TAG, `Failed to jump to the second page.Code is ${err.code},message is ${err.message}`); + }) + } + } + + private async _refreshDb(context: Context, menuInfoList: MenuInfo[]) { + let predicates = new relationalStore.RdbPredicates(DataShareConstants.ANTO_MENU_TABLE_V2.tableName); + let deleteResult: number = await RdbManager.getInstance().delete(context, predicates); + Logger.info(TAG, 'Delete menuInfo Result: ' + deleteResult); + for (let index = 0; index < menuInfoList.length; index++) { + const element = menuInfoList[index]; + const valueBucket: relationalStore.ValuesBucket = this._generateBucket(element); + await RdbManager.getInstance().insert(context, DataShareConstants.ANTO_MENU_TABLE_V2.tableName, valueBucket); + } + Logger.info(TAG, '_refreshDb end.') + } + + // MenuConfig[] to MenuInfo[] + private async _convertMenuConfigToMenuInfo(context: Context, menuConfigList: MenuConfig[], userId: number): Promise { + let menuInfoList: MenuInfo[] = []; + for (let i = 0; i < menuConfigList.length; i++) { + const menuConfig: MenuConfig = menuConfigList[i]; + let menuInfo: MenuInfo = { + businessId: menuConfig.businessId, + intent: menuConfig.dstBundleName + '-' + menuConfig.dstAbilityName, + userId: userId, + iconBackgroundColorResource: '', + isClickable: 1, + displayedMode: menuConfig.displayedMode, + iconResource: menuConfig.iconResource, + mainTitleResource: menuConfig.mainTitleResource, + subTitleResource: menuConfig.subTitleResource, + showControlAbilityUri: menuConfig.showControlAbilityUri, + dstAbilityMode: menuConfig.dstAbilityMode, + dstAbilityName: menuConfig.dstAbilityName, + dstBundleName: menuConfig.dstBundleName, + bundleName: menuConfig.bundleName, + priority: await AutoMenuManager.getInstance().getMenuPriority(context, menuConfig), + isSupport: await AutoMenuManager.getInstance().isSupportMenu(context, menuConfig), + titleString: await this._getConfigResString(context, menuConfig.bundleName, menuConfig.mainTitleResource), + subTitleString: await this._getConfigResString(context, menuConfig.bundleName, menuConfig.subTitleResource) + } + menuInfoList.push(menuInfo); + } + return menuInfoList; + } + + private async _getUserId(): Promise { + const accountManager: osAccount.AccountManager = osAccount.getAccountManager(); + let userIdList: number[] = await accountManager.getActivatedOsAccountLocalIds(); + const userId: number = userIdList[0]; + return userId; + } + + // 获取配置的标题字符串资源 + private async _getConfigResString(context: Context, bundleName: string, res: string): Promise { + if (res === null || res === undefined) { + return ''; + } + let resourceManager = resourceUtil.getBundleResourceManager(bundleName, context); + if (resourceManager === null) { + return ''; + } + let titleResList = res.split(':'); + if (titleResList.length >= 2) { + let title = titleResList[1]; + return await resourceManager.getStringByName(title); + } + return ''; + } + + private _generateBucket(menuInfo: MenuInfo): relationalStore.ValuesBucket { + let obj: relationalStore.ValuesBucket = {}; + obj.businessId = menuInfo.intent; + obj.intent = menuInfo.intent; + obj.userId = menuInfo.userId; + obj.iconBackgroundColorResource = menuInfo.iconBackgroundColorResource; + obj.priority = menuInfo.priority; + obj.isSupport = menuInfo.isSupport; + obj.isClickable = menuInfo.isClickable; + obj.displayedMode = menuInfo.displayedMode; + obj.iconResource = menuInfo.iconResource; + obj.mainTitleResource = menuInfo.mainTitleResource; + obj.subTitleResource = menuInfo.subTitleResource; + obj.showControlAbilityUri = menuInfo.showControlAbilityUri; + obj.dstAbilityMode = menuInfo.dstAbilityMode; + obj.dstAbilityName = menuInfo.dstAbilityName; + obj.dstBundleName = menuInfo.dstBundleName; + obj.bundleName = menuInfo.bundleName; + return obj; + } +} diff --git a/entry/src/main/ets/main/auto_menu/AutoMenuViewModel.ets b/entry/src/main/ets/main/auto_menu/AutoMenuViewModel.ets new file mode 100644 index 0000000..75204e6 --- /dev/null +++ b/entry/src/main/ets/main/auto_menu/AutoMenuViewModel.ets @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2022-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 { ProcessResult } from '../../common/base/BaseViewModel'; +import { BaseViewModel } from '../../common/base/BaseViewModel'; +import { BaseIntent } from '../../common/base/BaseIntent'; +import MenuInfo from '../../common/bean/MenuInfo'; +import { AutoMenuClickIntent, AutoMenuInitIntent, AutoMenuRefreshIntent } from './AutoMenuIntent'; +import { AutoMenuModel } from './AutoMenuModel'; +import { AutoMenuViewState } from './AutoMenuViewState'; +import Logger from '../../common/utils/Logger'; + +const TAG = 'AutoMenu'; +const DISPLAY_MODEL_LIST = 'list'; +const DISPLAY_MODEL_CARD = 'card'; + +export class AutoMenuViewModel extends BaseViewModel { + protected initModel(): AutoMenuModel { + return new AutoMenuModel(); + } + + protected initViewState(): AutoMenuViewState { + return new AutoMenuViewState(); + } + + protected async processIntentWithModel(intent: BaseIntent, model: AutoMenuModel, viewStat: AutoMenuViewState): Promise { + Logger.info(TAG, 'start processIntentWithModel: ' + intent.getIntentTag()); + if (intent instanceof AutoMenuInitIntent) { + let menuInfoList: MenuInfo[] = await model.getMenuInfoListFromRdb(intent.context); + viewStat.listMenuList = menuInfoList.filter((item) => { + return (DISPLAY_MODEL_LIST === item.displayedMode || DISPLAY_MODEL_CARD === item.displayedMode) + }) + return ProcessResult.SUCCESS; + } + if (intent instanceof AutoMenuRefreshIntent) { + let menuInfoList: MenuInfo[] = await model.getMenuInfoListFromBms(intent.context); + viewStat.listMenuList = menuInfoList.filter((item) => { + return (DISPLAY_MODEL_LIST === item.displayedMode || DISPLAY_MODEL_CARD === item.displayedMode) + }) + Logger.info(TAG, 'AutoMenuRefreshIntent: ' + JSON.stringify(menuInfoList)); + Logger.info(TAG, 'viewState: ' + JSON.stringify(viewStat)); + return ProcessResult.SUCCESS; + } + if (intent instanceof AutoMenuClickIntent) { + model.handleMenuClick(intent.menuInfo); + return ProcessResult.SUCCESS; + } + Logger.error(TAG, 'undefined intent: ' + intent.getIntentTag()); + return ProcessResult.FAIL; + } +} \ No newline at end of file diff --git a/entry/src/main/ets/main/auto_menu/AutoMenuViewState.ets b/entry/src/main/ets/main/auto_menu/AutoMenuViewState.ets new file mode 100644 index 0000000..839e215 --- /dev/null +++ b/entry/src/main/ets/main/auto_menu/AutoMenuViewState.ets @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2022-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 { BaseState } from '../../common/base/BaseState'; +import MenuInfo from '../../common/bean/MenuInfo'; + +@Observed +export class AutoMenuViewState extends BaseState { + // 功能接入,列表数据 + public listMenuList: MenuInfo[] = []; + // 功能接入,卡片数据 + public cardMenuList: MenuInfo[] = []; +} \ No newline at end of file diff --git a/entry/src/main/ets/model/bundleInfo/BundleInfoModel.ets b/entry/src/main/ets/model/bundleInfo/BundleInfoModel.ets new file mode 100644 index 0000000..4960c7e --- /dev/null +++ b/entry/src/main/ets/model/bundleInfo/BundleInfoModel.ets @@ -0,0 +1,274 @@ +/** + * Copyright (c) 2022-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 i18n from '@ohos.i18n'; +import bundleManager from '@ohos.bundle.bundleManager'; +import { BundleInfoBean } from '../../common/bean/BundleInfoBean'; +import common from '@ohos.app.ability.common'; +import Want from '@ohos.app.ability.Want'; +import Logger from '../../common/utils/Logger'; +import { StringUtil } from '../../common/utils/StringUtil'; +import resourceManager from '@ohos.resourceManager'; + +const USER_ID = 100; +const TAG = 'BundleInfoModel'; +const ACTION = 'action.access.privacy.center'; + +class BundleInfoModel { + private context = getContext(this) as common.UIAbilityContext; + + getAllBundleLabelAndIcon(allBundleInfo: bundleManager.ApplicationInfo[]) { + let bundleInfoList: BundleInfoBean[] = [] + return new Promise(async (resolve, reject) => { + try { + allBundleInfo = allBundleInfo.filter((item, index, arr) => { + return arr.findIndex(t => t.name === item.name) === index; + }); + for (let index = 0; index < allBundleInfo.length; index++) { + const info = allBundleInfo[index]; + let bundleInfo: BundleInfoBean = { + bundleName: info.name, + icon: '', + iconId: info.iconId, + label: '', + labelId: info.labelId, + permissionName: '', + permissionLabel: '', + checkedState: '', + checkedStateLabel: '', + zhTag: '', + indexTag: '', + language: '', + labelResource: info.labelResource, + iconResource: info.iconResource, + } + await this.updateAppLabelAndIcon(bundleInfo); + if (bundleInfo.label && bundleInfo.icon) { + bundleInfoList.push(bundleInfo) + } + } + } catch (error) { + Logger.error(TAG, `getAllBundleLabelAndIcon error: ${JSON.stringify(error)}`) + } + resolve(bundleInfoList); + }) + } + + queryExtensionAbilityInfo(bundleName: string) { + Logger.info(TAG, `queryExtensionAbilityInfo bundleName: ${bundleName}`); + let extensionAbilityType = bundleManager.ExtensionAbilityType.UNSPECIFIED; + let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_WITH_METADATA; + let userId = USER_ID; + let want: Want = { + bundleName: bundleName, + action: ACTION, + } + + return new Promise((resolve) => { + bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId, (err, data) => { + if (err) { + Logger.error(TAG, `queryExtensionAbilityInfo failed: ${err.message}`) + } else { + resolve(data); + Logger.info(TAG, `queryExtensionAbilityInfo successfully: ${JSON.stringify(data)}`) + } + }) + }) + } + + async queryExtensionAbilityInfoOther() { + Logger.info(TAG, 'queryExtensionAbilityInfoOther'); + let extensionAbilityType = bundleManager.ExtensionAbilityType.UNSPECIFIED; + let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_WITH_METADATA | + bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION; + let userId = USER_ID; + let want: Want = { + action: ACTION, + }; + let result: bundleManager.ExtensionAbilityInfo[] = []; + try { + result = await bundleManager.queryExtensionAbilityInfo(want, extensionAbilityType, extensionFlags, userId) + } catch (err) { + Logger.error(TAG, `queryExtensionAbilityInfoOther fail: ${JSON.stringify(err)}`); + } + return result; + } + + async queryAbilityInfoOther() { + Logger.info(TAG, 'queryAbilityInfoOther'); + let extensionFlags = bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_WITH_METADATA | + bundleManager.ExtensionAbilityFlag.GET_EXTENSION_ABILITY_INFO_WITH_APPLICATION; + let userId = USER_ID; + let want: Want = { + action: ACTION, + }; + let result: bundleManager.AbilityInfo[] = []; + try { + result = await bundleManager.queryAbilityInfo(want, extensionFlags, userId) + } catch (err) { + Logger.error(TAG, `queryExtensionAbilityInfoOther fail: ${JSON.stringify(err)}`); + } + return result; + } + + // 获取所有应用信息关于功能接入 + getAllBundleInfoByFunctionAccess() { + let modelFlags = bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA | + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_HAP_MODULE | + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY | + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_ABILITY; + return new Promise((resolve) => { + bundleManager.getAllBundleInfo(modelFlags).then((data) => { + resolve(data) + }).catch((error: Error) => { + resolve([]) + Logger.error(TAG, `getAllBundleInfo error: ${JSON.stringify(error)}`) + }) + }) + } + + /** + * Get app label and icon resources + * @param {Number} index index of all app permissions array + * @param {String} bundleName Package names + */ + async updateAppLabelAndIcon(info: BundleInfoBean): Promise { + let resourceManager: resourceManager.ResourceManager = this.context.createBundleContext(info.bundleName) + .resourceManager; + return new Promise(async (resolve, reject) => { + try { + await resourceManager.getStringValue(info.labelId).then(value => { + info.label = value; + }).catch((error: Error) => { + Logger.error(TAG, `${info.bundleName} getStringValue by ${info.labelId} error=${JSON.stringify(error)}`); + }) + try { + let iconDescriptor = resourceManager.getDrawableDescriptor(info.iconId); + info.icon = iconDescriptor?.getPixelMap(); + } catch (exception) { + Logger.warn(TAG, `get adaptive icon exception: ${JSON.stringify(exception)}`) + } + if (!info.icon) { + info.icon = await resourceManager.getMediaContentBase64(info.iconId) || $r('app.media.icon'); + } + } catch (error) { + Logger.error(TAG, `updateAppLabelAndIcon error: ${JSON.stringify(error)}`) + } + resolve(); + }) + } + + static readonly zh: string = '阿八嚓哒妸发旮哈靃讥咔垃呣拏噢妑七呥仨它唾畖窊夕丫币'; + static readonly en: string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; + indexValue: string[] = + ['#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'] + + getStringZh(input: string): string { + let result: string = ''; + let upperCaseStr = input.toLocaleUpperCase(); + let regex: RegExp = new RegExp('[A-Z]'); + for (let i = 0; i < input.length; i++) { + if (upperCaseStr[i].match(regex)) { + let index = upperCaseStr.charCodeAt(i) - 'A'.charCodeAt(0); + let ch = BundleInfoModel.zh.charAt(index); + result += ch; + } else { + result += upperCaseStr[i]; + } + } + return result; + } + + findZhIndex(zhCharacter: string): string { + if (StringUtil.isEmpty(zhCharacter) || zhCharacter.localeCompare(BundleInfoModel.zh[0], 'zh') < 0) { + return '#'; + } + for (let left = 0; left < BundleInfoModel.zh.length - 1; left++) { + let next = left + 1; + if (zhCharacter.localeCompare(BundleInfoModel.zh[left], 'zh') >= 0 && zhCharacter.localeCompare(BundleInfoModel.zh[next], 'zh') < 0) { + return BundleInfoModel.en[left]; + } + if (next === BundleInfoModel.zh.length - 1 && zhCharacter.localeCompare(BundleInfoModel.zh[next], 'zh') >= 0) { + return BundleInfoModel.en[next]; + } + } + return ''; + } + + sortByName(appArray: BundleInfoBean[]): BundleInfoBean[] { + let enComparator = new Intl.Collator('en'); + let zhComparator = new Intl.Collator('zh-Hans-CN'); + try { + return appArray.sort((item1: BundleInfoBean, item2: BundleInfoBean) => { + if (item1.indexTag !== item2.indexTag) { + return enComparator.compare(item1.indexTag, item2.indexTag); + } + let isEn1 = item1.language === 'EN'; + let isEn2 = item2.language === 'EN'; + if (isEn1 && isEn2) { + return enComparator.compare(item1.label, item2.label) + } else if (isEn1 && !isEn2) { + return 1; + } else if (!isEn1 && isEn2) { + return -1; + } else { + return zhComparator.compare(item1.zhTag, item2.zhTag); + } + }) + } catch (error) { + Logger.error(TAG, `sortByName error: ${JSON.stringify(error)}`) + return []; + } + } + + addLocalTag(info: BundleInfoBean) { + let isZh = i18n.System.getSystemLanguage().indexOf('zh') >= 0; + let appName: string = info.label; + let upperCase = StringUtil.isEmpty(appName) ? '' : appName[0].toLocaleUpperCase(); + let regexEn: RegExp = new RegExp('[A-Z]'); + let regexNm: RegExp = new RegExp('[0-9]'); + + if (isZh) { + if (upperCase.match(regexEn)) { + info.zhTag = this.getStringZh(appName); + info.indexTag = upperCase; + info.language = 'EN'; + } else { + info.zhTag = appName; + info.language = 'CN'; + if (upperCase.match(regexNm)) { + info.indexTag = '#'; + } else { + info.indexTag = this.findZhIndex(upperCase); + } + } + } else { + if (upperCase.match(regexEn)) { + info.zhTag = appName; + info.indexTag = upperCase; + info.language = 'EN'; + } else { + info.zhTag = appName; + info.indexTag = '#'; + info.language = 'CN'; + } + } + } +} + +let bundleInfoModel = new BundleInfoModel(); + +export default bundleInfoModel as BundleInfoModel; diff --git a/entry/src/main/ets/model/locationServicesImpl/ListenerBean.ets b/entry/src/main/ets/model/locationServicesImpl/ListenerBean.ets new file mode 100644 index 0000000..ae56cd7 --- /dev/null +++ b/entry/src/main/ets/model/locationServicesImpl/ListenerBean.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022-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 ListenerBean { + updateServiceState: Function; + + constructor(updateServiceState:Function) { + this.updateServiceState = updateServiceState + } +} \ No newline at end of file diff --git a/entry/src/main/ets/model/locationServicesImpl/LocationService.ets b/entry/src/main/ets/model/locationServicesImpl/LocationService.ets new file mode 100644 index 0000000..4a5a7a0 --- /dev/null +++ b/entry/src/main/ets/model/locationServicesImpl/LocationService.ets @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2022-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 geolocation from '@ohos.geoLocationManager'; +import Logger from '../../common/utils/Logger'; +import ConfigData from '../../common/baseUtile/ConfigData'; +import { BusinessError } from '@ohos.base'; +import { ListenerBean } from './ListenerBean'; + +export class LocationService { + mIsStart: boolean = false; + mListener: ListenerBean = new ListenerBean(() => { + }); + + startService() { + if (this.mIsStart) { + return; + } + Logger.info(ConfigData.TAG, 'start location service') + this.mIsStart = true; + geolocation.on('locationEnabledChange', (isChanged: boolean) => { + Logger.info(ConfigData.TAG, `start location service isChanged: ${JSON.stringify(isChanged)}`) + this.getServiceState(); + }); + } + + registerListener(listener: ListenerBean) { + Logger.info(ConfigData.TAG, `register locations listener : ${listener}`) + this.mListener = listener; + } + + async getServiceState(): Promise { + Logger.info(ConfigData.TAG, 'get location state'); + try { + let state: boolean = await geolocation.isLocationEnabled(); + Logger.info(ConfigData.TAG, `get location state, data: ${JSON.stringify(state)}`); + this.mListener?.updateServiceState(state); + } catch (error) { + Logger.info(ConfigData.TAG, `get location state, data: ${error}`); + } + + } + + enableLocation() { + Logger.info(ConfigData.TAG, 'enable location'); + try { + geolocation.enableLocation() + .then((res): void => Logger.info(ConfigData.TAG, `enable location, result: ${JSON.stringify(res)}`)) + .catch((error: BusinessError): void => Logger.info(ConfigData.TAG, `enable location, result: ${error}`)); + } catch (err) { + Logger.info(ConfigData.TAG, `enable location, result: ${err}`); + } + + } + + disableLocation() { + Logger.info(ConfigData.TAG, 'disable location'); + try { + geolocation.disableLocation(); + } catch (err) { + Logger.info(ConfigData.TAG, `disenable location, result: ${err}`); + } + } +} + +let locationService = new LocationService(); + +export default locationService as LocationService; \ No newline at end of file diff --git a/entry/src/main/ets/model/locationServicesImpl/LocationViewModel.ets b/entry/src/main/ets/model/locationServicesImpl/LocationViewModel.ets new file mode 100644 index 0000000..1107069 --- /dev/null +++ b/entry/src/main/ets/model/locationServicesImpl/LocationViewModel.ets @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2022-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 LocationService from './LocationService'; +import Logger from '../../common/utils/Logger'; +import ConfigData from '../../common/baseUtile/ConfigData'; + +export const LocationServiceOpenStatusKey = "LocationServiceStatus"; + +export class LocationVM { + mIsStart: boolean = false; + + initViewModel() { + if (this.mIsStart) { + return; + } + Logger.info(ConfigData.TAG, 'init location view model') + this.mIsStart = true; + LocationService.registerListener(this); + LocationService.startService(); + LocationService.getServiceState(); + } + + updateServiceState(state: boolean) { + Logger.info(ConfigData.TAG, `update location service state, state: ${state} `) + AppStorage.setOrCreate(LocationServiceOpenStatusKey, state); + } + + enableLocation() { + Logger.info(ConfigData.TAG, 'enable location') + LocationService.enableLocation(); + } + + disableLocation() { + Logger.info(ConfigData.TAG, 'disable location') + LocationService.disableLocation(); + } +} + +let locationVM = new LocationVM(); + +export default locationVM as LocationVM; \ 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 0000000..cf50796 --- /dev/null +++ b/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,175 @@ +/** + * Copyright (c) 2022-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 '../common/utils/Logger'; +import common from '@ohos.app.ability.common'; +import BundleInfoModel from '../model/bundleInfo/BundleInfoModel'; +import bundleManager from '@ohos.bundle.bundleManager'; +import { StringUtil } from '../common/utils/StringUtil'; +import Constants from '../common/constants/ComConstant'; +import { BusinessError } from '@ohos.base'; +import TitleBar from '../common/components/TitleBarComponent'; +import PrivacyProtectionListView from '../view/privacy/PrivacyProtectionListView'; +import router from '@ohos.router'; +import ResourceUtil from '../common/utils/ResourceUtil'; +import HiSysEventUtil from '../common/utils/HiSysEventUtil'; +import HiSysEventConstant from '../common/constants/HiSysEventConstant'; +import { AutoMenuClickIntent, AutoMenuRefreshIntent } from '../main/auto_menu/AutoMenuIntent'; +import { AutoMenuViewModel } from '../main/auto_menu/AutoMenuViewModel'; +import MenuInfo from '../common/bean/MenuInfo'; + +const TAG: string = 'Index'; +const autoMenuViewModel: AutoMenuViewModel = new AutoMenuViewModel(); +let storage = LocalStorage.getShared(); + +@Entry(storage) +@Component +struct Index { + @State startTime: number = 0; + private context = getContext(this) as common.UIAbilityContext; + @State isSplitMode: boolean = false; + scroller: Scroller = new Scroller(); + @State windowWidth: number = 0; + + @Styles + PressedStyles() { + .backgroundColor($r('sys.color.ohos_id_color_click_effect')) + } + + @Styles + normalStyles() { + .backgroundColor($r('sys.color.ohos_id_color_list_card_bg')) + } + + onPageShow() { + this.startTime = new Date().getTime(); + autoMenuViewModel.processIntent(new AutoMenuRefreshIntent(this.context)); + this.getBundleInfo(); + } + + // 获取所有包信息 + getBundleInfo() { + BundleInfoModel.getAllBundleInfoByFunctionAccess() + .then(async (data: bundleManager.BundleInfo[]) => { + // filter blank icon and text label resources + let initAppInfoList: bundleManager.ApplicationInfo[] = []; + for (let i = 0; i < data.length; i++) { + let info = data[i] + if (StringUtil.isNotEmpty(info.appInfo.icon)) { + initAppInfoList = initAppInfoList.concat(info.appInfo); + } + } + if (initAppInfoList?.length) { + AppStorage.setOrCreate(Constants.INIT_APP_INFO_LIST, initAppInfoList) + } + }) + } + + build() { + Column() { + TitleBar({ + title: JSON.stringify($r('app.string.EntryAbility_label')), + isSplitMode: this.isSplitMode, + }).padding({ + left: $r('sys.float.ohos_id_default_padding_start'), + right: $r('sys.float.ohos_id_default_padding_end') + }) + + Scroll(this.scroller) { + Column() { + // 组件1 功能接入‘列表’ + PrivacyProtectionListView({ + menuViewState: autoMenuViewModel.getViewState(), + itemClickEvent: ((menuInfo: MenuInfo) => { + autoMenuViewModel.processIntent(new AutoMenuClickIntent(menuInfo)); + }) + }) + // 组件2 位置信息 + Row() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text($r('app.string.locationServicesTab')) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .textAlign(TextAlign.Start) + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Medium) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + Row() { + Image($r('app.media.ic_settings_arrow')) + .width($r('app.float.width_height_xs')) + .height($r('app.float.width_height_m')) + .align(Alignment.End) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .draggable(false) + } + .padding({ + top: $r('app.float.function_access_inside_list_padding'), + bottom: $r('app.float.function_access_inside_list_padding'), + left: $r('app.float.function_access_list_padding_top'), + right: $r('app.float.function_access_list_padding_top') + }) + .margin({ + left: $r('sys.float.ohos_id_text_margin_horizontal'), + }) + } + .stateStyles({ + pressed: this.PressedStyles, + normal: this.normalStyles + }) + .padding({ + top: $r('app.float.book_mark_padding'), + bottom: $r('app.float.book_mark_padding'), + left: $r('app.float.function_access_inside_list_padding'), + right: $r('app.float.function_access_inside_list_padding') + }) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .hoverEffect(HoverEffect.Highlight) + .borderRadius(ResourceUtil.getFloatNumber($r('sys.float.ohos_id_corner_radius_default_l')) - 4) + .onClick(async () => { + // 定位服务打点 + HiSysEventUtil.reportAccessClick(HiSysEventConstant.BUNDLE_NAME) + + router.pushUrl({ + url: 'pages/locationServices' + }, router.RouterMode.Standard).then(() => { + Logger.info(TAG, 'succeeded in jumping to the locationServices page.') + }).catch((err: BusinessError) => { + Logger.error(TAG, `Failed to jump to the locationServices page.code is ${err.code}.message is ${err.message}`); + }) + }) + } + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) + .padding($r('app.float.function_access_list_padding')) + .backgroundColor($r('sys.color.ohos_id_color_list_card_bg')) + } + } + .height(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .scrollable(ScrollDirection.Vertical) //滚动方向纵向 + .edgeEffect(EdgeEffect.Spring) + .margin({ + bottom: $r('app.float.index_margin_bottom') + }) + .padding({ + left: $r('sys.float.ohos_id_default_padding_start'), + right: $r('sys.float.ohos_id_default_padding_end') + }) + .align(Alignment.Top) + } + .height(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .backgroundColor($r('sys.color.ohos_id_color_sub_background')) + + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/UiExtensionPage.ets b/entry/src/main/ets/pages/UiExtensionPage.ets new file mode 100644 index 0000000..cd97436 --- /dev/null +++ b/entry/src/main/ets/pages/UiExtensionPage.ets @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2022-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 Constants from '../common/constants/ComConstant'; +import Logger from '../common/utils/Logger'; + +const TAG = 'UiExtensionPage' + +@Entry +@Component +struct UiExtensionPage { + @State routerParma: Record = router.getParams() as Record; + @State dstBundleName: string = this.routerParma['dstBundleName']; + @State dstAbilityName: string = this.routerParma['dstAbilityName']; + + build() { + Row() { + UIExtensionComponent({ + bundleName: this.dstBundleName, + abilityName: this.dstAbilityName, + parameters: { + 'ability.want.params.uiExtensionType': 'sys/commonUI', + } + }) + .onRemoteReady((data) => { + Logger.debug(TAG, 'UiExtensionPage onRemoteReady: ' + JSON.stringify(data)); + }) + .onResult((data) => { + Logger.debug(TAG, 'UiExtensionPage onResult: ' + JSON.stringify(data)); + }) + .onRelease((code) => { + Logger.debug(TAG, 'UiExtensionPage code: ' + JSON.stringify(code)); + }) + .onReceive((data) => { + // update message + Logger.debug(TAG, 'UiExtensionPage onReceive: ' + JSON.stringify(data)); + if (data['action'] === 'exit') { + router.back(); + } + }) + .height(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + } + .height(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/locationServices.ets b/entry/src/main/ets/pages/locationServices.ets new file mode 100644 index 0000000..e84ea73 --- /dev/null +++ b/entry/src/main/ets/pages/locationServices.ets @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2022-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 ViewModel from '../model/locationServicesImpl/LocationViewModel'; +import Logger from '../common/utils/Logger'; +import ConfigData from '../common/baseUtile/ConfigData'; +import HeadComponent from '../common/components/headComponent'; +import HiSysEventUtil from '../common/utils/HiSysEventUtil'; +import HiSysEventConstant from '../common/constants/HiSysEventConstant'; + +/** + * LocationServices + */ +@Entry +@Component +struct LocationServices { + @StorageLink('LocationServiceStatus') locationServiceStatus: boolean = false; + + build() { + Column() { + GridContainer({ gutter: ConfigData.GRID_CONTAINER_GUTTER_24, margin: ConfigData.GRID_CONTAINER_MARGIN_24 }) { + Column() { + HeadComponent({ headName: $r('app.string.locationServicesTab'), isActive: true }); + + Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text($r('app.string.positionInformation')) + .fontColor($r("app.color.font_color_182431")) + .fontStyle(FontStyle.Normal) + .fontSize($r("app.float.location_font_size")) + .margin({ left: $r('app.float.distance_12') }) + + Toggle({ type: ToggleType.Switch, isOn: this.locationServiceStatus }) + .margin({ right: $r('app.float.padding_or_margin_s') }) + .width('36vp') + .height('20vp') + .selectedColor('#007DFF') + .onChange((isOn: boolean) => { + Logger.info(ConfigData.TAG, 'location service status is :' + this.locationServiceStatus); + if (isOn) { + ViewModel.enableLocation(); + HiSysEventUtil.reportLocationClick(HiSysEventConstant.BUNDLE_NAME, 1) + + } else { + ViewModel.disableLocation(); + + HiSysEventUtil.reportLocationClick(HiSysEventConstant.BUNDLE_NAME, 0) + } + }); + } + .margin({ top: $r("app.float.padding_or_margin_m") }) + .height($r('app.float.wh_value_56')) + .backgroundColor($r("app.color.white_bg_color")) + .borderRadius($r("sys.float.ohos_id_corner_radius_default_l")) + } + .useSizeType({ + sm: { span: 4, offset: 0 }, + md: { span: 6, offset: 1 }, + lg: { span: 8, offset: 2 } + }) + } + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + } + .backgroundColor($r("sys.color.ohos_id_color_sub_background")) + .width(ConfigData.WH_100_100) + .height(ConfigData.WH_100_100) + } + + aboutToAppear(): void { + Logger.info(ConfigData.TAG, 'location service about to appear'); + ViewModel.initViewModel(); + } + + aboutToDisappear(): void { + Logger.info(ConfigData.TAG, 'location service about to disappear'); + } +} \ No newline at end of file diff --git a/entry/src/main/ets/view/privacy/PrivacyProtectionListView.ets b/entry/src/main/ets/view/privacy/PrivacyProtectionListView.ets new file mode 100644 index 0000000..4edb558 --- /dev/null +++ b/entry/src/main/ets/view/privacy/PrivacyProtectionListView.ets @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2022-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 Constants from '../../common/constants/ComConstant'; +import ResourceUtil from '../../common/utils/ResourceUtil'; +import { AutoMenuViewState } from '../../main/auto_menu/AutoMenuViewState'; +import MenuInfo from '../../common/bean/MenuInfo'; + +@Component +export default struct PrivacyProtectionListView { + // 功能接入卡片的数据 + @Prop menuViewState: AutoMenuViewState; + private itemClickEvent = (menuInfo: MenuInfo) => { + }; + + build() { + Column() { + //循环遍历渲染 + List({ space: Constants.DEFAULT_SPACE }) { + ForEach(this.menuViewState.listMenuList, (item: MenuInfo) => { + ListItem() { + PrivacyProtectionItem({ menuInfo: item, itemClickEvent: this.itemClickEvent }) + .visibility(item !== undefined && item !== null ? Visibility.Visible : Visibility.None) + } + }, (item: MenuInfo) => JSON.stringify(item)) + } + .borderRadius($r('sys.float.ohos_id_corner_radius_card')) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .margin({ + top: this.menuViewState.cardMenuList.length === 0 ? 0 : $r('app.float.function_access_list_default_margin_top'), + bottom: $r('app.float.function_access_list_margin_bottom') + }) + } + .visibility(this.menuViewState.listMenuList.length !== 0 ? Visibility.Visible : Visibility.None) + } +} + +@Component +struct PrivacyProtectionItem { + @Prop menuInfo: MenuInfo; + @State isTouched: boolean = false; + private itemClickEvent = (menuInfo: MenuInfo) => { + } + + build() { + Row() { + Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { + Text(this.menuInfo.titleString) + .fontColor($r('sys.color.ohos_id_color_text_primary')) + .textAlign(TextAlign.Start) + .fontFamily('HarmonyHeiTi') + .fontWeight(FontWeight.Medium) + .fontSize($r('sys.float.ohos_id_text_size_body1')) + Row() { + Image($r('app.media.ic_settings_arrow')) + .width($r('app.float.width_height_xs')) + .height($r('app.float.width_height_m')) + .align(Alignment.End) + .fillColor($r('sys.color.ohos_id_color_fourth')) + .draggable(false) + } + .padding({ + top: $r('app.float.function_access_inside_list_padding'), + bottom: $r('app.float.function_access_inside_list_padding'), + }) + .margin({ + left: $r('sys.float.ohos_id_text_margin_horizontal'), + }) + } + .hoverEffect(HoverEffect.Highlight) + .onClick(() => { + this.itemClickEvent(this.menuInfo) + }) + .backgroundColor(this.isTouched ? $r('sys.color.ohos_id_color_click_effect') : $r('sys.color.ohos_id_color_list_card_bg')) + .onTouch((event?: TouchEvent | undefined) => { + if (event?.type === TouchType.Down) { + this.isTouched = true; + } + if (event?.type === TouchType.Up) { + this.isTouched = false; + } + }) + .padding({ + left: $r('app.float.function_access_inside_list_padding'), + top: $r('app.float.function_access_list_padding_top'), + right: $r('app.float.function_access_inside_list_padding'), + bottom: $r('app.float.function_access_list_padding_top'), + }) + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .borderRadius(ResourceUtil.getFloatNumber($r('sys.float.ohos_id_corner_radius_default_l')) - 4) + } + .width(Constants.WIDTH_HEIGHT_FULL_SCREEN) + .borderRadius($r('sys.float.ohos_id_corner_radius_default_l')) + .padding($r('app.float.function_access_list_padding')) + .backgroundColor($r('sys.color.ohos_id_color_list_card_bg')) + .enabled(this.menuInfo.isClickable === 1) + .visibility(this.menuInfo.isSupport ? Visibility.Visible : Visibility.None) + } +} + + + + + diff --git a/entry/src/main/module.json5 b/entry/src/main/module.json5 new file mode 100644 index 0000000..0e96159 --- /dev/null +++ b/entry/src/main/module.json5 @@ -0,0 +1,54 @@ +{ + "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, + 'orientation': "auto_rotation", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.MANAGE_SECURE_SETTINGS" + }, + { + "name": "ohos.permission.ACCESS_BUNDLE_DIR" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST" + }, + { + "name": "ohos.permission.ACCESS_SECURITY_PRIVACY_CENTER" + } + ] + } +} \ 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 0000000..f87176f --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,25 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "font_color_182431", + "value": "#182431" + }, + { + "name": "white_bg_color", + "value": "#FFFFFF" + }, + { + "name": "color_E3E3E3_grey", + "value": "#E3E3E3" + }, + { + "name": "color_00000000_transparent", + "value": "#00000000" + } + + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/element/float.json b/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000..da09501 --- /dev/null +++ b/entry/src/main/resources/base/element/float.json @@ -0,0 +1,262 @@ +{ + "float": [ + { + "name": "index_margin_bottom", + "value": "56vp" + }, + { + "name": "list_item_sub_title", + "value": "14vp" + }, + { + "name": "search_radius", + "value": "20vp" + }, + { + "name": "list_item_height", + "value": "60vp" + }, + { + "name": "search_height", + "value": "40vp" + }, + { + "name": "title_height", + "value": "56vp" + }, + { + "name": "detail_list_item_height", + "value": "48vp" + }, + { + "name": "list_margin_top", + "value": "8vp" + }, + { + "name": "bar_height", + "value": "56vp" + }, + { + "name": "grid_row_margin", + "value": "24vp" + }, + { + "name": "book_mark_image_width_height", + "value": "16vp" + }, + { + "name": "book_mark_height", + "value": "36vp" + }, + { + "name": "width_height_xl", + "value": "40vp" + }, + { + "name": "width_height_xs", + "value": "12vp" + }, + { + "name": "width_height_m", + "value": "24vp" + }, + { + "name": "width_height_l", + "value": "32vp" + }, + { + "name": "book_mark_padding", + "value": "6vp" + }, + { + "name": "default_borderRadius", + "value": "16vp" + }, + { + "name": "width_height_s", + "value": "16vp" + }, + + { + "name": "padding_or_margin_xs", + "value": "4vp" + }, + { + "name": "padding_or_margin_s", + "value": "6vp" + }, + { + "name": "padding_or_margin_m", + "value": "8vp" + }, + { + "name": "padding_or_margin_l", + "value": "10vp" + }, + { + "name": "padding_or_margin_xl", + "value": "12vp" + }, + { + "name": "space_x", + "value": "16vp" + }, + { + "name": "mark_bar_height", + "value": "345vp" + }, + { + "name": "mark_bar_height_on_tablet_pc", + "value": "375vp" + }, + { + "name": "other_text_height", + "value": "48vp" + }, + { + "name": "other_text_margin", + "value": "20vp" + }, + { + "name": "function_access_card_colum_margin", + "value": "9vp" + }, + { + "name": "function_access_card_image_width", + "value": "19vp" + }, + { + "name": "function_access_card_image_padding", + "value": "12vp" + }, + { + "name": "function_access_card_image_height", + "value": "19vp" + }, + { + "name": "function_access_card_width", + "value": "32vp" + }, + { + "name": "function_access_card_height", + "value": "32vp" + }, + { + "name": "function_access_card_margin", + "value": "4vp" + }, + { + "name": "function_access_card_text_margin", + "value": "10vp" + }, + { + "name": "function_access_card_subtitle_height", + "value": "32vp" + }, + { + "name": "function_access_card_subtitle_margin", + "value": "2vp" + }, + { + "name": "function_access_list_subtitle_height", + "value": "56vp" + }, + { + "name": "function_access_list_padding_left", + "value": "8vp" + }, + { + "name": "function_access_inside_list_padding", + "value": "8vp" + }, + { + "name": "function_access_list_padding_top", + "value": "4vp" + }, + { + "name": "function_access_list_padding_right", + "value": "8vp" + }, + { + "name": "function_access_list_padding_bottom", + "value": "4vp" + }, + { + "name": "function_access_list_padding", + "value": "4vp" + }, + { + "name": "function_access_card_padding", + "value": "4vp" + }, + { + "name": "function_access_inside_card_padding", + "value": "8vp" + }, + { + "name": "function_access_list_margin_bottom", + "value": "24vp" + }, + { + "name": "function_access_list_margin_top", + "value": "9vp" + }, + { + "name": "function_access_list_default_margin_top", + "value": "12vp" + }, + { + "name": "no_result_text_padding_top", + "value": "16vp" + }, + { + "name": "no_result_image_min_height_with", + "value": "120vp" + }, + { + "name": "no_result_image_max_height_with", + "value": "160vp" + }, + { + "name": "image_margin_left_16", + "value": "16vp" + }, + { + "name": "location_font_size", + "value": "16fp" + }, + { + "name": "distance_12", + "value": "12vp" + }, + { + "name": "wh_value_56", + "value": "56vp" + }, + { + "name": "wh_value_16", + "value": "16vp" + }, + { + "name": "head_font_24", + "value": "24vp" + }, + { + "name": "wh_value_33", + "value": "33vp" + }, + { + "name": "wh_value_13", + "value": "13vp" + }, + { + "name": "wh_value_15", + "value": "15vp" + }, + { + "name": "wh_value_12", + "value": "12vp" + } + + ] +} \ 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 0000000..6e9d5ec --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,487 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "Entry to the privacy module" + } + ,{ + "name": "EntryAbility_desc", + "value": "Privacy home page" + },{ + "name": "EntryAbility_label", + "value": "Privacy" + }, + { + "name": "button_go", + "value": "Go set" + }, + { + "name": "button_ignore", + "value": "Ignore" + }, + { + "name": "category_title_lock_screen_password", + "value": "Lock screen password" + }, + { + "name": "category_desc_lock_screen_password", + "value": "Set a lock screen password to protect your device from unauthorized access" + }, + { + "name": "operation_froup_location", + "value": "Location" + }, + { + "name": "operation_group_camera", + "value": "Camera" + }, + { + "name": "operation_group_microphone", + "value": "Microphone" + }, + { + "name": "operation_group_image_and_videos", + "value": "Images & videos" + }, + { + "name": "operation_group_contacts", + "value": "Contacts" + }, + { + "name": "operation_group_application_tracing", + "value": "Tracking" + }, + { + "name": "operation_group_clipboard", + "value": "Clipboard" + }, + { + "name": "operation_group_document", + "value": "Files" + }, + { + "name": "operation_group_music_and_audio", + "value": "Music & audio" + }, + { + "name": "operation_group_health_and_fitness", + "value": "Physical activity" + }, + { + "name": "operation_group_calendar", + "value": "Calendar" + }, + { + "name": "operation_group_more_permission", + "value": "More permission" + }, + { + "name": "total_times_in_last_three_days", + "value": "Access in last %d days" + }, + { + "name": "other", + "value": "Other" + }, + { + "name": "privacy_permission", + "value": "Permissions" + }, + { + "name": "data_and_privacy", + "value": "Data & privacy" + }, + { + "name": "permission_more", + "value": "Show more" + }, + { + "name": "permission_collapse", + "value": "Show less" + }, + { + "name": "permission_by_default", + "value": "Default" + }, + { + "name": "allow", + "value": "Allow" + }, + { + "name": "media_only", + "value": "Media only" + }, + { + "name": "allow_management_of_all_files", + "value": "All files" + }, + { + "name": "precise_location", + "value": "Precise location" + }, + { + "name": "search_placeholder", + "value": "Search apps" + }, + { + "name": "today", + "value": "Today" + }, + { + "name": "yesterday", + "value": "Yesterday" + }, + { + "name": "allow_all_the_time", + "value": "Allow all the time" + }, + { + "name": "allow_only_while_in_use", + "value": "Allow only while using the app" + }, + { + "name": "ask_each_time", + "value": "Ask each time" + }, + { + "name": "deny", + "value": "Deny" + }, + { + "name": "allow_state", + "value": "Allowed" + }, + { + "name": "app_version_name", + "value": "Version %s" + }, + { + "name": "allow_all_the_time_state", + "value": "All the time" + }, + { + "name": "allow_only_while_in_use_state", + "value": "While in use" + }, + { + "name": "ask_each_time_state", + "value": "Ask each time" + }, + { + "name": "deny_state", + "value": "Denied" + }, + { + "name": "access_permission", + "value": "Location Services" + }, + { + "name": "view_ad_logo", + "value": "View OAID" + }, + { + "name": "operation_group_application_tracing_desc", + "value": "Your Open Anonymous Device Identifier (OAID) is a non-permanent device identifier that allows app developers to track your activity and serve personalized content,without revealing your personal data" + }, + { + "name": "privacy_introduction", + "value": "Huawei values your privacy. our products are designed to use and upload as little user data as possible - and only when necessary.\n\nwe respect both your right to know and your right to control how your date is used." + }, + { + "name": "use_privacy", + "value": "How we use your data" + }, + { + "name": "privacy_item1", + "value": "Our privacy commitment" + }, + { + "name": "privacy_protect_proposition_uri", + "value": "https://consumer.huawei.com/cn/privacy" + }, + { + "name": "privacy_item2", + "value": "Huawei Consumer Business Privacy Statement" + }, + { + "name": "consumer_business_privacy_statement_uri", + "value": "https://consumer.huawei.com/cn/privacy/privacy-policy/" + }, + { + "name": "privacy_item3", + "value": "Use of cookies" + }, + { + "name": "cookies_policy_uri", + "value": "https://consumer.huawei.com/cn/legal/cookie-policy" + }, + { + "name": "privacy_item4", + "value": "Privacy & security certifications" + }, + { + "name": "privacy_and_security_certification_uri", + "value": "https://consumer.huawei.com/cn/privacy/certification" + }, + { + "name": "more_privacy", + "value": "More about privacy protection" + }, + { + "name": "more_privacy_protection_information_uri", + "value": "https://privacy.consumer.huawei.com/tool?lang-cn&themeName=blue" + }, + { + "name": "app_state_foreground", + "value": "foreground" + }, + { + "name": "app_state_background", + "value": "background" + }, + { + "name": "app_state_screen_locked", + "value": "screen locked" + }, + { + "name": "app_state_common", + "value": "common" + }, + { + "name": "precise_location_description", + "value": "Allow this app to access your precise location. When disabled,this app can only access your approximate location." + }, + { + "name": "system_services", + "value": "System services" + }, + { + "name": "Improves_accuracy", + "value": "here" + }, + { + "name": "make_location_more_accurate_desc", + "value": "To improve location accuracy, touch %s." + }, + { + "name": "permission_group_storage", + "value": "Media and files" + }, + { + "name": "permission_group_phone", + "value": "Phone" + }, + { + "name": "permission_group_sms", + "value": "Messaging" + }, + { + "name": "permission_group_sensors", + "value": "Body sensors" + }, + { + "name": "permission_group_call_log", + "value": "Caii logs" + }, + { + "name": "permission_group_nearby_devices", + "value": "Nearby devices" + }, + { + "name": "permission_group_request_install_packages", + "value": "In-app installations" + }, + { + "name": "permission_group_shortcut", + "value": "Create home screen shortcuts" + }, + { + "name": "permission_group_system_alert_window", + "value": "Dropzone" + }, + { + "name": "permission_group_get_install_apps", + "value": "App list" + }, + { + "name": "permission_group_popup_background_window", + "value": "Background pop-ups" + }, + { + "name": "permission_group_distribution", + "value": "Multi-device collaboration" + }, + { + "name": "no_access_records_in_the_last_seven_days", + "value": "No access records for the last %d days" + }, + { + "name": "search_item_permission", + "value": "Permission manager" + }, + { + "name": "no_matching_results", + "value": "No results" + }, + { + "name": "forbidden_description_location", + "value": "Location Services is disabled.No apps can access your location." + }, + { + "name": "precise_location_app_description", + "value": "Allow this app to access your precise location. When disabled, this app can only access your approximate location.Some apps that don't support this feature may fall to get any location " + }, + { + "name": "barchart_no_access_record", + "value": "No records" + }, + { + "name": "loading", + "value": "Loading-" + }, + { + "name": "total_times_in_last_seven_days", + "value": "Accessed %3$s by %2$s in the %1$s days" + }, + { + "name": "location_access_record_title", + "value": "Permission history" + }, + { + "name": "camera_access_record_title", + "value": "Permission history" + }, + { + "name": "microphone_access_record_title", + "value": "Permission history" + }, + { + "name": "image_and_videos_access_record_title", + "value": "Permission history" + }, + { + "name": "contacts_access_record_title", + "value": "Permission history" + }, + { + "name": "application_tracing_access_record_title", + "value": "Permission history" + }, + { + "name": "clipboard_access_record_title", + "value": "Permission history" + }, + { + "name": "document_access_record_title", + "value": "Permission history" + }, + { + "name": "music_and_audio_access_record_title", + "value": "Permission history" + }, + { + "name": "health_and_fitness_access_record_title", + "value": "Permission history" + }, + { + "name": "calendar_access_record_title", + "value": "Permission history" + }, + { + "name": "location_portrait_permission_title", + "value": "Location Permission" + }, + { + "name": "camera_portrait_permission_title", + "value": "Camera Permission" + }, + { + "name": "microphone_portrait_permission_title", + "value": "Microphone Permission" + }, + { + "name": "image_and_videos_portrait_permission_title", + "value": "Image & videos Permission" + }, + { + "name": "contacts_portrait_permission_title", + "value": "Contacts Permission" + }, + { + "name": "application_tracing_portrait_permission_title", + "value": "App tracking Permission" + }, + { + "name": "clipboard_portrait_permission_title", + "value": "Clipboard Permission" + }, + { + "name": "document_portrait_permission_title", + "value": "Files Permission" + }, + { + "name": "music_and_audio_portrait_permission_title", + "value": "Music & audio Permission" + }, + { + "name": "health_and_fitness_portrait_permission_title", + "value": "Physical activity permission" + }, + { + "name": "calendar_portrait_permission_title", + "value": "Calendar Permission" + }, + { + "name": "location_portrait_permission_subtitle", + "value": "Location access for this app" + }, + { + "name": "camera_portrait_permission_subtitle", + "value": "Camera permission" + }, + { + "name": "microphone_portrait_permission_subtitle", + "value": "Microphone access for this app" + }, + { + "name": "image_and_videos_portrait_permission_subtitle", + "value": "Image & videos access for this app" + }, + { + "name": "contacts_portrait_permission_subtitle", + "value": "Contacts access for this app" + }, + { + "name": "application_tracing_portrait_permission_subtitle", + "value": "App tracking for this app" + }, + { + "name": "clipboard_portrait_permission_subtitle", + "value": "Clipboard access for this app" + }, + { + "name": "document_portrait_permission_subtitle", + "value": "Files access for this app" + }, + { + "name": "music_and_audio_portrait_permission_subtitle", + "value": "Music & audio access for this app" + }, + { + "name": "health_and_fitness_portrait_permission_subtitle", + "value": "Physical activity access for this app" + }, + { + "name": "calendar_portrait_permission_subtitle", + "value": "Calendar access for this app" + }, + { + "name": "locationServicesTab", + "value": "locationServices" + }, + { + "name": "positionInformation", + "value": "access my location information" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_back.svg b/entry/src/main/resources/base/media/ic_back.svg new file mode 100644 index 0000000..50e4ecd --- /dev/null +++ b/entry/src/main/resources/base/media/ic_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/media/ic_settings_arrow.svg b/entry/src/main/resources/base/media/ic_settings_arrow.svg new file mode 100644 index 0000000..ff6293c --- /dev/null +++ b/entry/src/main/resources/base/media/ic_settings_arrow.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+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!aV=cHAhi_E_mfUth(sM4^hJq7B zQsGWqdZUm9S%F`$nQ*_#NcuD`&)Ek%_s{&^78{9Hm ztri&rYLOxgFdG>O@+XHy z9#;|&vBCPXH5Mon^I`jSuR$&~ZWtyB67ujzFSj!51>#C}C17~TffQ{c-!QFQkTQ%! zIR^b1`zHx|*1GU?tbBx23weFLz5H?y_Q%N&t$}k?w+``2A=aotj0;2v$~AL z{scF-cL{wsdrmPvf#a9OHyYLcwQD4Kcm)`LLwMh4WT~p29f7M!iafJSU`IV}QY5Wa z(n44-9oA}?J{a+ah*@31WTs#&J#o1`H98#6IQf;Wv0N_!);f&9g7o-k(lW5rWnDUR zQBFIRG+X=6NnsI@mxnwm;tf5;_Uxg?jZ8m-m0}&6+DA!qam(p$mN5R})yA_7m$q@| zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y { + // 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('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc' + let b = 'b' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b) + expect(a).assertEqual(a) + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..27c8925 --- /dev/null +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2022-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 LocationViewModelTest from './bean/model/locationServicesImpl/LocationViewModel.test' +import LocationServiceTest from './bean/model/locationServicesImpl/LocationService.test' +import abilityTest from './Ability.test' +import CommonTest from './common/Common.test' +import ModelTest from './Model.test' + +export default function testsuite() { + abilityTest() + LocationServiceTest() + LocationViewModelTest() + CommonTest() + ModelTest() +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Model.test.ets b/entry/src/ohosTest/ets/test/Model.test.ets new file mode 100644 index 0000000..bacbfb2 --- /dev/null +++ b/entry/src/ohosTest/ets/test/Model.test.ets @@ -0,0 +1,133 @@ +/** + * Copyright (c) 2022-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 bundleManager from '@ohos.bundle.bundleManager'; +import BundleInfoModel from '../../../main/ets/model/bundleInfo/BundleInfoModel'; +import { BundleInfoBean } from '../../../main/ets/common/bean/BundleInfoBean'; +import { MenuConfig } from '../../../main/ets/common/bean/MenuConfig'; +import AccessTypedef from '../../../main/ets/common/bean/MenuInfo'; +import Logger from '../../../main/ets/common/utils/Logger'; +import { AutoMenuViewModel } from '../../../main/ets/main/auto_menu/AutoMenuViewModel'; +import { AutoMenuInitIntent, AutoMenuRefreshIntent } from '../../../main/ets/main/auto_menu/AutoMenuIntent'; +import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import { ProcessResult } from '../../../main/ets/common/base/BaseViewModel'; + +const TAG = 'ModelTest'; + +export default function ModelTest() { + describe('ModelTest', () => { + // 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('BundleInfoModelTest_01', 0, async () => { + let bundleName: string = 'com.ohos.security_privacy_center' + await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT) + .then((data) => { + BundleInfoModel.getAllBundleLabelAndIcon([data]).then((value) => { + expect(value).not().assertNull() + }) + }) + }) + it('BundleInfoModelTest_02', 0, async () => { + let bundleName: string = '' + await BundleInfoModel.queryExtensionAbilityInfo(bundleName).then(data => { + expect(data).not().assertNull() + }) + }) + it('BundleInfoModelTest_03', 0, async () => { + let bundleName: string = 'com.ohos.security_privacy_center' + await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT) + .then((info) => { + let bundleInfo: BundleInfoBean = { + bundleName: info.name, + icon: '', + iconId: info.iconId, + label: '', + labelId: info.labelId, + permissionName: '', + permissionLabel: '', + zhTag: '', + indexTag: '', + language: '', + labelResource: info.labelResource, + iconResource: info.iconResource, + checkedState: '', + checkedStateLabel: '' + } + BundleInfoModel.updateAppLabelAndIcon(bundleInfo).then(() => { + }) + }) + }) + it('BundleInfoModelTest_04', 0, async () => { + let bundleName: string = '' + await BundleInfoModel.getAllBundleInfoByFunctionAccess().then(data => { + expect(data).not().assertNull() + }) + }) + it('BundleInfoModelTest_05', 0, async () => { + let bundleName: string = 'com.ohos.security_privacy_center' + await bundleManager.getApplicationInfo(bundleName, bundleManager.ApplicationFlag.GET_APPLICATION_INFO_DEFAULT) + .then((info) => { + let bundleInfo: BundleInfoBean = { + bundleName: info.name, + icon: '', + iconId: info.iconId, + label: '', + labelId: info.labelId, + permissionName: '', + permissionLabel: '', + zhTag: '', + indexTag: '', + language: '', + labelResource: info.labelResource, + iconResource: info.iconResource, + checkedState: '', + checkedStateLabel: '' + } + BundleInfoModel.addLocalTag(bundleInfo) + }) + }) + it('AutoMenuTest_01', 0, async () => { + Logger.info(TAG, 'AutoMenuTest_01 is start') + let autoMenuViewModel: AutoMenuViewModel = new AutoMenuViewModel(); + let context: Context = abilityDelegatorRegistry.getAbilityDelegator().getAppContext(); + let processResult: ProcessResult = await autoMenuViewModel.processIntent(new AutoMenuInitIntent(context.getApplicationContext())) + expect(processResult).assertEqual(ProcessResult.SUCCESS) + processResult = await autoMenuViewModel.processIntent(new AutoMenuRefreshIntent(context.getApplicationContext())) + expect(processResult).assertEqual(ProcessResult.SUCCESS) + processResult = await autoMenuViewModel.processIntent(new AutoMenuInitIntent(context.getApplicationContext())) + expect(processResult).assertEqual(ProcessResult.SUCCESS) + Logger.info(TAG, 'AutoMenuTest_01 is end') + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/bean/BundleInfoBean.test.ets b/entry/src/ohosTest/ets/test/bean/BundleInfoBean.test.ets new file mode 100644 index 0000000..67f464c --- /dev/null +++ b/entry/src/ohosTest/ets/test/bean/BundleInfoBean.test.ets @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2022-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 interface ResourceObj { + bundleName: string, + moduleName: string, + id: number +} + +export interface BundleInfoBean { + bundleName: string; + icon: ResourceStr | PixelMap; + iconId: number; + label: string; + labelId: number; + permissionName: string; + permissionLabel: string; + checkedState: string; + checkedStateLabel: Resource | string; + zhTag: string; + indexTag: string; + language: string; + labelResource: Resource | ResourceObj; + iconResource: Resource | ResourceObj; +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationService.test.ets b/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationService.test.ets new file mode 100644 index 0000000..34b0e28 --- /dev/null +++ b/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationService.test.ets @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2022-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 LocationService from '../../../../../../main/ets/model/locationServicesImpl/LocationService'; +import geolocation from '@ohos.geoLocationManager'; +import ConfigData from '../../../../../../main/ets/common/baseUtile/ConfigData'; +import { ListenerBean } from '../../../../../../main/ets/model/locationServicesImpl/ListenerBean'; + +export default function LocationServiceTest() { + describe('LocationServiceTest',() => { + // 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('LocationServiceTest_startService_01', 0, () => { + LocationService.mIsStart = false; + LocationService.startService() + expect(0).assertEqual(0) + }) + it('LocationServiceTest_startService_02', 0, () => { + LocationService.mIsStart = true; + LocationService.startService() + expect(0).assertEqual(0) + }) + it('LocationServiceTest_registerListener', 0, () => { + let listener: ListenerBean = { + 'updateServiceState': () => { + } + } + LocationService.registerListener(listener) + expect(0).assertEqual(0) + }) + it('LocationServiceTest_getServiceState', 0, async () => { + LocationService.getServiceState() + expect(0).assertEqual(0) + }) + it('LocationServiceTest_enableLocation', 0, () => { + LocationService.enableLocation() + expect(0).assertEqual(0) + }) + it('LocationServiceTest_disableLocation', 0, () => { + LocationService.disableLocation() + expect(0).assertEqual(0) + }) + + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationViewModel.test.ets b/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationViewModel.test.ets new file mode 100644 index 0000000..5141741 --- /dev/null +++ b/entry/src/ohosTest/ets/test/bean/model/locationServicesImpl/LocationViewModel.test.ets @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2022-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 LocationService from '../../../../../../main/ets/model/locationServicesImpl/LocationService'; +import LocationViewModel from '../../../../../../main/ets/model/locationServicesImpl/LocationViewModel'; +import ConfigData from '../../../../../../main/ets/common/baseUtile/ConfigData'; + +export default function LocationViewModelTest() { + describe('LocationViewModelTest', () => { + // 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('LocationViewModelTest_initViewModel_01', 0, () => { + LocationViewModel.mIsStart = false; + LocationViewModel.initViewModel() + expect(0).assertEqual(0) + }) + it('LocationViewModelTest_initViewModel_02', 0, () => { + LocationViewModel.mIsStart = true; + LocationViewModel.initViewModel() + expect(0).assertEqual(0) + }) + it('LocationViewModelTest_updateServiceState_01', 0, () => { + let state = false; + LocationViewModel.updateServiceState(state) + expect(0).assertEqual(0) + }) + it('LocationViewModelTest_updateServiceState_02', 0, () => { + let state = true; + LocationViewModel.updateServiceState(state) + expect(0).assertEqual(0) + }) + it('LocationViewModelTest_enableLocation', 0, () => { + LocationViewModel.enableLocation() + expect(0).assertEqual(0) + }) + it('LocationViewModelTest_disableLocation', 0, () => { + LocationViewModel.disableLocation() + expect(0).assertEqual(0) + }) + + + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/common/Common.test.ets b/entry/src/ohosTest/ets/test/common/Common.test.ets new file mode 100644 index 0000000..836cfe4 --- /dev/null +++ b/entry/src/ohosTest/ets/test/common/Common.test.ets @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2022-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 HiSysEventConstant from '../../../../main/ets/common/constants/HiSysEventConstant'; +import getSelfBundleInfoUtils from '../../../../main/ets/common/utils/GetSelfBundleInfoUtils'; +import HiSysEventUtil from '../../../../main/ets/common/utils/HiSysEventUtil'; +import { RawFileUtil } from '../../../../main/ets/common/utils/RawFileUtil'; +import ResourceUtil from '../../../../main/ets/common/utils/ResourceUtil'; +import { StringUtil } from '../../../../main/ets/common/utils/StringUtil'; +import Logger from '../../../../main/ets/common/utils/Logger'; +import Constants from '../../../../main/ets/common/constants/ComConstant'; +import DataShareConstants from '../../../../main/ets/common/constants/DataShareConstant'; +import RouterConstant from '../../../../main/ets/common/constants/RouterConstant'; + +export default function BundleInfoBeanTest() { + describe('CommonTest', () => { + // 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('getSelfBundleInfoUtilsTest', 0, () => { + getSelfBundleInfoUtils.getVersionName() + }) + it('HiSysEventUtilTest', 0, () => { + HiSysEventUtil.reportAppPermJumpMorePerm('com.example.test', '1.0.0'); + HiSysEventUtil.reportAppPermissionJumpPage('com.example.test', '1.0.0', 'ohos.permission.Location'); + HiSysEventUtil.reportUpdateAppPermissionGroupState('com.example.test', '1.0.0', 'ohos.permission.Location', 'ALLOW', 1, 1) + HiSysEventUtil.reportAccessClick('com.example.test'); + HiSysEventUtil.reportDataPrivacyClick('test'); + + let eventParams: Record = { + "PERMISSION_GROUP": 'ohos.permission.Location' + } + HiSysEventUtil.reportClick(HiSysEventConstant.PERMISSION_PAGE_SEARCH_EVENT_NAME, eventParams) + + }) + it('RawfileUtilTest', 0, () => { + RawFileUtil.getStringByFile(abilityDelegatorRegistry.getAbilityDelegator() + .getAppContext() + .resourceManager, 'test') + RawFileUtil.getRawFileByContext(getContext(), 'test') + }) + it('ResourceUtilTest', 0, () => { + ResourceUtil.getResourceString(abilityDelegatorRegistry.getAbilityDelegator() + .getAppContext(), $r('app.media.ic_back')) + ResourceUtil.getBundleResourceManager('', abilityDelegatorRegistry.getAbilityDelegator().getAppContext()) + expect(ResourceUtil.getBundleResourceManager('', null)).assertNull() + ResourceUtil.getBundleResourceManager('com.huawei.hmos.security.privacycenter', abilityDelegatorRegistry.getAbilityDelegator() + .getAppContext()) + }) + it('StringUtilTest', 0, () => { + StringUtil.isEmpty('') + StringUtil.isEmpty('111') + StringUtil.isNotEmpty('') + StringUtil.isNotEmpty('111') + }) + it('LoggerTest', 0, () => { + Logger.info('LOGGER_TEST', 'logger info test') + Logger.debug('LOGGER_TEST', 'logger debug test') + Logger.warn('LOGGER_TEST', 'logger warn test') + Logger.error('LOGGER_TEST', 'logger error test') + }) + it('ConstantsTest', 0, () => { + expect(Constants.TITLE_BAR_HEIGHT).assertEqual(56) + expect(DataShareConstants.STORE_CONFIG.name).assertEqual('access.db') + expect(HiSysEventConstant.BUNDLE_NAME).assertEqual('com.ohos.security_privacy_center') + expect(RouterConstant.INDEX_URL).assertEqual('pages/Index') + }) + + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/model/CheckedStateParameter.ets b/entry/src/ohosTest/ets/test/model/CheckedStateParameter.ets new file mode 100644 index 0000000..534a016 --- /dev/null +++ b/entry/src/ohosTest/ets/test/model/CheckedStateParameter.ets @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2022-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 CheckedStateParameter { + // 权限组检查状态 + // 有效的权限状态:ALLOW,ALLOW_ALL_THE_TIME,ALLOW_ONLY_WHILE_IN_USE,ASK_EACH_TIME,DENY, + // MEDIA_ONLY,ALLOW_MANAGEMENT_OF_ALL_FILES + checkedState: string; + // 附加标志 + flagMask: number; + // 附加标志 + flagValue: number; + + constructor(checkedState: string, flagMask: number, flagValue: number) { + this.checkedState = checkedState; + this.flagMask = flagMask; + this.flagValue = flagValue; + } +} diff --git a/entry/src/ohosTest/ets/testability/TestAbility.ets b/entry/src/ohosTest/ets/testability/TestAbility.ets new file mode 100644 index 0000000..c9c75ef --- /dev/null +++ b/entry/src/ohosTest/ets/testability/TestAbility.ets @@ -0,0 +1,65 @@ +/** + * Copyright (c) 2022-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 AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; +import hilog from '@ohos.hilog'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; +import window from '@ohos.window'; +import Want from '@ohos.app.ability.Want'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default class TestAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + let abilityDelegator: AbilityDelegatorRegistry.AbilityDelegator + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: AbilityDelegatorRegistry.AbilityDelegatorArgs + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + + onDestroy() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage) { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); + windowStage.loadContent('testability/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() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); + } + + onForeground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); + } + + onBackground() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testability/pages/Index.ets b/entry/src/ohosTest/ets/testability/pages/Index.ets new file mode 100644 index 0000000..5838517 --- /dev/null +++ b/entry/src/ohosTest/ets/testability/pages/Index.ets @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2022-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'; + +@Entry +@Component +struct Index { + aboutToAppear() { + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility 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%') + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000..de2144d --- /dev/null +++ b/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022-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 TestRunner from '@ohos.application.testRunner'; +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +async function onAbilityCreateCallback() { + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); + } + + async onRun() { + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + const bundleName = abilityDelegatorArguments.bundleName; + const testAbilityName = 'TestAbility'; + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + const want = { + bundleName: bundleName, + abilityName: testAbilityName + }; + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator(); + abilityDelegator.startAbility(want, (err: any, data: any) => { + hilog.info(0x0000, 'testTag', 'startAbility : err : %{public}s', JSON.stringify(err) ?? ''); + hilog.info(0x0000, 'testTag', 'startAbility : data : %{public}s', JSON.stringify(data) ?? ''); + }) + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} \ No newline at end of file diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000..c386019 --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,36 @@ +{ + "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/entry/src/ohosTest/resources/base/element/color.json b/entry/src/ohosTest/resources/base/element/color.json new file mode 100644 index 0000000..3c71296 --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/element/string.json b/entry/src/ohosTest/resources/base/element/string.json new file mode 100644 index 0000000..65d8fa5 --- /dev/null +++ b/entry/src/ohosTest/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "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/entry/src/ohosTest/resources/base/media/ic_back.svg b/entry/src/ohosTest/resources/base/media/ic_back.svg new file mode 100644 index 0000000..50e4ecd --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/entry/src/ohosTest/resources/base/media/ic_settings_arrow.svg b/entry/src/ohosTest/resources/base/media/ic_settings_arrow.svg new file mode 100644 index 0000000..ff6293c --- /dev/null +++ b/entry/src/ohosTest/resources/base/media/ic_settings_arrow.svg @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/entry/src/ohosTest/resources/base/media/icon.png b/entry/src/ohosTest/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c GIT binary patch literal 6790 zcmX|G1ymHk)?T_}Vd;>R?p|tHQo6fg38|$UVM!6BLrPFWk?s;$LOP{GmJpBl$qoSA!PUg~PA65-S00{{S`XKG6NkG0RgjEntPrmV+?0|00mu7;+5 zrdpa{2QLqPJ4Y{j7=Mrl{BaxrkdY69+c~(w{Fv-v&aR%aEI&JYSeRTLWm!zbv;?)_ ziZB;fwGbbeL5Q}YLx`J$lp~A09KK8t_z}PZ=4ZzgdeKtgoc+o5EvN9A1K1_<>M?MBqb#!ASf&# zEX?<)!RH(7>1P+j=jqG(58}TVN-$psA6K}atCuI!KTJD&FMmH-78ZejBm)0qc{ESp z|LuG1{QnBUJRg_E=h1#XMWt2%fcoN@l7eAS!Es?Q+;XsRNPhiiE=@AqlLkJzF`O18 zbsbSmKN=aaq8k3NFYZfDWpKmM!coBU0(XnL8R{4=i|wi{!uWYM2je{U{B*K2PVdu&=E zTq*-XsEsJ$u5H4g6DIm2Y!DN`>^v|AqlwuCD;w45K0@eqauiqWf7l&o)+YLHm~|L~ z7$0v5mkobriU!H<@mVJHLlmQqzQ3d6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zFEd|dpS595rxQr-n#GjI5i-AhnUE>Cr;jpCqSrD~EwK_DqI^7%3#p5)%T_od!t3SOmH9MyXeeGO2(UQL;ax|x?Ncixmeo1=$ z{-);Au{*tfzOG?KQ~K|ak8-HQ?`Pekhe2WM(8s{xv-p>Zmu_6{G!-oE$7$mY`MOJorI=+mMx?H;`pr!;fVYz?5~yXBACruWB`Ph zZM}90_<^OBxIhyZ9BW$`>6JvO;%VFpqVr8|7t3~AmxYak6?`Pp#c;**_SYmi`&z23 z`p6_~ePvH)C6x-G9$hgL=eVALq`-AiamN>!3~Lxw&{H(b{B(7xSRm6<3<{%{yXiH# zos5Rv1L+8fUKJLo%P>4I&$}y="a"&&u<="z"||u>="A"&&u<="Z"||"$"===u||"_"===u||y.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||y.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 I=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(v,"__esModule",{value:!0}),v.parseJsonText=v.parseJsonFile=void 0;const N=I(e),b=I(D),S=I(u),w=g;var H;!function(u){u[u.Char=0]="Char",u[u.EOF=1]="EOF",u[u.Identifier=2]="Identifier"}(H||(H={}));let x,M,T,V,G,j,J="start",U=[],W=0,L=1,$=0,k=!1,K="default",z="'",q=1;function Z(u,D=!1){M=String(u),J="start",U=[],W=0,L=1,$=0,V=void 0,k=D;do{x=X(),ru[J]()}while("eof"!==x.type);return V}function X(){for(K="default",G="",z="'",q=1;;){j=Q();const u=uu[K]();if(u)return u}}function Q(){if(M[W])return String.fromCodePoint(M.codePointAt(W))}function Y(){const u=Q();return"\n"===u?(L++,$=0):u?$+=u.length:$++,u&&(W+=u.length),u}v.parseJsonFile=function(u,D=!1,e="utf-8"){const t=N.default.readFileSync(S.default.resolve(u),{encoding:e});try{return Z(t,D)}catch(D){if(D instanceof SyntaxError){const e=D.message.split("at");if(2===e.length)throw new Error(`${e[0].trim()}${b.default.EOL}\t at ${u}:${e[1].trim()}`)}throw new Error(`${u} is not in valid JSON/JSON5 format.`)}},v.parseJsonText=Z;const uu={default(){switch(j){case"/":return Y(),void(K="comment");case void 0:return Y(),Du("eof")}if(!w.JudgeUtil.isIgnoreChar(j)&&!w.JudgeUtil.isSpaceSeparator(j))return uu[J]();Y()},start(){K="value"},beforePropertyName(){switch(j){case"$":case"_":return G=Y(),void(K="identifierName");case"\\":return Y(),void(K="identifierNameStartEscape");case"}":return Du("punctuator",Y());case'"':case"'":return z=j,Y(),void(K="string")}if(w.JudgeUtil.isIdStartChar(j))return G+=Y(),void(K="identifierName");throw Fu(H.Char,Y())},afterPropertyName(){if(":"===j)return Du("punctuator",Y());throw Fu(H.Char,Y())},beforePropertyValue(){K="value"},afterPropertyValue(){switch(j){case",":case"}":return Du("punctuator",Y())}throw Fu(H.Char,Y())},beforeArrayValue(){if("]"===j)return Du("punctuator",Y());K="value"},afterArrayValue(){switch(j){case",":case"]":return Du("punctuator",Y())}throw Fu(H.Char,Y())},end(){throw Fu(H.Char,Y())},comment(){switch(j){case"*":return Y(),void(K="multiLineComment");case"/":return Y(),void(K="singleLineComment")}throw Fu(H.Char,Y())},multiLineComment(){switch(j){case"*":return Y(),void(K="multiLineCommentAsterisk");case void 0:throw Fu(H.Char,Y())}Y()},multiLineCommentAsterisk(){switch(j){case"*":return void Y();case"/":return Y(),void(K="default");case void 0:throw Fu(H.Char,Y())}Y(),K="multiLineComment"},singleLineComment(){switch(j){case"\n":case"\r":case"\u2028":case"\u2029":return Y(),void(K="default");case void 0:return Y(),Du("eof")}Y()},value(){switch(j){case"{":case"[":return Du("punctuator",Y());case"n":return Y(),eu("ull"),Du("null",null);case"t":return Y(),eu("rue"),Du("boolean",!0);case"f":return Y(),eu("alse"),Du("boolean",!1);case"-":case"+":return"-"===Y()&&(q=-1),void(K="numerical");case".":case"0":case"I":case"N":return void(K="numerical");case'"':case"'":return z=j,Y(),G="",void(K="string")}if(void 0===j||!w.JudgeUtil.isDigitWithoutZero(j))throw Fu(H.Char,Y());K="numerical"},numerical(){switch(j){case".":return G=Y(),void(K="decimalPointLeading");case"0":return G=Y(),void(K="zero");case"I":return Y(),eu("nfinity"),Du("numeric",q*(1/0));case"N":return Y(),eu("aN"),Du("numeric",NaN)}if(void 0!==j&&w.JudgeUtil.isDigitWithoutZero(j))return G=Y(),void(K="decimalInteger");throw Fu(H.Char,Y())},zero(){switch(j){case".":case"e":case"E":return void(K="decimal");case"x":case"X":return G+=Y(),void(K="hexadecimal")}return Du("numeric",0)},decimalInteger(){switch(j){case".":case"e":case"E":return void(K="decimal")}if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},decimal(){switch(j){case".":G+=Y(),K="decimalFraction";break;case"e":case"E":G+=Y(),K="decimalExponent"}},decimalPointLeading(){if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalFraction");throw Fu(H.Char,Y())},decimalFraction(){switch(j){case"e":case"E":return G+=Y(),void(K="decimalExponent")}if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},decimalExponent(){switch(j){case"+":case"-":return G+=Y(),void(K="decimalExponentSign")}if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalExponentInteger");throw Fu(H.Char,Y())},decimalExponentSign(){if(w.JudgeUtil.isDigit(j))return G+=Y(),void(K="decimalExponentInteger");throw Fu(H.Char,Y())},decimalExponentInteger(){if(!w.JudgeUtil.isDigit(j))return Du("numeric",q*Number(G));G+=Y()},hexadecimal(){if(w.JudgeUtil.isHexDigit(j))return G+=Y(),void(K="hexadecimalInteger");throw Fu(H.Char,Y())},hexadecimalInteger(){if(!w.JudgeUtil.isHexDigit(j))return Du("numeric",q*Number(G));G+=Y()},identifierNameStartEscape(){if("u"!==j)throw Fu(H.Char,Y());Y();const u=tu();switch(u){case"$":case"_":break;default:if(!w.JudgeUtil.isIdStartChar(u))throw Fu(H.Identifier)}G+=u,K="identifierName"},identifierName(){switch(j){case"$":case"_":case"‌":case"‍":return void(G+=Y());case"\\":return Y(),void(K="identifierNameEscape")}if(!w.JudgeUtil.isIdContinueChar(j))return Du("identifier",G);G+=Y()},identifierNameEscape(){if("u"!==j)throw Fu(H.Char,Y());Y();const u=tu();switch(u){case"$":case"_":case"‌":case"‍":break;default:if(!w.JudgeUtil.isIdContinueChar(u))throw Fu(H.Identifier)}G+=u,K="identifierName"},string(){switch(j){case"\\":return Y(),void(G+=function(){const u=Q(),D=function(){switch(Q()){case"b":return Y(),"\b";case"f":return Y(),"\f";case"n":return Y(),"\n";case"r":return Y(),"\r";case"t":return Y(),"\t";case"v":return Y(),"\v"}return}();if(D)return D;switch(u){case"0":if(Y(),w.JudgeUtil.isDigit(Q()))throw Fu(H.Char,Y());return"\0";case"x":return Y(),function(){let u="",D=Q();if(!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());if(u+=Y(),D=Q(),!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());return u+=Y(),String.fromCodePoint(parseInt(u,16))}();case"u":return Y(),tu();case"\n":case"\u2028":case"\u2029":return Y(),"";case"\r":return Y(),"\n"===Q()&&Y(),""}if(void 0===u||w.JudgeUtil.isDigitWithoutZero(u))throw Fu(H.Char,Y());return Y()}());case'"':case"'":if(j===z){const u=Du("string",G);return Y(),u}return void(G+=Y());case"\n":case"\r":case void 0:throw Fu(H.Char,Y());case"\u2028":case"\u2029":!function(u){console.warn(`JSON5: '${Cu(u)}' in strings is not valid ECMAScript; consider escaping.`)}(j)}G+=Y()}};function Du(u,D){return{type:u,value:D,line:L,column:$}}function eu(u){for(const D of u){if(Q()!==D)throw Fu(H.Char,Y());Y()}}function tu(){let u="",D=4;for(;D-- >0;){const D=Q();if(!w.JudgeUtil.isHexDigit(D))throw Fu(H.Char,Y());u+=Y()}return String.fromCodePoint(parseInt(u,16))}const ru={start(){if("eof"===x.type)throw Fu(H.EOF);nu()},beforePropertyName(){switch(x.type){case"identifier":case"string":return T=x.value,void(J="afterPropertyName");case"punctuator":return void iu();case"eof":throw Fu(H.EOF)}},afterPropertyName(){if("eof"===x.type)throw Fu(H.EOF);J="beforePropertyValue"},beforePropertyValue(){if("eof"===x.type)throw Fu(H.EOF);nu()},afterPropertyValue(){if("eof"===x.type)throw Fu(H.EOF);switch(x.value){case",":return void(J="beforePropertyName");case"}":iu()}},beforeArrayValue(){if("eof"===x.type)throw Fu(H.EOF);"punctuator"!==x.type||"]"!==x.value?nu():iu()},afterArrayValue(){if("eof"===x.type)throw Fu(H.EOF);switch(x.value){case",":return void(J="beforeArrayValue");case"]":iu()}},end(){}};function nu(){const u=function(){let u;switch(x.type){case"punctuator":switch(x.value){case"{":u={};break;case"[":u=[]}break;case"null":case"boolean":case"numeric":case"string":u=x.value}return u}();if(k&&"object"==typeof u&&(u._line=L,u._column=$),void 0===V)V=u;else{const D=U[U.length-1];Array.isArray(D)?k&&"object"!=typeof u?D.push({value:u,_line:L,_column:$}):D.push(u):D[T]=k&&"object"!=typeof u?{value:u,_line:L,_column:$}:u}!function(u){if(u&&"object"==typeof u)U.push(u),J=Array.isArray(u)?"beforeArrayValue":"beforePropertyName";else{const u=U[U.length-1];J=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}}(u)}function iu(){U.pop();const u=U[U.length-1];J=u?Array.isArray(u)?"afterArrayValue":"afterPropertyValue":"end"}function Cu(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 Fu(u,D){let e="";switch(u){case H.Char:e=void 0===D?`JSON5: invalid end of input at ${L}:${$}`:`JSON5: invalid character '${Cu(D)}' at ${L}:${$}`;break;case H.EOF:e=`JSON5: invalid end of input at ${L}:${$}`;break;case H.Identifier:$-=5,e=`JSON5: invalid identifier character at ${L}:${$}`}const t=new Eu(e);return t.lineNumber=L,t.columnNumber=$,t}class Eu extends SyntaxError{}var Au={},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]}),au=n&&n.__setModuleDefault||(Object.create?function(u,D){Object.defineProperty(u,"default",{enumerable:!0,value:D})}:function(u,D){u.default=D}),cu=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 au(D,u),D},su=n&&n.__importDefault||function(u){return u&&u.__esModule?u:{default:u}};Object.defineProperty(Au,"__esModule",{value:!0}),Au.isFileExists=Au.offlinePluginConversion=Au.executeCommand=Au.getNpmPath=Au.hasNpmPackInPaths=void 0;const lu=t,Bu=su(e),du=cu(u),fu=i,_u=l;Au.hasNpmPackInPaths=function(u,D){try{return require.resolve(u,{paths:[...D]}),!0}catch(u){return!1}},Au.getNpmPath=function(){const u=process.execPath;return du.join(du.dirname(u),fu.NPM_TOOL)},Au.executeCommand=function(u,D,e){0!==(0,lu.spawnSync)(u,D,e).status&&(0,_u.logErrorAndExit)(`Error: ${u} ${D} execute failed.See above for details.`)},Au.offlinePluginConversion=function(u,D){return D.startsWith("file:")||D.endsWith(".tgz")?du.resolve(u,fu.HVIGOR,D.replace("file:","")):D},Au.isFileExists=function(u){return Bu.default.existsSync(u)&&Bu.default.statSync(u).isFile()};var pu={};!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 t=D(r),i=D(e);u.createHash=(u="MD5")=>t.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)}}(pu);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=Pu(u),yu=i,Iu=v,Nu=l,bu=Au,Su=vu(D),wu=pu;let Hu,xu,Mu;function Tu(u,D,e){return void 0!==e.dependencies&&(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,D.dependencies[u])===Ru.normalize(e.dependencies[u])}function Vu(){const u=Ru.join(Mu,yu.WORK_SPACE);if((0,Nu.logInfoPrintConsole)("Hvigor cleaning..."),!mu.existsSync(u))return;const D=mu.readdirSync(u);if(!D||0===D.length)return;const e=Ru.resolve(Mu,"node_modules","@ohos","hvigor","bin","hvigor.js");mu.existsSync(e)&&(0,bu.executeCommand)(process.argv[0],[e,"--stop-daemon"],{});try{D.forEach((D=>{mu.rmSync(Ru.resolve(u,D),{recursive:!0})}))}catch(D){(0,Nu.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=Ru.resolve(yu.HVIGOR_PROJECT_WRAPPER_HOME,yu.DEFAULT_HVIGOR_CONFIG_JSON_FILE_NAME);mu.existsSync(u)||(0,Nu.logErrorAndExit)(`Error: Hvigor config file ${u} does not exist.`);return(0,Iu.parseJsonFile)(u)}(),Mu=function(u){let D,e=u.hvigorVersion;e.endsWith(".tgz")&&(e=function(u){let D=Ru.normalize(u);const e=D.lastIndexOf(Ru.sep);-1!==e&&(D=D.substring(e+1));D=D.replace(".tgz","");let t=0;for(let u=0;u="0"&&D.charAt(u)<="9"){t=u;break}return D=D.substring(t),D}(e));D=e>"2.5.0"?function(u){let D=`${yu.HVIGOR_ENGINE_PACKAGE_NAME}@${u.hvigorVersion}`;const e=u.dependencies;if(e){Object.getOwnPropertyNames(e).sort().forEach((u=>{D+=`,${u}@${e[u]}`}))}return(0,wu.hash)(D)}(u):(0,wu.hash)(process.cwd());return Ru.resolve(Su.default.homedir(),".hvigor","project_caches",D)}(Hu),xu=function(){const u=Ru.resolve(Mu,yu.WORK_SPACE,yu.DEFAULT_PACKAGE_JSON);return mu.existsSync(u)?(0,Iu.parseJsonFile)(u):{dependencies:{}}}(),!(0,bu.hasNpmPackInPaths)(yu.HVIGOR_ENGINE_PACKAGE_NAME,[Ru.join(Mu,yu.WORK_SPACE)])||(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion)!==xu.dependencies[yu.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,bu.hasNpmPackInPaths)(u,[Ru.join(Mu,yu.WORK_SPACE)])||!Tu(u,Hu,xu))return!1;return!0}()){Vu();try{!function(){(0,Nu.logInfoPrintConsole)("Hvigor installing...");for(const u in Hu.dependencies)Hu.dependencies[u]&&(Hu.dependencies[u]=(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.dependencies[u]));const u={dependencies:{...Hu.dependencies}};u.dependencies[yu.HVIGOR_ENGINE_PACKAGE_NAME]=(0,bu.offlinePluginConversion)(yu.HVIGOR_PROJECT_ROOT_DIR,Hu.hvigorVersion);const D=Ru.join(Mu,yu.WORK_SPACE);try{mu.mkdirSync(D,{recursive:!0});const e=Ru.resolve(D,yu.DEFAULT_PACKAGE_JSON);mu.writeFileSync(e,JSON.stringify(u))}catch(u){(0,Nu.logErrorAndExit)(u)}(function(){const u=["config","set","store-dir",yu.HVIGOR_PNPM_STORE_PATH],D={cwd:Ru.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,bu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)})(),function(){const u=["install"],D={cwd:Ru.join(Mu,yu.WORK_SPACE),stdio:["inherit","inherit","inherit"]};(0,bu.executeCommand)(yu.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH,u,D)}(),(0,Nu.logInfoPrintConsole)("Hvigor install success.")}()}catch(u){Vu()}}return Mu};var Gu={};!function(r){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(r,"__esModule",{value:!0}),r.executeInstallPnpm=r.isPnpmInstalled=r.environmentHandler=r.checkNpmConifg=r.PNPM_VERSION=void 0;const o=t,a=E(e),c=A(D),s=E(u),B=i,d=l,f=Au;r.PNPM_VERSION="7.30.0",r.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.")},r.environmentHandler=function(){process.env["npm_config_update-notifier"]="false"},r.isPnpmInstalled=function(){return!!a.existsSync(B.HVIGOR_WRAPPER_PNPM_SCRIPT_PATH)&&(0,f.hasNpmPackInPaths)("pnpm",[B.HVIGOR_WRAPPER_TOOLS_HOME])},r.executeInstallPnpm=function(){(0,d.logInfoPrintConsole)(`Installing pnpm@${r.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]=r.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/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000..f3cb9f1 --- /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/hvigorw b/hvigorw new file mode 100644 index 0000000..ff6a29a --- /dev/null +++ b/hvigorw @@ -0,0 +1,48 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME="`pwd -P`" +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@" diff --git a/hvigorw.bat b/hvigorw.bat new file mode 100644 index 0000000..d570007 --- /dev/null +++ b/hvigorw.bat @@ -0,0 +1,64 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Hvigor startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js +set NODE_EXE=node.exe + +goto start + +:start +@rem Find node.exe +if defined NODE_HOME goto findNodeFromNodeHome + +%NODE_EXE% --version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:findNodeFromNodeHome +set NODE_HOME=%NODE_HOME:"=% +set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% + +if exist "%NODE_EXE_PATH%" goto execute +echo. +echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. +echo. +echo Please set the NODE_HOME variable in your environment to match the +echo location of your NodeJs installation. + +goto fail + +:execute +@rem Execute hvigor +"%NODE_EXE%" "%WRAPPER_MODULE_PATH%" %* + +if "%ERRORLEVEL%" == "0" goto hvigorwEnd + +:fail +exit /b 1 + +:hvigorwEnd +if "%OS%" == "Windows_NT" endlocal + +:end diff --git a/kernel_vendor.yaml b/kernel_vendor.yaml new file mode 100644 index 0000000..1b1e1d0 --- /dev/null +++ b/kernel_vendor.yaml @@ -0,0 +1,415 @@ +# Copyright (c) 2022-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. + +domain: KERNEL_VENDOR + +POWER_KEY: + __BASE: {type: FAULT, level: CRITICAL, desc: press powerkey} + MSG: {type: STRING, desc: POWER_KEY event message} + +LONG_PRESS: + __BASE: {type: FAULT, level: CRITICAL, desc: long press powerkey} + MSG: {type: STRING, desc: LONG_PRESS event message} + +SCREEN_OFF: + __BASE: {type: FAULT, level: CRITICAL, desc: check LCD off} + MSG: {type: STRING, desc: SCREEN_OFF event message} + +SCREEN_ON: + __BASE: {type: FAULT, level: CRITICAL, desc: check LCD on} + MSG: {type: STRING, desc: SCREEN_ON event message} + +HUNGTASK: + __BASE: {type: FAULT, level: CRITICAL, desc: process D_state and panic} + MSG: {type: STRING, desc: HUNGTASK event message} + +PANIC: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: kernel panic} + MSG: {type: STRING, desc: panic event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +BOOTFAIL: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: device reboot fail} + MSG: {type: STRING, desc: bootFail event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +HWWATCHDOG: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: hw_watchdog event in device} + MSG: {type: STRING, desc: hwwatchdog event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +LPM3EXCEPTION: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: lpm3exception subsystem event} + MSG: {type: STRING, desc: lpm3exception event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +BOOTLOADER_CRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: bootloader_crash subsystem event} + MSG: {type: STRING, desc: bootloader_crash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +TRUSTZONE_REBOOTSYS: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: trustzone_rebootsys subsystem event} + MSG: {type: STRING, desc: trustzone_rebootsys event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +MODEM_REBOOTSYS: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: modem_rebootsys subsystem event} + MSG: {type: STRING, desc: modem_rebootsys event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +HARDWARE_FAULT: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: hardware fault in device} + MSG: {type: STRING, desc: hardware event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +MODEMCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: modemcrash subsystem event} + MSG: {type: STRING, desc: modemcrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +HIFICRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: hificrash subsystem event} + MSG: {type: STRING, desc: hificrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +AUDIO_CODEC_CRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: audio_codec_crash subsystem event} + MSG: {type: STRING, desc: audio_codec_crash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +SENSORHUBCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: sensorhubcrash subsystem event} + MSG: {type: STRING, desc: sensorhubcrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +ISPCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: ispcrash subsystem event} + MSG: {type: STRING, desc: ispcrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +IVPCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: ivpcrash subsystem event} + MSG: {type: STRING, desc: ivpcrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +TRUSTZONECRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: trustzonecrash subsystem event} + MSG: {type: STRING, desc: trustzonecrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +GENERAL_SEE_CRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: general_see_crash subsystem event} + MSG: {type: STRING, desc: general_see_crash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +UNKNOWNS: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: unknows event in device} + MSG: {type: STRING, desc: unknows event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +PRESS10S: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: press10s subsystem event} + MSG: {type: STRING, desc: press10s event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +PRESS6S: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: press6s subsystem event} + MSG: {type: STRING, desc: press6s event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +NPUEXCEPTION: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: npuexception subsystem event} + MSG: {type: STRING, desc: npuexception event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +CONNEXCEPTION: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: connexception subsystem event} + MSG: {type: STRING, desc: connexception event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +FDULCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: fdulcrash subsystem event} + MSG: {type: STRING, desc: fdulcrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +DSSCRASH: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: dsscrash subsystem event} + MSG: {type: STRING, desc: dsscrash event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +CMA: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: cma event} + MSG: {type: STRING, desc: cma event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + PID: {type: INT32, desc: cma leak pid} + UID: {type: INT32, desc: cma leak uid} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + PACKAGE_NAME: {type: STRING, desc: process package name} + PROCESS_NAME: {type: STRING, desc: process name} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +SLUB_OBJ: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: slub obj event} + MSG: {type: STRING, desc: slub obj event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + PID: {type: INT32, desc: slub obj leak pid} + UID: {type: INT32, desc: slub obj leak uid} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + PACKAGE_NAME: {type: STRING, desc: process package name} + PROCESS_NAME: {type: STRING, desc: process name} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +LOWMEM: + __BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: lowmem event} + MSG: {type: STRING, desc: lowmem event message} + MODULE: {type: STRING, desc: module name} + REASON: {type: STRING, desc: fault reason} + PID: {type: INT32, desc: lowmem leak pid} + UID: {type: INT32, desc: lowmem leak uid} + HAPPEN_TIME: {type: INT64, desc: fault trigger time} + PACKAGE_NAME: {type: STRING, desc: process package name} + PROCESS_NAME: {type: STRING, desc: process name} + SUMMARY: {type: STRING, desc: fault summary} + LOG_PATH: {type: STRING, desc: fault log dir} + SUB_LOG_PATH: {type: STRING, desc: sub fault log dir} + FINGERPRINT: {type: STRING, desc: unique id for grouping same fault} + FIRST_FRAME: {type: STRING, desc: first stack info} + SECOND_FRAME: {type: STRING, desc: second stack info} + LAST_FRAME: {type: STRING, desc: last stack info} + +XPOWER_KERNEL_MESSAGE: + __BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: kernel message} + TAG: {type: STRING, desc: tag of the message} + MESSAGE: {type: STRING, desc: kernel event} \ No newline at end of file diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000..ddc8a54 --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,13 @@ +{ + "lockfileVersion": 1, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hypium@1.0.11": "@ohos/hypium@1.0.11" + }, + "packages": { + "@ohos/hypium@1.0.11": { + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.11.tgz", + "integrity": "sha512-KawcLnv43C3QIYv1UbDnKCFX3MohtDxGuFvzlUxT/qf2DBilR56Ws6zrj90LdH6PjloJQwOPESuBQIHBACAK7w==" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000..c2f75b1 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "license": "", + "devDependencies": { + "@ohos/hypium": "1.0.11" + }, + "author": "", + "name": "security_privacy_center", + "description": "Please describe the basic information.", + "main": "", + "version": "1.0.0", + "dependencies": {} +} diff --git a/signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.cer b/signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.cer new file mode 100644 index 0000000..baaf591 --- /dev/null +++ b/signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.cer @@ -0,0 +1,29 @@ +-----BEGIN CERTIFICATE----- +MIICFTCCAZygAwIBAgIJALIozvk6giikMAoGCCqGSM49BAMDMGMxCzAJBgNVBAYT +AkNOMRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkg +VGVhbTEjMCEGA1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwHhcNMjQw +MzA1MDYzMzA3WhcNMzQwMzAzMDYzMzA3WjBKMRUwEwYDVQQDDAxpZGVfZGVtb19h +cHAxDTALBgNVBAsTBFVuaXQxFTATBgNVBAoTDE9yZ2FuaXphdGlvbjELMAkGA1UE +BhMCQ04wWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATk76MhGNbJaNvTlTWL3M2c +O1xeTCl1Ryr2KoInh643lZoImc3BL2Q8/l/CSw+yRT/gWacq+dMS5FB+cMW9+YP5 +o1IwUDAdBgNVHQ4EFgQUlsmBMQ08BZD2zzQ+vU7r2inowe4wDgYDVR0PAQH/BAQD +AgeAMB8GA1UdIwQYMBaAFNuGtyIW1QuhS7fdJXu58QV9oi1HMAoGCCqGSM49BAMD +A2cAMGQCMAGjRPTkHWnKtix2MFeqD38prV1W5cyw5dgewp6Hty3J1wgkGxqIxeDL +gkKUyGxcHAIwAJPJ258R2PcXwlWb6YaBZ77SZAxdcOyGz8MDjGyeAY0ygLv85ybP +xwFKl4y+eNtI +-----END CERTIFICATE----- +-----BEGIN CERTIFICATE----- +MIICYTCCAeWgAwIBAgIEHmXAPTAMBggqhkjOPQQDAwUAMGgxCzAJBgNVBAYTAkNO +MRQwEgYDVQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVh +bTEoMCYGA1UEAxMfT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gUm9vdCBDQTAeFw0y +MTAyMDIxMjE1MzJaFw00OTEyMzExMjE1MzJaMGMxCzAJBgNVBAYTAkNOMRQwEgYD +VQQKEwtPcGVuSGFybW9ueTEZMBcGA1UECxMQT3Blbkhhcm1vbnkgVGVhbTEjMCEG +A1UEAxMaT3Blbkhhcm1vbnkgQXBwbGljYXRpb24gQ0EwdjAQBgcqhkjOPQIBBgUr +gQQAIgNiAAQhnu7Hna8XNa2KyqRf5+lBJScE4xqf89N0g0OuqAb2re8nGsvWkw26 +uDekfnBYicd+G3Cydqa2zFIwV7Talyg2ULW3r8KbGpyl84mJEPPRmCGJ+H9gtCsf ++OrJ4Y76LVWjYzBhMB8GA1UdIwQYMBaAFBc6EKGrGXzlAE+s0Zgnsphadw7NMA8G +A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTbhrciFtUL +oUu33SV7ufEFfaItRzAMBggqhkjOPQQDAwUAA2gAMGUCMG3cXjiDmXTvf7D4Omhf +qcc2nuO+EMfWE+N9ZhBP5UhV34mAGWi3SfLU6rcV0urWEQIxAMYIb3epOnKhUrcm +Lfu1WKzFlpYQwmw73RaCHP2I3k6NcuWOYeNwWXSNZ8o0nzvaLg== +-----END CERTIFICATE----- diff --git a/signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p12 b/signature/auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p12 new file mode 100644 index 0000000000000000000000000000000000000000..9e80702f0e7a6b8e3e1ab107b2b901ae962a8126 GIT binary patch literal 1128 zcmXqLVo70QWHxAG;bY^}YV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