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