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 #ifndef FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PRE_SCAN_INFO_H 17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PRE_SCAN_INFO_H 18 19 #include <string> 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 namespace { GetBoolStrVal(bool val)24 std::string GetBoolStrVal(bool val) 25 { 26 return val ? "true" : "false"; 27 } 28 } 29 struct PreBundleConfigInfo { 30 std::string bundleName; 31 bool keepAlive = false; 32 bool singleton = false; 33 bool runningResourcesApply = false; 34 bool associatedWakeUp = false; 35 bool allowUsePrivilegeExtension = false; 36 bool allowMultiProcess = false; 37 bool formVisibleNotify = false; 38 bool allowQueryPriority = false; 39 bool allowExcludeFromMissions = false; 40 bool userDataClearable = true; 41 bool hideDesktopIcon = false; 42 std::vector<std::string> allowCommonEvent; 43 std::vector<std::string> appSignature; 44 std::vector<std::string> existInJsonFile; 45 46 bool operator <(const PreBundleConfigInfo &preBundleConfigInfo) const 47 { 48 return bundleName < preBundleConfigInfo.bundleName; 49 } 50 ResetPreBundleConfigInfo51 void Reset() 52 { 53 bundleName.clear(); 54 keepAlive = false; 55 singleton = false; 56 runningResourcesApply = false; 57 associatedWakeUp = false; 58 allowUsePrivilegeExtension = false; 59 allowMultiProcess = false; 60 formVisibleNotify = false; 61 allowQueryPriority = false; 62 allowExcludeFromMissions = false; 63 userDataClearable = true; 64 hideDesktopIcon = false; 65 allowCommonEvent.clear(); 66 appSignature.clear(); 67 existInJsonFile.clear(); 68 } 69 ToStringPreBundleConfigInfo70 std::string ToString() const 71 { 72 return "[ bundleName = " + bundleName 73 + ", keepAlive = " + GetBoolStrVal(keepAlive) 74 + ", singleton = " + GetBoolStrVal(singleton) 75 + ", runningResourcesApply = " + GetBoolStrVal(runningResourcesApply) 76 + ", associatedWakeUp = " + GetBoolStrVal(associatedWakeUp) 77 + ", allowUsePrivilegeExtension = " + GetBoolStrVal(allowUsePrivilegeExtension) 78 + ", allowMultiProcess = " + GetBoolStrVal(allowMultiProcess) 79 + ", formVisibleNotify = " + GetBoolStrVal(formVisibleNotify) 80 + ", allowQueryPriority = " + GetBoolStrVal(allowQueryPriority) 81 + ", allowExcludeFromMissions = " + GetBoolStrVal(allowExcludeFromMissions) 82 + ", userDataClearable = " + GetBoolStrVal(userDataClearable) 83 + ", hideDesktopIcon = " + GetBoolStrVal(hideDesktopIcon) + "]"; 84 } 85 }; 86 87 struct PreScanInfo { 88 std::string bundleDir; 89 bool removable = true; 90 int32_t priority = 0; 91 92 bool operator < (const PreScanInfo &preScanInfo) const 93 { 94 if (bundleDir == preScanInfo.bundleDir) { 95 return false; 96 } 97 98 return priority >= preScanInfo.priority; 99 } 100 101 friend bool operator == (const PreScanInfo& oldPreScanInfo, const PreScanInfo& newPreScanInfo) 102 { 103 return oldPreScanInfo.bundleDir == newPreScanInfo.bundleDir; 104 } 105 ResetPreScanInfo106 void Reset() 107 { 108 bundleDir.clear(); 109 removable = true; 110 priority = 0; 111 } 112 ToStringPreScanInfo113 std::string ToString() const 114 { 115 return "[ bundleDir = " + bundleDir 116 + ", removable = " + GetBoolStrVal(removable) 117 + ", priority = " + std::to_string(priority) + "]"; 118 } 119 }; 120 } // namespace AppExecFwk 121 } // namespace OHOS 122 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PRE_SCAN_INFO_H 123