• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_CONSTANT_H
16 #define OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_CONSTANT_H
17 
18 #include <string>
19 #include <sys/sysinfo.h>
20 #include "os_account_info.h"
21 
22 namespace OHOS {
23 namespace AccountSA {
24 namespace Constants {
25 const std::string PATH_SEPARATOR = "/";
26 #ifndef ACCOUNT_TEST
27 const std::string USER_INFO_BASE = "/data/service/el1/public/account";
28 #else
29 const std::string USER_INFO_BASE = "/data/service/el1/public/account/test";
30 #endif // ACCOUNT_TEST
31 const std::string SYSTEM_ETC_BASE = "/system/etc/account";
32 const std::string OSACCOUNT_CONSTRAINTS_JSON_PATH = SYSTEM_ETC_BASE + PATH_SEPARATOR + "osaccount_constraints.json";
33 const std::string CONSTRAINTS_LIST_JSON_PATH = SYSTEM_ETC_BASE + PATH_SEPARATOR + "constraints_list_collection.json";
34 const std::string ACCOUNT_LIST_FILE_JSON_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_list.json";
35 const std::string ACCOUNT_INDEX_JSON_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_index_info.json";
36 const std::string ACCOUNT_INFO_DIGEST_FILE_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_info_digest.json";
37 const std::string BASE_OSACCOUNT_CONSTRAINTS_JSON_PATH =
38     USER_INFO_BASE + PATH_SEPARATOR + "base_os_account_constraints.json";
39 const std::string GLOBAL_OSACCOUNT_CONSTRAINTS_JSON_PATH =
40     USER_INFO_BASE + PATH_SEPARATOR + "global_os_account_constraints.json";
41 const std::string SPECIFIC_OSACCOUNT_CONSTRAINTS_JSON_PATH =
42     USER_INFO_BASE + PATH_SEPARATOR + "specific_os_account_constraints.json";
43 const char USER_PHOTO_FILE_TXT_NAME[] = "photo.txt";
44 const char USER_INFO_FILE_NAME[] = "account_info.json";
45 const char USER_ADD_SECRET_FLAG_FILE_NAME[] = "add_secret_flag";
46 const char OPERATION_BOOT_ACTIVATED[] = "boot_activated";
47 const char OPERATION_BOOT_CREATE[] = "boot_create";
48 const char OPERATION_BOOT_ACTIVATING[] = "boot_activating";
49 const char OPERATION_CLEAN[] = "cleanGarbage";
50 const char OPERATION_ACTIVATE[] = "activate";
51 const char OPERATION_CREATE[] = "create";
52 const char OPERATION_REMOVE[] = "remove";
53 const char OPERATION_SWITCH[] = "switch";
54 const char OPERATION_STOP[] = "stop";
55 const char OPERATION_UNLOCK[] = "unlock";
56 const char OPERATION_UPDATE_CRED[] = "updateCredential";
57 const char OPERATION_ADD_CRED[] = "addCredential";
58 const char OPERATION_DELETE_CRED[] = "deleteCredential";
59 const char OPERATION_LOG_ERROR[] = "errLog";
60 const char OPERATION_EVENT_PUBLISH[] = "eventPublish";
61 
62 // distributed database
63 const bool SYNC_OS_ACCOUNT_DATABASE = false;
64 const std::uint32_t DEVICE_UUID_LENGTH = 65;
65 
66 // uid judgment
67 const std::int32_t APP_UID_START = 2100;
68 const std::int32_t MAX_SYSTEM_UID_NUM = 2899;
69 
70 // subscribe
71 const int SUBSCRIBER_MAX_SIZE = 100;
72 // account restrict
73 const unsigned int LOCAL_NAME_MAX_SIZE = sysconf(_SC_LOGIN_NAME_MAX);
74 const unsigned int LOCAL_PHOTO_MAX_SIZE = 1024 * 1024;
75 const uint32_t SHORT_NAME_MAX_SIZE = 255;
76 const uint32_t IPC_WRITE_RAW_DATA_MAX_SIZE = 1024 * 1024 * 128;
77 
78 // domain info limits
79 const unsigned int DOMAIN_NAME_MAX_SIZE = 128;
80 
81 // constraint limits
82 const unsigned int CONSTRAINT_MAX_SIZE = 128;
83 
84 const std::int32_t ADMIN_LOCAL_ID = 0;
85 const int ADMIN_TYPE = -1;
86 const std::int32_t START_USER_ID = 100;
87 const std::int32_t MAX_USER_ID = 10736; // Int32 maximum value divided by 200000
88 const std::int32_t INVALID_OS_ACCOUNT_ID = -1;
89 const size_t MAX_USER_ID_LENGTH = 4;
90 const int64_t SERIAL_NUMBER_NUM_START_FOR_ADMIN = 20210231;
91 const int64_t SERIAL_NUMBER_NUM_START = 1;
92 const int64_t CARRY_NUM = 100000000;
93 const bool IS_SERIAL_NUMBER_FULL_INIT_VALUE = false;
94 const int64_t TIME_WAIT_TIME_OUT = 5;
95 const std::int32_t WAIT_ONE_TIME = 1000;
96 const uint64_t DEFAULT_DISPALY_ID = 0;
97 const uint64_t INVALID_DISPALY_ID = -1ull;
98 const uint64_t REENROLL_WAIT_TIME = 3;
99 
100 // an error code of ipc which means peer end is dead
101 const int32_t E_IPC_ERROR = 29189;
102 const int32_t E_IPC_SA_DIED = 32;
103 
104 // max size of subscribed states
105 constexpr uint8_t MAX_SUBSCRIBED_STATES_SIZE = 32;
106 
107 // type template
108 const char ALL_GLOBAL_CONSTRAINTS[] = "allGlobalConstraints";
109 const char ALL_SPECIFIC_CONSTRAINTS[] = "allSpecificConstraints";
110 const char ACCOUNT_LIST[] = "AccountList";
111 const char COUNT_ACCOUNT_NUM[] = "CountAccountNum";
112 const char MAX_ALLOW_CREATE_ACCOUNT_ID[] = "MaxAllowCreateAccountID";
113 const char SERIAL_NUMBER_NUM[] = "SerialNumber";
114 const char IS_MULTI_OS_ACCOUNT_ENABLE[] = "IsMultiOsAccountEnable";
115 const char LOCAL_NAME[] = "localName";
116 const char SHORT_NAME[] = "shortName";
117 
118 // start type
119 const OS_ACCOUNT_SWITCH_MOD NOW_OS_ACCOUNT_SWITCH_MOD = OS_ACCOUNT_SWITCH_MOD::HOT_SWITCH;
120 };  // namespace Constants
121 }  // namespace AccountSA
122 }  // namespace OHOS
123 #endif  // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_CONSTANT_H
124