• 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 "RadioNetwork.h"
18 
19 #include <libminradio/debug.h>
20 #include <libminradio/network/structs.h>
21 #include <libminradio/response.h>
22 
23 #define RADIO_MODULE "NetworkImpl"
24 
25 namespace android::hardware::radio::service {
26 
27 using ::aidl::android::hardware::radio::RadioConst;
28 using ::android::hardware::radio::minimal::noError;
29 using ::ndk::ScopedAStatus;
30 namespace aidl = ::aidl::android::hardware::radio::network;
31 namespace aidlRadio = ::aidl::android::hardware::radio;
32 constexpr auto ok = &ScopedAStatus::ok;
33 
getDataRegistrationState(int32_t serial)34 ScopedAStatus RadioNetwork::getDataRegistrationState(int32_t serial) {
35     LOG_CALL;
36 
37     aidl::CellIdentityLte cellid{
38             .mcc = "310",
39             .mnc = "555",
40             .ci = 12345,
41             .pci = 102,
42             .tac = 1040,
43             .earfcn = 103,
44             .operatorNames =
45                     {
46                             .alphaLong = "Minradio",
47                             .alphaShort = "MR",
48                             .operatorNumeric = "310555",
49                             .status = aidl::OperatorInfo::STATUS_CURRENT,
50                     },
51             .bandwidth = 1400,
52             .additionalPlmns = {},
53             .csgInfo = std::nullopt,
54             .bands =
55                     {
56                             aidl::EutranBands::BAND_1,
57                             aidl::EutranBands::BAND_88,
58                     },
59     };
60     aidl::RegStateResult res{
61             .regState = aidl::RegState::REG_HOME,
62             .rat = aidlRadio::RadioTechnology::LTE,
63             .reasonForDenial = aidl::RegistrationFailCause::NONE,
64             .cellIdentity = cellid,
65             .registeredPlmn = "310555",
66             .accessTechnologySpecificInfo = aidl::EutranRegistrationInfo{},
67     };
68     respond()->getDataRegistrationStateResponse(noError(serial), res);
69     return ok();
70 }
71 
getSignalStrength(int32_t serial)72 ScopedAStatus RadioNetwork::getSignalStrength(int32_t serial) {
73     LOG_CALL;
74 
75     auto signal = minimal::structs::makeSignalStrength();
76     signal.lte = {
77             30,   // (0-31, 99)
78             100,  // Range: 44 to 140 dBm
79             10,   // Range: 20 to 3 dB
80             100, 10, RadioConst::VALUE_UNAVAILABLE, RadioConst::VALUE_UNAVAILABLE,
81     };
82 
83     respond()->getSignalStrengthResponse(noError(serial), signal);
84     return ok();
85 }
86 
87 }  // namespace android::hardware::radio::service
88