1 /*
2 * Copyright (C) 2025 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 #pragma once
18
19 #include <cstdint>
20 #include <aidl/android/hardware/radio/RadioTechnology.h>
21
22 namespace aidl {
23 namespace android {
24 namespace hardware {
25 namespace radio {
26 namespace implementation {
27 namespace ratUtils {
28
ratbit(const RadioTechnology r)29 constexpr uint32_t ratbit(const RadioTechnology r) {
30 return 1U << static_cast<unsigned>(r);
31 }
32
33 enum class ModemTechnology {
34 GSM, WCDMA, CDMA, EVDO, TDSCDMA, LTE, NR
35 };
36
37 constexpr uint32_t kGSM = ratbit(RadioTechnology::GSM) |
38 ratbit(RadioTechnology::GPRS) |
39 ratbit(RadioTechnology::EDGE);
40 constexpr uint32_t kWCDMA = ratbit(RadioTechnology::HSUPA) |
41 ratbit(RadioTechnology::HSDPA) |
42 ratbit(RadioTechnology::HSPA) |
43 ratbit(RadioTechnology::HSPAP) |
44 ratbit(RadioTechnology::UMTS);
45 constexpr uint32_t kCDMA = ratbit(RadioTechnology::IS95A) |
46 ratbit(RadioTechnology::IS95B) |
47 ratbit(RadioTechnology::ONE_X_RTT);
48 constexpr uint32_t kEVDO = ratbit(RadioTechnology::EVDO_0) |
49 ratbit(RadioTechnology::EVDO_A) |
50 ratbit(RadioTechnology::EVDO_B) |
51 ratbit(RadioTechnology::EHRPD);
52 constexpr uint32_t kTDSCDMA =
53 ratbit(RadioTechnology::TD_SCDMA);
54 constexpr uint32_t kLTE = ratbit(RadioTechnology::LTE);
55 constexpr uint32_t kNR = ratbit(RadioTechnology::NR);
56
57 uint32_t supportedRadioTechBitmask(const ModemTechnology mtech);
58 RadioTechnology currentRadioTechnology(const ModemTechnology mtech);
59
60 ModemTechnology modemTechnologyFromRadioTechnologyBitmask(
61 uint32_t radioTechnologyBitmask);
62
63 uint32_t modemTechnologyBitmaskFromRadioTechnologyBitmask(
64 uint32_t radioTechnologyBitmask);
65
66 } // namespace ratUtils
67 } // namespace implementation
68 } // namespace radio
69 } // namespace hardware
70 } // namespace android
71 } // namespace aidl
72