1/* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { PermissionInfo, GroupInfo } from './typedef'; 17import { Permission, PermissionGroup, ButtonStatus } from './definition'; 18 19export const permissionInfos: Map<Permission, PermissionInfo> = new Map([ 20 [Permission.LOCATION_IN_BACKGROUND, new PermissionInfo(Permission.LOCATION_IN_BACKGROUND, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_location_in_background'), 0)], 21 [Permission.APPROXIMATELY_LOCATION, new PermissionInfo(Permission.APPROXIMATELY_LOCATION, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_approximately_location'), 0)], 22 [Permission.LOCATION, new PermissionInfo(Permission.LOCATION, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_location'), 0)], 23 [Permission.CAMERA, new PermissionInfo(Permission.CAMERA, PermissionGroup.CAMERA, $r('sys.string.ohos_lab_camera'), 1)], 24 [Permission.MICROPHONE, new PermissionInfo(Permission.MICROPHONE, PermissionGroup.MICROPHONE, $r('sys.string.ohos_lab_microphone'), 2)], 25 [Permission.READ_CONTACTS, new PermissionInfo(Permission.READ_CONTACTS, PermissionGroup.CONTACTS, $r('sys.string.ohos_lab_read_contacts'), 3, 'app.string.enable_description_read_contacts', $r('app.string.forbidden_description_read_contacts'))], 26 [Permission.WRITE_CONTACTS, new PermissionInfo(Permission.WRITE_CONTACTS, PermissionGroup.CONTACTS, $r('sys.string.ohos_lab_write_contacts'), 3, 'app.string.enable_description_write_contacts', $r('app.string.forbidden_description_write_contacts'))], 27 [Permission.READ_CALENDAR, new PermissionInfo(Permission.READ_CALENDAR, PermissionGroup.CALENDAR, $r('sys.string.ohos_lab_read_calendar'), 4, 'app.string.enable_description_read_calendar', $r('app.string.forbidden_description_read_calendar'))], 28 [Permission.WRITE_CALENDAR, new PermissionInfo(Permission.WRITE_CALENDAR, PermissionGroup.CALENDAR, $r('sys.string.ohos_lab_write_calendar'), 4, 'app.string.enable_description_write_calendar', $r('app.string.forbidden_description_write_calendar'))], 29 [Permission.READ_WHOLE_CALENDAR, new PermissionInfo(Permission.READ_WHOLE_CALENDAR, PermissionGroup.CALENDAR, $r('sys.string.ohos_lab_read_whole_calendar'), 4, 'app.string.enable_description_read_whole_calendar', $r('app.string.forbidden_description_read_whole_calendar'))], 30 [Permission.WRITE_WHOLE_CALENDAR, new PermissionInfo(Permission.WRITE_WHOLE_CALENDAR, PermissionGroup.CALENDAR, $r('sys.string.ohos_lab_write_whole_calendar'), 4, 'app.string.enable_description_write_whole_calendar', $r('app.string.forbidden_description_write_whole_calendar'))], 31 [Permission.ACTIVITY_MOTION, new PermissionInfo(Permission.ACTIVITY_MOTION, PermissionGroup.SPORT, $r('sys.string.ohos_lab_activity_motion'), 5)], 32 [Permission.READ_HEALTH_DATA, new PermissionInfo(Permission.READ_HEALTH_DATA, PermissionGroup.HEALTH, $r('sys.string.ohos_lab_read_health_data'), 6)], 33 [Permission.READ_IMAGEVIDEO, new PermissionInfo(Permission.READ_IMAGEVIDEO, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_desc_read_imagevideo'), 8)], 34 [Permission.WRITE_IMAGEVIDEO, new PermissionInfo(Permission.WRITE_IMAGEVIDEO, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_desc_write_imagevideo'), 8)], 35 [Permission.MEDIA_LOCATION, new PermissionInfo(Permission.MEDIA_LOCATION, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_lab_media_location'), 8)], 36 [Permission.READ_AUDIO, new PermissionInfo(Permission.READ_AUDIO, PermissionGroup.AUDIOS, $r('sys.string.ohos_desc_read_audio'), 9)], 37 [Permission.WRITE_AUDIO, new PermissionInfo(Permission.WRITE_AUDIO, PermissionGroup.AUDIOS, $r('sys.string.ohos_desc_write_audio'), 9)], 38 [Permission.READ_DOCUMENT, new PermissionInfo(Permission.READ_DOCUMENT, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_desc_read_document'), 10)], 39 [Permission.WRITE_DOCUMENT, new PermissionInfo(Permission.WRITE_DOCUMENT, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_desc_write_document'), 10)], 40 [Permission.READ_MEDIA, new PermissionInfo(Permission.READ_MEDIA, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_read_media'), 10)], 41 [Permission.WRITE_MEDIA, new PermissionInfo(Permission.WRITE_MEDIA, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_write_media'), 10)], 42 [Permission.APP_TRACKING_CONSENT, new PermissionInfo(Permission.APP_TRACKING_CONSENT, PermissionGroup.ADS, $r('sys.string.ohos_lab_app_tracking_consent'), 11)], 43 [Permission.GET_INSTALLED_BUNDLE_LIST, new PermissionInfo(Permission.GET_INSTALLED_BUNDLE_LIST, PermissionGroup.GET_INSTALLED_BUNDLE_LIST, $r('sys.string.ohos_lab_get_installed_bundle_list'), 12)], 44 [Permission.DISTRIBUTED_DATASYNC, new PermissionInfo(Permission.DISTRIBUTED_DATASYNC, PermissionGroup.DISTRIBUTED_DATASYNC, $r('sys.string.ohos_lab_distributed_datasync'), 13)], 45 [Permission.ACCESS_BLUETOOTH, new PermissionInfo(Permission.ACCESS_BLUETOOTH, PermissionGroup.BLUETOOTH, $r('sys.string.ohos_lab_access_bluetooth'), 14)], 46 [Permission.READ_PASTEBOARD, new PermissionInfo(Permission.READ_PASTEBOARD, PermissionGroup.PASTEBOARD, $r('sys.string.ohos_lab_read_pasteboard'), 15)], 47 [Permission.READ_WRITE_DOWNLOAD_DIRECTORY, new PermissionInfo(Permission.READ_WRITE_DOWNLOAD_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_download_directory'), 16)], 48 [Permission.READ_WRITE_DESKTOP_DIRECTORY, new PermissionInfo(Permission.READ_WRITE_DESKTOP_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_desktop_directory'), 16)], 49 [Permission.READ_WRITE_DOCUMENTS_DIRECTORY, new PermissionInfo(Permission.READ_WRITE_DOCUMENTS_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_documents_directory'), 16)], 50 [Permission.ACCESS_NEARLINK, new PermissionInfo(Permission.ACCESS_NEARLINK, PermissionGroup.NEARLINK, $r('sys.string.ohos_lab_access_nearlink'), 17)], 51 [Permission.CUSTOM_SCREEN_CAPTURE, new PermissionInfo(Permission.CUSTOM_SCREEN_CAPTURE, PermissionGroup.CUSTOM_SCREEN_CAPTURE, $r('sys.string.ohos_lab_custom_screen_capture'), 18)] 52]) 53 54export const groups: GroupInfo[] = [ 55 new GroupInfo(PermissionGroup.LOCATION, $r('app.string.groupName_location'), 'app.string.group_label_location', $r('app.media.ic_public_gps'), [], '', [Permission.LOCATION_IN_BACKGROUND, Permission.APPROXIMATELY_LOCATION, Permission.LOCATION], [ButtonStatus.ALLOW_ONLY_DURING_USE, ButtonStatus.ALLOW_THIS_TIME, ButtonStatus.CANCEL], true, 'app.string.enable_description_location', $r('app.string.forbidden_description_location')), 56 new GroupInfo(PermissionGroup.CAMERA, $r('app.string.groupName_camera'), 'app.string.group_label_camera', $r('app.media.ic_public_camera'), [], '', [Permission.CAMERA], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_camera', $r('app.string.forbidden_description_camera')), 57 new GroupInfo(PermissionGroup.MICROPHONE, $r('app.string.groupName_microphone'), 'app.string.group_label_microphone', $r('app.media.ic_public_voice'), [], '', [Permission.MICROPHONE], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_microphone', $r('app.string.forbidden_description_microphone')), 58 new GroupInfo(PermissionGroup.CONTACTS, $r('app.string.groupName_contacts'), 'app.string.group_label_contacts', $r('app.media.ic_public_contacts_group'), [], '', [Permission.READ_CONTACTS, Permission.WRITE_CONTACTS], [ButtonStatus.DENY, ButtonStatus.ALLOW], false), 59 new GroupInfo(PermissionGroup.CALENDAR, $r('app.string.groupName_calendar'), 'app.string.group_label_calendar', $r('app.media.ic_public_calendar'), [], '', [Permission.READ_CALENDAR, Permission.WRITE_CALENDAR, Permission.READ_WHOLE_CALENDAR, Permission.WRITE_WHOLE_CALENDAR], [ButtonStatus.DENY, ButtonStatus.ALLOW], true), 60 new GroupInfo(PermissionGroup.SPORT, $r('app.string.groupName_sport'), 'app.string.group_label_sport', $r('app.media.ic_sport'), [], '', [Permission.ACTIVITY_MOTION], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_sport', $r('app.string.forbidden_description_sport')), 61 new GroupInfo(PermissionGroup.HEALTH, $r('app.string.groupName_health'), 'app.string.group_label_health', $r('app.media.ic_ssensor'), [], '', [Permission.READ_HEALTH_DATA], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_health', $r('app.string.forbidden_description_health')), 62 new GroupInfo(PermissionGroup.OTHER, $r('app.string.groupName_other'), '', $r('app.media.ic_more'), [], '', [], [ButtonStatus.DENY, ButtonStatus.ALLOW], true), 63 new GroupInfo(PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_lab_read_imagevideo'), 'app.string.group_label_image_and_videos', $r('app.media.ic_public_picture'), [], '', [Permission.READ_IMAGEVIDEO, Permission.WRITE_IMAGEVIDEO, Permission.MEDIA_LOCATION], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_image', $r('app.string.forbidden_description_image')), 64 new GroupInfo(PermissionGroup.AUDIOS, $r('sys.string.ohos_lab_read_audio'), 'app.string.group_label_audios', $r('app.media.ic_public_audio'), [], '', [Permission.READ_AUDIO, Permission.WRITE_AUDIO], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_audios', $r('app.string.forbidden_description_audios')), 65 new GroupInfo(PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_read_document'), 'app.string.group_label_document', $r('app.media.ic_public_folder'), [], '', [Permission.READ_DOCUMENT, Permission.WRITE_DOCUMENT, Permission.READ_MEDIA, Permission.WRITE_MEDIA], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_documents', $r('app.string.forbidden_description_documents')), 66 new GroupInfo(PermissionGroup.ADS, $r('app.string.groupName_ADS'), 'app.string.group_label_ADS', $r('app.media.track'), [], '', [Permission.APP_TRACKING_CONSENT], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_ADS', $r('app.string.forbidden_description_ADS')), 67 new GroupInfo(PermissionGroup.GET_INSTALLED_BUNDLE_LIST, $r('app.string.groupName_appList'), 'app.string.group_label_appList', $r('app.media.ic_public_app_list'), [], '', [Permission.GET_INSTALLED_BUNDLE_LIST], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_appList', $r('app.string.forbidden_description_appList')), 68 new GroupInfo(PermissionGroup.DISTRIBUTED_DATASYNC, $r('app.string.multi_device_collaboration'), 'app.string.group_label_distributed_datasync', $r('app.media.ic_multi_device_vector'), [], '', [Permission.DISTRIBUTED_DATASYNC], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_distributed_datasync', $r('app.string.forbidden_description_distributed_datasync')), 69 new GroupInfo(PermissionGroup.BLUETOOTH, $r('app.string.groupName_bluetooth'), 'app.string.group_label_bluetooth', $r('app.media.ic_public_bluetooth'), [], '', [Permission.ACCESS_BLUETOOTH], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_bluetooth', $r('app.string.forbidden_description_bluetooth')), 70 new GroupInfo(PermissionGroup.PASTEBOARD, $r('app.string.groupName_pasteboard'), 'app.string.group_label_pasteboard', $r('app.media.ic_clipboard'), [], '', [Permission.READ_PASTEBOARD], [ButtonStatus.DENY, ButtonStatus.THIS_TIME_ONLY], false, 'app.string.enable_description_pasteboard', $r('app.string.forbidden_description_pasteboard')), 71 new GroupInfo(PermissionGroup.FOLDER, $r('app.string.groupName_folder'), 'app.string.group_label_folder', $r('app.media.ic_public_folder'), [], '', [Permission.READ_WRITE_DOWNLOAD_DIRECTORY, Permission.READ_WRITE_DESKTOP_DIRECTORY, Permission.READ_WRITE_DOCUMENTS_DIRECTORY], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_folder', $r('app.string.forbidden_description_folder')), 72 new GroupInfo(PermissionGroup.NEARLINK, $r('app.string.groupName_nearLink'), 'app.string.group_label_nearLink', $r('app.media.ic_nearLink'), [], '', [Permission.ACCESS_NEARLINK], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_nearLink', $r('app.string.forbidden_description_nearLink')), 73 new GroupInfo(PermissionGroup.CUSTOM_SCREEN_CAPTURE, $r('app.string.groupName_screenCapture'), 'app.string.group_label_screenCapture', $r('app.media.ic_public_screen_capture'), [], '', [Permission.CUSTOM_SCREEN_CAPTURE], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_screenCapture', $r('app.string.forbidden_description_screenCapture')) 74]; 75 76export const userGrantPermissions: Permission[] = [ 77 Permission.LOCATION_IN_BACKGROUND, 78 Permission.APPROXIMATELY_LOCATION, 79 Permission.LOCATION, 80 Permission.CAMERA, 81 Permission.MICROPHONE, 82 Permission.READ_CONTACTS, 83 Permission.WRITE_CONTACTS, 84 Permission.READ_CALENDAR, 85 Permission.WRITE_CALENDAR, 86 Permission.READ_WHOLE_CALENDAR, 87 Permission.WRITE_WHOLE_CALENDAR, 88 Permission.ACTIVITY_MOTION, 89 Permission.READ_HEALTH_DATA, 90 Permission.READ_IMAGEVIDEO, 91 Permission.WRITE_IMAGEVIDEO, 92 Permission.MEDIA_LOCATION, 93 Permission.READ_AUDIO, 94 Permission.WRITE_AUDIO, 95 Permission.READ_DOCUMENT, 96 Permission.WRITE_DOCUMENT, 97 Permission.READ_MEDIA, 98 Permission.WRITE_MEDIA, 99 Permission.APP_TRACKING_CONSENT, 100 Permission.GET_INSTALLED_BUNDLE_LIST, 101 Permission.DISTRIBUTED_DATASYNC, 102 Permission.ACCESS_BLUETOOTH, 103 Permission.READ_PASTEBOARD, 104 Permission.READ_WRITE_DOWNLOAD_DIRECTORY, 105 Permission.READ_WRITE_DESKTOP_DIRECTORY, 106 Permission.READ_WRITE_DOCUMENTS_DIRECTORY, 107 Permission.ACCESS_NEARLINK, 108 Permission.CUSTOM_SCREEN_CAPTURE 109]; 110 111export const only2in1AndTabletSupportedPermissions: Permission[] = [ 112 Permission.READ_WRITE_DOWNLOAD_DIRECTORY, 113 Permission.READ_WRITE_DESKTOP_DIRECTORY, 114 Permission.READ_WRITE_DOCUMENTS_DIRECTORY, 115 Permission.CUSTOM_SCREEN_CAPTURE 116] 117 118export const buttonResource: Map<ButtonStatus, Resource> = new Map([ 119 [ButtonStatus.ALLOW, $r('app.string.allow')], 120 [ButtonStatus.DENY, $r('app.string.ban')], 121 [ButtonStatus.CANCEL, $r('app.string.cancel')], 122 [ButtonStatus.THIS_TIME_ONLY, $r('app.string.This_time_only')], 123 [ButtonStatus.ALLOW_THIS_TIME, $r('app.string.allow_this_time')], 124 [ButtonStatus.ALLOW_ONLY_DURING_USE, $r('app.string.allowed_only_during_use')] 125]) 126 127export const showSubPermissionsGroup: PermissionGroup[] = [ 128 PermissionGroup.CALENDAR, 129 PermissionGroup.CONTACTS, 130]; 131 132export const polymorphismGroup: PermissionGroup[] = [ 133 PermissionGroup.LOCATION, 134 PermissionGroup.FOLDER 135] 136 137export const globalGroup: PermissionGroup[] = [ 138 PermissionGroup.MICROPHONE, 139 PermissionGroup.CAMERA 140]