• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "remote_client_manager.h"
17 
18 #include "hilog_wrapper.h"
19 #include "iservice_registry.h"
20 #include "system_ability_definition.h"
21 
22 
23 namespace OHOS {
24 namespace AppExecFwk {
RemoteClientManager()25 RemoteClientManager::RemoteClientManager()
26     : appSpawnClient_(std::make_shared<AppSpawnClient>()), nwebSpawnClient_(std::make_shared<AppSpawnClient>(true))
27 {}
28 
~RemoteClientManager()29 RemoteClientManager::~RemoteClientManager()
30 {}
31 
GetSpawnClient()32 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetSpawnClient()
33 {
34     if (appSpawnClient_) {
35         return appSpawnClient_;
36     }
37     return nullptr;
38 }
39 
SetSpawnClient(const std::shared_ptr<AppSpawnClient> & appSpawnClient)40 void RemoteClientManager::SetSpawnClient(const std::shared_ptr<AppSpawnClient> &appSpawnClient)
41 {
42     appSpawnClient_ = appSpawnClient;
43 }
44 
GetBundleManager()45 sptr<IBundleMgr> RemoteClientManager::GetBundleManager()
46 {
47     if (bundleManager_ == nullptr) {
48         sptr<ISystemAbilityManager> systemManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
49         if (systemManager != nullptr) {
50             bundleManager_ =
51                 iface_cast<AppExecFwk::IBundleMgr>(systemManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID));
52         } else {
53             HILOG_ERROR("AppMgrServiceInner::GetBundleManager fail to get SAMGR");
54         }
55     }
56     return bundleManager_;
57 }
58 
SetBundleManager(sptr<IBundleMgr> bundleManager)59 void RemoteClientManager::SetBundleManager(sptr<IBundleMgr> bundleManager)
60 {
61     bundleManager_ = bundleManager;
62 }
63 
GetNWebSpawnClient()64 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNWebSpawnClient()
65 {
66     return nwebSpawnClient_;
67 }
68 }  // namespace AppExecFwk
69 }  // namespace OHOS
70