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 #ifndef DATASHARESERVICE_EXTENSION_ABILITY_MANAGER_H
17 #define DATASHARESERVICE_EXTENSION_ABILITY_MANAGER_H
18 
19 #include "concurrent_map.h"
20 #include "executor_pool.h"
21 #include "iremote_object.h"
22 #include "want.h"
23 
24 namespace OHOS::DataShare {
25 class ExtensionAbilityManager {
26 public:
27     static ExtensionAbilityManager &GetInstance();
28     void SetExecutorPool(std::shared_ptr<ExecutorPool> executor);
29     int32_t ConnectExtension(const std::string &uri, const std::string &bundleName,
30         const sptr<IRemoteObject> &callback, AAFwk::WantParams &wantParams);
31     void DelayDisconnect(const std::string &bundleName);
32 
33 private:
34     void Disconnect(const std::string &bundleName, int time);
35     std::shared_ptr<ExecutorPool> executor_ = nullptr;
36     ConcurrentMap<std::string, sptr<IRemoteObject>> connectCallbackCache_;
37     static constexpr int WAIT_DISCONNECT_TIME = 5;
38     static constexpr int MAX_WAIT_DISCONNECT_TIME = 30;
39 };
40 } // namespace OHOS::DataShare
41 #endif // DATASHARESERVICE_EXTENSION_ABILITY_MANAGER_H
42