• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_SAPROFILE_H
17 #define SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_SAPROFILE_H
18 
19 #include <map>
20 #include <string>
21 #include <vector>
22 
23 namespace OHOS {
24 using DlHandle = void*;
25 
26 enum {
27     INTERFACE_CALL = 0,
28     DEVICE_ONLINE,
29     SETTING_SWITCH,
30     PARAM,
31     COMMON_EVENT,
32     TIMED_EVENT,
33 };
34 
35 enum {
36     START_ON_DEMAND = 1,
37     STOP_ON_DEMAND,
38 };
39 
40 enum {
41     START = 1,
42     KILL,
43     FREEZE,
44 };
45 
46 enum {
47     HIGH_PRIORITY = 1,
48     MEDIUM_PRIORITY = 2,
49     LOW_PRIORITY = 3,
50 };
51 
52 enum {
53     IMMEDIATELY = 0,
54     LOW_MEMORY,
55 };
56 
57 struct OnDemandCondition {
58     int32_t eventId;
59     std::string name;
60     std::string value;
61     std::map<std::string, std::string> extraMessages;
62 };
63 
64 struct OnDemandEvent {
65     int32_t eventId;
66     std::string name;
67     std::string value;
68     int64_t extraDataId = -1;
69     bool persistence = false;
70     std::vector<OnDemandCondition> conditions;
71     bool enableOnce = false;
72     uint32_t loadPriority = LOW_PRIORITY;
73     std::map<std::string, std::string> extraMessages;
74 
75     bool operator==(const OnDemandEvent& event) const
76     {
77         return this->eventId == event.eventId && this->name == event.name && this->value == event.value;
78     }
79 
ToStringOnDemandEvent80     std::string ToString() const
81     {
82         return this->name + "_" + this->value;
83     }
84 };
85 
86 struct SaControlInfo {
87     int32_t ondemandId;
88     int32_t saId;
89     bool enableOnce = false;
90     uint32_t loadPriority = LOW_PRIORITY;
91 };
92 
93 struct StartOnDemand {
94     bool allowUpdate = false;
95     std::vector<OnDemandEvent> onDemandEvents;
96 };
97 
98 struct StopOnDemand {
99     bool allowUpdate = false;
100     int32_t delayTime = 20000;
101     std::vector<OnDemandEvent> onDemandEvents;
102 };
103 
104 struct SaProfile {
105     std::u16string process;
106     int32_t saId = 0;
107     std::string libPath;
108     std::vector<int32_t> dependSa;
109     int32_t dependTimeout = 0;
110     bool runOnCreate = false;
111     bool autoRestart = false;
112     bool distributed = false;
113     int32_t dumpLevel = 0;
114     std::u16string capability;
115     std::u16string permission;
116     // default OTHER_START
117     uint32_t bootPhase = 3;
118     StartOnDemand startOnDemand;
119     StopOnDemand stopOnDemand;
120     DlHandle handle = nullptr;
121     int32_t recycleStrategy = IMMEDIATELY;
122 };
123 }
124 #endif // SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_SAPROFILE_H
125