| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /**
- * m-permission-manager UTS 插件 TypeScript 类型声明
- */
- export type PermissionKey =
- | 'camera'
- | 'photoLibrary'
- | 'storage'
- | 'readStorage'
- | 'location'
- | 'coarseLocation'
- | 'microphone'
- | 'contacts'
- | 'writeContacts'
- | 'bluetooth'
- | 'phone'
- | 'phoneState'
- | 'sms'
- | 'readSms'
- | 'receiveSms'
- | 'overlay'
- | 'writeSettings'
- export type PermissionStatus =
- | 'granted'
- | 'denied'
- | 'notDetermined'
- | 'restricted'
- | 'unsupported'
- export interface PermissionCheckResult {
- permission: PermissionKey
- status: PermissionStatus
- granted: boolean
- }
- export interface PermissionGrantResult {
- permission: PermissionKey
- status: PermissionStatus
- granted: boolean
- }
- export interface CheckPermissionsResult {
- results: PermissionCheckResult[]
- allGranted: boolean
- }
- export interface RequestPermissionsResult {
- results: PermissionGrantResult[]
- allGranted: boolean
- }
- export interface PermissionFail {
- errCode: 9020001 | 9020002 | 9020003 | 9020004 | 9020005 | 9020006
- errMsg: string
- }
- export interface CheckPermissionOptions {
- permission: PermissionKey
- success?: (res: PermissionCheckResult) => void
- fail?: (res: PermissionFail) => void
- complete?: (res: unknown) => void
- }
- export interface CheckPermissionsOptions {
- permissions: PermissionKey[]
- success?: (res: CheckPermissionsResult) => void
- fail?: (res: PermissionFail) => void
- complete?: (res: unknown) => void
- }
- export interface RequestPermissionOptions {
- permission: PermissionKey
- success?: (res: PermissionGrantResult) => void
- fail?: (res: PermissionFail) => void
- complete?: (res: unknown) => void
- }
- export interface RequestPermissionsOptions {
- permissions: PermissionKey[]
- success?: (res: RequestPermissionsResult) => void
- fail?: (res: PermissionFail) => void
- complete?: (res: unknown) => void
- }
- export interface OpenAppSettingsOptions {
- /** 指定权限类型,各端将尽量跳转到对应设置页 */
- permission?: PermissionKey
- success?: (res: PermissionCheckResult) => void
- fail?: (res: PermissionFail) => void
- complete?: (res: unknown) => void
- }
- export interface GetSupportedPermissionsResult {
- permissions: PermissionKey[]
- }
- export interface BluetoothDemoInfo {
- available: boolean
- enabled: boolean
- stateText: string
- stateCode: number
- }
- export function checkPermissionSync(permission: PermissionKey): PermissionCheckResult
- export function checkPermissionsSync(permissions: PermissionKey[]): CheckPermissionsResult
- export function checkPermission(options: CheckPermissionOptions): void
- export function checkPermissions(options: CheckPermissionsOptions): void
- export function requestPermission(options: RequestPermissionOptions): void
- export function requestPermissions(options: RequestPermissionsOptions): void
- export function openAppSettings(options?: OpenAppSettingsOptions): void
- export function getSupportedPermissionsSync(): GetSupportedPermissionsResult
- export function getBluetoothDemoInfoSync(): BluetoothDemoInfo
|