1 /*
2 * Copyright (c) 2021-2024 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 "mock_bundle_installer_host.h"
17
18 namespace OHOS {
19 namespace AppExecFwk {
MockBundleInstallerHost()20 MockBundleInstallerHost::MockBundleInstallerHost()
21 {
22 APP_LOGI("create mock bundle installer host instance");
23 }
24
~MockBundleInstallerHost()25 MockBundleInstallerHost::~MockBundleInstallerHost()
26 {
27 APP_LOGI("destroy mock bundle installer host instance");
28 }
29
Install(const std::string & bundleFilePath,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)30 bool MockBundleInstallerHost::Install(
31 const std::string &bundleFilePath, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
32 {
33 APP_LOGI("enter");
34
35 APP_LOGI("bundleFilePath: %{private}s", bundleFilePath.c_str());
36 APP_LOGI("installParam.installFlag: %{public}hhd", installParam.installFlag);
37
38 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
39
40 return true;
41 }
42
Install(const std::vector<std::string> & bundleFilePath,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)43 bool MockBundleInstallerHost::Install(const std::vector<std::string> &bundleFilePath, const InstallParam &installParam,
44 const sptr<IStatusReceiver> &statusReceiver)
45 {
46 APP_LOGI("enter");
47
48 for_each(bundleFilePath.begin(), bundleFilePath.end(), [](const auto &path)->decltype(auto) {
49 APP_LOGI("bundleFilePath: %{private}s", path.c_str());
50 });
51 APP_LOGI("installParam.installFlag: %{public}hhd", installParam.installFlag);
52
53 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
54
55 return true;
56 }
57
Uninstall(const std::string & bundleName,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)58 bool MockBundleInstallerHost::Uninstall(
59 const std::string &bundleName, const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
60 {
61 APP_LOGI("enter");
62
63 APP_LOGI("bundleName: %{public}s", bundleName.c_str());
64 APP_LOGI("installParam.installFlag: %{public}hhd", installParam.installFlag);
65
66 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
67
68 return true;
69 }
70
Uninstall(const std::string & bundleName,const std::string & modulePackage,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)71 bool MockBundleInstallerHost::Uninstall(const std::string &bundleName, const std::string &modulePackage,
72 const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
73 {
74 APP_LOGI("enter");
75
76 APP_LOGI("bundleName: %{public}s", bundleName.c_str());
77 APP_LOGI("modulePackage: %{public}s", modulePackage.c_str());
78 APP_LOGI("installParam.installFlag: %{public}hhd", installParam.installFlag);
79
80 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
81
82 return true;
83 }
84
Recover(const std::string & bundleName,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)85 bool MockBundleInstallerHost::Recover(const std::string &bundleName, const InstallParam &installParam,
86 const sptr<IStatusReceiver> &statusReceiver)
87 {
88 APP_LOGD("enter");
89 APP_LOGD("bundleName: %{public}s", bundleName.c_str());
90 APP_LOGD("installParam.installFlag: %{public}hhd", installParam.installFlag);
91 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
92 return true;
93 }
94
StreamInstall(const std::vector<std::string> & bundleFilePaths,const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver)95 ErrCode MockBundleInstallerHost::StreamInstall(const std::vector<std::string> &bundleFilePaths,
96 const InstallParam &installParam, const sptr<IStatusReceiver> &statusReceiver)
97 {
98 APP_LOGD("enter");
99 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
100 return OHOS::ERR_OK;
101 }
102
InstallSandboxApp(const std::string & bundleName,int32_t dplType,int32_t userId,int32_t & appIndex)103 ErrCode MockBundleInstallerHost::InstallSandboxApp(const std::string &bundleName, int32_t dplType, int32_t userId,
104 int32_t &appIndex)
105 {
106 return OHOS::ERR_OK;
107 }
108
UninstallSandboxApp(const std::string & bundleName,int32_t appIndex,int32_t userId)109 ErrCode MockBundleInstallerHost::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId)
110 {
111 return OHOS::ERR_OK;
112 }
113
CreateStreamInstaller(const InstallParam & installParam,const sptr<IStatusReceiver> & statusReceiver,const std::vector<std::string> & originHapPaths)114 sptr<IBundleStreamInstaller> MockBundleInstallerHost::CreateStreamInstaller(const InstallParam &installParam,
115 const sptr<IStatusReceiver> &statusReceiver, const std::vector<std::string> &originHapPaths)
116 {
117 return nullptr;
118 }
119
DestoryBundleStreamInstaller(uint32_t streamInstallerId)120 bool MockBundleInstallerHost::DestoryBundleStreamInstaller(uint32_t streamInstallerId)
121 {
122 return true;
123 }
124
Uninstall(const UninstallParam & uninstallParam,const sptr<IStatusReceiver> & statusReceiver)125 bool MockBundleInstallerHost::Uninstall(const UninstallParam &uninstallParam,
126 const sptr<IStatusReceiver> &statusReceiver)
127 {
128 statusReceiver->OnFinished(OHOS::ERR_OK, MSG_SUCCESS);
129 return true;
130 }
131 } // namespace AppExecFwk
132 } // namespace OHOS