• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <libminradio/SlotContext.h>
18 
19 #include <android-base/logging.h>
20 #include <libminradio/RadioSlotBase.h>
21 
22 namespace android::hardware::radio::minimal {
23 
SlotContext(unsigned slotIndex)24 SlotContext::SlotContext(unsigned slotIndex) : mSlotIndex(slotIndex) {}
25 
setConnected()26 void SlotContext::setConnected() {
27     CHECK(!mIsConnected) << "Can't setConnected twice";
28     mIsConnected = true;
29     for (auto weakHal : mHals) {
30         auto hal = weakHal.lock();
31         if (!hal) continue;
32         hal->onConnected();
33     }
34 }
35 
isConnected() const36 bool SlotContext::isConnected() const {
37     return mIsConnected;
38 }
39 
getSlotIndex() const40 unsigned SlotContext::getSlotIndex() const {
41     return mSlotIndex;
42 }
43 
addHal(std::weak_ptr<RadioSlotBase> hal)44 void SlotContext::addHal(std::weak_ptr<RadioSlotBase> hal) {
45     mHals.push_back(hal);
46 }
47 
48 }  // namespace android::hardware::radio::minimal
49