1 /* 2 * Copyright (c) 2025 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 #include <set> 17 #include <vector> 18 #include "user_delegate_mock.h" 19 20 namespace OHOS::DistributedData { 21 using namespace OHOS::DistributedKv; 22 using DistributedData::UserStatus; GetLocalDeviceId()23std::string GetLocalDeviceId() 24 { 25 return ""; 26 } 27 GetInstance()28UserDelegate &UserDelegate::GetInstance() 29 { 30 static UserDelegate instance; 31 return instance; 32 } 33 GetLocalUserStatus()34std::vector<UserStatus> UserDelegate::GetLocalUserStatus() 35 { 36 if (BUserDelegate::userDelegate == nullptr) { 37 return {}; 38 } 39 return BUserDelegate::userDelegate->GetLocalUserStatus(); 40 } 41 GetRemoteUserStatus(const std::string & deviceId)42std::vector<DistributedData::UserStatus> UserDelegate::GetRemoteUserStatus(const std::string &deviceId) 43 { 44 if (BUserDelegate::userDelegate == nullptr) { 45 return {}; 46 } 47 return BUserDelegate::userDelegate->GetRemoteUserStatus(deviceId); 48 } 49 GetLocalUsers()50std::set<std::string> UserDelegate::GetLocalUsers() 51 { 52 return {}; 53 } 54 GetUsers(const std::string & deviceId)55std::vector<UserStatus> UserDelegate::GetUsers(const std::string &deviceId) 56 { 57 return {}; 58 } 59 DeleteUsers(const std::string & deviceId)60void UserDelegate::DeleteUsers(const std::string &deviceId) 61 { 62 return; 63 } 64 UpdateUsers(const std::string & deviceId,const std::vector<UserStatus> & userStatus)65void UserDelegate::UpdateUsers(const std::string &deviceId, const std::vector<UserStatus> &userStatus) 66 { 67 return; 68 } 69 InitLocalUserMeta()70bool UserDelegate::InitLocalUserMeta() 71 { 72 return true; 73 } 74 Init(const std::shared_ptr<ExecutorPool> & executors)75void UserDelegate::Init(const std::shared_ptr<ExecutorPool> &executors) 76 { 77 return; 78 } 79 GeTask()80ExecutorPool::Task UserDelegate::GeTask() 81 { 82 return [this] { 83 return; 84 }; 85 } 86 NotifyUserEvent(const UserDelegate::UserEvent & userEvent)87bool UserDelegate::NotifyUserEvent(const UserDelegate::UserEvent &userEvent) 88 { 89 return true; 90 } 91 OnAccountChanged(const AccountEventInfo & eventInfo,int32_t timeout)92void UserDelegate::LocalUserObserver::OnAccountChanged(const AccountEventInfo &eventInfo, int32_t timeout) 93 { 94 userDelegate_.NotifyUserEvent({}); 95 } 96 LocalUserObserver(UserDelegate & userDelegate)97UserDelegate::LocalUserObserver::LocalUserObserver(UserDelegate &userDelegate) : userDelegate_(userDelegate) {} 98 Name()99std::string UserDelegate::LocalUserObserver::Name() 100 { 101 return "user_delegate"; 102 } 103 }