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 {}
30 
~RemoteClientManager()31 RemoteClientManager::~RemoteClientManager()
32 {}
33 
GetSpawnClient()34 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetSpawnClient()
35 {
36     if (appSpawnClient_) {
37         return appSpawnClient_;
38     }
39     return nullptr;
40 }
41 
SetSpawnClient(const std::shared_ptr<AppSpawnClient> & appSpawnClient)42 void RemoteClientManager::SetSpawnClient(const std::shared_ptr<AppSpawnClient> &appSpawnClient)
43 {
44     appSpawnClient_ = appSpawnClient;
45 }
46 
GetBundleManagerHelper()47 std::shared_ptr<BundleMgrHelper> RemoteClientManager::GetBundleManagerHelper()
48 {
49     if (bundleManagerHelper_ == nullptr) {
50         bundleManagerHelper_  = DelayedSingleton<BundleMgrHelper>::GetInstance();
51     }
52     return bundleManagerHelper_;
53 }
54 
SetBundleManagerHelper(const std::shared_ptr<BundleMgrHelper> & bundleMgrHelper)55 void RemoteClientManager::SetBundleManagerHelper(const std::shared_ptr<BundleMgrHelper> &bundleMgrHelper)
56 {
57     bundleManagerHelper_ = bundleMgrHelper;
58 }
59 
GetNWebSpawnClient()60 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNWebSpawnClient()
61 {
62     return nwebSpawnClient_;
63 }
64 
GetCJSpawnClient()65 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetCJSpawnClient()
66 {
67     if (cjAppSpawnClient_) {
68         return cjAppSpawnClient_;
69     }
70     return nullptr;
71 }
72 
GetNativeSpawnClient()73 std::shared_ptr<AppSpawnClient> RemoteClientManager::GetNativeSpawnClient()
74 {
75     return nativeSpawnClient_;
76 }
77 }  // namespace AppExecFwk
78 }  // namespace OHOS
79