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 allowMissionNotCleared = false; 41 bool userDataClearable = true; 42 bool hideDesktopIcon = false; 43 bool appShareLibrary = false; 44 std::vector<std::string> allowCommonEvent; 45 std::vector<std::string> appSignature; 46 std::vector<std::string> existInJsonFile; 47 std::vector<int32_t> resourcesApply; 48 49 bool operator <(const PreBundleConfigInfo &preBundleConfigInfo) const 50 { 51 return bundleName < preBundleConfigInfo.bundleName; 52 } 53 ResetPreBundleConfigInfo54 void Reset() 55 { 56 bundleName.clear(); 57 keepAlive = false; 58 singleton = false; 59 runningResourcesApply = false; 60 associatedWakeUp = false; 61 allowUsePrivilegeExtension = false; 62 allowMultiProcess = false; 63 formVisibleNotify = false; 64 allowQueryPriority = false; 65 allowExcludeFromMissions = false; 66 allowMissionNotCleared = false; 67 userDataClearable = true; 68 hideDesktopIcon = false; 69 appShareLibrary = false; 70 allowCommonEvent.clear(); 71 appSignature.clear(); 72 existInJsonFile.clear(); 73 resourcesApply.clear(); 74 } 75 ToStringPreBundleConfigInfo76 std::string ToString() const 77 { 78 return "[ bundleName = " + bundleName 79 + ", keepAlive = " + GetBoolStrVal(keepAlive) 80 + ", singleton = " + GetBoolStrVal(singleton) 81 + ", runningResourcesApply = " + GetBoolStrVal(runningResourcesApply) 82 + ", associatedWakeUp = " + GetBoolStrVal(associatedWakeUp) 83 + ", allowUsePrivilegeExtension = " + GetBoolStrVal(allowUsePrivilegeExtension) 84 + ", allowMultiProcess = " + GetBoolStrVal(allowMultiProcess) 85 + ", formVisibleNotify = " + GetBoolStrVal(formVisibleNotify) 86 + ", allowQueryPriority = " + GetBoolStrVal(allowQueryPriority) 87 + ", allowExcludeFromMissions = " + GetBoolStrVal(allowExcludeFromMissions) 88 + ", allowMissionNotCleared = " + GetBoolStrVal(allowMissionNotCleared) 89 + ", userDataClearable = " + GetBoolStrVal(userDataClearable) 90 + ", hideDesktopIcon = " + GetBoolStrVal(hideDesktopIcon) 91 + ", appShareLibrary = " + GetBoolStrVal(appShareLibrary) + "]"; 92 } 93 }; 94 95 struct PreScanInfo { 96 std::string bundleDir; 97 bool removable = true; 98 int32_t priority = 0; 99 100 bool operator < (const PreScanInfo &preScanInfo) const 101 { 102 if (bundleDir == preScanInfo.bundleDir) { 103 return false; 104 } 105 106 return priority >= preScanInfo.priority; 107 } 108 109 friend bool operator == (const PreScanInfo& oldPreScanInfo, const PreScanInfo& newPreScanInfo) 110 { 111 return oldPreScanInfo.bundleDir == newPreScanInfo.bundleDir; 112 } 113 ResetPreScanInfo114 void Reset() 115 { 116 bundleDir.clear(); 117 removable = true; 118 priority = 0; 119 } 120 ToStringPreScanInfo121 std::string ToString() const 122 { 123 return "[ bundleDir = " + bundleDir 124 + ", removable = " + GetBoolStrVal(removable) 125 + ", priority = " + std::to_string(priority) + "]"; 126 } 127 }; 128 } // namespace AppExecFwk 129 } // namespace OHOS 130 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PRE_SCAN_INFO_H 131