1 /*
2  * Copyright (c) 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 BUNDLE_ACTIVE_CONSTANT_H
17 #define BUNDLE_ACTIVE_CONSTANT_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace DeviceUsageStats {
23 const int32_t DURATION_TABLE_ROW_NUMBER = 1;
24 const int32_t TABLE_ROW_ZERO = 0;
25 const int32_t SORTED_TABLE_ARRAY_NUMBER = 4;
26 const int32_t ALL_TABLE_ARRAY_NUMBER = 6;
27 const int32_t NO_UPDATE_ROW = 0;
28 const int32_t NO_DELETE_ROW = 0;
29 const int32_t EVENT_TABLE_NUMBER = 1;
30 const int32_t APP_GROUP_TABLE_NUMBER = 2;
31 const int32_t TABLE_NOT_EXIST = 0;
32 const int32_t DAILY_DATABASE_INDEX = 0;
33 const int32_t WEEKLY_DATABASE_INDEX = 1;
34 const int32_t MONTHLY_DATABASE_INDEX = 2;
35 const int32_t YEARLY_DATABASE_INDEX = 3;
36 const int32_t EVENT_DATABASE_INDEX = 4;
37 const int32_t APP_GROUP_DATABASE_INDEX = 5;
38 const int32_t BUNDLE_ACTIVE_VERSION_V1 = 1;
39 const int32_t BUNDLE_ACTIVE_CURRENT_VERSION = 2;
40 const int32_t BUNDLE_ACTIVE_SUCCESS = 0;
41 const int32_t BUNDLE_ACTIVE_FAIL = -1;
42 const int32_t BUNDLE_ACTIVE_RDB_VERSION = 1;
43 const int32_t BUNDLE_ACTIVE_DB_INDEX_NORMAL = 0;
44 const int32_t BUNDLE_ACTIVE_DB_INDEX_MODULE = 1;
45 const int32_t BUNDLE_ACTIVE_DB_INDEX_FORM = 2;
46 const int32_t USER_ID_COLUMN_INDEX = 0;
47 const int32_t BUNDLE_NAME_COLUMN_INDEX = 1;
48 const int32_t BUNDLE_STARTED_COUNT_COLUMN_INDEX = 2;
49 const int32_t LAST_TIME_COLUMN_INDEX = 3;
50 const int32_t LAST_TIME_CONTINUOUS_TASK_COLUMN_INDEX = 4;
51 const int32_t TOTAL_TIME_COLUMN_INDEX = 5;
52 const int32_t TOTAL_TIME_CONTINUOUS_TASK_COLUMN_INDEX = 6;
53 const int32_t PACKAGE_LOG_UID_COLUMN_INDEX = 7;
54 const int32_t EVENT_ID_COLUMN_INDEX = 2;
55 const int32_t TIME_STAMP_COLUMN_INDEX = 3;
56 const int32_t ABILITY_ID_COLUMN_INDEX = 4;
57 const int32_t EVENT_UID_COLUMN_INDEX = 5;
58 const int32_t LAST_BOOT_FROM_USED_TIME_COLUMN_INDEX = 2;
59 const int32_t LAST_SCREEN_USED_TIME_COLUMN_INDEX = 3;
60 const int32_t CURRENT_GROUP_COLUMN_INDEX = 4;
61 const int32_t REASON_IN_GROUP_COLUMN_INDEX = 5;
62 const int32_t BUNDLE_ALIVE_TIMEOUT_TIME_COLUMN_INDEX = 6;
63 const int32_t BUNDLE_DAILY_TIMEOUT_TIME_COLUMN_INDEX = 7;
64 const int32_t BUNDLE_HISTORY_LOG_UID_COLUMN_INDEX = 8;
65 const int32_t BOOT_BASED_DURATION_COLUMN_INDEX = 0;
66 const int32_t SCREEN_ON_DURATION_COLUMN_INDEX = 1;
67 const int32_t DURATION_FLAG_COLUMN_INDEX = 2;
68 const int32_t MODULE_NAME_COLUMN_INDEX = 2;
69 const int32_t MODULE_USED_COUNT_COLUMN_INDEX = 3;
70 const int32_t MODULE_LAST_TIME_COLUMN_INDEX = 4;
71 const int32_t MODULE_UID_COLUMN_INDEX = 5;
72 const int32_t FORM_NAME_COLUMN_INDEX = 3;
73 const int32_t FORM_DIMENSION_COLUMN_INDEX = 4;
74 const int32_t FORM_ID_COLUMN_INDEX = 5;
75 const int32_t FORM_COUNT_COLUMN_INDEX = 6;
76 const int32_t FORM_LAST_TIME_COLUMN_INDEX = 7;
77 const int32_t FORM_UID_COLUMN_INDEX = 8;
78 const int32_t QUERY_CONDITION_VALID = 0;
79 const int32_t QUERY_CONDITION_INVALID = -1;
80 const int64_t TWO_SECONDS = 2 * 1000LL;
81 const int64_t THIRTY_MINUTE = 30 * 60 * 1000LL;
82 const int64_t SIX_DAY_IN_MILLIS_MAX_DEBUG = 6 * 1 * 10 * 60 * 1000LL;
83 const int64_t SIX_DAY_IN_MILLIS_MAX = 6 * 24 * 60 * 60 * 1000LL;
84 const int64_t ONE_DAY_TIME_DEBUG = 1 * 10 * 60 * 1000LL;
85 const int64_t ONE_DAY_TIME = 1 * 24 * 60 * 60 * 1000LL;
86 const int64_t ONE_WEEK_TIME_DEBUG = 1 * 20 * 60 * 1000LL;
87 const int64_t ONE_WEEK_TIME = 7 * 24 * 60 * 60 * 1000LL;
88 const int64_t ONE_MONTH_TIME_DEBUG = 1 * 30 * 60 * 1000LL;
89 const int64_t ONE_MONTH_TIME = 30 * 24 * 60 * 60 * 1000LL;
90 const int64_t ONE_YEAR_TIME_DEBUG = 1 * 40 * 60 * 1000LL;
91 const int64_t ONE_YEAR_TIME = 365 * 24 * 60 * 60 * 1000LL;
92 const int64_t LAST_TIME_IN_MILLIS_MIN = 0LL;
93 const int64_t EVENT_TIME_IN_MILLIS_MIN = 0LL;
94 const int64_t EVENT_BEGIN_TIME_INITIAL_VALUE = -1LL;
95 const std::string PACKAGE_LOG_TABLE = "PackageLog";
96 const std::string PACKAGE_LOG_TABLE_INDEX_PREFIX = "PackageLogIndex";
97 const std::string EVENT_LOG_TABLE = "DeviceEventLog";
98 const std::string EVENT_LOG_TABLE_INDEX_PREFIX = "DeviceEventLogIndex";
99 const std::string DURATION_LOG_TABLE = "DurationLog";
100 const std::string BUNDLE_HISTORY_LOG_TABLE = "BundleHistoryLog";
101 const std::string BUNDLE_HISTORY_LOG_TABLE_INDEX_PREFIX = "BundleHistoryLogIndex";
102 const std::string MODULE_RECORD_LOG_TABLE = "ModuleRecordLog";
103 const std::string MODULE_RECORD_LOG_TABLE_INDEX_PREFIX = "ModuleRecordLogIndex";
104 const std::string FORM_RECORD_LOG_TABLE = "FormRecordLog";
105 const std::string FORM_RECORD_LOG_TABLE_INDEX_PREFIX = "FormRecordLogIndex";
106 const std::string UNKNOWN_TABLE_NAME = "unknownTableName";
107 const std::string BUNDLE_ACTIVE_DB_USER_ID = "userId";
108 const std::string BUNDLE_ACTIVE_DB_BUNDLE_NAME = "bundleName";
109 const std::string BUNDLE_ACTIVE_DB_MODULE_NAME = "moduleName";
110 const std::string BUNDLE_ACTIVE_DB_FORM_NAME = "formName";
111 const std::string BUNDLE_ACTIVE_DB_FORM_DIMENSION = "formDimension";
112 const std::string BUNDLE_ACTIVE_DB_FORM_ID = "formId";
113 const std::string BUNDLE_ACTIVE_DB_MODULE_LAUNCHED_COUNT = "launchedCount";
114 const std::string BUNDLE_ACTIVE_DB_FORM_TOUCH_COUNT = "touchCount";
115 const std::string BUNDLE_ACTIVE_DB_BUNDLE_STARTED_COUNT = "bundleStartedCount";
116 const std::string BUNDLE_ACTIVE_DB_LAST_TIME = "lastTime";
117 const std::string BUNDLE_ACTIVE_DB_LAST_TIME_CONTINUOUS_TASK = "lastTimeContinuousTask";
118 const std::string BUNDLE_ACTIVE_DB_TOTAL_TIME = "totalTime";
119 const std::string BUNDLE_ACTIVE_DB_TOTAL_TIME_CONTINUOUS_TASK = "totalTimeContinuousTask";
120 const std::string BUNDLE_ACTIVE_DB_EVENT_ID = "eventId";
121 const std::string BUNDLE_ACTIVE_DB_TIME_STAMP = "timeStamp";
122 const std::string BUNDLE_ACTIVE_DB_ABILITY_ID = "abilityId";
123 const std::string BUNDLE_ACTIVE_DB_LAST_BOOT_FROM_USED_TIME = "lastBootFromUsedTime";
124 const std::string BUNDLE_ACTIVE_DB_LAST_SCREEN_USED_TIME = "lastScreenUsedTime";
125 const std::string BUNDLE_ACTIVE_DB_CURRENT_GROUP = "currentGroup";
126 const std::string BUNDLE_ACTIVE_DB_REASON_IN_GROUP = "reasonInGroup";
127 const std::string BUNDLE_ACTIVE_DB_BUNDLE_ALIVE_TIMEOUT_TIME = "bundleAliveTimeoutTime";
128 const std::string BUNDLE_ACTIVE_DB_BUNDLE_DAILY_TIMEOUT_TIME = "bundleDailyTimeoutTime";
129 const std::string BUNDLE_ACTIVE_DB_BOOT_BASED_DURATION = "bootBasedDuration";
130 const std::string BUNDLE_ACTIVE_DB_SCREEN_ON_DURATION = "screenOnDuration";
131 const std::string RDB_STORE_COLUMN_TYPE_INT = "INTERGER";
132 const std::string BUNDLE_ACTIVE_DB_UID = "uid";
133 
134 const std::string REFRESH_DATABASE_RUNNER_NAME = "RefreshDatabase";
135 const std::string BUNDLE_ACTIVE_DATABASE_DIR = "/data/service/el1/public/bundle_usage/";
136 const std::string BUNDLE_ACTIVE_VERSION_FILE = "/version";
137 const std::string BUNDLE_ACTIVE_VERSION_DIRECTORY_PATH = BUNDLE_ACTIVE_DATABASE_DIR + BUNDLE_ACTIVE_VERSION_FILE;
138 const std::string DATABASE_FILE_TABLE_NAME = "table";
139 const std::string SQLITE_MASTER_NAME = "name";
140 const std::string COMMON_EVENT_UNLOCK_SCREEN = "common.event.UNLOCK_SCREEN";
141 const std::string COMMON_EVENT_LOCK_SCREEN = "common.event.LOCK_SCREEN";
142 const std::string DATABASE_TYPE[] = {"daily", "weekly", "monthly", "yearly", "event", "usageGroup"};
143 const std::string SUFFIX_TYPE[] = {".db"};
144 const std::string OPERATION_SYSTEM_LOCK = "SYSTEM_LOCK";
145 const std::string OPERATION_SYSTEM_UNLOCK = "SYSTEM_UNLOCK";
146 const std::string OPERATION_SYSTEM_SLEEP = "SYSTEM_SLEEP";
147 const std::string OPERATION_SYSTEM_WAKEUP = "SYSTEM_WAKEUP";
148 }  // namespace DeviceUsageStats
149 }  // namespace OHOS
150 #endif  // BUNDLE_ACTIVE_CONSTANT_H
151 
152