1 /* 2 * Copyright (c) 2021-2024 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 OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_INTERFACE_H 17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_INTERFACE_H 18 19 #include <chrono> 20 #include <vector> 21 #include "account_error_no.h" 22 #include <mutex> 23 #include "os_account_info.h" 24 #include "os_account_user_callback.h" 25 26 namespace OHOS { 27 namespace AccountSA { 28 class OsAccountInterface { 29 public: 30 static ErrCode SendToAMSAccountStart(OsAccountInfo &osAccountInfo, 31 const OsAccountStartCallbackFunc &callbackFunc, bool isAppRecovery = false); 32 static ErrCode SendToAMSAccountStop(OsAccountInfo &osAccountInfo); 33 static ErrCode SendToAMSAccountDeactivate(OsAccountInfo &osAccountInfo); 34 static ErrCode SendToBMSAccountCreate( 35 OsAccountInfo &osAccountInfo, const std::vector<std::string> &disallowedHapList = {}, 36 const std::optional<std::vector<std::string>> &allowedHapList = std::nullopt); 37 static ErrCode SendToBMSAccountDelete(OsAccountInfo &osAccountInfo); 38 #ifdef HAS_USER_IDM_PART 39 static ErrCode SendToIDMAccountDelete(OsAccountInfo &osAccountInfo); 40 #endif // HAS_USER_IDM_PART 41 static void SendToCESAccountCreate(OsAccountInfo &osAccountInfo); 42 static void SendToCESAccountDelete(OsAccountInfo &osAccountInfo); 43 static void SendToCESAccountSwitched(int newId, int oldId); 44 static ErrCode SendToStorageAccountCreateComplete(int32_t localId); 45 static ErrCode SendToStorageAccountCreate(OsAccountInfo &osAccountInfo); 46 static ErrCode SendToStorageAccountRemove(OsAccountInfo &osAccountInfo); 47 static ErrCode SendToStorageAccountStart(OsAccountInfo &osAccountInfo); 48 static ErrCode SendToStorageAccountStop(OsAccountInfo &osAccountInfo); 49 static void PublishCommonEvent( 50 const OsAccountInfo &osAccountInfo, const std::string &commonEvent, const std::string &operation); 51 static ErrCode CheckAllAppDied(int32_t accountId); 52 53 private: 54 static ErrCode InnerSendToStorageAccountCreateComplete(int32_t localId); 55 static ErrCode InnerSendToStorageAccountCreate(OsAccountInfo &osAccountInfo); 56 static int32_t UnlockUser(const int localId); 57 }; 58 } // namespace AccountSA 59 } // namespace OHOS 60 61 #endif // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_OSACCOUNT_OS_ACCOUNT_INTERFACE_H 62