1 /*
2  * Copyright (c) 2023 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 DisposedType {
34     BLOCK_APPLICATION = 1,
35     BLOCK_ABILITY = 2,
36     NON_BLOCK = 3,
37 };
38 
39 enum class ControlType {
40     ALLOWED_LIST = 1,
41     DISALLOWED_LIST = 2,
42 };
43 
44 struct DisposedRule : public Parcelable {
45 public:
46     std::shared_ptr<AAFwk::Want> want = nullptr;
47     ComponentType componentType = ComponentType::UI_ABILITY;
48     DisposedType disposedType = DisposedType::BLOCK_APPLICATION;
49     ControlType controlType = ControlType::ALLOWED_LIST;
50     std::vector<ElementName> elementList;
51     int32_t priority = 0;
52     bool isEdm = false;
53 
54     bool ReadFromParcel(Parcel &parcel);
55     virtual bool Marshalling(Parcel &parcel) const override;
56     static DisposedRule *Unmarshalling(Parcel &parcel);
57 
58     static bool FromString(const std::string &ruleString, DisposedRule &rule);
59     std::string ToString() const;
60 };
61 }  // namespace AppExecFwk
62 }  // namespace OHOS
63 #endif  // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_BASE_INCLUDE_DISPOSED_RULE_H
64