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 "udmf_client.h" 17 18 namespace OHOS { 19 namespace UDMF { 20 GetInstance()21UdmfClient &UdmfClient::GetInstance() 22 { 23 static UdmfClient utils; 24 return utils; 25 } 26 Init()27void UdmfClient::Init() 28 { 29 getBatchDataRet_ = 0; 30 addPrivilegeRet_ = 0; 31 UdmfClient::unifiedData_.clear(); 32 } 33 GetBatchData(const QueryOption & query,std::vector<UnifiedData> & unifiedDataset)34int32_t UdmfClient::GetBatchData(const QueryOption &query, std::vector<UnifiedData> &unifiedDataset) 35 { 36 unifiedDataset = unifiedData_; 37 return getBatchDataRet_; 38 } 39 AddPrivilege(const QueryOption & query,const Privilege & privilege)40int32_t UdmfClient::AddPrivilege(const QueryOption &query, const Privilege &privilege) 41 { 42 if (privilege.tokenId == privilegeTokenId_) { 43 return 0; 44 } 45 return addPrivilegeRet_; 46 } 47 GetBundleNameByUdKey(const std::string & key)48std::string UdmfClient::GetBundleNameByUdKey(const std::string &key) 49 { 50 return keyAuthority; 51 } 52 53 int32_t UdmfClient::getBatchDataRet_ = 0; 54 int32_t UdmfClient::addPrivilegeRet_ = 0; 55 int32_t UdmfClient::privilegeTokenId_ = 10000; 56 std::vector<UnifiedData> UdmfClient::unifiedData_ = {}; 57 std::string UdmfClient::keyAuthority = ""; 58 } // OHOS 59 } // UDMF