• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "ability_info.h"
17 #include "bundle_info.h"
18 #include "bundle_manager_helper.h"
19 
20 #include "continuous_task_log.h"
21 
22 namespace OHOS {
23 namespace BackgroundTaskMgr {
24 namespace {
25 static constexpr char TEST_DEFAULT_BUNDLE[]  = "bundleName";
26 static constexpr uint32_t ALL_NEED_CHECK_BGMODE = 62;
27 static constexpr int32_t NO_SYSTEM_APP_UID = -100;
28 }
29 
BundleManagerHelper()30 BundleManagerHelper::BundleManagerHelper() {}
31 
~BundleManagerHelper()32 BundleManagerHelper::~BundleManagerHelper() {}
33 
GetClientBundleName(int32_t uid)34 std::string BundleManagerHelper::GetClientBundleName(int32_t uid)
35 {
36     return TEST_DEFAULT_BUNDLE;
37 }
38 
CheckPermission(const std::string & permission)39 bool BundleManagerHelper::CheckPermission(const std::string &permission)
40 {
41     return true;
42 }
43 
IsSystemApp(int32_t uid)44 bool BundleManagerHelper::IsSystemApp(int32_t uid)
45 {
46     if (uid == NO_SYSTEM_APP_UID) {
47         return false;
48     }
49     return true;
50 }
51 
GetBundleInfo(const std::string & bundleName,const AppExecFwk::BundleFlag flag,AppExecFwk::BundleInfo & bundleInfo,int32_t userId)52 bool BundleManagerHelper::GetBundleInfo(const std::string &bundleName, const AppExecFwk::BundleFlag flag,
53     AppExecFwk::BundleInfo &bundleInfo, int32_t userId)
54 {
55     if (bundleName == "false-test") {
56         return false;
57     }
58     if (bundleName == "empty-info") {
59         AppExecFwk::AbilityInfo abilityInfo;
60         abilityInfo.backgroundModes = 0;
61         bundleInfo.abilityInfos.emplace_back(abilityInfo);
62         return true;
63     }
64     AppExecFwk::AbilityInfo abilityInfo;
65     abilityInfo.name = "ability1";
66     abilityInfo.backgroundModes = ALL_NEED_CHECK_BGMODE;
67     bundleInfo.abilityInfos.emplace_back(abilityInfo);
68     bundleInfo.name = TEST_DEFAULT_BUNDLE;
69     return true;
70 }
71 
GetApplicationInfo(const std::string & appName,const AppExecFwk::ApplicationFlag flag,const int userId,AppExecFwk::ApplicationInfo & appInfo)72 bool BundleManagerHelper::GetApplicationInfo(const std::string &appName, const AppExecFwk::ApplicationFlag flag,
73     const int userId, AppExecFwk::ApplicationInfo &appInfo)
74 {
75     appInfo.runningResourcesApply = true;
76     return true;
77 }
78 
QueryAbilityInfo(const AAFwk::Want & want,int32_t flags,int32_t userId,AppExecFwk::AbilityInfo & abilityInfo)79 bool BundleManagerHelper::QueryAbilityInfo(const AAFwk::Want &want, int32_t flags, int32_t userId,
80     AppExecFwk::AbilityInfo &abilityInfo)
81 {
82     abilityInfo.labelId = 1;
83     abilityInfo.label = "ability";
84     return true;
85 }
86 
Connect()87 bool BundleManagerHelper::Connect()
88 {
89     return true;
90 }
91 
Disconnect()92 void BundleManagerHelper::Disconnect() {}
93 
OnRemoteDied(const wptr<IRemoteObject> & object)94 void BundleManagerHelper::OnRemoteDied(const wptr<IRemoteObject> &object) {}
95 }  // namespace BackgroundTaskMgr
96 }  // namespace OHOS