1 /*
2 * Copyright (c) 2021-2022 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_mgr_host.h"
17
18 using namespace OHOS::AAFwk;
19 namespace OHOS {
20 namespace AppExecFwk {
21 namespace {
22 const std::string MODULE_NAME = "moduleName";
23 } // namespace
24
DumpInfos(const DumpFlag flag,const std::string & bundleName,int32_t userId,std::string & result)25 bool MockBundleMgrHost::DumpInfos(
26 const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result)
27 {
28 APP_LOGD("enter");
29 APP_LOGD("flag: %{public}d", flag);
30 APP_LOGD("bundleName: %{public}s", bundleName.c_str());
31 if (bundleName.size() > 0) {
32 result = bundleName + "\n";
33 } else {
34 result = "OK";
35 }
36 return true;
37 }
38
CleanBundleCacheFiles(const std::string & bundleName,const sptr<ICleanCacheCallback> & cleanCacheCallback,int32_t userId)39 ErrCode MockBundleMgrHost::CleanBundleCacheFiles(const std::string &bundleName,
40 const sptr<ICleanCacheCallback> &cleanCacheCallback, int32_t userId)
41 {
42 APP_LOGD("enter");
43 APP_LOGD("bundleName: %{public}s", bundleName.c_str());
44 cleanCacheCallback->OnCleanCacheFinished(true);
45 return ERR_OK;
46 }
47
CleanBundleDataFiles(const std::string & bundleName,const int userId)48 bool MockBundleMgrHost::CleanBundleDataFiles(const std::string &bundleName, const int userId)
49 {
50 APP_LOGD("enter");
51 APP_LOGD("bundleName: %{public}s", bundleName.c_str());
52 return true;
53 }
54
SetApplicationEnabled(const std::string & bundleName,bool isEnable,int32_t userId)55 ErrCode MockBundleMgrHost::SetApplicationEnabled(const std::string &bundleName, bool isEnable, int32_t userId)
56 {
57 APP_LOGD("enter");
58 APP_LOGD("bundleName: %{public}s", bundleName.c_str());
59 APP_LOGD("isEnable: %{public}d", isEnable);
60 return ERR_OK;
61 }
62
SetAbilityEnabled(const AbilityInfo & abilityInfo,bool isEnable,int32_t userId)63 ErrCode MockBundleMgrHost::SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnable, int32_t userId)
64 {
65 APP_LOGD("enter");
66 APP_LOGD("abilityName: %{public}s", abilityInfo.name.c_str());
67 APP_LOGD("isEnable: %{public}d", isEnable);
68 return ERR_OK;
69 }
70
GetBundleArchiveInfo(const std::string & hapFilePath,const BundleFlag flag,BundleInfo & bundleInfo)71 bool MockBundleMgrHost::GetBundleArchiveInfo(const std::string &hapFilePath, const BundleFlag flag,
72 BundleInfo &bundleInfo)
73 {
74 bundleInfo.moduleNames.emplace_back(MODULE_NAME);
75 return true;
76 }
77 } // namespace AppExecFwk
78 } // namespace OHOS