1/* 2 * Copyright (c) 2021-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 ACCOUNT_SYNC_H 17#define ACCOUNT_SYNC_H 18 19#include <vector> 20#include <ctime> 21 22#include "account_info.h" 23 24#include "account_data_collection.h" 25#include "contacts_database.h" 26#include "profile_database.h" 27 28namespace OHOS { 29namespace Contacts { 30class AccountSync { 31public: 32 ~AccountSync(); 33 static std::shared_ptr<AccountSync> GetInstance(); 34 static std::shared_ptr<ContactsDataBase> contactsDataBase_; 35 static std::shared_ptr<ProfileDatabase> profileDataBase_; 36 // Update account synchronously 37 void SyncUpdateAccount(std::vector<OHOS::AccountSA::OhosAccountInfo> sysAccounts, bool isProfile); 38 39private: 40 AccountSync(); 41 static std::shared_ptr<AccountSync> instance_; 42 int ClearData(std::shared_ptr<OHOS::NativeRdb::RdbStore> store, int accountId); 43 void getShouldUpdateAndAddAccounts(std::vector<OHOS::AccountSA::OhosAccountInfo> systemAccounts, 44 std::vector<AccountDataCollection> localAccounts, 45 std::vector<OHOS::AccountSA::OhosAccountInfo> &shouldUpdateAccounts, 46 std::vector<OHOS::AccountSA::OhosAccountInfo> &shouldAddAccounts); 47}; 48} // namespace Contacts 49} // namespace OHOS 50 51#endif // ACCOUNT_SYNC_H 52