• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2025 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 #ifndef OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_INTERFACE_H
17 #define OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_INTERFACE_H
18 
19 #include <iremote_broker.h>
20 #include <vector>
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 enum class ExtensionAbilityType;
25 }
26 namespace AAFwk {
27 struct ExtensionRunningInfo;
28 namespace {
29 constexpr int DEFAULT_INVALID_USER_ID = -1;
30 }
31 class Want;
32 /**
33  * @class IExtensionManager
34  * IExtensionManager interface is used to access ability manager services.
35  */
36 class IExtensionManager : public OHOS::IRemoteBroker {
37 public:
38     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.ExtensionManager")
39 
40     /**
41      * Connect ability common method.
42      *
43      * @param want, special want for service type's ability.
44      * @param connect, callback used to notify caller the result of connecting or disconnecting.
45      * @param callerToken, caller ability token.
46      * @param extensionType, type of the extension.
47      * @param userId, the service user ID.
48      * @return Returns ERR_OK on success, others on failure.
49      */
50     virtual int ConnectAbilityCommon(const Want &want, sptr<IRemoteObject> connect,
51         const sptr<IRemoteObject> &callerToken, AppExecFwk::ExtensionAbilityType extensionType,
52         int32_t userId = DEFAULT_INVALID_USER_ID, bool isQuerryExtensionOnly = true)
53     {
54         return 0;
55     }
56 
57     /**
58      * Disconnect session with extension ability.
59      *
60      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
61      * @return Returns ERR_OK on success, others on failure.
62      */
63     virtual int DisconnectAbility(const sptr<IRemoteObject> &connect) = 0;
64 
65     /**
66      * @brief Get the extension running information.
67      *
68      * @param upperLimit The maximum limit of information wish to get.
69      * @param info Extension running information.
70      * @return Returns ERR_OK on success, others on failure.
71      */
72     virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) = 0;
73 
74     /**
75      * Transfer resultCode & want to ability manager service.
76      *
77      * @param resultCode, the resultCode of the ability to terminate.
78      * @param resultWant, the Want of the ability to return.
79      * @return Returns ERR_OK on success, others on failure.
80      */
TransferAbilityResultForExtension(const sptr<IRemoteObject> & callerToken,int32_t resultCode,const Want & want)81     virtual int32_t TransferAbilityResultForExtension(const sptr<IRemoteObject> &callerToken, int32_t resultCode,
82         const Want &want)
83     {
84         return 0;
85     }
86 };
87 }  // namespace AAFwk
88 }  // namespace OHOS
89 #endif  // OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_INTERFACE_H
90