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