• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_AAFWK_SYS_MRG_CLIENT_H
17 #define OHOS_AAFWK_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 
31 class SysMrgClient {
32     DECLARE_DELAYED_SINGLETON(SysMrgClient)
33 public:
34     /**
35      *
36      * Get the systemAbility by ID.
37      *
38      * @param systemAbilityId The ID of systemAbility whitch want to get.
39      */
40     sptr<IRemoteObject> GetSystemAbility(const int32_t systemAbilityId);
41 
42     /**
43      *
44      * Register the systemAbility by ID.
45      *
46      * @param systemAbilityId The ID of systemAbility whitch want to register.
47      * @param broker The systemAbility whitch want to be registered.
48      */
49     void RegisterSystemAbility(const int32_t systemAbilityId, sptr<IRemoteObject> broker);
50 
51     /**
52      *
53      * Unregister the systemAbility by ID.
54      *
55      * @param systemAbilityId The ID of systemAbility whitch want to unregister.
56      */
57     void UnregisterSystemAbility(const int32_t systemAbilityId);
58 
59 private:
60     OHOS::sptr<ISystemAbilityManager> abilityManager_;
61     std::mutex saMutex_;
62     std::unordered_map<int32_t, sptr<IRemoteObject>> servicesMap_;
63 };
64 
65 }  // namespace AppExecFwk
66 }  // namespace OHOS
67 #endif  // OHOS_AAFWK_SYS_MRG_CLIENT_H
68