1 /* 2 * Copyright (c) 2023-2025 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_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_DISPOSED_RULE_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_DISPOSED_RULE_H 18 19 #include <string> 20 #include <vector> 21 22 #include "element_name.h" 23 #include "parcel.h" 24 #include "want.h" 25 26 namespace OHOS { 27 namespace AppExecFwk { 28 enum class ComponentType { 29 UI_ABILITY = 1, 30 UI_EXTENSION = 2, 31 }; 32 33 enum class UninstallComponentType { 34 EXTENSION = 1, 35 }; 36 37 enum class DisposedType { 38 BLOCK_APPLICATION = 1, 39 BLOCK_ABILITY = 2, 40 NON_BLOCK = 3, 41 }; 42 43 enum class ControlType { 44 ALLOWED_LIST = 1, 45 DISALLOWED_LIST = 2, 46 }; 47 48 struct DisposedRule : public Parcelable { 49 public: 50 bool isEdm = false; 51 int32_t priority = 0; 52 ComponentType componentType = ComponentType::UI_ABILITY; 53 DisposedType disposedType = DisposedType::BLOCK_APPLICATION; 54 ControlType controlType = ControlType::ALLOWED_LIST; 55 std::shared_ptr<AAFwk::Want> want = nullptr; 56 std::vector<ElementName> elementList; 57 58 // used for log 59 std::string callerName; 60 int64_t setTime = 0; 61 62 bool ReadFromParcel(Parcel &parcel); 63 virtual bool Marshalling(Parcel &parcel) const override; 64 static DisposedRule *Unmarshalling(Parcel &parcel); 65 66 static bool FromString(const std::string &ruleString, DisposedRule &rule); 67 std::string ToString() const; 68 }; 69 70 struct UninstallDisposedRule : public Parcelable { 71 public: 72 std::shared_ptr<AAFwk::Want> want = nullptr; 73 UninstallComponentType uninstallComponentType = UninstallComponentType::EXTENSION; 74 int32_t priority = 0; 75 76 bool ReadFromParcel(Parcel &parcel); 77 virtual bool Marshalling(Parcel &parcel) const override; 78 static UninstallDisposedRule *Unmarshalling(Parcel &parcel); 79 80 static bool FromString(const std::string &ruleString, UninstallDisposedRule &rule); 81 std::string ToString() const; 82 }; 83 84 struct DisposedRuleConfiguration : public Parcelable { 85 public: 86 DisposedRule disposedRule; 87 std::string appId; 88 int32_t appIndex = 0; 89 90 bool ReadFromParcel(Parcel &parcel); 91 virtual bool Marshalling(Parcel &parcel) const override; 92 static DisposedRuleConfiguration *Unmarshalling(Parcel &parcel); 93 }; 94 } // namespace AppExecFwk 95 } // namespace OHOS 96 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_DISPOSED_RULE_H 97