mirror of
https://gitee.com/openharmony/applications_permission_manager
synced 2024-11-23 03:09:41 +00:00
commit
d434f27e5d
@ -141,7 +141,7 @@ struct applicationItem {
|
||||
private context = getContext(this) as common.ServiceExtensionContext;
|
||||
@State globalIsOn: boolean = false;
|
||||
@State backTitle: string = '';
|
||||
@State groupInfo: GroupInfo = new GroupInfo('', '', '', '', [], '', [], false);
|
||||
@State groupInfo: GroupInfo = new GroupInfo('', '', '', '', [], '', [], [], false);
|
||||
@State currentGroup: string = '';
|
||||
@State isMuteSupported: boolean = false;
|
||||
@State appName: ResourceStr = '';
|
||||
|
@ -27,19 +27,12 @@ import { AppInfo, CallerBundleInfo,
|
||||
MediaDocObj,
|
||||
WantInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
import { Permission } from '../common/model/definition';
|
||||
import abilityAccessCtrl, { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
import { groups, showSubPermissionsGroup } from '../common/model/permissionGroup';
|
||||
import UIExtensionContentSession from '@ohos.app.ability.UIExtensionContentSession';
|
||||
import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog'
|
||||
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
const BACKGROUND_LOCATION_PERMISSION = 'ohos.permission.LOCATION_IN_BACKGROUND';
|
||||
const DOWNLOAD_PERMISSION = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY';
|
||||
const DESKTOP_PERMISSION = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY';
|
||||
const DOCUMENTS_PERMISSION = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY';
|
||||
const PASTE = 'ohos.permission.READ_PASTEBOARD';
|
||||
|
||||
let storage = LocalStorage.getShared();
|
||||
let accessTokenId: number = 0;
|
||||
let session: UIExtensionContentSession;
|
||||
@ -280,14 +273,17 @@ struct PermissionStateSheetDialog {
|
||||
if (group === 'LOCATION') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.applicationInfo?.tokenId, FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(
|
||||
this.applicationInfo?.tokenId, Permission.APPROXIMATELY_LOCATION
|
||||
);
|
||||
fuzzyState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.isGranted = Constants.PERMISSION_ALLOWED_ONLY_DURING_USE : null;
|
||||
let backgroundState =
|
||||
acManager.verifyAccessTokenSync(this.applicationInfo?.tokenId, BACKGROUND_LOCATION_PERMISSION);
|
||||
acManager.verifyAccessTokenSync(this.applicationInfo?.tokenId, Permission.LOCATION_IN_BACKGROUND);
|
||||
backgroundState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.isGranted = Constants.PERMISSION_ALLOW : null;
|
||||
await acManager.getPermissionFlags(this.applicationInfo?.tokenId, FUZZY_LOCATION_PERMISSION ).then(flag => {
|
||||
await acManager.getPermissionFlags(this.applicationInfo?.tokenId, Permission.APPROXIMATELY_LOCATION )
|
||||
.then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.isGranted = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
} catch (err) {
|
||||
@ -304,13 +300,13 @@ struct PermissionStateSheetDialog {
|
||||
}
|
||||
if (group === 'FOLDER' && res === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
this.folderStatus[0] = true;
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
this.folderStatus[1] = true;
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
this.folderStatus[2] = true;
|
||||
break;
|
||||
}
|
||||
@ -431,13 +427,13 @@ struct mediaDocumentItem {
|
||||
}
|
||||
if (this.currentGroup === 'FOLDER' && res === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
folderStatus[0] = true;
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
folderStatus[1] = true;
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
folderStatus[2] = true;
|
||||
break;
|
||||
}
|
||||
@ -453,7 +449,7 @@ struct mediaDocumentItem {
|
||||
if (this.currentGroup === 'PASTEBOARD') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
acManager.getPermissionFlags(this.tokenId, PASTE).then(flag => {
|
||||
acManager.getPermissionFlags(this.tokenId, Permission.READ_PASTEBOARD).then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.selected = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
});
|
||||
} catch (err) {
|
||||
@ -462,15 +458,15 @@ struct mediaDocumentItem {
|
||||
} else if (this.currentGroup === 'LOCATION') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.tokenId, FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.tokenId, Permission.APPROXIMATELY_LOCATION);
|
||||
fuzzyState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.selected = Constants.PERMISSION_ALLOWED_ONLY_DURING_USE : null;
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(this.tokenId, PRECISE_LOCATION_PERMISSION);
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(this.tokenId, Permission.LOCATION);
|
||||
this.accurateIsOn = (accurateStatus == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) ? true : false;
|
||||
let backgroundState = acManager.verifyAccessTokenSync(this.tokenId, BACKGROUND_LOCATION_PERMISSION);
|
||||
let backgroundState = acManager.verifyAccessTokenSync(this.tokenId, Permission.LOCATION_IN_BACKGROUND);
|
||||
backgroundState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.selected = Constants.PERMISSION_ALLOW : null;
|
||||
acManager.getPermissionFlags(this.tokenId, FUZZY_LOCATION_PERMISSION).then(flag => {
|
||||
acManager.getPermissionFlags(this.tokenId, Permission.APPROXIMATELY_LOCATION).then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.selected = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
} catch (err) {
|
||||
@ -501,11 +497,11 @@ struct mediaDocumentItem {
|
||||
|
||||
getCheckboxInfo(permission: Permissions): CheckboxInfo {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Download_folder'), 0);
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Desktop_folder'), 1);
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Document_folder'), 2);
|
||||
default:
|
||||
return new CheckboxInfo($r('app.string.Download_folder'), 0);
|
||||
@ -528,16 +524,16 @@ struct mediaDocumentItem {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj($r('app.string.per_inquiry'), this.permissions, Constants.PERMISSION_ONLY_THIS_TIME)
|
||||
);
|
||||
if (this.permissions.includes(BACKGROUND_LOCATION_PERMISSION)) {
|
||||
if (this.permissions.includes(Permission.LOCATION_IN_BACKGROUND)) {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj($r('app.string.always_allow'), this.permissions, Constants.PERMISSION_ALLOW)
|
||||
);
|
||||
}
|
||||
if (this.permissions.includes(FUZZY_LOCATION_PERMISSION)) {
|
||||
if (this.permissions.includes(Permission.APPROXIMATELY_LOCATION)) {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj(
|
||||
$r('app.string.allowed_only_during_use'),
|
||||
[FUZZY_LOCATION_PERMISSION],
|
||||
[Permission.APPROXIMATELY_LOCATION],
|
||||
Constants.PERMISSION_ALLOWED_ONLY_DURING_USE
|
||||
)
|
||||
);
|
||||
@ -600,10 +596,11 @@ struct mediaDocumentItem {
|
||||
this.version = res.versionName;
|
||||
accessTokenId = res.appInfo.accessTokenId;
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, PRECISE_LOCATION_PERMISSION);
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, Permission.LOCATION);
|
||||
this.accurateIsOn = (accurateStatus == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) ? true : false;
|
||||
try {
|
||||
let getFlagPermission = this.currentGroup === 'LOCATION' ? FUZZY_LOCATION_PERMISSION : this.permissions[0];
|
||||
let getFlagPermission =
|
||||
this.currentGroup === 'LOCATION' ? Permission.APPROXIMATELY_LOCATION : this.permissions[0];
|
||||
let flag = await acManager.getPermissionFlags(res.appInfo.accessTokenId, getFlagPermission);
|
||||
Log.info(`getPermissionFlags success, data->${JSON.stringify(flag)}`);
|
||||
this.isRisk = (flag == Constants.PERMISSION_POLICY_FIXED) ? true : false;
|
||||
@ -649,18 +646,18 @@ struct mediaDocumentItem {
|
||||
for (const permission of item.permissions) {
|
||||
Log.info('item click index:' + item.index);
|
||||
if (item.index === Constants.PERMISSION_ALLOW) {
|
||||
if (permission !== PRECISE_LOCATION_PERMISSION) {
|
||||
if (permission !== Permission.LOCATION) {
|
||||
await this.grantUserGrantedPermission(accessTokenId, permission);
|
||||
}
|
||||
} else if (item.index === Constants.PERMISSION_BAN) {
|
||||
if (permission == PRECISE_LOCATION_PERMISSION && this.accurateIsOn) {
|
||||
if (permission == Permission.LOCATION && this.accurateIsOn) {
|
||||
this.revokeUserGrantedPermission(accessTokenId, permission, Constants.PERMISSION_FLAG);
|
||||
this.accurateIsOn = false;
|
||||
} else {
|
||||
this.revokeUserGrantedPermission(accessTokenId, permission, Constants.PERMISSION_FLAG);
|
||||
}
|
||||
} else if (item.index === Constants.PERMISSION_ONLY_THIS_TIME) {
|
||||
if (permission !== PRECISE_LOCATION_PERMISSION) {
|
||||
if (permission !== Permission.LOCATION) {
|
||||
await this.revokeUserGrantedPermission(
|
||||
accessTokenId, permission, Constants.PERMISSION_ALLOW_THIS_TIME
|
||||
);
|
||||
@ -668,7 +665,7 @@ struct mediaDocumentItem {
|
||||
} else if (item.index === Constants.PERMISSION_ALLOWED_ONLY_DURING_USE) {
|
||||
await this.grantUserGrantedPermission(accessTokenId, permission);
|
||||
await this.revokeUserGrantedPermission(
|
||||
accessTokenId, BACKGROUND_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
accessTokenId, Permission.LOCATION_IN_BACKGROUND, Constants.PERMISSION_FLAG
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -880,7 +877,7 @@ struct mediaDocumentItem {
|
||||
endMargin: Constants.DEFAULT_MARGIN_END
|
||||
})
|
||||
|
||||
if (this.permissions.includes(PRECISE_LOCATION_PERMISSION)) {
|
||||
if (this.permissions.includes(Permission.LOCATION)) {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.precise_location'))
|
||||
@ -894,15 +891,13 @@ struct mediaDocumentItem {
|
||||
.onChange((isOn: boolean) => {
|
||||
let acManager = abilityAccessCtrl.createAtManager()
|
||||
if (isOn) {
|
||||
acManager.grantUserGrantedPermission(
|
||||
accessTokenId, PRECISE_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
).then(() => {
|
||||
acManager.grantUserGrantedPermission(accessTokenId, Permission.LOCATION, Constants.PERMISSION_FLAG)
|
||||
.then(() => {
|
||||
this.accurateIsOn = true
|
||||
})
|
||||
} else {
|
||||
acManager.revokeUserGrantedPermission(
|
||||
accessTokenId, PRECISE_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
).then(() => {
|
||||
acManager.revokeUserGrantedPermission(accessTokenId, Permission.LOCATION, Constants.PERMISSION_FLAG)
|
||||
.then(() => {
|
||||
this.accurateIsOn = false
|
||||
})
|
||||
}
|
||||
|
78
permissionmanager/src/main/ets/common/model/definition.ets
Normal file
78
permissionmanager/src/main/ets/common/model/definition.ets
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export enum Permission {
|
||||
LOCATION_IN_BACKGROUND = 'ohos.permission.LOCATION_IN_BACKGROUND',
|
||||
APPROXIMATELY_LOCATION = 'ohos.permission.APPROXIMATELY_LOCATION',
|
||||
LOCATION = 'ohos.permission.LOCATION',
|
||||
CAMERA = 'ohos.permission.CAMERA',
|
||||
MICROPHONE = 'ohos.permission.MICROPHONE',
|
||||
READ_CONTACTS = 'ohos.permission.READ_CONTACTS',
|
||||
WRITE_CONTACTS = 'ohos.permission.WRITE_CONTACTS',
|
||||
READ_CALENDAR = 'ohos.permission.READ_CALENDAR',
|
||||
WRITE_CALENDAR = 'ohos.permission.WRITE_CALENDAR',
|
||||
READ_WHOLE_CALENDAR = 'ohos.permission.READ_WHOLE_CALENDAR',
|
||||
WRITE_WHOLE_CALENDAR = 'ohos.permission.WRITE_WHOLE_CALENDAR',
|
||||
ACTIVITY_MOTION = 'ohos.permission.ACTIVITY_MOTION',
|
||||
READ_HEALTH_DATA = 'ohos.permission.READ_HEALTH_DATA',
|
||||
READ_IMAGEVIDEO = 'ohos.permission.READ_IMAGEVIDEO',
|
||||
WRITE_IMAGEVIDEO = 'ohos.permission.WRITE_IMAGEVIDEO',
|
||||
MEDIA_LOCATION = 'ohos.permission.MEDIA_LOCATION',
|
||||
READ_AUDIO = 'ohos.permission.READ_AUDIO',
|
||||
WRITE_AUDIO = 'ohos.permission.WRITE_AUDIO',
|
||||
READ_DOCUMENT = 'ohos.permission.READ_DOCUMENT',
|
||||
WRITE_DOCUMENT = 'ohos.permission.WRITE_DOCUMENT',
|
||||
READ_MEDIA = 'ohos.permission.READ_MEDIA',
|
||||
WRITE_MEDIA = 'ohos.permission.WRITE_MEDIA',
|
||||
APP_TRACKING_CONSENT = 'ohos.permission.APP_TRACKING_CONSENT',
|
||||
GET_INSTALLED_BUNDLE_LIST = 'ohos.permission.GET_INSTALLED_BUNDLE_LIST',
|
||||
DISTRIBUTED_DATASYNC = 'ohos.permission.DISTRIBUTED_DATASYNC',
|
||||
ACCESS_BLUETOOTH = 'ohos.permission.ACCESS_BLUETOOTH',
|
||||
READ_PASTEBOARD = 'ohos.permission.READ_PASTEBOARD',
|
||||
READ_WRITE_DOWNLOAD_DIRECTORY = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY',
|
||||
READ_WRITE_DESKTOP_DIRECTORY = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY',
|
||||
READ_WRITE_DOCUMENTS_DIRECTORY = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY',
|
||||
ACCESS_NEARLINK = 'ohos.permission.ACCESS_NEARLINK'
|
||||
}
|
||||
|
||||
export enum PermissionGroup {
|
||||
LOCATION = 'LOCATION',
|
||||
CAMERA = 'CAMERA',
|
||||
MICROPHONE = 'MICROPHONE',
|
||||
CONTACTS = 'CONTACTS',
|
||||
CALENDAR = 'CALENDAR',
|
||||
SPORT = 'SPORT',
|
||||
HEALTH = 'HEALTH',
|
||||
IMAGE_AND_VIDEOS = 'IMAGE_AND_VIDEOS',
|
||||
AUDIOS = 'AUDIOS',
|
||||
DOCUMENTS = 'DOCUMENTS',
|
||||
ADS = 'ADS',
|
||||
GET_INSTALLED_BUNDLE_LIST = 'GET_INSTALLED_BUNDLE_LIST',
|
||||
DISTRIBUTED_DATASYNC = 'DISTRIBUTED_DATASYNC',
|
||||
BLUETOOTH = 'BLUETOOTH',
|
||||
PASTEBOARD = 'PASTEBOARD',
|
||||
FOLDER = 'FOLDER',
|
||||
NEARLINK = 'NEARLINK',
|
||||
OTHER = 'OTHER'
|
||||
}
|
||||
|
||||
export enum ButtonStatus {
|
||||
ALLOW = 'ALLOW',
|
||||
DENY = 'DENY',
|
||||
CANCEL = 'CANCEL',
|
||||
THIS_TIME_ONLY = 'THIS_TIME_ONLY',
|
||||
ALLOW_THIS_TIME = 'ALLOW_THIS_TIME',
|
||||
ALLOW_ONLY_DURING_USE = 'ALLOW_ONLY_DURING_USE'
|
||||
}
|
@ -14,107 +14,117 @@
|
||||
*/
|
||||
|
||||
import { PermissionInfo, GroupInfo } from './typedef';
|
||||
import { Permission, PermissionGroup, ButtonStatus } from './definition';
|
||||
|
||||
export const permissionGroups: PermissionInfo[] = [
|
||||
new PermissionInfo('ohos.permission.LOCATION_IN_BACKGROUND', 'LOCATION', $r('sys.string.ohos_lab_location_in_background'), 0),
|
||||
new PermissionInfo('ohos.permission.APPROXIMATELY_LOCATION', 'LOCATION', $r('sys.string.ohos_lab_approximately_location'), 0),
|
||||
new PermissionInfo('ohos.permission.LOCATION', 'LOCATION', $r('sys.string.ohos_lab_location'), 0),
|
||||
new PermissionInfo('ohos.permission.CAMERA', 'CAMERA', $r('sys.string.ohos_lab_camera'), 1),
|
||||
new PermissionInfo('ohos.permission.MICROPHONE', 'MICROPHONE', $r('sys.string.ohos_lab_microphone'), 2),
|
||||
new PermissionInfo('ohos.permission.READ_CONTACTS', 'CONTACTS', $r('sys.string.ohos_lab_read_contacts'), 3, 'app.string.enable_description_read_contacts', $r('app.string.forbidden_description_read_contacts')),
|
||||
new PermissionInfo('ohos.permission.WRITE_CONTACTS', 'CONTACTS', $r('sys.string.ohos_lab_write_contacts'), 3, 'app.string.enable_description_write_contacts', $r('app.string.forbidden_description_write_contacts')),
|
||||
new PermissionInfo('ohos.permission.READ_CALENDAR', 'CALENDAR', $r('sys.string.ohos_lab_read_calendar'), 4, 'app.string.enable_description_read_calendar', $r('app.string.forbidden_description_read_calendar')),
|
||||
new PermissionInfo('ohos.permission.WRITE_CALENDAR', 'CALENDAR', $r('sys.string.ohos_lab_write_calendar'), 4, 'app.string.enable_description_write_calendar', $r('app.string.forbidden_description_write_calendar')),
|
||||
new PermissionInfo('ohos.permission.READ_WHOLE_CALENDAR', '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')),
|
||||
new PermissionInfo('ohos.permission.WRITE_WHOLE_CALENDAR', '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')),
|
||||
new PermissionInfo('ohos.permission.ACTIVITY_MOTION', 'SPORT', $r('sys.string.ohos_lab_activity_motion'), 5),
|
||||
new PermissionInfo('ohos.permission.READ_HEALTH_DATA', 'HEALTH', $r('sys.string.ohos_lab_read_health_data'), 6),
|
||||
new PermissionInfo('ohos.permission.READ_IMAGEVIDEO', 'IMAGE_AND_VIDEOS', $r('sys.string.ohos_desc_read_imagevideo'), 8),
|
||||
new PermissionInfo('ohos.permission.WRITE_IMAGEVIDEO', 'IMAGE_AND_VIDEOS', $r('sys.string.ohos_desc_write_imagevideo'), 8),
|
||||
new PermissionInfo('ohos.permission.MEDIA_LOCATION', 'IMAGE_AND_VIDEOS', $r('sys.string.ohos_lab_media_location'), 8),
|
||||
new PermissionInfo('ohos.permission.READ_AUDIO', 'AUDIOS', $r('sys.string.ohos_desc_read_audio'), 9),
|
||||
new PermissionInfo('ohos.permission.WRITE_AUDIO', 'AUDIOS', $r('sys.string.ohos_desc_write_audio'), 9),
|
||||
new PermissionInfo('ohos.permission.READ_DOCUMENT', 'DOCUMENTS', $r('sys.string.ohos_desc_read_document'), 10),
|
||||
new PermissionInfo('ohos.permission.WRITE_DOCUMENT', 'DOCUMENTS', $r('sys.string.ohos_desc_write_document'), 10),
|
||||
new PermissionInfo('ohos.permission.READ_MEDIA', 'DOCUMENTS', $r('sys.string.ohos_lab_read_media'), 10),
|
||||
new PermissionInfo('ohos.permission.WRITE_MEDIA', 'DOCUMENTS', $r('sys.string.ohos_lab_write_media'), 10),
|
||||
new PermissionInfo('ohos.permission.APP_TRACKING_CONSENT', 'ADS', $r('sys.string.ohos_lab_app_tracking_consent'), 11),
|
||||
new PermissionInfo('ohos.permission.GET_INSTALLED_BUNDLE_LIST', 'GET_INSTALLED_BUNDLE_LIST', $r('sys.string.ohos_lab_get_installed_bundle_list'), 12),
|
||||
new PermissionInfo('ohos.permission.DISTRIBUTED_DATASYNC', 'DISTRIBUTED_DATASYNC', $r('sys.string.ohos_lab_distributed_datasync'), 13),
|
||||
new PermissionInfo('ohos.permission.ACCESS_BLUETOOTH', 'BLUETOOTH', $r('sys.string.ohos_lab_access_bluetooth'), 14),
|
||||
new PermissionInfo('ohos.permission.READ_PASTEBOARD', 'PASTEBOARD', $r('sys.string.ohos_lab_read_pasteboard'), 15),
|
||||
new PermissionInfo('ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY', 'FOLDER', $r('sys.string.ohos_lab_read_write_download_directory'), 16),
|
||||
new PermissionInfo('ohos.permission.READ_WRITE_DESKTOP_DIRECTORY', 'FOLDER', $r('sys.string.ohos_lab_read_write_desktop_directory'), 16),
|
||||
new PermissionInfo('ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY', 'FOLDER', $r('sys.string.ohos_lab_read_write_documents_directory'), 16),
|
||||
new PermissionInfo('ohos.permission.ACCESS_NEARLINK', 'NEARLINK', $r('sys.string.ohos_lab_access_nearlink'), 17)
|
||||
new PermissionInfo(Permission.LOCATION_IN_BACKGROUND, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_location_in_background'), 0),
|
||||
new PermissionInfo(Permission.APPROXIMATELY_LOCATION, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_approximately_location'), 0),
|
||||
new PermissionInfo(Permission.LOCATION, PermissionGroup.LOCATION, $r('sys.string.ohos_lab_location'), 0),
|
||||
new PermissionInfo(Permission.CAMERA, PermissionGroup.CAMERA, $r('sys.string.ohos_lab_camera'), 1),
|
||||
new PermissionInfo(Permission.MICROPHONE, PermissionGroup.MICROPHONE, $r('sys.string.ohos_lab_microphone'), 2),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
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')),
|
||||
new PermissionInfo(Permission.ACTIVITY_MOTION, PermissionGroup.SPORT, $r('sys.string.ohos_lab_activity_motion'), 5),
|
||||
new PermissionInfo(Permission.READ_HEALTH_DATA, PermissionGroup.HEALTH, $r('sys.string.ohos_lab_read_health_data'), 6),
|
||||
new PermissionInfo(Permission.READ_IMAGEVIDEO, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_desc_read_imagevideo'), 8),
|
||||
new PermissionInfo(Permission.WRITE_IMAGEVIDEO, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_desc_write_imagevideo'), 8),
|
||||
new PermissionInfo(Permission.MEDIA_LOCATION, PermissionGroup.IMAGE_AND_VIDEOS, $r('sys.string.ohos_lab_media_location'), 8),
|
||||
new PermissionInfo(Permission.READ_AUDIO, PermissionGroup.AUDIOS, $r('sys.string.ohos_desc_read_audio'), 9),
|
||||
new PermissionInfo(Permission.WRITE_AUDIO, PermissionGroup.AUDIOS, $r('sys.string.ohos_desc_write_audio'), 9),
|
||||
new PermissionInfo(Permission.READ_DOCUMENT, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_desc_read_document'), 10),
|
||||
new PermissionInfo(Permission.WRITE_DOCUMENT, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_desc_write_document'), 10),
|
||||
new PermissionInfo(Permission.READ_MEDIA, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_read_media'), 10),
|
||||
new PermissionInfo(Permission.WRITE_MEDIA, PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_write_media'), 10),
|
||||
new PermissionInfo(Permission.APP_TRACKING_CONSENT, PermissionGroup.ADS, $r('sys.string.ohos_lab_app_tracking_consent'), 11),
|
||||
new PermissionInfo(Permission.GET_INSTALLED_BUNDLE_LIST, PermissionGroup.GET_INSTALLED_BUNDLE_LIST, $r('sys.string.ohos_lab_get_installed_bundle_list'), 12),
|
||||
new PermissionInfo(Permission.DISTRIBUTED_DATASYNC, PermissionGroup.DISTRIBUTED_DATASYNC, $r('sys.string.ohos_lab_distributed_datasync'), 13),
|
||||
new PermissionInfo(Permission.ACCESS_BLUETOOTH, PermissionGroup.BLUETOOTH, $r('sys.string.ohos_lab_access_bluetooth'), 14),
|
||||
new PermissionInfo(Permission.READ_PASTEBOARD, PermissionGroup.PASTEBOARD, $r('sys.string.ohos_lab_read_pasteboard'), 15),
|
||||
new PermissionInfo(Permission.READ_WRITE_DOWNLOAD_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_download_directory'), 16),
|
||||
new PermissionInfo(Permission.READ_WRITE_DESKTOP_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_desktop_directory'), 16),
|
||||
new PermissionInfo(Permission.READ_WRITE_DOCUMENTS_DIRECTORY, PermissionGroup.FOLDER, $r('sys.string.ohos_lab_read_write_documents_directory'), 16),
|
||||
new PermissionInfo(Permission.ACCESS_NEARLINK, PermissionGroup.NEARLINK, $r('sys.string.ohos_lab_access_nearlink'), 17)
|
||||
]
|
||||
|
||||
export const groups: GroupInfo[] = [
|
||||
new GroupInfo('LOCATION', $r('app.string.groupName_location'), 'app.string.group_label_location', $r('app.media.ic_public_gps'), [], '', ['ohos.permission.LOCATION_IN_BACKGROUND', 'ohos.permission.APPROXIMATELY_LOCATION', 'ohos.permission.LOCATION'], true, 'app.string.enable_description_location', $r('app.string.forbidden_description_location')),
|
||||
new GroupInfo('CAMERA', $r('app.string.groupName_camera'), 'app.string.group_label_camera', $r('app.media.ic_public_camera'), [], '', ['ohos.permission.CAMERA'], true, 'app.string.enable_description_camera', $r('app.string.forbidden_description_camera')),
|
||||
new GroupInfo('MICROPHONE', $r('app.string.groupName_microphone'), 'app.string.group_label_microphone', $r('app.media.ic_public_voice'), [], '', ['ohos.permission.MICROPHONE'], true, 'app.string.enable_description_microphone', $r('app.string.forbidden_description_microphone')),
|
||||
new GroupInfo('CONTACTS', $r('app.string.groupName_contacts'), 'app.string.group_label_contacts', $r('app.media.ic_public_contacts_group'), [], '', ['ohos.permission.READ_CONTACTS', 'ohos.permission.WRITE_CONTACTS'], false),
|
||||
new GroupInfo('CALENDAR', $r('app.string.groupName_calendar'), 'app.string.group_label_calendar', $r('app.media.ic_public_calendar'), [], '', ['ohos.permission.READ_CALENDAR', 'ohos.permission.WRITE_CALENDAR', 'ohos.permission.READ_WHOLE_CALENDAR', 'ohos.permission.WRITE_WHOLE_CALENDAR'], true),
|
||||
new GroupInfo('SPORT', $r('app.string.groupName_sport'), 'app.string.group_label_sport', $r('app.media.ic_sport'), [], '', ['ohos.permission.ACTIVITY_MOTION'], true, 'app.string.enable_description_sport', $r('app.string.forbidden_description_sport')),
|
||||
new GroupInfo('HEALTH', $r('app.string.groupName_health'), 'app.string.group_label_health', $r('app.media.ic_ssensor'), [], '', ['ohos.permission.READ_HEALTH_DATA'], true, 'app.string.enable_description_health', $r('app.string.forbidden_description_health')),
|
||||
new GroupInfo('OTHER', $r('app.string.groupName_other'), '', $r('app.media.ic_more'), [], '', [], true),
|
||||
new GroupInfo('IMAGE_AND_VIDEOS', $r('sys.string.ohos_lab_read_imagevideo'), 'app.string.group_label_image_and_videos', $r('app.media.ic_public_picture'), [], '', ['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO', 'ohos.permission.MEDIA_LOCATION'], false, 'app.string.enable_description_image', $r('app.string.forbidden_description_image')),
|
||||
new GroupInfo('AUDIOS', $r('sys.string.ohos_lab_read_audio'), 'app.string.group_label_audios', $r('app.media.ic_public_audio'), [], '', ['ohos.permission.READ_AUDIO', 'ohos.permission.WRITE_AUDIO'], false, 'app.string.enable_description_audios', $r('app.string.forbidden_description_audios')),
|
||||
new GroupInfo('DOCUMENTS', $r('sys.string.ohos_lab_read_document'), 'app.string.group_label_document', $r('app.media.ic_public_folder'), [], '', ['ohos.permission.READ_DOCUMENT', 'ohos.permission.WRITE_DOCUMENT', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA'], false, 'app.string.enable_description_documents', $r('app.string.forbidden_description_documents')),
|
||||
new GroupInfo('ADS', $r('app.string.groupName_ADS'), 'app.string.group_label_ADS', $r('app.media.track'), [], '', ['ohos.permission.APP_TRACKING_CONSENT'], false, 'app.string.enable_description_ADS', $r('app.string.forbidden_description_ADS')),
|
||||
new GroupInfo('GET_INSTALLED_BUNDLE_LIST', $r('app.string.groupName_appList'), 'app.string.group_label_appList', $r('app.media.ic_public_app_list'), [], '', ['ohos.permission.GET_INSTALLED_BUNDLE_LIST'], false, 'app.string.enable_description_appList', $r('app.string.forbidden_description_appList')),
|
||||
new GroupInfo('DISTRIBUTED_DATASYNC', $r('app.string.multi_device_collaboration'), 'app.string.group_label_distributed_datasync', $r('app.media.ic_multi_device_vector'), [], '', ['ohos.permission.DISTRIBUTED_DATASYNC'], false, 'app.string.enable_description_distributed_datasync', $r('app.string.forbidden_description_distributed_datasync')),
|
||||
new GroupInfo('BLUETOOTH', $r('app.string.groupName_bluetooth'), 'app.string.group_label_bluetooth', $r('app.media.ic_public_bluetooth'), [], '', ['ohos.permission.ACCESS_BLUETOOTH'], false, 'app.string.enable_description_bluetooth', $r('app.string.forbidden_description_bluetooth')),
|
||||
new GroupInfo('PASTEBOARD', $r('app.string.groupName_pasteboard'), 'app.string.group_label_pasteboard', $r('app.media.ic_clipboard'), [], '', ['ohos.permission.READ_PASTEBOARD'], false, 'app.string.enable_description_pasteboard', $r('app.string.forbidden_description_pasteboard')),
|
||||
new GroupInfo('FOLDER', $r('app.string.groupName_folder'), 'app.string.group_label_folder', $r('app.media.ic_public_folder'), [], '', ['ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY', 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY', 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY'], false, 'app.string.enable_description_folder', $r('app.string.forbidden_description_folder')),
|
||||
new GroupInfo('NEARLINK', $r('app.string.groupName_nearLink'), 'app.string.group_label_nearLink', $r('app.media.ic_nearLink'), [], '', ['ohos.permission.ACCESS_NEARLINK'], false, 'app.string.enable_description_nearLink', $r('app.string.forbidden_description_nearLink'))
|
||||
new GroupInfo(PermissionGroup.LOCATION, $r('app.string.groupName_location'), 'app.string.group_label_location', $r('app.media.ic_public_gps'), [], '', ['ohos.permission.LOCATION_IN_BACKGROUND', 'ohos.permission.APPROXIMATELY_LOCATION', 'ohos.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')),
|
||||
new GroupInfo(PermissionGroup.CAMERA, $r('app.string.groupName_camera'), 'app.string.group_label_camera', $r('app.media.ic_public_camera'), [], '', ['ohos.permission.CAMERA'], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_camera', $r('app.string.forbidden_description_camera')),
|
||||
new GroupInfo(PermissionGroup.MICROPHONE, $r('app.string.groupName_microphone'), 'app.string.group_label_microphone', $r('app.media.ic_public_voice'), [], '', ['ohos.permission.MICROPHONE'], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_microphone', $r('app.string.forbidden_description_microphone')),
|
||||
new GroupInfo(PermissionGroup.CONTACTS, $r('app.string.groupName_contacts'), 'app.string.group_label_contacts', $r('app.media.ic_public_contacts_group'), [], '', ['ohos.permission.READ_CONTACTS', 'ohos.permission.WRITE_CONTACTS'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false),
|
||||
new GroupInfo(PermissionGroup.CALENDAR, $r('app.string.groupName_calendar'), 'app.string.group_label_calendar', $r('app.media.ic_public_calendar'), [], '', ['ohos.permission.READ_CALENDAR', 'ohos.permission.WRITE_CALENDAR', 'ohos.permission.READ_WHOLE_CALENDAR', 'ohos.permission.WRITE_WHOLE_CALENDAR'], [ButtonStatus.DENY, ButtonStatus.ALLOW], true),
|
||||
new GroupInfo(PermissionGroup.SPORT, $r('app.string.groupName_sport'), 'app.string.group_label_sport', $r('app.media.ic_sport'), [], '', ['ohos.permission.ACTIVITY_MOTION'], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_sport', $r('app.string.forbidden_description_sport')),
|
||||
new GroupInfo(PermissionGroup.HEALTH, $r('app.string.groupName_health'), 'app.string.group_label_health', $r('app.media.ic_ssensor'), [], '', ['ohos.permission.READ_HEALTH_DATA'], [ButtonStatus.DENY, ButtonStatus.ALLOW], true, 'app.string.enable_description_health', $r('app.string.forbidden_description_health')),
|
||||
new GroupInfo(PermissionGroup.OTHER, $r('app.string.groupName_other'), '', $r('app.media.ic_more'), [], '', [], [ButtonStatus.DENY, ButtonStatus.ALLOW], true),
|
||||
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'), [], '', ['ohos.permission.READ_IMAGEVIDEO', 'ohos.permission.WRITE_IMAGEVIDEO', 'ohos.permission.MEDIA_LOCATION'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_image', $r('app.string.forbidden_description_image')),
|
||||
new GroupInfo(PermissionGroup.AUDIOS, $r('sys.string.ohos_lab_read_audio'), 'app.string.group_label_audios', $r('app.media.ic_public_audio'), [], '', ['ohos.permission.READ_AUDIO', 'ohos.permission.WRITE_AUDIO'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_audios', $r('app.string.forbidden_description_audios')),
|
||||
new GroupInfo(PermissionGroup.DOCUMENTS, $r('sys.string.ohos_lab_read_document'), 'app.string.group_label_document', $r('app.media.ic_public_folder'), [], '', ['ohos.permission.READ_DOCUMENT', 'ohos.permission.WRITE_DOCUMENT', 'ohos.permission.READ_MEDIA', 'ohos.permission.WRITE_MEDIA'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_documents', $r('app.string.forbidden_description_documents')),
|
||||
new GroupInfo(PermissionGroup.ADS, $r('app.string.groupName_ADS'), 'app.string.group_label_ADS', $r('app.media.track'), [], '', ['ohos.permission.APP_TRACKING_CONSENT'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_ADS', $r('app.string.forbidden_description_ADS')),
|
||||
new GroupInfo(PermissionGroup.GET_INSTALLED_BUNDLE_LIST, $r('app.string.groupName_appList'), 'app.string.group_label_appList', $r('app.media.ic_public_app_list'), [], '', ['ohos.permission.GET_INSTALLED_BUNDLE_LIST'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_appList', $r('app.string.forbidden_description_appList')),
|
||||
new GroupInfo(PermissionGroup.DISTRIBUTED_DATASYNC, $r('app.string.multi_device_collaboration'), 'app.string.group_label_distributed_datasync', $r('app.media.ic_multi_device_vector'), [], '', ['ohos.permission.DISTRIBUTED_DATASYNC'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_distributed_datasync', $r('app.string.forbidden_description_distributed_datasync')),
|
||||
new GroupInfo(PermissionGroup.BLUETOOTH, $r('app.string.groupName_bluetooth'), 'app.string.group_label_bluetooth', $r('app.media.ic_public_bluetooth'), [], '', ['ohos.permission.ACCESS_BLUETOOTH'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_bluetooth', $r('app.string.forbidden_description_bluetooth')),
|
||||
new GroupInfo(PermissionGroup.PASTEBOARD, $r('app.string.groupName_pasteboard'), 'app.string.group_label_pasteboard', $r('app.media.ic_clipboard'), [], '', ['ohos.permission.READ_PASTEBOARD'], [ButtonStatus.DENY, ButtonStatus.THIS_TIME_ONLY], false, 'app.string.enable_description_pasteboard', $r('app.string.forbidden_description_pasteboard')),
|
||||
new GroupInfo(PermissionGroup.FOLDER, $r('app.string.groupName_folder'), 'app.string.group_label_folder', $r('app.media.ic_public_folder'), [], '', ['ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY', 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY', 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_folder', $r('app.string.forbidden_description_folder')),
|
||||
new GroupInfo(PermissionGroup.NEARLINK, $r('app.string.groupName_nearLink'), 'app.string.group_label_nearLink', $r('app.media.ic_nearLink'), [], '', ['ohos.permission.ACCESS_NEARLINK'], [ButtonStatus.DENY, ButtonStatus.ALLOW], false, 'app.string.enable_description_nearLink', $r('app.string.forbidden_description_nearLink'))
|
||||
];
|
||||
|
||||
export const userGrantPermissions: string[] = [
|
||||
'ohos.permission.LOCATION_IN_BACKGROUND',
|
||||
'ohos.permission.APPROXIMATELY_LOCATION',
|
||||
'ohos.permission.LOCATION',
|
||||
'ohos.permission.CAMERA',
|
||||
'ohos.permission.MICROPHONE',
|
||||
'ohos.permission.READ_CONTACTS',
|
||||
'ohos.permission.WRITE_CONTACTS',
|
||||
'ohos.permission.MEDIA_LOCATION',
|
||||
'ohos.permission.READ_MEDIA',
|
||||
'ohos.permission.WRITE_MEDIA',
|
||||
'ohos.permission.READ_CALENDAR',
|
||||
'ohos.permission.WRITE_CALENDAR',
|
||||
'ohos.permission.ACTIVITY_MOTION',
|
||||
'ohos.permission.READ_HEALTH_DATA',
|
||||
'ohos.permission.READ_IMAGEVIDEO',
|
||||
'ohos.permission.WRITE_IMAGEVIDEO',
|
||||
'ohos.permission.READ_AUDIO',
|
||||
'ohos.permission.WRITE_AUDIO',
|
||||
'ohos.permission.READ_DOCUMENT',
|
||||
'ohos.permission.WRITE_DOCUMENT',
|
||||
'ohos.permission.READ_WHOLE_CALENDAR',
|
||||
'ohos.permission.WRITE_WHOLE_CALENDAR',
|
||||
'ohos.permission.APP_TRACKING_CONSENT',
|
||||
'ohos.permission.GET_INSTALLED_BUNDLE_LIST',
|
||||
'ohos.permission.DISTRIBUTED_DATASYNC',
|
||||
'ohos.permission.ACCESS_BLUETOOTH',
|
||||
'ohos.permission.READ_PASTEBOARD',
|
||||
'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY',
|
||||
'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY',
|
||||
'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY',
|
||||
'ohos.permission.ACCESS_NEARLINK'
|
||||
Permission.LOCATION_IN_BACKGROUND,
|
||||
Permission.APPROXIMATELY_LOCATION,
|
||||
Permission.LOCATION,
|
||||
Permission.CAMERA,
|
||||
Permission.MICROPHONE,
|
||||
Permission.READ_CONTACTS,
|
||||
Permission.WRITE_CONTACTS,
|
||||
Permission.READ_CALENDAR,
|
||||
Permission.WRITE_CALENDAR,
|
||||
Permission.READ_WHOLE_CALENDAR,
|
||||
Permission.WRITE_WHOLE_CALENDAR,
|
||||
Permission.ACTIVITY_MOTION,
|
||||
Permission.READ_HEALTH_DATA,
|
||||
Permission.READ_IMAGEVIDEO,
|
||||
Permission.WRITE_IMAGEVIDEO,
|
||||
Permission.MEDIA_LOCATION,
|
||||
Permission.READ_AUDIO,
|
||||
Permission.WRITE_AUDIO,
|
||||
Permission.READ_DOCUMENT,
|
||||
Permission.WRITE_DOCUMENT,
|
||||
Permission.READ_MEDIA,
|
||||
Permission.WRITE_MEDIA,
|
||||
Permission.APP_TRACKING_CONSENT,
|
||||
Permission.GET_INSTALLED_BUNDLE_LIST,
|
||||
Permission.DISTRIBUTED_DATASYNC,
|
||||
Permission.ACCESS_BLUETOOTH,
|
||||
Permission.READ_PASTEBOARD,
|
||||
Permission.READ_WRITE_DOWNLOAD_DIRECTORY,
|
||||
Permission.READ_WRITE_DESKTOP_DIRECTORY,
|
||||
Permission.READ_WRITE_DOCUMENTS_DIRECTORY,
|
||||
Permission.ACCESS_NEARLINK
|
||||
];
|
||||
|
||||
export const buttonResource: Map<ButtonStatus, Resource> = new Map([
|
||||
[ButtonStatus.ALLOW, $r('app.string.allow')],
|
||||
[ButtonStatus.DENY, $r('app.string.ban')],
|
||||
[ButtonStatus.CANCEL, $r('app.string.cancel')],
|
||||
[ButtonStatus.THIS_TIME_ONLY, $r('app.string.This_time_only')],
|
||||
[ButtonStatus.ALLOW_THIS_TIME, $r('app.string.allow_this_time')],
|
||||
[ButtonStatus.ALLOW_ONLY_DURING_USE, $r('app.string.allowed_only_during_use')]
|
||||
])
|
||||
|
||||
export const showSubPermissionsGroup: string[] = [
|
||||
'CALENDAR',
|
||||
'CONTACTS',
|
||||
PermissionGroup.CALENDAR,
|
||||
PermissionGroup.CONTACTS,
|
||||
];
|
||||
|
||||
export const polymorphismGroup: string[] = [
|
||||
'LOCATION',
|
||||
'FOLDER'
|
||||
PermissionGroup.LOCATION,
|
||||
PermissionGroup.FOLDER
|
||||
]
|
||||
|
||||
export const globalGroup: string[] = [
|
||||
'MICROPHONE',
|
||||
'CAMERA'
|
||||
PermissionGroup.MICROPHONE,
|
||||
PermissionGroup.CAMERA
|
||||
]
|
@ -13,6 +13,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { Permissions } from '@ohos.abilityAccessCtrl';
|
||||
import { ButtonStatus } from './definition';
|
||||
|
||||
export class AppInfo {
|
||||
public bundleName: string
|
||||
@ -257,6 +258,7 @@ export class GroupInfo {
|
||||
public description: Array<ResourceStr>
|
||||
public reason: string
|
||||
public permissions: Array<Permissions>
|
||||
public buttons: Array<ButtonStatus>
|
||||
public isShow: boolean
|
||||
public enableDescription?: string
|
||||
public forbiddenDescription?: ResourceStr
|
||||
@ -269,6 +271,7 @@ export class GroupInfo {
|
||||
description: Array<ResourceStr>,
|
||||
reason: string,
|
||||
permissions: Array<Permissions>,
|
||||
buttons: Array<ButtonStatus>,
|
||||
isShow: boolean,
|
||||
enableDescription?: string,
|
||||
forbiddenDescription?: ResourceStr
|
||||
@ -280,6 +283,7 @@ export class GroupInfo {
|
||||
this.description = description;
|
||||
this.reason = reason;
|
||||
this.permissions = permissions;
|
||||
this.buttons = buttons;
|
||||
this.isShow = isShow;
|
||||
this.enableDescription = enableDescription;
|
||||
this.forbiddenDescription = forbiddenDescription;
|
||||
|
@ -141,6 +141,7 @@ export default class Constants {
|
||||
public static DIVIDER_MARGIN_RIGHT_APPLICATION = 68;
|
||||
public static DIALOG_TITLE_MAX_SCALE = 2;
|
||||
public static DIALOG_TEXT_MAX_SCALE = 3.2;
|
||||
public static DIALOG_BUTTON_MAX_WIDTH = 135;
|
||||
|
||||
// application-secondary, authority-secondary
|
||||
public static FLEX_MARGIN_TOP = 8;
|
||||
|
@ -24,13 +24,7 @@ import Constants from '../common/utils/constant';
|
||||
import { Log, verifyAccessToken, getGroupIdByPermission } from '../common/utils/utils';
|
||||
import { PermissionObj, AppInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
const BACKGROUND_LOCATION_PERMISSION = 'ohos.permission.LOCATION_IN_BACKGROUND';
|
||||
const DOWNLOAD_PERMISSION = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY';
|
||||
const DESKTOP_PERMISSION = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY';
|
||||
const DOCUMENTS_PERMISSION = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY';
|
||||
import { Permission } from '../common/model/definition';
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
@ -213,14 +207,18 @@ struct appNamePlusPage {
|
||||
if (group === 'LOCATION') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.applicationInfo.tokenId, FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(
|
||||
this.applicationInfo.tokenId, Permission.APPROXIMATELY_LOCATION
|
||||
);
|
||||
fuzzyState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.isGranted = Constants.PERMISSION_ALLOWED_ONLY_DURING_USE : null;
|
||||
let backgroundState =
|
||||
acManager.verifyAccessTokenSync(this.applicationInfo.tokenId, BACKGROUND_LOCATION_PERMISSION);
|
||||
let backgroundState = acManager.verifyAccessTokenSync(
|
||||
this.applicationInfo.tokenId, Permission.LOCATION_IN_BACKGROUND
|
||||
);
|
||||
backgroundState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.isGranted = Constants.PERMISSION_ALLOW : null;
|
||||
await acManager.getPermissionFlags(this.applicationInfo.tokenId, FUZZY_LOCATION_PERMISSION ).then(flag => {
|
||||
await acManager.getPermissionFlags(this.applicationInfo.tokenId, Permission.APPROXIMATELY_LOCATION )
|
||||
.then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.isGranted = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
} catch (err) {
|
||||
@ -237,13 +235,13 @@ struct appNamePlusPage {
|
||||
}
|
||||
if (group === 'FOLDER' && res === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
this.folderStatus[0] = true;
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
this.folderStatus[1] = true;
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
this.folderStatus[2] = true;
|
||||
break;
|
||||
}
|
||||
|
@ -24,14 +24,8 @@ import { Log, getPermissionLabel } from '../common/utils/utils';
|
||||
import Constants from '../common/utils/constant';
|
||||
import { MediaDocObj, RouterParams3, AppInfo, CheckboxInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
import { Permission } from '../common/model/definition';
|
||||
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
const BACKGROUND_LOCATION_PERMISSION = 'ohos.permission.LOCATION_IN_BACKGROUND';
|
||||
const DOWNLOAD_PERMISSION = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY';
|
||||
const DESKTOP_PERMISSION = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY';
|
||||
const DOCUMENTS_PERMISSION = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY';
|
||||
const PASTE = 'ohos.permission.READ_PASTEBOARD';
|
||||
const showPrecise: number[] = [Constants.PERMISSION_ALLOW, Constants.PERMISSION_ALLOWED_ONLY_DURING_USE];
|
||||
let accessTokenId: number = 0;
|
||||
let reqPermissionInfo: bundleManager.ReqPermissionDetail;
|
||||
@ -110,13 +104,13 @@ struct mediaDocumentPage {
|
||||
}
|
||||
if (this.currentGroup === 'FOLDER' && res === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
folderStatus[0] = true;
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
folderStatus[1] = true;
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
folderStatus[2] = true;
|
||||
break;
|
||||
}
|
||||
@ -133,7 +127,7 @@ struct mediaDocumentPage {
|
||||
if (this.currentGroup === 'PASTEBOARD') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
acManager.getPermissionFlags(this.tokenId, PASTE).then(flag => {
|
||||
acManager.getPermissionFlags(this.tokenId, Permission.READ_PASTEBOARD).then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.selected = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
} catch (err) {
|
||||
@ -143,15 +137,15 @@ struct mediaDocumentPage {
|
||||
if (this.currentGroup === 'LOCATION') {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.tokenId, FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(this.tokenId, Permission.APPROXIMATELY_LOCATION);
|
||||
fuzzyState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.selected = Constants.PERMISSION_ALLOWED_ONLY_DURING_USE : null;
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(this.tokenId, PRECISE_LOCATION_PERMISSION);
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(this.tokenId, Permission.LOCATION);
|
||||
this.accurateIsOn = (accurateStatus == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) ? true : false;
|
||||
let backgroundState = acManager.verifyAccessTokenSync(this.tokenId, BACKGROUND_LOCATION_PERMISSION);
|
||||
let backgroundState = acManager.verifyAccessTokenSync(this.tokenId, Permission.LOCATION_IN_BACKGROUND);
|
||||
backgroundState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.selected = Constants.PERMISSION_ALLOW : null;
|
||||
acManager.getPermissionFlags(this.tokenId, FUZZY_LOCATION_PERMISSION ).then(flag => {
|
||||
acManager.getPermissionFlags(this.tokenId, Permission.APPROXIMATELY_LOCATION ).then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ? this.selected = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
} catch (err) {
|
||||
@ -238,11 +232,11 @@ struct mediaDocumentItem {
|
||||
|
||||
getCheckboxInfo(permission: Permissions): CheckboxInfo {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Download_folder'), 0);
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Desktop_folder'), 1);
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
return new CheckboxInfo($r('app.string.Document_folder'), 2);
|
||||
default:
|
||||
return new CheckboxInfo($r('app.string.Download_folder'), 0);
|
||||
@ -262,16 +256,16 @@ struct mediaDocumentItem {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj($r('app.string.per_inquiry'), this.permissions, Constants.PERMISSION_ONLY_THIS_TIME)
|
||||
);
|
||||
if (this.permissions.includes(BACKGROUND_LOCATION_PERMISSION)) {
|
||||
if (this.permissions.includes(Permission.LOCATION_IN_BACKGROUND)) {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj($r('app.string.always_allow'), this.permissions, Constants.PERMISSION_ALLOW)
|
||||
);
|
||||
}
|
||||
if (this.permissions.includes(FUZZY_LOCATION_PERMISSION)) {
|
||||
if (this.permissions.includes(Permission.APPROXIMATELY_LOCATION)) {
|
||||
this.mediaDocListItem.push(
|
||||
new MediaDocObj(
|
||||
$r('app.string.allowed_only_during_use'),
|
||||
[FUZZY_LOCATION_PERMISSION],
|
||||
[Permission.APPROXIMATELY_LOCATION],
|
||||
Constants.PERMISSION_ALLOWED_ONLY_DURING_USE
|
||||
)
|
||||
);
|
||||
@ -333,10 +327,11 @@ struct mediaDocumentItem {
|
||||
this.version = res.versionName;
|
||||
accessTokenId = res.appInfo.accessTokenId;
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, PRECISE_LOCATION_PERMISSION);
|
||||
let accurateStatus = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, Permission.LOCATION);
|
||||
this.accurateIsOn = (accurateStatus == abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED) ? true : false;
|
||||
try {
|
||||
let getFlagPermission = this.currentGroup === 'LOCATION' ? FUZZY_LOCATION_PERMISSION : this.permissions[0];
|
||||
let getFlagPermission =
|
||||
this.currentGroup === 'LOCATION' ? Permission.APPROXIMATELY_LOCATION : this.permissions[0];
|
||||
acManager.getPermissionFlags(res.appInfo.accessTokenId, getFlagPermission).then((flag) => {
|
||||
Log.info(`getPermissionFlags success, data->${JSON.stringify(flag)}`);
|
||||
this.isRisk = (flag == Constants.PERMISSION_POLICY_FIXED) ? true : false;
|
||||
@ -525,19 +520,19 @@ struct mediaDocumentItem {
|
||||
this.selected = item.index;
|
||||
item.permissions.forEach((permission): boolean => {
|
||||
if (item.index === Constants.PERMISSION_ALLOW) {
|
||||
if (permission === PRECISE_LOCATION_PERMISSION) {
|
||||
if (permission === Permission.LOCATION) {
|
||||
return false;
|
||||
}
|
||||
this.grantUserGrantedPermission(accessTokenId, permission);
|
||||
} else if (item.index === Constants.PERMISSION_BAN) {
|
||||
if (permission == PRECISE_LOCATION_PERMISSION && this.accurateIsOn) {
|
||||
if (permission == Permission.LOCATION && this.accurateIsOn) {
|
||||
this.revokeUserGrantedPermission(accessTokenId, permission, Constants.PERMISSION_FLAG);
|
||||
this.accurateIsOn = false;
|
||||
} else {
|
||||
this.revokeUserGrantedPermission(accessTokenId, permission, Constants.PERMISSION_FLAG);
|
||||
}
|
||||
} else if (item.index === Constants.PERMISSION_ONLY_THIS_TIME) {
|
||||
if (permission === PRECISE_LOCATION_PERMISSION) {
|
||||
if (permission === Permission.LOCATION) {
|
||||
return false;
|
||||
}
|
||||
this.revokeUserGrantedPermission(
|
||||
@ -546,7 +541,7 @@ struct mediaDocumentItem {
|
||||
} else if (item.index === Constants.PERMISSION_ALLOWED_ONLY_DURING_USE) {
|
||||
this.grantUserGrantedPermission(accessTokenId, permission);
|
||||
this.revokeUserGrantedPermission(
|
||||
accessTokenId, BACKGROUND_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
accessTokenId, Permission.LOCATION_IN_BACKGROUND, Constants.PERMISSION_FLAG
|
||||
);
|
||||
}
|
||||
return true;
|
||||
@ -595,7 +590,7 @@ struct mediaDocumentItem {
|
||||
endMargin: Constants.DEFAULT_MARGIN_END
|
||||
})
|
||||
|
||||
if (this.permissions.includes(PRECISE_LOCATION_PERMISSION) && showPrecise.includes(this.selected)) {
|
||||
if (this.permissions.includes(Permission.LOCATION) && showPrecise.includes(this.selected)) {
|
||||
Column() {
|
||||
Row() {
|
||||
Text($r('app.string.precise_location'))
|
||||
@ -607,15 +602,17 @@ struct mediaDocumentItem {
|
||||
.selectedColor($r('sys.color.icon_emphasize'))
|
||||
.switchPointColor($r('sys.color.comp_background_primary_contrary'))
|
||||
.onChange((isOn: boolean) => {
|
||||
let acManager = abilityAccessCtrl.createAtManager()
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
if (isOn) {
|
||||
acManager.grantUserGrantedPermission(
|
||||
accessTokenId, PRECISE_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
).then(() => { this.accurateIsOn = true })
|
||||
acManager.grantUserGrantedPermission(accessTokenId, Permission.LOCATION, Constants.PERMISSION_FLAG)
|
||||
.then(() => {
|
||||
this.accurateIsOn = true;
|
||||
})
|
||||
} else {
|
||||
acManager.revokeUserGrantedPermission(
|
||||
accessTokenId, PRECISE_LOCATION_PERMISSION, Constants.PERMISSION_FLAG
|
||||
).then(() => { this.accurateIsOn = false })
|
||||
acManager.revokeUserGrantedPermission(accessTokenId, Permission.LOCATION, Constants.PERMISSION_FLAG)
|
||||
.then(() => {
|
||||
this.accurateIsOn = false;
|
||||
})
|
||||
}
|
||||
})
|
||||
.padding({ right: 0 })
|
||||
|
@ -26,11 +26,10 @@ import { groups, userGrantPermissions, globalGroup, permissionGroups, showSubPer
|
||||
import { Log, indexValue, getPermissionGroupByName, getGroupIdByPermission, addLocalTag, sortByName } from '../common/utils/utils';
|
||||
import { AppInfo, PermissionApplications, GroupPermission, GroupInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
import { Permission } from '../common/model/definition';
|
||||
import Constants from '../common/utils/constant';
|
||||
import bundleManager from '@ohos.bundle.bundleManager';
|
||||
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
let storage = LocalStorage.getShared();
|
||||
|
||||
@Extend(Image)function customizeImage(width: number, height: number) {
|
||||
@ -272,7 +271,7 @@ struct authorityManagementPage {
|
||||
if (reqPermissionsLen > 0) {
|
||||
for (let j = 0; j < reqPermissions.length; j++) {
|
||||
let permission = reqPermissions[j];
|
||||
if ((permission == PRECISE_LOCATION_PERMISSION) && !reqPermissions.includes(FUZZY_LOCATION_PERMISSION)) {
|
||||
if ((permission == Permission.LOCATION) && !reqPermissions.includes(Permission.APPROXIMATELY_LOCATION)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
@ -26,17 +26,10 @@ import { CustomContentDialog } from '@ohos.arkui.advanced.Dialog';
|
||||
import { Log, verifyAccessToken, indexValue, sortByName } from '../common/utils/utils';
|
||||
import { ApplicationObj, GroupInfo, RouterParams1, PermissionApplications, AppInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
import { Permission, PermissionGroup } from '../common/model/definition';
|
||||
import Constants from '../common/utils/constant';
|
||||
import { polymorphismGroup, globalGroup, groups } from '../common/model/permissionGroup';
|
||||
|
||||
const CAMERA = 'CAMERA';
|
||||
const MICROPHONE = 'MICROPHONE';
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
const BACKGROUND_LOCATION_PERMISSION = 'ohos.permission.LOCATION_IN_BACKGROUND';
|
||||
const DOWNLOAD_PERMISSION = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY';
|
||||
const DESKTOP_PERMISSION = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY';
|
||||
const DOCUMENTS_PERMISSION = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY';
|
||||
const locationStatus: Resource[] = [
|
||||
$r('app.string.always_allow'),
|
||||
$r('app.string.ban'),
|
||||
@ -115,16 +108,16 @@ struct locationInfoPage {
|
||||
reqPermissions.push(item.name);
|
||||
})
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
if (this.currentGroup === 'LOCATION' && reqPermissions.includes(FUZZY_LOCATION_PERMISSION)) {
|
||||
if (this.currentGroup === 'LOCATION' && reqPermissions.includes(Permission.APPROXIMATELY_LOCATION)) {
|
||||
try {
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyState = acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, Permission.APPROXIMATELY_LOCATION);
|
||||
fuzzyState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.polymorphismIsOn[index] = Constants.PERMISSION_ALLOWED_ONLY_DURING_USE : null;
|
||||
let backgroundState =
|
||||
acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, BACKGROUND_LOCATION_PERMISSION);
|
||||
acManager.verifyAccessTokenSync(res.appInfo.accessTokenId, Permission.LOCATION_IN_BACKGROUND);
|
||||
backgroundState === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED ?
|
||||
this.polymorphismIsOn[index] = Constants.PERMISSION_ALLOW : null;
|
||||
acManager.getPermissionFlags(res.appInfo.accessTokenId, FUZZY_LOCATION_PERMISSION ).then(flag => {
|
||||
acManager.getPermissionFlags(res.appInfo.accessTokenId, Permission.APPROXIMATELY_LOCATION ).then(flag => {
|
||||
flag === Constants.PERMISSION_ALLOW_THIS_TIME ?
|
||||
this.polymorphismIsOn[index] = Constants.PERMISSION_ONLY_THIS_TIME : null;
|
||||
})
|
||||
@ -147,13 +140,13 @@ struct locationInfoPage {
|
||||
|
||||
updateFolderStatus(index: number, idx: number) {
|
||||
switch (this.list[idx].permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
this.folderStatusArray[index][0] = true;
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
this.folderStatusArray[index][1] = true;
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
this.folderStatusArray[index][2] = true;
|
||||
break;
|
||||
}
|
||||
@ -175,7 +168,7 @@ struct applicationItem {
|
||||
@State globalIsOn: boolean = true;
|
||||
@State selectedIndex: number = 0;
|
||||
@State isTouch: string = '';
|
||||
@State groupInfo: GroupInfo = new GroupInfo('', '', '', '', [], '', [], false);
|
||||
@State groupInfo: GroupInfo = new GroupInfo('', '', '', '', [], '', [], [], false);
|
||||
@State currentGroup: string = GlobalContext.load('currentPermissionGroup');
|
||||
@State isMuteSupported: boolean = GlobalContext.load('isMuteSupported');
|
||||
@State allBundleInfo: AppInfo[] = GlobalContext.load('allBundleInfo');
|
||||
@ -201,7 +194,7 @@ struct applicationItem {
|
||||
buttonStyle: ButtonStyleMode.TEXTUAL,
|
||||
action: () => {
|
||||
Log.info('global accept');
|
||||
if (this.currentGroup == MICROPHONE) {
|
||||
if (this.currentGroup == PermissionGroup.MICROPHONE) {
|
||||
let audioManager = audio.getAudioManager();
|
||||
let audioVolumeManager = audioManager.getVolumeManager();
|
||||
audioVolumeManager.getVolumeGroupManager(audio.DEFAULT_VOLUME_GROUP_ID).then(audioVolumeGroupManager => {
|
||||
|
@ -29,11 +29,13 @@ import {
|
||||
getFontSizeScale,
|
||||
getLimitFontSize
|
||||
} from '../common/utils/utils';
|
||||
import { Permission, ButtonStatus } from '../common/model/definition';
|
||||
import { GroupInfo, WantInfo } from '../common/model/typedef';
|
||||
import { GlobalContext } from '../common/utils/globalContext';
|
||||
import Constants from '../common/utils/constant';
|
||||
import { showSubPermissionsGroup, userGrantPermissions } from '../common/model/permissionGroup';
|
||||
import { showSubPermissionsGroup, userGrantPermissions, buttonResource } from '../common/model/permissionGroup';
|
||||
import { LocationCanvas } from '../common/components/location';
|
||||
import { MeasureText } from '@kit.ArkUI';
|
||||
|
||||
@Extend(Button)function customizeButton() {
|
||||
.buttonStyle(ButtonStyleMode.TEXTUAL)
|
||||
@ -41,13 +43,6 @@ import { LocationCanvas } from '../common/components/location';
|
||||
.width(Constants.HALF_LENGTH)
|
||||
}
|
||||
|
||||
const FUZZY_LOCATION_PERMISSION = 'ohos.permission.APPROXIMATELY_LOCATION';
|
||||
const PRECISE_LOCATION_PERMISSION = 'ohos.permission.LOCATION';
|
||||
const PASTE = 'ohos.permission.READ_PASTEBOARD';
|
||||
const APP_TRACKING_CONSENT = 'ohos.permission.APP_TRACKING_CONSENT';
|
||||
const DOWNLOAD_PERMISSION = 'ohos.permission.READ_WRITE_DOWNLOAD_DIRECTORY';
|
||||
const DESKTOP_PERMISSION = 'ohos.permission.READ_WRITE_DESKTOP_DIRECTORY';
|
||||
const DOCUMENTS_PERMISSION = 'ohos.permission.READ_WRITE_DOCUMENTS_DIRECTORY';
|
||||
const fuzzyMarks = [Constants.LOCATION_FUZZY, Constants.LOCATION_BOTH_FUZZY, Constants.LOCATION_BOTH_PRECISE];
|
||||
const preciseMarks = [Constants.LOCATION_UPGRADE, Constants.LOCATION_BOTH_PRECISE];
|
||||
let storage = LocalStorage.getShared();
|
||||
@ -177,46 +172,15 @@ struct dialogPlusPage {
|
||||
}
|
||||
}
|
||||
}.constraintSize({ maxHeight: Constants.MAXIMUM_HEADER_HEIGHT })
|
||||
if (this.currentGroup().name === 'LOCATION') {
|
||||
Column() {
|
||||
Button($r('app.string.allowed_only_during_use'))
|
||||
.customizeButton()
|
||||
.width(Constants.FULL_WIDTH)
|
||||
.margin({ bottom: Constants.MARGIN_4 })
|
||||
.onClick(() => {
|
||||
this.privacyAccept(
|
||||
this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag
|
||||
)
|
||||
})
|
||||
Button($r('app.string.allow_this_time'))
|
||||
.customizeButton()
|
||||
.width(Constants.FULL_WIDTH)
|
||||
.margin({ bottom: Constants.MARGIN_4 })
|
||||
.onClick(() => {
|
||||
this.privacyAccept(
|
||||
this.grantGroups[this.count],
|
||||
this.accessTokenId,
|
||||
this.reqPerms,
|
||||
Constants.PERMISSION_ALLOW_THIS_TIME
|
||||
)
|
||||
})
|
||||
Button($r('app.string.cancel'))
|
||||
.customizeButton()
|
||||
.width(Constants.FULL_WIDTH)
|
||||
.onClick(() => {
|
||||
this.count ++;
|
||||
})
|
||||
}
|
||||
.padding({ left: Constants.PADDING_16, right: Constants.PADDING_16 })
|
||||
} else {
|
||||
if (this.currentGroup().buttons.length <= 2 && this.calculateButtonWidth(this.currentGroup().buttons)) {
|
||||
//横向布局
|
||||
Row() {
|
||||
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
|
||||
Button($r('app.string.ban'))
|
||||
Button(buttonResource.get(this.currentGroup().buttons[0]))
|
||||
.customizeButton()
|
||||
.onClick(() => {
|
||||
this.privacyCancel(
|
||||
this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag
|
||||
)
|
||||
}).customizeButton()
|
||||
this.clickHandle(this.currentGroup().buttons[0]);
|
||||
})
|
||||
Divider()
|
||||
.color($r('sys.color.comp_divider'))
|
||||
.vertical(true)
|
||||
@ -224,24 +188,31 @@ struct dialogPlusPage {
|
||||
.height(Constants.DIVIDER_HEIGHT)
|
||||
.opacity(0.2)
|
||||
.margin({ left: Constants.MARGIN_8, right: Constants.MARGIN_8 })
|
||||
Button(
|
||||
this.currentGroup().name === 'PASTEBOARD' ? $r('app.string.This_time_only') : $r('app.string.allow')
|
||||
)
|
||||
Button(buttonResource.get(this.currentGroup().buttons[1]))
|
||||
.customizeButton()
|
||||
.onClick(() => {
|
||||
this.privacyAccept(
|
||||
this.grantGroups[this.count],
|
||||
this.accessTokenId,
|
||||
this.reqPerms,
|
||||
this.currentGroup().name === 'PASTEBOARD' ?
|
||||
Constants.PERMISSION_ALLOW_THIS_TIME : this.userFixedFlag
|
||||
)
|
||||
}).customizeButton()
|
||||
this.clickHandle(this.currentGroup().buttons[1]);
|
||||
})
|
||||
}.margin({
|
||||
left: Constants.BUTTON_MARGIN_LEFT,
|
||||
right: Constants.BUTTON_MARGIN_RIGHT,
|
||||
bottom: Constants.MARGIN_8
|
||||
})
|
||||
}
|
||||
} else {
|
||||
//纵向布局
|
||||
Column() {
|
||||
ForEach(this.currentGroup().buttons, (buttonStatus: ButtonStatus, idx: number) => {
|
||||
Button(buttonResource.get(buttonStatus))
|
||||
.customizeButton()
|
||||
.width(Constants.FULL_WIDTH)
|
||||
.margin({ bottom: idx + 1 < this.currentGroup().buttons.length ? Constants.MARGIN_4 : 0 })
|
||||
.onClick(() => {
|
||||
this.clickHandle(buttonStatus);
|
||||
})
|
||||
})
|
||||
}
|
||||
.padding({ left: Constants.PADDING_16, right: Constants.PADDING_16 })
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -270,16 +241,59 @@ struct dialogPlusPage {
|
||||
return this.grantGroups[index];
|
||||
}
|
||||
|
||||
calculateButtonWidth(buttonStatus: ButtonStatus[]): boolean {
|
||||
let denyText = buttonResource.get(buttonStatus[0]);
|
||||
let allowText = buttonResource.get(buttonStatus[1]);
|
||||
let maxButtonTextLength = Math.max(
|
||||
MeasureText.measureText({ textContent: denyText }),
|
||||
MeasureText.measureText({ textContent: allowText })
|
||||
)
|
||||
|
||||
Log.info(`px2vp(maxButtonTextLength): ${px2vp(maxButtonTextLength)}`);
|
||||
if (px2vp(maxButtonTextLength) > Constants.DIALOG_BUTTON_MAX_WIDTH) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
clickHandle(buttonStatus: ButtonStatus) {
|
||||
switch (buttonStatus) {
|
||||
case ButtonStatus.ALLOW:
|
||||
this.privacyAccept(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag);
|
||||
return;
|
||||
case ButtonStatus.DENY:
|
||||
this.privacyCancel(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag);
|
||||
return;
|
||||
case ButtonStatus.CANCEL:
|
||||
this.count ++;
|
||||
return;
|
||||
case ButtonStatus.THIS_TIME_ONLY:
|
||||
this.privacyAccept(
|
||||
this.grantGroups[this.count], this.accessTokenId, this.reqPerms, Constants.PERMISSION_ALLOW_THIS_TIME
|
||||
);
|
||||
return;
|
||||
case ButtonStatus.ALLOW_THIS_TIME:
|
||||
this.privacyAccept(
|
||||
this.grantGroups[this.count], this.accessTokenId, this.reqPerms, Constants.PERMISSION_ALLOW_THIS_TIME
|
||||
);
|
||||
return;
|
||||
case ButtonStatus.ALLOW_ONLY_DURING_USE:
|
||||
this.privacyAccept(this.grantGroups[this.count], this.accessTokenId, this.reqPerms, this.userFixedFlag);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
async privacyAccept(group: GroupInfo, accessTokenId: number, permissionList: string[], userFixedFlag: number) {
|
||||
let num = 0;
|
||||
group.permissions.forEach(async permission => {
|
||||
this.grantStatus = -1;
|
||||
if (showSubPermissionsGroup.indexOf(group.name) == -1) {
|
||||
if (group.name == 'LOCATION') {
|
||||
if (fuzzyMarks.includes(this.locationFlag) && permission === FUZZY_LOCATION_PERMISSION) {
|
||||
if (fuzzyMarks.includes(this.locationFlag) && permission === Permission.APPROXIMATELY_LOCATION) {
|
||||
await this.operationPermission(true, accessTokenId, permission, userFixedFlag);
|
||||
}
|
||||
if (preciseMarks.includes(this.locationFlag) && permission === PRECISE_LOCATION_PERMISSION) {
|
||||
if (preciseMarks.includes(this.locationFlag) && permission === Permission.LOCATION) {
|
||||
await this.operationPermission(true, accessTokenId, permission, userFixedFlag);
|
||||
}
|
||||
} else {
|
||||
@ -377,28 +391,28 @@ struct dialogPlusPage {
|
||||
}
|
||||
|
||||
getPasteBoardInfo() {
|
||||
if (this.reqPerms.includes(PASTE)) {
|
||||
if (this.reqPerms.includes(Permission.READ_PASTEBOARD)) {
|
||||
let systemPasteboard: pasteboard.SystemPasteboard = pasteboard.getSystemPasteboard();
|
||||
this.pasteBoardName = systemPasteboard.getDataSource();
|
||||
}
|
||||
}
|
||||
|
||||
getGrantGroups(stateGroup: number[]) {
|
||||
if (this.reqPerms.includes(FUZZY_LOCATION_PERMISSION)) {
|
||||
if (this.reqPerms.includes(Permission.APPROXIMATELY_LOCATION)) {
|
||||
this.locationFlag = Constants.LOCATION_FUZZY;
|
||||
if (this.reqPerms.includes(PRECISE_LOCATION_PERMISSION)) {
|
||||
if (this.reqPerms.includes(Permission.LOCATION)) {
|
||||
this.locationFlag = Constants.LOCATION_BOTH_PRECISE;
|
||||
let fuzzyIndex = this.reqPerms.indexOf(FUZZY_LOCATION_PERMISSION);
|
||||
let fuzzyIndex = this.reqPerms.indexOf(Permission.APPROXIMATELY_LOCATION);
|
||||
if (stateGroup[fuzzyIndex] == Constants.PASS_OPER) {
|
||||
this.locationFlag = Constants.LOCATION_UPGRADE;
|
||||
}
|
||||
}
|
||||
} else if (this.reqPerms.includes(PRECISE_LOCATION_PERMISSION)) {
|
||||
} else if (this.reqPerms.includes(Permission.LOCATION)) {
|
||||
this.locationFlag = Constants.LOCATION_UPGRADE;
|
||||
}
|
||||
|
||||
this.reqPerms.forEach(async (permission, idx) => {
|
||||
if (permission === APP_TRACKING_CONSENT) {
|
||||
if (permission === Permission.APP_TRACKING_CONSENT) {
|
||||
let toggleStatus = await this.appTrackHandle(idx);
|
||||
if (toggleStatus === abilityAccessCtrl.PermissionRequestToggleStatus.CLOSED) {
|
||||
return;
|
||||
@ -421,10 +435,12 @@ struct dialogPlusPage {
|
||||
async appTrackHandle(index: number): Promise<abilityAccessCtrl.PermissionRequestToggleStatus> {
|
||||
try {
|
||||
let acManager = abilityAccessCtrl.createAtManager();
|
||||
let toggleStatus = await acManager.getPermissionRequestToggleStatus(APP_TRACKING_CONSENT);
|
||||
let toggleStatus = await acManager.getPermissionRequestToggleStatus(Permission.APP_TRACKING_CONSENT);
|
||||
Log.info(`APP_TRACKING_CONSENT toggleStatus: ${toggleStatus}.`);
|
||||
if (toggleStatus === abilityAccessCtrl.PermissionRequestToggleStatus.CLOSED) {
|
||||
await acManager.grantUserGrantedPermission(this.accessTokenId, APP_TRACKING_CONSENT, this.userFixedFlag);
|
||||
await acManager.grantUserGrantedPermission(
|
||||
this.accessTokenId, Permission.APP_TRACKING_CONSENT, this.userFixedFlag
|
||||
);
|
||||
this.result[index] = abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED;
|
||||
Log.info('APP_TRACKING_CONSENT grant success.');
|
||||
}
|
||||
@ -439,19 +455,25 @@ struct dialogPlusPage {
|
||||
let group = getPermissionGroup(permission);
|
||||
if (group.name === 'FOLDER') {
|
||||
switch (permission) {
|
||||
case DOWNLOAD_PERMISSION:
|
||||
let downloadGroup = new GroupInfo(group.name, group.groupName, 'app.string.group_label_download_folder',
|
||||
group.icon, group.description, group.reason, [DOWNLOAD_PERMISSION], group.isShow)
|
||||
case Permission.READ_WRITE_DOWNLOAD_DIRECTORY:
|
||||
let downloadGroup = new GroupInfo(
|
||||
group.name, group.groupName, 'app.string.group_label_download_folder', group.icon, group.description,
|
||||
group.reason, [Permission.READ_WRITE_DOWNLOAD_DIRECTORY], group.buttons, group.isShow
|
||||
)
|
||||
this.grantGroups.push(downloadGroup);
|
||||
break;
|
||||
case DESKTOP_PERMISSION:
|
||||
let desktopGroup = new GroupInfo(group.name, group.groupName, 'app.string.group_label_desktop_folder',
|
||||
group.icon, group.description, group.reason, [DESKTOP_PERMISSION], group.isShow)
|
||||
case Permission.READ_WRITE_DESKTOP_DIRECTORY:
|
||||
let desktopGroup = new GroupInfo(
|
||||
group.name, group.groupName, 'app.string.group_label_desktop_folder', group.icon, group.description,
|
||||
group.reason, [Permission.READ_WRITE_DESKTOP_DIRECTORY], group.buttons, group.isShow
|
||||
)
|
||||
this.grantGroups.push(desktopGroup);
|
||||
break;
|
||||
case DOCUMENTS_PERMISSION:
|
||||
let documentGroup = new GroupInfo(group.name, group.groupName, 'app.string.group_label_document_folder',
|
||||
group.icon, group.description, group.reason, [DOCUMENTS_PERMISSION], group.isShow)
|
||||
case Permission.READ_WRITE_DOCUMENTS_DIRECTORY:
|
||||
let documentGroup = new GroupInfo(
|
||||
group.name, group.groupName, 'app.string.group_label_document_folder', group.icon, group.description,
|
||||
group.reason, [Permission.READ_WRITE_DOCUMENTS_DIRECTORY], group.buttons, group.isShow
|
||||
)
|
||||
this.grantGroups.push(documentGroup);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user