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 16 #ifndef BASE_NOTIFICATION_OS_ACCOUNT_MANAGER_HELPER_H 17 #define BASE_NOTIFICATION_OS_ACCOUNT_MANAGER_HELPER_H 18 19 #include "errors.h" 20 #include "singleton.h" 21 #include <vector> 22 23 namespace OHOS { 24 namespace Notification { 25 class OsAccountManagerHelper : public DelayedSingleton<OsAccountManagerHelper> { 26 public: 27 28 OsAccountManagerHelper() = default; 29 ~OsAccountManagerHelper() = default; 30 31 /** 32 * @brief Get OsAccountManagerHelper instance object. 33 */ 34 static OsAccountManagerHelper &GetInstance(); 35 36 /** 37 * @brief check is system account 38 */ 39 static bool IsSystemAccount(int32_t userId); 40 41 /** 42 * Gets operating system account local ID from uid. 43 * 44 * @param uid Indicates the uid. 45 * @param id Indicates the account ID. 46 * @return Returns result code. 47 */ 48 ErrCode GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id); 49 50 /** 51 * Gets operating system account local ID from current calling. 52 * 53 * @param id Indicates the current calling account ID. 54 * @return Returns result code. 55 */ 56 ErrCode GetCurrentCallingUserId(int32_t &id); 57 58 /** 59 * Gets operating system account local ID from current active. 60 * 61 * @param id Indicates the current active account ID. 62 * @return Returns result code. 63 */ 64 ErrCode GetCurrentActiveUserId(int32_t &id); 65 66 /** 67 * Check the userId whether exists in OsAccount service. 68 * 69 * @param userId Indicates the current active account ID. 70 * @return Returns result. 71 */ 72 bool CheckUserExists(const int32_t &userId); 73 74 /** 75 * Get All os account userIds. 76 * 77 * @param userIds Indicates the current created account ID. 78 * @return Returns result. 79 */ 80 ErrCode GetAllOsAccount(std::vector<int32_t> &userIds); 81 82 /** 83 * Get All active account userIds. 84 * 85 * @param userIds Indicates the current active account ID. 86 * @return Returns result. 87 */ 88 ErrCode GetAllActiveOsAccount(std::vector<int32_t> &userIds); 89 }; 90 } // namespace OHOS 91 } // namespace Notification 92 #endif // BASE_NOTIFICATION_OS_ACCOUNT_MANAGER_HELPER_H