1 /* 2 * Copyright (c) 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 #include "account_bundle_info.h" 17 #include "memmgr_log.h" 18 19 namespace OHOS { 20 namespace Memory { 21 namespace { 22 const std::string TAG = "AccountBundleInfo"; 23 } // namespace 24 AccountBundleInfo(int accountId)25AccountBundleInfo::AccountBundleInfo(int accountId):id_(accountId) 26 { 27 } 28 HasBundle(int bundleUid)29bool AccountBundleInfo::HasBundle(int bundleUid) 30 { 31 if (bundleIdInfoMapping_.count(bundleUid) == 0) { 32 return false; 33 } 34 return true; 35 } 36 FindBundleById(int bundleUid)37std::shared_ptr<BundlePriorityInfo> AccountBundleInfo::FindBundleById(int bundleUid) 38 { 39 return bundleIdInfoMapping_.at(bundleUid); 40 } 41 AddBundleToOsAccount(std::shared_ptr<BundlePriorityInfo> bundle)42void AccountBundleInfo::AddBundleToOsAccount(std::shared_ptr<BundlePriorityInfo> bundle) 43 { 44 bundleIdInfoMapping_.insert(std::make_pair(bundle->uid_, bundle)); 45 } 46 RemoveBundleById(int bundleUid)47void AccountBundleInfo::RemoveBundleById(int bundleUid) 48 { 49 bundleIdInfoMapping_.erase(bundleUid); 50 } 51 GetBundlesCount()52int AccountBundleInfo::GetBundlesCount() 53 { 54 return bundleIdInfoMapping_.size(); 55 } 56 } // namespace Memory 57 } // namespace OHOS 58