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 OS_ACCOUNT_CONSTRAINT_CONFIG_PATH = 33 SYSTEM_ETC_BASE + PATH_SEPARATOR + "os_account_constraint_config.json"; 34 const std::string OS_ACCOUNT_CONSTRAINT_DEFINITION_PATH = 35 SYSTEM_ETC_BASE + PATH_SEPARATOR + "os_account_constraint_definition.json"; 36 const std::string ACCOUNT_LIST_FILE_JSON_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_list.json"; 37 const std::string ACCOUNT_INDEX_JSON_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_index_info.json"; 38 const std::string ACCOUNT_INFO_DIGEST_FILE_PATH = USER_INFO_BASE + PATH_SEPARATOR + "account_info_digest.json"; 39 const std::string BASE_OSACCOUNT_CONSTRAINTS_JSON_PATH = 40 USER_INFO_BASE + PATH_SEPARATOR + "base_os_account_constraints.json"; 41 const std::string GLOBAL_OSACCOUNT_CONSTRAINTS_JSON_PATH = 42 USER_INFO_BASE + PATH_SEPARATOR + "global_os_account_constraints.json"; 43 const std::string SPECIFIC_OSACCOUNT_CONSTRAINTS_JSON_PATH = 44 USER_INFO_BASE + PATH_SEPARATOR + "specific_os_account_constraints.json"; 45 const std::string IS_DOMAIN_BOUND_COMPLETED_FILE_NAME = "isDomainAccountBoundCompleted"; 46 const char USER_PHOTO_FILE_TXT_NAME[] = "photo.txt"; 47 const char USER_INFO_FILE_NAME[] = "account_info.json"; 48 const char USER_SECRET_FLAG_FILE_NAME[] = "iam_fault"; 49 const char OPERATION_BOOT_ACTIVATED[] = "boot_activated"; 50 const char OPERATION_BOOT_CREATE[] = "boot_create"; 51 const char OPERATION_BOOT_ACTIVATING[] = "boot_activating"; 52 const char OPERATION_CLEAN[] = "cleanGarbage"; 53 const char OPERATION_ACTIVATE[] = "activate"; 54 const char OPERATION_CREATE[] = "create"; 55 const char OPERATION_REMOVE[] = "remove"; 56 const char OPERATION_SWITCH[] = "switch"; 57 const char OPERATION_STARTING[] = "starting"; 58 const char OPERATION_STARTED[] = "started"; 59 const char OPERATION_STOP[] = "stop"; 60 const char OPERATION_UNLOCK[] = "unlock"; 61 const char OPERATION_LOCKING[] = "locking"; 62 const char OPERATION_LOCKED[] = "locked"; 63 const char OPERATION_UPDATE_CRED[] = "updateCredential"; 64 const char OPERATION_ADD_CRED[] = "addCredential"; 65 const char OPERATION_DELETE_CRED[] = "deleteCredential"; 66 const char OPERATION_LOG_ERROR[] = "errLog"; 67 const char OPERATION_UPDATE_SERVER_CONFIG[] = "updateServerConfig"; 68 69 // Domain account DFX flag 70 const char OPERATION_BIND_DOMAIN_ACCOUNT[] = "bindDomainAccount"; 71 const char OPERATION_RECOVER_BIND_DOMAIN_ACCOUNT[] = "recoverBindDomainAccount"; 72 const char OPERATION_BOOT_RECOVER_BIND_DOMAIN_ACCOUNT[] = "boot_recoverBindDomainAccount"; 73 // distributed database 74 const bool SYNC_OS_ACCOUNT_DATABASE = false; 75 const std::uint32_t DEVICE_UUID_LENGTH = 65; 76 77 // uid judgment 78 const std::int32_t APP_UID_START = 2100; 79 const std::int32_t MAX_SYSTEM_UID_NUM = 2899; 80 81 // subscribe 82 const int SUBSCRIBER_MAX_SIZE = 100; 83 // account restrict 84 const unsigned int LOCAL_NAME_MAX_SIZE = sysconf(_SC_LOGIN_NAME_MAX); 85 const unsigned int LOCAL_PHOTO_MAX_SIZE = 1024 * 1024; 86 const uint32_t SHORT_NAME_MAX_SIZE = 255; 87 const uint32_t IPC_WRITE_RAW_DATA_MAX_SIZE = 1024 * 1024 * 128; 88 89 // domain info limits 90 const unsigned int DOMAIN_NAME_MAX_SIZE = 128; 91 92 // constraint limits 93 const unsigned int CONSTRAINT_MAX_SIZE = 128; 94 95 const std::int32_t ADMIN_LOCAL_ID = 0; 96 const std::int32_t U1_ID = 1; 97 const int ADMIN_TYPE = -1; 98 const std::int32_t START_USER_ID = 100; 99 const std::int32_t MAINTENANCE_USER_ID = 10377; 100 const std::int32_t MAX_USER_ID = 10736; // Int32 maximum value divided by 200000 101 const std::int32_t MAX_CREATABLE_USER_ID = 999; 102 const std::int32_t INVALID_OS_ACCOUNT_ID = -1; 103 const size_t MAX_USER_ID_LENGTH = 4; 104 const int64_t SERIAL_NUMBER_NUM_START_FOR_ADMIN = 20210231; 105 const int64_t SERIAL_NUMBER_NUM_START = 1; 106 const int64_t CARRY_NUM = 100000000; 107 const bool IS_SERIAL_NUMBER_FULL_INIT_VALUE = false; 108 const int64_t TIME_WAIT_TIME_OUT = 5; 109 const std::int32_t WAIT_ONE_TIME = 1000; 110 const uint64_t DEFAULT_DISPALY_ID = 0; 111 const uint64_t INVALID_DISPALY_ID = -1ull; 112 const uint64_t REENROLL_WAIT_TIME = 3; 113 114 // max size of subscribed states 115 constexpr uint8_t MAX_SUBSCRIBED_STATES_SIZE = 32; 116 117 // type template 118 const char ALL_GLOBAL_CONSTRAINTS[] = "allGlobalConstraints"; 119 const char ALL_SPECIFIC_CONSTRAINTS[] = "allSpecificConstraints"; 120 const char ACCOUNT_LIST[] = "AccountList"; 121 const char COUNT_ACCOUNT_NUM[] = "CountAccountNum"; 122 const char MAX_ALLOW_CREATE_ACCOUNT_ID[] = "MaxAllowCreateAccountID"; 123 const char SERIAL_NUMBER_NUM[] = "SerialNumber"; 124 const char IS_MULTI_OS_ACCOUNT_ENABLE[] = "IsMultiOsAccountEnable"; 125 const char LOCAL_NAME[] = "localName"; 126 const char SHORT_NAME[] = "shortName"; 127 128 // start type 129 const OS_ACCOUNT_SWITCH_MOD NOW_OS_ACCOUNT_SWITCH_MOD = OS_ACCOUNT_SWITCH_MOD::HOT_SWITCH; 130 }; // namespace Constants 131 } // namespace AccountSA 132 } // namespace OHOS 133 #endif // OS_ACCOUNT_INTERFACES_INNERKITS_OS_ACCOUNT_CONSTANT_H 134