1/* 2 * Copyright (C) 2024 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 16/** 17 * @file 18 * @kit AbilityKit 19 */ 20 21import common from '@ohos.app.ability.common'; 22import type { SendableContext as _SendableContext } from './application/SendableContext'; 23 24/** 25 * Sendable context manager. 26 * 27 * @namespace sendableContextManager 28 * @syscap SystemCapability.Ability.AbilityRuntime.Core 29 * @stagemodelonly 30 * @atomicservice 31 * @since 12 32 */ 33declare namespace sendableContextManager { 34 /** 35 * The class of sendable context object. 36 * 37 * @typedef { _SendableContext } 38 * @syscap SystemCapability.Ability.AbilityRuntime.Core 39 * @stagemodelonly 40 * @atomicservice 41 * @since 12 42 */ 43 export type SendableContext = _SendableContext; 44 45 /** 46 * Convert the context to a sendable context object. 47 * Support Context, ApplicationContext, AbilityStageContext and UIAbilityContext. 48 * 49 * @param { context } common.Context - The Context. 50 * @returns { SendableContext } The sendable context object. 51 * @throws { BusinessError } 401 - If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 52 * 2.Parameter verification failed. 53 * @syscap SystemCapability.Ability.AbilityRuntime.Core 54 * @stagemodelonly 55 * @atomicservice 56 * @since 12 57 */ 58 function convertFromContext(context: common.Context): SendableContext; 59 60 /** 61 * Convert a sendable context to a Context. 62 * 63 * @param { sendableContext } SendableContext - The sendable context. 64 * @returns { common.Context } The Context. 65 * @throws { BusinessError } 401 - If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 66 * 2.Parameter verification failed. 67 * @syscap SystemCapability.Ability.AbilityRuntime.Core 68 * @stagemodelonly 69 * @atomicservice 70 * @since 12 71 */ 72 function convertToContext(sendableContext: SendableContext): common.Context; 73 74 /** 75 * Convert a sendable context to a ApplicationContext. 76 * 77 * @param { sendableContext } SendableContext - The sendable context. 78 * @returns { common.ApplicationContext } The ApplicationContext. 79 * @throws { BusinessError } 401 - If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 80 * 2.Parameter verification failed. 81 * @syscap SystemCapability.Ability.AbilityRuntime.Core 82 * @stagemodelonly 83 * @atomicservice 84 * @since 12 85 */ 86 function convertToApplicationContext(sendableContext: SendableContext): common.ApplicationContext; 87 88 /** 89 * Convert a sendable context to a AbilityStageContext. 90 * 91 * @param { sendableContext } SendableContext - The sendable context. 92 * @returns { common.AbilityStageContext } The AbilityStageContext. 93 * @throws { BusinessError } 401 - If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 94 * 2.Parameter verification failed. 95 * @syscap SystemCapability.Ability.AbilityRuntime.Core 96 * @stagemodelonly 97 * @atomicservice 98 * @since 12 99 */ 100 function convertToAbilityStageContext(sendableContext: SendableContext): common.AbilityStageContext; 101 102 /** 103 * Convert a sendable context to a UIAbilityContext. 104 * 105 * @param { sendableContext } SendableContext - The sendable context. 106 * @returns { common.UIAbilityContext } The UIAbilityContext. 107 * @throws { BusinessError } 401 - If the input parameter invalid. Possible causes: 1.Incorrect parameter types; 108 * 2.Parameter verification failed. 109 * @syscap SystemCapability.Ability.AbilityRuntime.Core 110 * @stagemodelonly 111 * @atomicservice 112 * @since 12 113 */ 114 function convertToUIAbilityContext(sendableContext: SendableContext): common.UIAbilityContext; 115 116 /** 117 * Enable/disable multi-threaded communication capability for the EventHub widthin the specified context. 118 * After it is enabled, eventHub emit data is transmitted through serialization, 119 * the data at the sender and receiver are independent. 120 * 121 * @param { common.Context } context - the context where multi-threading eventHub should be enabled. 122 * @param { boolean } enabled - the value true means to enable it, and the value false means to disable it. 123 * @syscap SystemCapability.Ability.AbilityRuntime.Core 124 * @stagemodelonly 125 * @atomicservice 126 * @since 20 127 */ 128 function setEventHubMultithreadingEnabled(context: common.Context, enabled: boolean): void; 129} 130 131export default sendableContextManager; 132