1 /*
2  * Copyright (c) 2023 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 
21 namespace OHOS {
22 namespace AppExecFwk {
23 enum class ExtensionAbilityType;
24 }
25 namespace AAFwk {
26 namespace {
27 constexpr int DEFAULT_INVALID_USER_ID = -1;
28 }
29 class Want;
30 /**
31  * @class IExtensionManager
32  * IExtensionManager interface is used to access ability manager services.
33  */
34 class IExtensionManager : public OHOS::IRemoteBroker {
35 public:
36     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.ExtensionManager")
37 
38     /**
39      * Connect ability common method.
40      *
41      * @param want, special want for service type's ability.
42      * @param connect, callback used to notify caller the result of connecting or disconnecting.
43      * @param callerToken, caller ability token.
44      * @param extensionType, type of the extension.
45      * @param userId, the service user ID.
46      * @return Returns ERR_OK on success, others on failure.
47      */
48     virtual int ConnectAbilityCommon(const Want &want, const sptr<IRemoteObject> &connect,
49         const sptr<IRemoteObject> &callerToken, AppExecFwk::ExtensionAbilityType extensionType,
50         int32_t userId = DEFAULT_INVALID_USER_ID, bool isQuerryExtensionOnly = true)
51     {
52         return 0;
53     }
54 
55     /**
56      * Disconnect session with extension ability.
57      *
58      * @param connect, Callback used to notify caller the result of connecting or disconnecting.
59      * @return Returns ERR_OK on success, others on failure.
60      */
61     virtual int DisconnectAbility(const sptr<IRemoteObject> &connect) = 0;
62 };
63 }  // namespace AAFwk
64 }  // namespace OHOS
65 #endif  // OHOS_ABILITY_RUNTIME_EXTENSION_MANAGER_INTERFACE_H
66