• 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 <string>
20 #include <vector>
21 
22 namespace OHOS {
23 using DlHandle = void*;
24 
25 enum {
26     INTERFACE_CALL = 0,
27     DEVICE_ONLINE,
28     SETTING_SWITCH,
29     PARAM,
30     COMMON_EVENT,
31     TIMED_EVENT,
32 };
33 
34 enum {
35     START_ON_DEMAND = 1,
36     STOP_ON_DEMAND,
37 };
38 
39 enum {
40     START = 1,
41     KILL,
42     FREEZE,
43 };
44 
45 struct OnDemandCondition {
46     int32_t eventId;
47     std::string name;
48     std::string value;
49 };
50 
51 struct OnDemandEvent {
52     int32_t eventId;
53     std::string name;
54     std::string value;
55     int64_t extraDataId = -1;
56     std::vector<OnDemandCondition> conditions;
57     bool enableOnce = false;
58 
59     bool operator==(const OnDemandEvent& event) const
60     {
61         return this->eventId == event.eventId && this->name == event.name && this->value == event.value;
62     }
63 };
64 
65 struct SaControlInfo {
66     int32_t ondemandId;
67     int32_t saId;
68     bool enableOnce = false;
69 };
70 
71 struct StartOnDemand {
72     bool allowUpdate = false;
73     std::vector<OnDemandEvent> onDemandEvents;
74 };
75 
76 struct StopOnDemand {
77     bool allowUpdate = false;
78     int32_t delayTime = 20000;
79     std::vector<OnDemandEvent> onDemandEvents;
80 };
81 
82 struct SaProfile {
83     std::u16string process;
84     int32_t saId = 0;
85     std::string libPath;
86     std::vector<int32_t> dependSa;
87     int32_t dependTimeout = 0;
88     bool runOnCreate = false;
89     bool autoRestart = false;
90     bool distributed = false;
91     int32_t dumpLevel = 0;
92     std::u16string capability;
93     std::u16string permission;
94     // default OTHER_START
95     uint32_t bootPhase = 3;
96     StartOnDemand startOnDemand;
97     StopOnDemand stopOnDemand;
98     DlHandle handle = nullptr;
99 };
100 }
101 #endif // SAMGR_INTERFACE_INNERKITS_COMMOM_INCLUDE_SAPROFILE_H
102