1 /* 2 * Copyright (c) 2021-2024 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 bool keepAlive = false; 31 bool singleton = false; 32 bool runningResourcesApply = false; 33 bool associatedWakeUp = false; 34 bool allowUsePrivilegeExtension = false; 35 bool allowMultiProcess = false; 36 bool formVisibleNotify = false; 37 bool allowQueryPriority = false; 38 bool allowExcludeFromMissions = false; 39 bool allowMissionNotCleared = false; 40 bool userDataClearable = true; 41 bool hideDesktopIcon = false; 42 bool appShareLibrary = false; 43 bool allowEnableNotification = false; 44 bool allowAppRunWhenDeviceFirstLocked = false; 45 std::string bundleName; 46 std::vector<std::string> allowCommonEvent; 47 std::vector<std::string> appSignature; 48 std::vector<std::string> existInJsonFile; 49 std::vector<int32_t> resourcesApply; 50 51 bool operator <(const PreBundleConfigInfo &preBundleConfigInfo) const 52 { 53 return bundleName < preBundleConfigInfo.bundleName; 54 } 55 ResetPreBundleConfigInfo56 void Reset() 57 { 58 bundleName.clear(); 59 keepAlive = false; 60 singleton = false; 61 runningResourcesApply = false; 62 associatedWakeUp = false; 63 allowUsePrivilegeExtension = false; 64 allowMultiProcess = false; 65 formVisibleNotify = false; 66 allowQueryPriority = false; 67 allowExcludeFromMissions = false; 68 allowMissionNotCleared = false; 69 userDataClearable = true; 70 hideDesktopIcon = false; 71 appShareLibrary = false; 72 allowEnableNotification = false; 73 allowAppRunWhenDeviceFirstLocked = false; 74 allowCommonEvent.clear(); 75 appSignature.clear(); 76 existInJsonFile.clear(); 77 resourcesApply.clear(); 78 } 79 ToStringPreBundleConfigInfo80 std::string ToString() const 81 { 82 return "[ bundleName = " + bundleName 83 + ", keepAlive = " + GetBoolStrVal(keepAlive) 84 + ", singleton = " + GetBoolStrVal(singleton) 85 + ", runningResourcesApply = " + GetBoolStrVal(runningResourcesApply) 86 + ", associatedWakeUp = " + GetBoolStrVal(associatedWakeUp) 87 + ", allowUsePrivilegeExtension = " + GetBoolStrVal(allowUsePrivilegeExtension) 88 + ", allowMultiProcess = " + GetBoolStrVal(allowMultiProcess) 89 + ", formVisibleNotify = " + GetBoolStrVal(formVisibleNotify) 90 + ", allowQueryPriority = " + GetBoolStrVal(allowQueryPriority) 91 + ", allowExcludeFromMissions = " + GetBoolStrVal(allowExcludeFromMissions) 92 + ", allowMissionNotCleared = " + GetBoolStrVal(allowMissionNotCleared) 93 + ", userDataClearable = " + GetBoolStrVal(userDataClearable) 94 + ", hideDesktopIcon = " + GetBoolStrVal(hideDesktopIcon) 95 + ", appShareLibrary = " + GetBoolStrVal(appShareLibrary) 96 + ", allowAppRunWhenDeviceFirstLocked = " + GetBoolStrVal(allowAppRunWhenDeviceFirstLocked) 97 + ", allowEnableNotification = " + GetBoolStrVal(allowEnableNotification) + "]"; 98 } 99 }; 100 101 struct PreScanInfo { 102 bool removable = true; 103 bool isDataPreloadHap = false; 104 int32_t priority = 0; 105 std::string bundleDir; 106 std::string appIdentifier; 107 bool onDemandInstall = false; 108 109 bool operator < (const PreScanInfo &preScanInfo) const 110 { 111 if (bundleDir == preScanInfo.bundleDir) { 112 return false; 113 } 114 115 return priority >= preScanInfo.priority; 116 } 117 118 friend bool operator == (const PreScanInfo& oldPreScanInfo, const PreScanInfo& newPreScanInfo) 119 { 120 return oldPreScanInfo.bundleDir == newPreScanInfo.bundleDir; 121 } 122 ResetPreScanInfo123 void Reset() 124 { 125 bundleDir.clear(); 126 removable = true; 127 priority = 0; 128 appIdentifier.clear(); 129 isDataPreloadHap = false; 130 onDemandInstall = false; 131 } 132 ToStringPreScanInfo133 std::string ToString() const 134 { 135 return "[ bundleDir = " + bundleDir 136 + ", removable = " + GetBoolStrVal(removable) 137 + ", appIdentifier = " + appIdentifier 138 + ", isDataPreloadHap = " + GetBoolStrVal(isDataPreloadHap) 139 + ", priority = " + std::to_string(priority) + "]"; 140 } 141 }; 142 } // namespace AppExecFwk 143 } // namespace OHOS 144 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLEMGR_INCLUDE_PRE_SCAN_INFO_H 145