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 "partitionslot_impl.h"
17 
18 #include <hdf_base.h>
19 #include <hdf_log.h>
20 #include "partitionslot_manager.h"
21 
22 namespace OHOS {
23 namespace HDI {
24 namespace Partitionslot {
25 namespace V1_0 {
26 #define HDF_LOG_TAG           hdf_partitionslot_impl
27 
PartitionSlotImplGetInstance(void)28 extern "C" IPartitionSlot *PartitionSlotImplGetInstance(void)
29 {
30     return new (std::nothrow) PartitionSlotImpl();
31 }
32 
GetCurrentSlot(int32_t & currentSlot,int32_t & numOfSlots)33 int32_t PartitionSlotImpl::GetCurrentSlot(int32_t& currentSlot, int32_t& numOfSlots)
34 {
35     HDF_LOGD("%{public}s called!", __func__);
36     return PartitionSlotManager::GetInstance()->GetCurrentSlot(currentSlot, numOfSlots);
37 }
38 
GetSlotSuffix(int32_t slot,std::string & suffix)39 int32_t PartitionSlotImpl::GetSlotSuffix(int32_t slot, std::string& suffix)
40 {
41     HDF_LOGD("%{public}s called!", __func__);
42     return PartitionSlotManager::GetInstance()->GetSlotSuffix(slot, suffix);
43 }
44 
SetActiveSlot(int32_t slot)45 int32_t PartitionSlotImpl::SetActiveSlot(int32_t slot)
46 {
47     HDF_LOGD("%{public}s called!, slot is %{public}d", __func__, slot);
48     return PartitionSlotManager::GetInstance()->SetActiveSlot(slot);
49 }
50 
SetSlotUnbootable(int32_t slot)51 int32_t PartitionSlotImpl::SetSlotUnbootable(int32_t slot)
52 {
53     HDF_LOGD("%{public}s called!, slot is %{public}d", __func__, slot);
54     return PartitionSlotManager::GetInstance()->SetSlotUnbootable(slot);
55 }
56 } // V1_0
57 } // Partitionslot
58 } // HDI
59 } // OHOS
60