1 /*
2  * Copyright (c) 2021-2022 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_SYS_MRG_CLIENT_H
17 #define OHOS_ABILITY_RUNTIME_SYS_MRG_CLIENT_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <unordered_map>
23 
24 #include "if_system_ability_manager.h"
25 #include "iremote_object.h"
26 #include "singleton.h"
27 
28 namespace OHOS {
29 namespace AppExecFwk {
30 class SysMrgClient {
31     DECLARE_DELAYED_SINGLETON(SysMrgClient)
32 public:
33     /**
34      *
35      * Get the systemAbility by ID.
36      *
37      * @param systemAbilityId The ID of systemAbility which want to get.
38      */
39     sptr<IRemoteObject> GetSystemAbility(const int32_t systemAbilityId);
40 
41     /**
42      *
43      * Register the systemAbility by ID.
44      *
45      * @param systemAbilityId The ID of systemAbility which want to register.
46      * @param broker The systemAbility which want to be registered.
47      */
48     void RegisterSystemAbility(const int32_t systemAbilityId, sptr<IRemoteObject> broker);
49 
50     /**
51      *
52      * Unregister the systemAbility by ID.
53      *
54      * @param systemAbilityId The ID of systemAbility which want to unregister.
55      */
56     void UnregisterSystemAbility(const int32_t systemAbilityId);
57 
58 private:
59     OHOS::sptr<ISystemAbilityManager> abilityManager_;
60     std::mutex saMutex_;
61     std::unordered_map<int32_t, sptr<IRemoteObject>> servicesMap_;
62 };
63 }  // namespace AppExecFwk
64 }  // namespace OHOS
65 #endif  // OHOS_ABILITY_RUNTIME_SYS_MRG_CLIENT_H
66