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