/* * Copyright (c) 2022 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 { AsyncCallback } from './basic'; import { BundleInfo } from './bundleManager/BundleInfo'; import { ElementName } from './bundleManager/ElementName'; /** * Default application manager. * @namespace defaultAppManager * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ declare namespace defaultAppManager { /** * The constant for application type. * @enum {number} * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ export enum ApplicationType { /** * Default browser identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ BROWSER = "Web Browser", /** * Default image identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ IMAGE = "Image Gallery", /** * Default audio identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ AUDIO = "Audio Player", /** * Default video identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ VIDEO = "Video Player", /** * Default PDF identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ PDF = "PDF Viewer", /** * Default word identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ WORD = "Word Viewer", /** * Default excel identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ EXCEL = "Excel Viewer", /** * Default PPT identifier. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ PPT = "PPT Viewer", } /** * Query whether the caller is default application based on type. * @param { string } type - Application type or a file type that conforms to media type format. * @param { AsyncCallback } callback - The callback of querying default application result. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ function isDefaultApplication(type: string, callback: AsyncCallback) : void; /** * Query whether the caller is default application based on type. * @param { string } type - Application type or a file type that conforms to media type format. * @returns { Promise } Return true if caller is default application; return false otherwise. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @since 9 */ function isDefaultApplication(type: string) : Promise; /** * Get default application based on type. * @permission ohos.permission.GET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { number } userId - Indicates the id for the user. * @param { AsyncCallback } callback - The callback of the BundleInfo object result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700023 - The specified default app does not exist. * @throws { BusinessError } 17700025 - The specified type is invalid. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function getDefaultApplication(type: string, userId: number, callback: AsyncCallback) : void; function getDefaultApplication(type: string, callback: AsyncCallback) : void; /** * Get default application based on type. * @permission ohos.permission.GET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { number } userId - Indicates the id for the user. * @returns { Promise } Return the BundleInfo object. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700023 - The specified default app does not exist. * @throws { BusinessError } 17700025 - The specified type is invalid. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function getDefaultApplication(type: string, userId?: number) : Promise; /** * Set default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { ElementName } elementName - Uniquely identifies an ability or extensionAbility. * @param { number } userId - Indicates the id for the user. * @param { AsyncCallback } callback - The callback of setting default application result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700025 - The specified type is invalid. * @throws { BusinessError } 17700028 - The specified ability does not match the type. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function setDefaultApplication(type: string, elementName: ElementName, userId: number, callback: AsyncCallback) : void; function setDefaultApplication(type: string, elementName: ElementName, callback: AsyncCallback) : void; /** * Set default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { ElementName } elementName - Uniquely identifies an ability or extensionAbility. * @param { number } userId - Indicates the id for the user. * @returns { Promise } The result of setting default application. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700025 - The specified type is invalid. * @throws { BusinessError } 17700028 - The specified ability does not match the type. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function setDefaultApplication(type: string, elementName: ElementName, userId?: number) : Promise; /** * Reset default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { number } userId - Indicates the id for the user. * @param { AsyncCallback } callback - The callback of resetting default application result. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700025 - The specified type is invalid. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function resetDefaultApplication(type: string, userId: number, callback: AsyncCallback) : void; function resetDefaultApplication(type: string, callback: AsyncCallback) : void; /** * Reset default application based on type. * @permission ohos.permission.SET_DEFAULT_APPLICATION * @param { string } type - Application type or a file type that conforms to media type format. * @param { number } userId - Indicates the id for the user. * @returns { Promise } The result of resetting default application. * @throws { BusinessError } 201 - Permission denied. * @throws { BusinessError } 202 - Permission denied, non-system app called system api. * @throws { BusinessError } 401 - The parameter check failed. * @throws { BusinessError } 801 - Capability not supported. * @throws { BusinessError } 17700004 - The specified user ID is not found. * @throws { BusinessError } 17700025 - The specified type is invalid. * @syscap SystemCapability.BundleManager.BundleFramework.DefaultApp * @systemapi * @since 9 */ function resetDefaultApplication(type: string, userId?: number) : Promise; } export default defaultAppManager;