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_ABILITY_RUNTIME_SA_MGR_CLIENT_H 17 #define OHOS_ABILITY_RUNTIME_SA_MGR_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 AAFwk { 30 /** 31 * @class SaMgrClient 32 * SaMgrClient. 33 */ 34 class SaMgrClient { 35 DECLARE_DELAYED_SINGLETON(SaMgrClient) 36 public: 37 sptr<IRemoteObject> GetSystemAbility(const int32_t systemAbilityId); 38 sptr<IRemoteObject> CheckSystemAbility(const int32_t systemAbilityId); 39 void RegisterSystemAbility(const int32_t systemAbilityId, sptr<IRemoteObject> broker); 40 41 private: 42 OHOS::sptr<ISystemAbilityManager> saMgr_; 43 std::mutex saMutex_; 44 std::unordered_map<int32_t, sptr<IRemoteObject>> servicesMap_; 45 }; 46 } // namespace AAFwk 47 } // namespace OHOS 48 #endif // OHOS_ABILITY_RUNTIME_SA_MGR_CLIENT_H 49