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 SERVICES_INCLUDE_SCREENLOCK_COMMON_H 17 #define SERVICES_INCLUDE_SCREENLOCK_COMMON_H 18 19 #include <string> 20 21 #include "errors.h" 22 23 namespace OHOS { 24 namespace ScreenLock { 25 #define SCREENLOCK_SERVICE_NAME "ScreenLockService" 26 #define PARAM_ZERO 0 27 #define PARAM_ONE 1 28 #define PARAM_TWO 2 29 30 const std::string BEGIN_WAKEUP = "beginWakeUp"; 31 const std::string END_WAKEUP = "endWakeUp"; 32 const std::string BEGIN_SCREEN_ON = "beginScreenOn"; 33 const std::string END_SCREEN_ON = "endScreenOn"; 34 const std::string BEGIN_SLEEP = "beginSleep"; 35 const std::string END_SLEEP = "endSleep"; 36 const std::string BEGIN_SCREEN_OFF = "beginScreenOff"; 37 const std::string END_SCREEN_OFF = "endScreenOff"; 38 const std::string STRONG_AUTH_CHANGED = "strongAuthChanged"; 39 const std::string CHANGE_USER = "changeUser"; 40 const std::string SCREENLOCK_ENABLED = "screenlockEnabled"; 41 const std::string EXIT_ANIMATION = "beginExitAnimation"; 42 const std::string UNLOCKSCREEN = "unlockScreen"; 43 const std::string UNLOCK_SCREEN_RESULT = "unlockScreenResult"; 44 const std::string LOCKSCREEN = "lockScreen"; 45 const std::string LOCK_SCREEN_RESULT = "lockScreenResult"; 46 const std::string SCREEN_DRAWDONE = "screenDrawDone"; 47 const std::string SYSTEM_READY = "systemReady"; 48 const std::string SERVICE_RESTART = "serviceRestart"; 49 const int USER_NULL = -10000; 50 enum ScreenLockModule { 51 SCREENLOCK_MODULE_SERVICE_ID = 0x04, 52 }; 53 // time error offset, used only in this file. 54 constexpr ErrCode SCREENLOCK_ERR_OFFSET = ErrCodeOffset(SUBSYS_SMALLSERVICES, SCREENLOCK_MODULE_SERVICE_ID); 55 56 enum ScreenLockError { 57 E_SCREENLOCK_OK = SCREENLOCK_ERR_OFFSET, 58 E_SCREENLOCK_SA_DIED, 59 E_SCREENLOCK_READ_PARCEL_ERROR, 60 E_SCREENLOCK_WRITE_PARCEL_ERROR, 61 E_SCREENLOCK_PUBLISH_FAIL, 62 E_SCREENLOCK_TRANSACT_ERROR, 63 E_SCREENLOCK_DEAL_FAILED, 64 E_SCREENLOCK_PARAMETERS_INVALID, 65 E_SCREENLOCK_SET_RTC_FAILED, 66 E_SCREENLOCK_NOT_FOUND, 67 E_SCREENLOCK_NO_PERMISSION, 68 E_SCREENLOCK_NULLPTR, 69 E_SCREENLOCK_SENDREQUEST_FAILED, 70 E_SCREENLOCK_NOT_SYSTEM_APP, 71 E_SCREENLOCK_NOT_FOCUS_APP, 72 E_SCREENLOCK_USER_ID_INVALID, 73 }; 74 75 enum TraceTaskId : int32_t { 76 HITRACE_UNLOCKSCREEN, 77 HITRACE_LOCKSCREEN, 78 HITRACE_BUTT, 79 }; 80 81 enum ScreenChange { 82 SCREEN_SUCC = 0, 83 SCREEN_FAIL, 84 SCREEN_CANCEL, 85 }; 86 87 enum JsErrorCode : uint32_t { 88 ERR_NO_PERMISSION = 201, 89 ERR_NOT_SYSTEM_APP = 202, 90 ERR_INVALID_PARAMS = 401, 91 ERR_CANCEL_UNLOCK = 13200001, 92 ERR_SERVICE_ABNORMAL = 13200002, 93 ERR_ILLEGAL_USE = 13200003, 94 ERR_USER_ID_INVALID = 13200004, 95 }; 96 97 enum class Action : uint8_t { 98 LOCK = 0, 99 UNLOCK, 100 UNLOCKSCREEN, 101 }; 102 103 enum class StrongAuthReasonFlags : int32_t { 104 NONE = 0x00000000, 105 AFTER_BOOT = 0x00000001, 106 AFTER_TIMEOUT = 0x00000002, 107 ACTIVE_REQUEST = 0x00000004, 108 DPM_RESTRICT = 0x00000008, 109 }; 110 111 enum class SpecialUserId : int32_t { 112 USER_ALL = -1, 113 USER_CURRENT = -2, 114 USER_UNDEFINED = -10000, 115 }; 116 117 enum class ListenType : int32_t { 118 STRONG_AUTH, 119 DEVICE_LOCK, 120 LISTEN_TYPE_BUT, 121 }; 122 123 constexpr int BEGIN_SLEEP_DEVICE_ADMIN_REASON = 1; 124 constexpr int BEGIN_SLEEP_USER_REASON = 2; 125 constexpr int BEGIN_SLEEP_LONG_TIME_UNOPERATOR = 3; 126 127 constexpr int END_SLEEP_DEVICE_ADMIN_REASON = 1; 128 constexpr int END_SLEEP_USER_REASON = 2; 129 constexpr int END_SLEEP_LONG_TIME_UNOPERATE = 3; 130 131 constexpr int SCREENLOCK_APP_CAN_USE = 1; 132 constexpr int SCREENLOCK_APP_CAN_NOT_USE = 0; 133 134 constexpr std::int32_t DEFAULT_ERROR = -1; 135 constexpr int32_t NONE_EVENT_TYPE = 0; 136 constexpr int ARGV_ZERO = 0; 137 constexpr int ARGV_ONE = 1; 138 constexpr int ARGV_TWO = 2; 139 constexpr int ARGV_THREE = 3; 140 constexpr int ARGV_NORMAL = -100; 141 constexpr std::int32_t MAX_VALUE_LEN = 4096; 142 constexpr const std::int32_t STR_MAX_SIZE = 256; 143 constexpr int RESULT_COUNT = 2; 144 constexpr int PARAMTWO = 2; 145 constexpr std::int32_t ARGS_SIZE_ZERO = 0; 146 constexpr std::int32_t ARGS_SIZE_ONE = 1; 147 constexpr std::int32_t ARGS_SIZE_TWO = 2; 148 constexpr std::int32_t ARGS_SIZE_THREE = 3; 149 constexpr std::int32_t ARGS_SIZE_FOUR = 4; 150 constexpr std::int32_t RESULT_ZERO = 0; 151 } // namespace ScreenLock 152 } // namespace OHOS 153 #endif // SERVICES_INCLUDE_SCREENLOCK_COMMON_H