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 auto iter = bundleIdInfoMapping_.find(bundleUid); 40 if (iter != bundleIdInfoMapping_.end()) { 41 return iter->second; 42 } 43 HILOGD("not found the bundle info"); 44 return nullptr; 45 } 46 AddBundleToOsAccount(std::shared_ptr<BundlePriorityInfo> bundle)47void AccountBundleInfo::AddBundleToOsAccount(std::shared_ptr<BundlePriorityInfo> bundle) 48 { 49 bundleIdInfoMapping_.insert(std::make_pair(bundle->uid_, bundle)); 50 } 51 RemoveBundleById(int bundleUid)52void AccountBundleInfo::RemoveBundleById(int bundleUid) 53 { 54 bundleIdInfoMapping_.erase(bundleUid); 55 } 56 GetBundlesCount()57int AccountBundleInfo::GetBundlesCount() 58 { 59 return bundleIdInfoMapping_.size(); 60 } 61 } // namespace Memory 62 } // namespace OHOS 63