• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 "singleton.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     cjAppSpawnClient_(std::make_shared<AppSpawnClient>("cjappspawn")),
28     nativeSpawnClient_(std::make_shared<AppSpawnClient>("nativespawn")),
29     hybridSpawnClient_(std::make_shared<AppSpawnClient>("hybridspawn"))
30 {}
31 
~RemoteClientManager()32 RemoteClientManager::~RemoteClientManager()
33 {}
34 
GetSpawnClient()35 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetSpawnClient()
36 {
37     if (appSpawnClient_) {
38         return appSpawnClient_;
39     }
40     return nullptr;
41 }
42 
SetSpawnClient(const std::shared_ptr<AppSpawnClient> & appSpawnClient)43 void RemoteClientManager::SetSpawnClient(const std::shared_ptr<AppSpawnClient> &appSpawnClient)
44 {
45     appSpawnClient_ = appSpawnClient;
46 }
47 
GetBundleManagerHelper()48 std::shared_ptr<BundleMgrHelper> RemoteClientManager::GetBundleManagerHelper()
49 {
50     if (bundleManagerHelper_ == nullptr) {
51         bundleManagerHelper_  = DelayedSingleton<BundleMgrHelper>::GetInstance();
52     }
53     return bundleManagerHelper_;
54 }
55 
SetBundleManagerHelper(const std::shared_ptr<BundleMgrHelper> & bundleMgrHelper)56 void RemoteClientManager::SetBundleManagerHelper(const std::shared_ptr<BundleMgrHelper> &bundleMgrHelper)
57 {
58     bundleManagerHelper_ = bundleMgrHelper;
59 }
60 
GetNWebSpawnClient()61 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNWebSpawnClient()
62 {
63     return nwebSpawnClient_;
64 }
65 
GetCJSpawnClient()66 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetCJSpawnClient()
67 {
68     if (cjAppSpawnClient_) {
69         return cjAppSpawnClient_;
70     }
71     return nullptr;
72 }
73 
GetNativeSpawnClient()74 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNativeSpawnClient()
75 {
76     return nativeSpawnClient_;
77 }
78 
GetHybridSpawnClient()79 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetHybridSpawnClient()
80 {
81     if (hybridSpawnClient_) {
82         return hybridSpawnClient_;
83     }
84     return nullptr;
85 }
86 }  // namespace AppExecFwk
87 }  // namespace OHOS
88