安全隐私中心代码

This commit is contained in:
hwx869784 2024-03-20 15:37:18 +08:00
parent f2465083c3
commit 876c6d17ef
101 changed files with 7205 additions and 0 deletions

11
.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
/node_modules
/oh_modules
/local.properties
/.idea
**/build
/.hvigor
.cxx
/.clangd
/.clang-format
/.clang-tidy
**/.test

10
AppScope/app.json5 Normal file
View File

@ -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"
}
}

View File

@ -0,0 +1,8 @@
{
"string": [
{
"name": "app_name",
"value": "security_privacy_center"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

68
build-profile.json5 Normal file
View File

@ -0,0 +1,68 @@
/**
* 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.
*/
{
"app": {
"signingConfigs": [
{
"name": "default",
"material": {
"certpath": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.cer",
"storePassword": "0000001A071A12C914D5261FE99F711DE091ACD21B9C31BD58DAC8C360679BDFD5C3F3B394998C967632",
"keyAlias": "debugKey",
"keyPassword": "0000001A349964CF8C9D3C1E1861E35458069B1A813221EF2BCBF765051CBBCA2DE43D355551BD6D6994",
"profile": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p7b",
"signAlg": "SHA256withECDSA",
"storeFile": "C:\\Users\\ts\\.ohos\\config\\openharmony\\auto_ohos_default_security_privacy_center_com.ohos.security_privacy_center.p12"
}
}
],
"products": [
{
"name": "default",
"signingConfig": "default",
"compileSdkVersion": 10,
//指定OpenHarmony应用/服务编译时的版本git
"compatibleSdkVersion": 10,
//指定OpenHarmony应用/服务兼容的最低版本。
"targetSdkVersion": 10,
//指定OpenHarmony应用/服务目标版本。若没有设置默认为compatibleSdkVersion
"runtimeOS": "OpenHarmony",
//指定为OpenHarmony
}
],
"buildModeSet": [
{
"name": "debug",
},
{
"name": "release"
}
]
},
"modules": [
{
"name": "entry",
"srcPath": "./entry",
"targets": [
{
"name": "default",
"applyToProducts": [
"default"
]
}
]
}
]
}

166
bundle.json Normal file
View File

@ -0,0 +1,166 @@
{
"name": "@ohos/hiview",
"description": "Hiview is the module of OpenHarmony that provides toolkits for device maintenance across different platforms.",
"version": "3.1",
"license": "Apache License 2.0",
"publishAs": "code-segment",
"segment": {
"destPath": "base/hiviewdfx/hiview"
},
"dirs": {},
"scripts": {},
"component": {
"name": "hiview",
"subsystem": "hiviewdfx",
"syscap": [
"SystemCapability.HiviewDFX.Hiview.FaultLogger",
"SystemCapability.HiviewDFX.Hiview.LogLibrary"
],
"adapted_system_type": [
"standard"
],
"rom": "",
"ram": "",
"hisysevent_config": [
"//base/hiviewdfx/hiview/hisysevent.yaml",
"//base/hiviewdfx/hiview/hiviewdfx.yaml",
"//base/hiviewdfx/hiview/kernel_vendor.yaml"
],
"deps": {
"components": [
"ability_base",
"ability_runtime",
"access_token",
"battery_statistics",
"bundle_framework",
"common_event_service",
"c_utils",
"device_usage_statistics",
"display_manager",
"ets_runtime",
"faultloggerd",
"ffrt",
"hidumper",
"hilog",
"hiprofiler",
"hisysevent",
"init",
"input",
"ipc",
"os_account",
"power_manager",
"relational_store",
"safwk",
"samgr",
"storage_service",
"time_service",
"napi",
"hiperf",
"hitrace",
"wifi"
],
"third_party": [
"jsoncpp",
"libxml2",
"sqlite",
"openssl",
"bounds_checking_function",
"zlib"
]
},
"build": {
"sub_component": [
"//base/hiviewdfx/hiview:hiview_package",
"//base/hiviewdfx/hiview/plugins/faultlogger/interfaces/js/napi:faultlogger_napi",
"//base/hiviewdfx/hiview/interfaces/js/napi:loglibrary_napi",
"//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection/client:libucollection_client",
"//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection/utility:libucollection_utility"
],
"inner_kits": [
{
"name": "//base/hiviewdfx/hiview/plugins/faultlogger:libfaultlogger",
"header": {
"header_base": "//base/hiviewdfx/hiview/plugins/faultlogger/interfaces/cpp/innerkits/include",
"header_files": [
"faultlog_info.h",
"faultlog_query_result.h",
"faultlogger_client.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/interfaces/innerkits/xpower_event:libxpower_event",
"header": {
"header_base": "//base/hiviewdfx/hiview/interfaces/innerkits/xpower_event/include",
"header_files": [
"xpower_event_common.h",
"xpower_event.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/interfaces/innerkits/xpower_event:libxpower_event_js",
"header": {
"header_base": "//base/hiviewdfx/hiview/interfaces/innerkits/xpower_event/include",
"header_files": [
"xpower_event_common.h",
"xpower_event_js.h",
"xpower_event_jsvm.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/base:hiviewbase",
"header": {
"header_base": "//base/hiviewdfx/hiview/base/include",
"header_files": [
"plugin_factory.h",
"event_loop.h",
"plugin.h",
"event.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection/client:libucollection_client",
"header": {
"header_base": "//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection",
"header_files": [
"client/gpu_collector.h",
"client/io_collector.h",
"client/memory_collector.h",
"client/network_collector.h",
"client/trace_collector.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection/utility:libucollection_utility",
"header": {
"header_base": "//base/hiviewdfx/hiview/interfaces/inner_api/unified_collection",
"header_files": [
"utility/cpu_collector.h",
"utility/gpu_collector.h",
"utility/io_collector.h",
"utility/mem_profiler_collector.h",
"utility/memory_collector.h",
"utility/network_collector.h",
"utility/trace_collector.h",
"utility/wm_collector.h"
]
}
},
{
"name": "//base/hiviewdfx/hiview/plugins/faultlogger/service/sanitizer_collector/gwp_asan:libasan_logger",
"header": {
"header_base": "//base/hiviewdfx/hiview/plugins/faultlogger/service/sanitizer_collector/gwp_asan",
"header_files": [
"gwpasan_collector.h"
]
}
}
],
"test": [ "//base/hiviewdfx/hiview:hiview_test_package" ]
}
}
}

6
entry/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
/node_modules
/oh_modules
/.preview
/build
/.cxx
/.test

14
entry/build-profile.json5 Normal file
View File

@ -0,0 +1,14 @@
{
"apiType": "stageMode",
"buildOption": {
},
"targets": [
{
"name": "default",
"runtimeOS": "OpenHarmony"
},
{
"name": "ohosTest",
}
]
}

6
entry/hvigorfile.ts Normal file
View File

@ -0,0 +1,6 @@
import { hapTasks } from '@ohos/hvigor-ohos-plugin';
export default {
system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
}

10
entry/oh-package.json5 Normal file
View File

@ -0,0 +1,10 @@
{
"license": "",
"devDependencies": {},
"author": "",
"name": "entry",
"description": "Please describe the basic information.",
"main": "",
"version": "1.0.0",
"dependencies": {}
}

View File

@ -0,0 +1,18 @@
/**
* 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 abstract class BaseIntent {
abstract getIntentTag(): string;
}

View File

@ -0,0 +1,17 @@
/**
* 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 BaseModel {
}

View File

@ -0,0 +1,18 @@
/**
* 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 BaseState {
}

View File

@ -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 { BaseState } from './BaseState';
import { BaseIntent } from './BaseIntent';
import { BaseModel } from './BaseModel';
import Logger from '../utils/Logger';
const TAG = 'BaseViewModel';
/**
* 执行结果
*/
export enum ProcessResult {
FAIL = 0,
SUCCESS = 1
}
export abstract class BaseViewModel<M extends BaseModel, S extends BaseState> {
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<ProcessResult> {
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<ProcessResult>;
}

View File

@ -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;

View File

@ -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[];
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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|listcard代表卡片方式接入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;
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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'))
}
}

View File

@ -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)
}
}

View File

@ -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;
}

View File

@ -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'
]
}
}

View File

@ -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']
]);
}

View File

@ -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
}

View File

@ -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<string, DefaultMenuConfig> = new HashMap();
// key is bundle name, value is id.
private _defaultBusinessIdMap: HashMap<string, string> = 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<MenuConfig[]> {
// 获取所有配置信息,内部会检查权限
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<number> {
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<number> {
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<string> {
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<MenuConfig[]> {
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<MenuConfig[]> {
// 获取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<string> {
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<boolean> {
// 根据卡片或列表模式进行分类验证,目前暂只支持列表方式
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<string> {
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<boolean> {
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<boolean> {
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;
}
}
}

View File

@ -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<string> versionName
*/
getVersionName(): Promise<string> {
return new Promise<string>(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;

View File

@ -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<void>
*/
static async reportAppPermJumpMorePerm(bundleName: string, appVersion: string): Promise<void> {
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
let eventParams: Record<string, string | number> = {
'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<void>
*/
static async reportAppPermissionJumpPage(bundleName: string, appVersion: string, operationPermissionGroup: string): Promise<void> {
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
let eventParams: Record<string, string | number> = {
'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<void> {
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<void> {
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
let eventParams: Record<string, string | number> = {
'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<void> {
Logger.info(TAG,"reportAccessClick start.")
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
let eventParams: Record<string, string | number> = {
'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<string, string | number> = {
'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<void> {
if (StringUtil.isEmpty(clickItem)) {
Logger.info(TAG, 'clickItem is empty');
return;
}
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
let eventParams: Record<string, string | number> = {
'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<string, string | number>): Promise<void> {
let versionName: string = await GetSelfBundleInfoUtils.getVersionName();
params['PNAMEID'] = HiSysEventConstant.BUNDLE_NAME;
params['PVERSIONID'] = versionName;
let eventParams: Record<string, string | number> = 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}`)
}
)
}
}

View File

@ -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()

View File

@ -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<string> {
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<string> {
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 '';
}
}

View File

@ -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<relationalStore.RdbStore | undefined> {
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<number> {
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<number> {
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<string>): Promise<relationalStore.ResultSet | undefined> {
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;
}
}

View File

@ -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 | number>): 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;

View File

@ -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;
}
}

View File

@ -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');
}
}

View File

@ -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';
}
}

View File

@ -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<MenuInfo[]> {
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<MenuInfo[]> {
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<MenuInfo[]> {
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<number> {
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<string> {
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;
}
}

View File

@ -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<AutoMenuModel, AutoMenuViewState> {
protected initModel(): AutoMenuModel {
return new AutoMenuModel();
}
protected initViewState(): AutoMenuViewState {
return new AutoMenuViewState();
}
protected async processIntentWithModel(intent: BaseIntent, model: AutoMenuModel, viewStat: AutoMenuViewState): Promise<ProcessResult> {
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;
}
}

View File

@ -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[] = [];
}

View File

@ -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<BundleInfoBean[]>(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<bundleManager.ExtensionAbilityInfo[]>((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<bundleManager.BundleInfo[]>((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<void> {
let resourceManager: resourceManager.ResourceManager = this.context.createBundleContext(info.bundleName)
.resourceManager;
return new Promise<void>(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;

View File

@ -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
}
}

View File

@ -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<void> {
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;

View File

@ -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;

View File

@ -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'))
}
}

View File

@ -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<string, string> = router.getParams() as Record<string, string>;
@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)
}
}

View File

@ -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');
}
}

View File

@ -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)
}
}

View File

@ -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"
}
]
}
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -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"
}
]
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Public/ic_public_back</title>
<defs>
<path d="M5.31079777,13.7499686 L11.2803301,19.7196699 L11.3140714,19.7556673 C11.5727547,20.0502619 11.5615076,20.4991526 11.2803301,20.7803301 C10.9991526,21.0615076 10.5502619,21.0727547 10.2556673,20.8140714 L10.2196699,20.7803301 L3.18929777,13.7499686 L5.31079777,13.7499686 Z M11.2803301,3.21966991 C11.5615076,3.5008474 11.5727547,3.94973814 11.3140714,4.24433269 L11.2803301,4.28033009 L4.3105,11.25 L21,11.25 C21.3994202,11.25 21.7259152,11.56223 21.7487268,11.9559318 L21.75,12 C21.75,12.3994202 21.43777,12.7259152 21.0440682,12.7487268 L21,12.75 L3.10355339,12.75 C2.8383369,12.75 2.58398299,12.6446432 2.39644661,12.4571068 C2.01893979,12.0796 2.00635623,11.4753589 2.35869593,11.0827365 L2.39644661,11.0428932 L10.2196699,3.21966991 C10.5125631,2.9267767 10.9874369,2.9267767 11.2803301,3.21966991 Z" id="path-1"></path>
</defs>
<g id="Public/ic_public_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1"
id="图层_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 48 96"
enable-background="new 0 0 48 96"
xml:space="preserve">
<path
fill="#CCCCCC"
d="M37.1,45.9l-22-22c-1.2-1.2-3.1-1.2-4.2,0c-1.2,1.2-1.2,3.1,0,4.2L30.8,48L10.9,67.9c-1.2,1.2-1.2,3.1,0,4.2
c0.6,0.6,1.4,0.9,2.1,0.9s1.5-0.3,2.1-0.9l22-22C38.3,48.9,38.3,47.1,37.1,45.9z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,7 @@
{
"src": [
"pages/Index",
"pages/UiExtensionPage",
"pages/locationServices"
]
}

View File

@ -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"
}
]
}

View File

@ -0,0 +1,30 @@
[
{
"primaryKey": "lock_screen_password",
"bundleName": "com.huawei.hmos.settings",
"category": "lock_screen_password",
"uxConfig": {
"titleRes": "app.string.category_title_lock_screen_password",
"contentRes": "app.string.category_desc_lock_screen_password",
"iconRes": "app.media.ic_lock_password",
"actionButtonRes": "app.string.button_go",
"ignoreButtonRes": "app.string.button_ignore"
},
"urlConfig": {
"bundleName": "com.huawei.hmos.settings",
"abilityName": "com.huawei.hmos.settings.MainAbility",
"uri": "lock_screen_password_title",
"parameters": {
"pushParams": {
"action": "open_create_password_dialog"
}
}
},
"otherConfig": {
"ignoreTimesKey": "ignoreLockScreenTimes",
"ignoreTimestampKey": "ignoreLockScreenSetTimes",
"priority": 300,
"riskLevel": "HIGH"
}
}
]

View File

@ -0,0 +1,47 @@
[
{
"titleNameId": "privacy_protect_proposition",
"listType": "1",
"jumperType": "uri",
"uriResId": "privacy_protect_proposition_uri",
"bundleName": "",
"abilityName": "",
"ueParam": "1"
},
{
"titleNameId": "consumer_business_privacy_statement",
"listType": "1",
"jumperType": "uri",
"uriResId": "consumer_business_privacy_statement_uri",
"bundleName": "",
"abilityName": "",
"ueParam": "2"
},
{
"titleNameId": "cookies_policy",
"listType": "1",
"jumperType": "uri",
"uriResId": "cookies_policy_uri",
"bundleName": "",
"abilityName": "",
"ueParam": "3"
},
{
"titleNameId": "privacy_and_security_certification",
"listType": "1",
"jumperType": "uri",
"uriResId": "privacy_and_security_certification_uri",
"bundleName": "",
"abilityName": "",
"ueParam": "4"
},
{
"titleNameId": "more_privacy_protection_information",
"listType": "1",
"jumperType": "uri",
"uriResId": "more_privacy_protection_information_uri",
"bundleName": "",
"abilityName": "",
"ueParam": "5"
}
]

View File

@ -0,0 +1,23 @@
[
{
"businessId": "lock_screen_password",
"bundleName": "com.huawei.hmos.passwordvault",
"priority": 9999
},
{
"businessId": "high_safe_mode",
"bundleName": "com.huawei.hmos.advsecmode",
"priority": 8888
},
{
"businessId": "data_and_privacy",
"bundleName": "com.huawei.hmos.security.privacycenter",
"priority": 7777
},
{
"businessId": "hw_ads_service",
"bundleName": "com.huawei.hmos.adsservice",
"priority": 6666
}
]

View File

@ -0,0 +1,21 @@
{
"cardRuleList": [
{
"dstBundleName": "com.example.extensionabilitycard"
}
],
"listRuleList": [
{
"dstBundleName": "com.huawei.hmos.passwordvault"
},
{
"dstBundleName": "com.huawei.hmos.advsecmode"
},
{
"dstBundleName": "com.huawei.hmos.security.privacycenter"
},
{
"dstBundleName": "com.huawei.hmos.adsservice"
}
]
}

View File

@ -0,0 +1,24 @@
{
"searchPages": [
{
"pageTitle": "string:privacy_ability_label",
"pageDescription": "Privacy and security",
"entryKey": "privacy_settings",
"params": "",
"searchItems": [
{
"itemName": "Privacy and security",
"itemTitle": "$string:privacy_ability_label",
"itemDescription": "",
"icon": ""
},
{
"itemName": "Permission Management",
"itemTitle": "$string:search_item_permission_management",
"itemDescription": "",
"icon": ""
}
]
}
]
}

View File

@ -0,0 +1,486 @@
{
"string": [
{
"name": "module_desc",
"value": "隐私模块入口"
}
,{
"name": "EntryAbility_desc",
"value": "隐私主页面"
},{
"name": "EntryAbility_label",
"value": "隐私"
},
{
"name": "button_go",
"value": "前往"
},
{
"name": "button_ignore",
"value": "忽略"
},
{
"name": "category_title_lock_screen_password",
"value": "锁屏密码"
},
{
"name": "category_desc_lock_screen_password",
"value": "建议设置锁屏密码,以保护您的数据和财产安全。"
},
{
"name": "operation_froup_location",
"value": "位置信息"
},
{
"name": "operation_group_camera",
"value": "相机"
},
{
"name": "operation_group_microphone",
"value": "麦克风"
},
{
"name": "operation_group_image_and_videos",
"value": "图片与视频"
},
{
"name": "operation_group_contacts",
"value": "通讯录"
},
{
"name": "operation_group_application_tracing",
"value": "应用跟踪"
},
{
"name": "operation_group_clipboard",
"value": "剪贴板"
},
{
"name": "operation_group_document",
"value": "文件"
},
{
"name": "operation_group_music_and_audio",
"value": "音乐与音频"
},
{
"name": "operation_group_health_and_fitness",
"value": "健身运动"
},
{
"name": "operation_group_calendar",
"value": "日历"
},
{
"name": "operation_group_more_permission",
"value": "更多权限"
},
{
"name": "total_times_in_last_three_days",
"value": "近 %d 天应用访问权限次数"
},
{
"name": "other",
"value": "其他"
},
{
"name": "privacy_permission",
"value": "隐私权限"
},
{
"name": "data_and_privacy",
"value": "数据与隐私"
},
{
"name": "permission_more",
"value": "更多"
},
{
"name": "permission_collapse",
"value": "收起"
},
{
"name": "permission_by_default",
"value": "默认"
},
{
"name": "allow",
"value": "允许"
},
{
"name": "media_only",
"value": "仅媒体"
},
{
"name": "allow_management_of_all_files",
"value": "所有文件"
},
{
"name": "precise_location",
"value": "精确位置"
},
{
"name": "search_placeholder",
"value": "搜索应用"
},
{
"name": "today",
"value": "今天"
},
{
"name": "yesterday",
"value": "昨天"
},
{
"name": "allow_all_the_time",
"value": "始终允许"
},
{
"name": "allow_only_while_in_use",
"value": "仅使用期间允许"
},
{
"name": "ask_each_time",
"value": "每次使用询问"
},
{
"name": "deny",
"value": "禁止"
},
{
"name": "allow_state",
"value": "允许"
},
{
"name": "app_version_name",
"value": "版本 %s"
},
{
"name": "allow_all_the_time_state",
"value": "始终允许"
}, {
"name": "allow_only_while_in_use_state",
"value": "仅使用期间允许"
},
{
"name": "ask_each_time_state",
"value": "每次使用询问"
},
{
"name": "deny_state",
"value": "禁止"
},
{
"name": "access_permission",
"value": "访问我的位置信息"
},
{
"name": "view_ad_logo",
"value": "查看 OAID"
},
{
"name": "operation_group_application_tracing_desc",
"value": "开放匿名广告标识符Open Anonymous Device Identifier,OAID是一种非永久性设备标识符。使用OAID保护用户个人数据隐私安全的前提下提供给App开发者用于设备识别、跨设备跟踪、提供个性化广告或内容推荐。"
},
{
"name": "privacy_introduction",
"value": "华为讲隐私视作每个人的基本权利,所有华为产品力求使用最少得用户数据,尽可能采用本地处理,富裕用户对信息的知情权和控制权。"
},
{
"name": "use_privacy",
"value": "了解我们如何使用您的数据"
},
{
"name": "privacy_item1",
"value": "我们隐私保护的主张和承诺"
},
{
"name": "privacy_protect_proposition_uri",
"value": "https://consumer.huawei.com/cn/privacy"
},
{
"name": "privacy_item2",
"value": "华为消费者业务隐私声明"
},
{
"name": "consumer_business_privacy_statement_uri",
"value": "https://consumer.huawei.com/cn/privacy/privacy-policy"
},
{
"name": "privacy_item3",
"value": "Cookies 政策"
},
{
"name": "cookies_policy_uri",
"value": "https://consumer.huawei.com/cn/legal/cookie-pilicy"
},
{
"name": "privacy_item4",
"value": "我们获得的隐私安全认证"
},
{
"name": "privacy_and_security_certification_uri",
"value": "https://consumer.huawei.com/cn/privacy/certification"
},
{
"name": "more_privacy",
"value": "了解更多隐私保护信息"
},
{
"name": "more_privacy_protection_information_uri",
"value": "https://privacy.consumer.huawei.com/tool?lang=zh-cn&themeName=blue"
},
{
"name": "app_state_foreground",
"value": "前台"
},
{
"name": "app_state_background",
"value": "后台"
},
{
"name": "app_state_screen_locked",
"value": "锁屏"
},
{
"name": "app_state_common",
"value": "普通"
},
{
"name": "precise_location_description",
"value": "允许应用获取您的准确位置信息。关闭后,应用获取的位置信息会有偏差"
},
{
"name": "system_services",
"value": "系统服务"
},
{
"name": "Improves_accuracy",
"value": "提高精确度"
},
{
"name": "make_location_more_accurate_desc",
"value": "为了位置服务更准确, 您可以设置%s。"
},
{
"name": "permission_group_storage",
"value": "媒体和文件"
},
{
"name": "permission_group_phone",
"value": "电话"
},
{
"name": "permission_group_sms",
"value": "信息"
},
{
"name": "permission_group_call_log",
"value": "通话记录"
},
{
"name": "permission_group_sensors",
"value": "身体传感器"
},
{
"name": "permission_group_nearby_devices",
"value": "附近设备"
},
{
"name": "permission_group_request_install_packages",
"value": "应用内安装其他应用"
},
{
"name": "permission_group_shortcut",
"value": "创建桌面快捷方式"
},
{
"name": "permission_group_system_alert_window",
"value": "悬浮窗"
},
{
"name": "permission_group_get_install_apps",
"value": "读取已安装应用列表"
},
{
"name": "permission_group_popup_background_window",
"value": "后台弹窗"
},
{
"name": "permission_group_distribution",
"value": "多设备协同"
},
{
"name": "no_access_records_in_the_last_seven_days",
"value": "近 %d 天没有访问记录"
},
{
"name": "search_item_permission",
"value": "权限管理"
},
{
"name": "no_matching_results",
"value": "没有匹配结果"
},
{
"name": "forbidden_description_location",
"value": "位置信息已关闭,当前没有应用可以获取此设备的位置。"
},
{
"name": "precise_location_app_description",
"value": "允许此应用获取您的精确位置。关闭后,应用获取的位置会有偏差,部分不支持次功能的应用可能会定位失败。"
},
{
"name": "barchart_no_access_record",
"value": "暂未发现该权限使用记录"
},
{
"name": "loading",
"value": "正在加载..."
},
{
"name": "total_times_in_last_seven_days",
"value": "近 %1$d 天,%2$s共访问 %3$s "
},
{
"name": "location_access_record_title",
"value": "位置访问记录"
},
{
"name": "camera_access_record_title",
"value": "相机访问记录"
},
{
"name": "microphone_access_record_title",
"value": "麦克风访问记录"
},
{
"name": "image_and_videos_access_record_title",
"value": "图片与视频访问记录"
},
{
"name": "contacts_access_record_title",
"value": "通讯录访问记录"
},
{
"name": "application_tracing_access_record_title",
"value": "应用跟踪访问记录"
},
{
"name": "clipboard_access_record_title",
"value": "剪贴板访问记录"
},
{
"name": "document_access_record_title",
"value": "文件访问记录"
},
{
"name": "music_and_audio_access_record_title",
"value": "音乐与音频访问记录"
},
{
"name": "health_and_fitness_access_record_title",
"value": "健身运动访问记录"
},
{
"name": "calendar_access_record_title",
"value": "日历访问记录"
},
{
"name": "location_portrait_permission_title",
"value": "位置信息权限"
},
{
"name": "camera_portrait_permission_title",
"value": "相机权限"
},
{
"name": "microphone_portrait_permission_title",
"value": "麦克风权限"
},
{
"name": "image_and_videos_portrait_permission_title",
"value": "图片与视频权限"
},
{
"name": "contacts_portrait_permission_title",
"value": "通讯录权限"
},
{
"name": "application_tracing_portrait_permission_title",
"value": "应用跟踪权限"
},
{
"name": "clipboard_portrait_permission_title",
"value": "剪贴板权限"
},
{
"name": "document_portrait_permission_title",
"value": "文件权限"
},
{
"name": "music_and_audio_portrait_permission_title",
"value": "音乐与音频权限"
},
{
"name": "health_and_fitness_portrait_permission_title",
"value": "健身运动权限"
},
{
"name": "calendar_portrait_permission_title",
"value": "日历权限"
},
{
"name": "location_portrait_permission_subtitle",
"value": "位置信息访问权限"
},
{
"name": "camera_portrait_permission_subtitle",
"value": "相机访问权限"
},
{
"name": "microphone_portrait_permission_subtitle",
"value": "麦克风访问权限"
},
{
"name": "image_and_videos_portrait_permission_subtitle",
"value": "图片与视频访问权限"
},
{
"name": "contacts_portrait_permission_subtitle",
"value": "通讯录访问权限"
},
{
"name": "application_tracing_portrait_permission_subtitle",
"value": "应用跟踪访问权限"
},
{
"name": "clipboard_portrait_permission_subtitle",
"value": "剪切板访问权限"
},
{
"name": "document_portrait_permission_subtitle",
"value": "文件访问权限"
},
{
"name": "music_and_audio_portrait_permission_subtitle",
"value": "音乐与音频访问权限"
},
{
"name": "health_and_fitness_portrait_permission_subtitle",
"value": "健身运动权限"
},
{
"name": "calendar_portrait_permission_subtitle",
"value": "日历访问权限"
},
{
"name": "locationServicesTab",
"value": "定位服务"
},
{
"name": "positionInformation",
"value": "访问我的位置信息"
}
]
}

View File

@ -0,0 +1,37 @@
{
"description": "Configuration for demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.huawei.hmos.security.privacycenter",
"module-name": "entry_test",
"shell-timeout": 7000,
"testcase-timeout": "esmodule",
"coverage": true,
"package-tool-path": "D:\\Local\\coverage\\node_module\\@ohos\\coverage"
},
"kits": [
{
"run-command": [
"mount -o rw,remount /",
"rm -rf /system/app/SecurityPrivacyCenter/*",
"rm /data/service/el1/public/bms/bundle_manage_service/bmsdb.db",
"rm /data/service/el1/public/bms/bundle_manage_service/bmsdb.db-shm",
"rm /data/service/el1/public/bms/bundle_manage_service/bmsdb.db-wal",
"reboot"
],
"teardown-command": [
"mount -o rw,remount /"
],
"type": "ShellKit"
},
{
"test-file-name": [
"SecurityPrivacyCenter.hap",
"SecurityPrivacyCenterTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}

View File

@ -0,0 +1,50 @@
/**
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function abilityTest() {
describe('ActsAbilityTest', () => {
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
beforeAll(() => {
// Presets an action, which is performed only once before all test cases of the test suite start.
// This API supports only one parameter: preset action function.
})
beforeEach(() => {
// Presets an action, which is performed before each unit test case starts.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: preset action function.
})
afterEach(() => {
// Presets a clear action, which is performed after each unit test case ends.
// The number of execution times is the same as the number of test cases defined by **it**.
// This API supports only one parameter: clear action function.
})
afterAll(() => {
// Presets a clear action, which is performed after all test cases of the test suite end.
// This API supports only one parameter: clear action function.
})
it('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)
})
})
}

View File

@ -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()
}

View File

@ -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')
})
})
}

View File

@ -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;
}

View File

@ -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)
})
})
}

View File

@ -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)
})
})
}

View File

@ -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<string, string> = {
"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')
})
})
}

View File

@ -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;
}
}

View File

@ -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');
}
}

View File

@ -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%')
}
}

View File

@ -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');
}
}

View File

@ -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"
]
}
]
}
]
}
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}

View File

@ -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"
}
]
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Public/ic_public_back</title>
<defs>
<path d="M5.31079777,13.7499686 L11.2803301,19.7196699 L11.3140714,19.7556673 C11.5727547,20.0502619 11.5615076,20.4991526 11.2803301,20.7803301 C10.9991526,21.0615076 10.5502619,21.0727547 10.2556673,20.8140714 L10.2196699,20.7803301 L3.18929777,13.7499686 L5.31079777,13.7499686 Z M11.2803301,3.21966991 C11.5615076,3.5008474 11.5727547,3.94973814 11.3140714,4.24433269 L11.2803301,4.28033009 L4.3105,11.25 L21,11.25 C21.3994202,11.25 21.7259152,11.56223 21.7487268,11.9559318 L21.75,12 C21.75,12.3994202 21.43777,12.7259152 21.0440682,12.7487268 L21,12.75 L3.10355339,12.75 C2.8383369,12.75 2.58398299,12.6446432 2.39644661,12.4571068 C2.01893979,12.0796 2.00635623,11.4753589 2.35869593,11.0827365 L2.39644661,11.0428932 L10.2196699,3.21966991 C10.5125631,2.9267767 10.9874369,2.9267767 11.2803301,3.21966991 Z" id="path-1"></path>
</defs>
<g id="Public/ic_public_back" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1"
id="图层_1"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
x="0px"
y="0px"
viewBox="0 0 48 96"
enable-background="new 0 0 48 96"
xml:space="preserve">
<path
fill="#CCCCCC"
d="M37.1,45.9l-22-22c-1.2-1.2-3.1-1.2-4.2,0c-1.2,1.2-1.2,3.1,0,4.2L30.8,48L10.9,67.9c-1.2,1.2-1.2,3.1,0,4.2
c0.6,0.6,1.4,0.9,2.1,0.9s1.5-0.3,2.1-0.9l22-22C38.3,48.9,38.3,47.1,37.1,45.9z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 681 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,5 @@
{
"src": [
"testability/pages/Index"
]
}

183
hisysevent.yaml Normal file
View File

@ -0,0 +1,183 @@
# 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: RELIABILITY
APP_FREEZE:
_BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: application freeze }
SUB_EVENT_TYPE: { type: STRING, desc: sub event type }
EVENT_TIME: { type: STRING, desc: event time }
MODULE: { type: STRING, desc: module name }
PNAME: { type: STRING, desc: process name }
REASON: { type: STRING, desc: app_freeze reason }
DIAG_INFO: { type: STRING, desc: diagnostic info }
STACK: { type: STRING, desc: app_freeze info }
HIVIEW_LOG_FILE_PATHS: { type: STRING, arrsize: 10, desc: log paths }
DOMAIN: { type: STRING, desc: event domain }
STRING_ID: { type: STRING, desc: event stringid }
PID: { type: INT32, desc: app_freeze pid }
UID: { type: INT32, desc: app_freeze uid }
PACKAGE_NAME: { type: STRING, desc: package name }
PROCESS_NAME: { type: STRING, desc: process name }
MSG: { type: STRING, desc: application event message }
SUMMARY: { type: STRING, desc: fault summary }
FAULT_TYPE: { type: STRING, desc: fault type }
LOG_PATH: { type: STRING, desc: fault log path }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
PANME: { type: STRING, desc: process name }
FIRST_FRAME: { type: STRING, desc: first stack info }
SECOND_FRAME: { type: STRING, desc: second stack info }
LAST_FRAME: { type: STRING, desc: last stack info }
PRE_INSTALL: { type: STRING, desc: current app pre-install status(No:not-install Yes:pre-install empty:unknown) }
FOREGROUND: { type: STRING, desc: app running status(No:background Yes:foreground empty:unknown) }
SYS_FREEZE:
_BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: system freeze }
SUB_EVENT_TYPE: { type: STRING, desc: sub event type }
EVENT_TIME: { type: STRING, desc: event time }
MODULE: { type: STRING, desc: module name }
PNAME: { type: STRING, desc: process name }
REASON: { type: STRING, desc: sys_freeze reason }
DIAG_INFO: { type: STRING, desc: diagnostic info }
STACK: { type: STRING, desc: sys_freeze info }
HIVIEW_LOG_FILE_PATHS: { type: STRING, arrsize: 10, desc: log paths }
DOMAIN: { type: STRING, desc: event domain }
STRING_ID: { type: STRING, desc: event stringid }
PID: { type: INT32, desc: sys_freeze pid }
UID: { type: INT32, desc: sys_freeze uid }
PACKAGE_NAME: { type: STRING, desc: package name }
PROCESS_NAME: { type: STRING, desc: process name }
MSG: { type: STRING, desc: application event message }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
PANME: { type: STRING, desc: process name }
FIRST_FRAME: { type: STRING, desc: first stack info }
SECOND_FRAME: { type: STRING, desc: second stack info }
LAST_FRAME: { type: STRING, desc: last stack info }
LOG_PATH: { type: STRING, desc: fault log path }
STACK:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: system freeze }
PID: { type: INT32, desc: stack pid }
UID: { type: INT32, desc: stack uid }
PACKAGE_NAME: { type: STRING, desc: package name }
PROCESS_NAME: { type: STRING, desc: process name }
MSG: { type: STRING, desc: application event message }
SERVICE_BLOCK_REPORT:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: application freeze }
HIVIEW_LOG_FILE_PATHS: { type: STRING, arrsize: 10, desc: log paths }
PID: { type: INT32, desc: service_block_report pid }
TGID: { type: INT32, desc: service_block_report tgid }
MSG: { type: STRING, desc: watchdog event message }
SERVICE_TIMEOUT_REPORT:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: application freeze }
HIVIEW_LOG_FILE_PATHS: { type: STRING, arrsize: 10, desc: log paths }
PID: { type: INT32, desc: service_timeout_report pid }
TGID: { type: INT32, desc: service_timeout_report tgid }
MSG: { type: STRING, desc: timer event message }
CPP_CRASH:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: cpp crash }
MODULE: { type: STRING, desc: module name }
VERSION: { type: STRING, desc: module version }
REASON: { type: STRING, desc: fault reason }
PID: { type: INT32, desc: cpp_crash pid }
UID: { type: INT32, desc: cpp_crash uid }
SUMMARY: { type: STRING, desc: fault summary }
FAULT_TYPE: { type: STRING, desc: fault type }
LOG_PATH: { type: STRING, desc: fault log path }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
HAPPEN_TIME: { type: INT64, desc: fault trigger time }
LIFETIME: { type: INT64, desc: elapse time since process start }
PANME: { type: STRING, desc: process name }
FIRST_FRAME: { type: STRING, desc: first stack info }
SECOND_FRAME: { type: STRING, desc: second stack info }
LAST_FRAME: { type: STRING, desc: last stack info }
PRE_INSTALL: { type: STRING, desc: current app pre-installe status(No:not pre-install Yes:pre-install empty:unknown) }
FOREGROUND: { type: STRING, desc: app running status(No:background Yes:foreground empty:unknown) }
CPP_CRASH_NO_LOG:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: encounter cpp crash but no log generated }
PROCESS_NAME: { type: STRING, desc: process name }
PID: { type: INT32, desc: cpp_crash_no_log pid }
UID: { type: INT32, desc: cpp_crash_no_log uid }
HAPPEN_TIME: { type: INT64, desc: fault trigger time }
RUST_PANIC:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: rust panic }
MODULE: { type: STRING, desc: module name }
REASON: { type: STRING, desc: fault reason }
PID: { type: INT32, desc: rust panic pid }
TID: { type: INT32, desc: rust panic tid }
UID: { type: INT32, desc: rust panic uid }
SUMMARY: { type: STRING, desc: panic summary }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
HAPPEN_TIME: { type: INT64, desc: panic trigger time }
PNAME: { type: STRING, desc: process name }
FIRST_FRAME: { type: STRING, desc: first stack info }
SECOND_FRAME: { type: STRING, desc: second stack info }
LAST_FRAME: { type: STRING, desc: last stack info }
MEMORY_LEAK:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: MemoryLeak }
MODULE: { type: STRING, desc: module name }
VERSION: { type: STRING, desc: module version }
REASON: { type: STRING, desc: fault reason }
PID: { type: INT32, desc: memory_leak pid }
UID: { type: INT32, desc: memory_leak uid }
SUMMARY: { type: STRING, desc: fault summary }
FIRST_FRAME: { type: STRING, desc: f1Name }
SECOND_FRAME: { type: STRING, desc: log grade }
MEMTOTAL: { type: STRING, desc: memory total }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
LOG_PATH: { type: STRING, desc: memory leak log path }
HAPPEN_TIME: { type: STRING, desc: leaked time }
FD_LEAK:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: FdLeak }
MODULE: { type: STRING, desc: module name }
VERSION: { type: STRING, desc: module version }
PID: { type: INT32, desc: fd_leak pid }
UID: { type: INT32, desc: fd_leak uid }
FD_NUM: { type: INT32, desc: fd num }
SUMMARY: { type: STRING, desc: fault summary }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
LOG_PATH: { type: STRING, desc: fd leak log path }
HAPPEN_TIME: { type: INT64, desc: leaked time }
THREAD_LEAK:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: ThreadLeak }
MODULE: { type: STRING, desc: module name }
VERSION: { type: STRING, desc: module version }
PID: { type: INT32, desc: thread_leak pid }
UID: { type: INT32, desc: thread_leak uid }
THREAD_NUM: { type: INT64, desc: thread num }
SUMMARY: { type: STRING, desc: fault summary }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
LOG_PATH: { type: STRING, desc: thread leak log path }
HAPPEN_TIME: { type: INT64, desc: leaked time }
ADDR_SANITIZER:
__BASE: { type: FAULT, level: CRITICAL, tag: STABILITY, desc: AddressSanitizer }
MODULE: { type: STRING, desc: module name }
VERSION: { type: STRING, desc: module version }
REASON: { type: STRING, desc: fault reason }
PID: { type: INT32, desc: pid }
UID: { type: INT32, desc: uid }
SUMMARY: { type: STRING, desc: fault summary }
FAULT_TYPE: { type: STRING, desc: fault type }
LOG_NAME: { type: STRING, desc: fault log name }
FINGERPRINT: { type: STRING, desc: unique id for grouping same fault }
HAPPEN_TIME: { type: INT64, desc: fault trigger time }
FIRST_FRAME: { type: STRING, desc: first stack info }

73
hiview.gni Normal file
View File

@ -0,0 +1,73 @@
# Copyright (c) 2021-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.
# build type definitions
is_phone = true
is_tv = false
is_watch = false
# hiview path definitions
hiview_root = "//base/hiviewdfx/hiview"
hiview_adapter = "//base/hiviewdfx/hiview/adapter"
hiview_base = "//base/hiviewdfx/hiview/base"
hiview_core = "//base/hiviewdfx/hiview/core"
hiview_plugin = "//base/hiviewdfx/hiview/plugins"
hiview_service = "//base/hiviewdfx/hiview/service"
hiview_framework = "//base/hiviewdfx/hiview/framework"
hiview_interfaces = "//base/hiviewdfx/hiview/interfaces"
hiview_test = "//base/hiviewdfx/hiview/test"
# hiview plugin path definitions
hiview_faultlogger = "//base/hiviewdfx/hiview/plugins/faultlogger"
hiview_eventlogger = "//base/hiviewdfx/hiview/plugins/eventlogger"
# hiview module
hiview_module = "hiview/hiview"
declare_args() {
device_usage_statistics_enable = true
if (defined(global_parts_info) &&
!defined(global_parts_info.resourceschedule_device_usage_statistics)) {
device_usage_statistics_enable = false
}
battery_statistics_enable = true
if (defined(global_parts_info) &&
!defined(global_parts_info.powermgr_battery_statistics)) {
battery_statistics_enable = false
}
power_manager_enable = true
if (defined(global_parts_info) &&
!defined(global_parts_info.powermgr_power_manager)) {
power_manager_enable = false
}
enable_hiview_usage_event_report_build = true
has_hiperf = true
if (defined(global_parts_info) &&
!defined(global_parts_info.developtools_hiperf)) {
has_hiperf = false
}
has_hiprofiler = true
if (defined(global_parts_info) &&
!defined(global_parts_info.developtools_hiprofiler)) {
has_hiprofiler = false
}
is_wifi_enable = true
if (defined(global_parts_info) &&
!defined(global_parts_info.communication_wifi)) {
is_wifi_enable = false
}
}

101
hiviewdfx.yaml Normal file
View File

@ -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.
domain: HIVIEWDFX
PLUGIN_LOAD:
__BASE: {type: BEHAVIOR, level: CRITICAL, tag: hiviewPlugin, desc: load hiview plugin}
NAME: {type: STRING, desc: plugin name}
RESULT: {type: UINT32, desc: result of plugin loading}
PLUGIN_UNLOAD:
__BASE: {type: BEHAVIOR, level: CRITICAL, tag: hiviewPlugin, desc: unload hiview plugin}
NAME: {type: STRING, desc: plugin name}
RESULT: {type: UINT32, desc: result of plugin unloading}
PLUGIN_STATS:
__BASE: {type: STATISTIC, level: CRITICAL, tag: hiviewPlugin, desc: statistics of events handled by plugins}
NAME: {type: STRING, desc: plugin name}
AVG_TIME: {type: UINT32, desc: average time spent}
TOP_K_TIME: {type: UINT32, arrsize: 3, desc: K times that took the most time}
TOP_K_EVENT: {type: STRING, arrsize: 3, desc: K events that took the most time}
TOTAL: {type: UINT32, desc: total events}
PLUGIN_FAULT:
__BASE: {type: FAULT, level: CRITICAL, tag: hiviewPlugin, desc: plugin fault}
NAME: {type: STRING, desc: plugin name}
REASON: {type: STRING, desc: reason of plugin fault}
APP_USAGE:
__BASE: {type: STATISTIC, level: CRITICAL, tag: usageStats, desc: application usage statistics}
PACKAGE: {type: STRING, desc: package name}
VERSION: {type: STRING, desc: version name}
USAGE: {type: UINT32, desc: usage duration}
DATE: {type: STRING, desc: usage date}
TOTAL_START_NUM: {type: UINT32, desc: total start number}
SYS_USAGE:
__BASE: {type: STATISTIC, level: CRITICAL, tag: usageStats, desc: system usage statistics}
START: {type: UINT64, desc: start time}
END: {type: UINT64, desc: end time}
POWER: {type: UINT64, desc: power_on duration}
SCREEN: {type: UINT64, desc: screen_on duration}
RUNNING: {type: UINT64, desc: running duration}
PROFILE_STAT:
__BASE: {type: STATISTIC, level: CRITICAL, desc: hisysevent profile status}
MAX_TOTAL_COUNT: {type: UINT32, desc: maximum total count}
MAX_TOTAL_SIZE: {type: UINT32, desc: maximum total size}
DOMAINS: {type: STRING, arrsize: 100, desc: measured domains}
DOMAIN_DETAIL: {type: UINT32, arrsize: 100, desc: domain detail}
TOTAL_COUNT: {type: UINT32, desc: total count}
TOTAL_SIZE: {type: UINT32, desc: total size}
BREAK_COUNT: {type: UINT8, desc: break count}
BREAK_DURATION: {type: UINT64, desc: break duration}
MIN_SPEED: {type: UINT32, desc: minimum speed}
MAX_SPEED: {type: UINT32, desc: maximum speed}
REAL_COUNT: {type: UINT32, arrsize: 10, desc: real time cost distribution}
PROCESS_COUNT: {type: UINT32, arrsize: 10, desc: process time cost distribution}
WAIT_COUNT: {type: UINT32, arrsize: 10, desc: wait count cost distribution}
FINISHED_COUNT: {type: UINT32, desc: finished count}
OVER_REAL_COUNT: {type: UINT32, desc: over real time benchmark count}
OVER_REAL_PCT: {type: UINT32, desc: over real time benchmark percentage}
OVER_PROC_COUNT: {type: UINT32, desc: over process time cost benchmark count}
OVER_PROC_PCT: {type: UINT32, desc: over process time cost percentage}
BREAK:
__BASE: {type: BEHAVIOR, level: CRITICAL, desc: hisysevent is break}
TOTAL_COUNT: {type: UINT32, desc: total count}
TOTAL_SIZE: {type: UINT32, desc: total size}
REAL_SPEED: {type: UINT32, desc: real time of handle hisysevent each second}
PROC_SPEED: {type: UINT32, desc: process time of handle hisysevent each second}
AVG_REAL_TIME: {type: DOUBLE, desc: average real time cost}
AVG_PROC_TIME: {type: DOUBLE, desc: average process time cost}
AVG_WAIT_TIME: {type: DOUBLE, desc: average wait time cost}
TOP_EVENT: {type: STRING, arrsize: 3, desc: topN events}
TOP_EVENT_COUNT: {type: UINT32, arrsize: 3, desc: count of topN events}
TOP_DOMAIN: {type: STRING, arrsize: 3, desc: topN domains}
TOP_DOMAIN_COUNT: {type: UINT32, arrsize: 3, desc: count of topN domains}
RECOVER:
__BASE: {type: BEHAVIOR, level: CRITICAL, desc: hisysevent is recover}
DURATION: {type: INT64, desc: recover after break duration}
XPOWER_STACKTRACE:
__BASE: {type: STATISTIC, level: MINOR, tag: PowerStats, desc: stack trace info}
TAGNAME: {type: STRING, desc: tag name}
INFO: {type: STRING, desc: additional information}
STACKTRACE: {type: STRING, desc: stack data}
CPU_COLLECTION:
__BASE: {type: FAULT, level: MINOR, desc: HiView CPU Unified Collection Event}

View File

@ -0,0 +1,18 @@
{
"hvigorVersion": "3.0.9",
"dependencies": {
"@ohos/hvigor-ohos-plugin": "3.0.9"
},
"execution": {
// "daemon": true, /* Enable daemon compilation. Default: true */
// "incremental": true, /* Enable incremental compilation. Default: true */
// "parallel": true, /* Enable parallel compilation. Default: true */
// "typeCheck": false, /* Enable typeCheck. Default: false */
},
"logging": {
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
},
"debugging": {
// "stacktrace": false /* Disable stacktrace compilation. Default: false */
}
}

1
hvigor/hvigor-wrapper.js Normal file

File diff suppressed because one or more lines are too long

6
hvigorfile.ts Normal file
View File

@ -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. */
}

48
hvigorw Normal file
View File

@ -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}" "$@"

64
hvigorw.bat Normal file
View File

@ -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

415
kernel_vendor.yaml Normal file
View File

@ -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}

13
oh-package-lock.json5 Normal file
View File

@ -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=="
}
}
}

12
oh-package.json5 Normal file
View File

@ -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": {}
}

View File

@ -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-----

View File

@ -0,0 +1 @@
rtXÄdmò<EFBFBD>”8 E] (m

Binary file not shown.

View File

@ -0,0 +1 @@
 &;IŠÝ<C5A0>˙Şîl

View File

@ -0,0 +1 @@
1rС(k+ет²

Some files were not shown because too many files have changed in this diff Show More