• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include <memory>
19 #include <mutex>
20 
21 #include <aidl/android/hardware/radio/network/BnRadioNetwork.h>
22 #include "AtChannel.h"
23 
24 namespace aidl {
25 namespace android {
26 namespace hardware {
27 namespace radio {
28 namespace implementation {
29 using ::ndk::ScopedAStatus;
30 
31 struct RadioNetwork : public network::BnRadioNetwork {
32     RadioNetwork(std::shared_ptr<AtChannel> atChannel);
33 
34     ScopedAStatus getAllowedNetworkTypesBitmap(int32_t serial) override;
35     ScopedAStatus getAvailableBandModes(int32_t serial) override;
36     ScopedAStatus getAvailableNetworks(int32_t serial) override;
37     ScopedAStatus getBarringInfo(int32_t serial) override;
38     ScopedAStatus getCdmaRoamingPreference(int32_t serial) override;
39     ScopedAStatus getCellInfoList(int32_t serial) override;
40     ScopedAStatus getDataRegistrationState(int32_t serial) override;
41     ScopedAStatus getImsRegistrationState(int32_t serial) override;
42     ScopedAStatus getNetworkSelectionMode(int32_t serial) override;
43     ScopedAStatus getOperator(int32_t serial) override;
44     ScopedAStatus getSignalStrength(int32_t serial) override;
45     ScopedAStatus getSystemSelectionChannels(int32_t serial) override;
46     ScopedAStatus getVoiceRadioTechnology(int32_t serial) override;
47     ScopedAStatus getVoiceRegistrationState(int32_t serial) override;
48     ScopedAStatus isNrDualConnectivityEnabled(int32_t serial) override;
49     ScopedAStatus setAllowedNetworkTypesBitmap(int32_t serial,
50                                                int32_t networkTypeBitmap) override;
51     ScopedAStatus setBandMode(
52             int32_t serial, network::RadioBandMode mode) override;
53     ScopedAStatus setBarringPassword(int32_t serial, const std::string& facility,
54                                      const std::string& oldPassword,
55                                      const std::string& newPassword) override;
56     ScopedAStatus setCdmaRoamingPreference(
57             int32_t serial, network::CdmaRoamingType type) override;
58     ScopedAStatus setCellInfoListRate(int32_t serial, int32_t rate) override;
59     ScopedAStatus setIndicationFilter(int32_t serial, int32_t indicationFilter) override;
60     ScopedAStatus setLinkCapacityReportingCriteria(
61             int32_t serial, int32_t hysteresisMs, int32_t hysteresisDlKbps,
62             int32_t hysteresisUlKbps, const std::vector<int32_t>& thresholdsDownlinkKbps,
63             const std::vector<int32_t>& thresholdsUplinkKbps, AccessNetwork accessNetwork) override;
64     ScopedAStatus setLocationUpdates(int32_t serial, bool enable) override;
65     ScopedAStatus setNetworkSelectionModeAutomatic(int32_t serial) override;
66     ScopedAStatus setNetworkSelectionModeManual(
67             int32_t serial, const std::string& operatorNumeric, AccessNetwork ran) override;
68     ScopedAStatus setNrDualConnectivityState(
69             int32_t serial, network::NrDualConnectivityState nrSt) override;
70     ScopedAStatus setSignalStrengthReportingCriteria(
71             int32_t serial, const std::vector<network::SignalThresholdInfo>&
72                     signalThresholdInfos) override;
73     ScopedAStatus setSuppServiceNotifications(int32_t serial, bool enable) override;
74     ScopedAStatus setSystemSelectionChannels(
75             int32_t serial, bool specifyChannels,
76             const std::vector<network::RadioAccessSpecifier>& specifiers) override;
77     ScopedAStatus startNetworkScan(
78             int32_t serial, const network::NetworkScanRequest& request) override;
79     ScopedAStatus stopNetworkScan(int32_t serial) override;
80     ScopedAStatus supplyNetworkDepersonalization(int32_t serial, const std::string& netPin) override;
81     ScopedAStatus setUsageSetting(
82             int32_t serial, network::UsageSetting usageSetting) override;
83     ScopedAStatus getUsageSetting(int32_t serial) override;
84     ScopedAStatus setEmergencyMode(
85             int32_t serial, network::EmergencyMode emergencyMode) override;
86     ScopedAStatus triggerEmergencyNetworkScan(
87             int32_t serial, const network::EmergencyNetworkScanTrigger& scanTrigger) override;
88     ScopedAStatus cancelEmergencyNetworkScan(int32_t serial, bool resetScan) override;
89     ScopedAStatus exitEmergencyMode(int32_t serial) override;
90     ScopedAStatus isN1ModeEnabled(int32_t serial) override;
91     ScopedAStatus setN1ModeEnabled(int32_t serial, bool enable) override;
92     ScopedAStatus setNullCipherAndIntegrityEnabled(int32_t serial, bool enabled) override;
93     ScopedAStatus isNullCipherAndIntegrityEnabled(int32_t serial) override;
94     ScopedAStatus isCellularIdentifierTransparencyEnabled(int32_t serial) override;
95     ScopedAStatus setCellularIdentifierTransparencyEnabled(int32_t serial,
96                                                            bool enabled) override;
97     ScopedAStatus setSecurityAlgorithmsUpdatedEnabled(int32_t serial, bool enabled) override;
98     ScopedAStatus isSecurityAlgorithmsUpdatedEnabled(int32_t serial) override;
99 
100     void atResponseSink(const AtResponsePtr& response);
101     void handleUnsolicited(const AtResponse::CFUN&);
102     void handleUnsolicited(const AtResponse::CREG&);
103     void handleUnsolicited(const AtResponse::CGREG&);
104     void handleUnsolicited(const AtResponse::CSQ&);
105     void handleUnsolicited(const AtResponse::COPS&);
106     void handleUnsolicited(const AtResponse::CTEC&);
107     void handleUnsolicited(const AtResponse::CGFPCCFG&);
108     void handleUnsolicited(const AtResponse::CTZV&);
handleUnsolicitedRadioNetwork109     template <class IGNORE> void handleUnsolicited(const IGNORE&) {}
110 
111     ScopedAStatus responseAcknowledgement() override;
112     ScopedAStatus setResponseFunctions(
113             const std::shared_ptr<network::IRadioNetworkResponse>& radioNetworkResponse,
114             const std::shared_ptr<network::IRadioNetworkIndication>& radioNetworkIndication) override;
115 
116 private:
117     const std::shared_ptr<AtChannel> mAtChannel;
118     AtChannel::Conversation mAtConversation;
119     std::shared_ptr<network::IRadioNetworkResponse> mRadioNetworkResponse;
120     std::shared_ptr<network::IRadioNetworkIndication> mRadioNetworkIndication;
121 
122     std::mutex          mMtx;
123     AtResponse::CREG    mCreg;
124     AtResponse::CGREG   mCgreg;
125     AtResponse::CSQ     mCsq;
126     std::optional<AtResponse::COPS::OperatorInfo> mCurrentOperator;
127     std::optional<ratUtils::ModemTechnology> mCurrentModemTech;
128     AtResponse::CTZV    mCtzv;
129     int64_t             mCtzvTimestamp;
130     modem::RadioState   mRadioState = modem::RadioState::OFF;
131     int                 mPrimaryBandwidth = 0;
132     int                 mSecondaryBandwidth = 0;
133     bool                mNullCipherAndIntegrityEnabled = false;
134     bool                mIsCellularIdentifierTransparencyEnabled = false;
135     bool                mSecurityAlgorithmsUpdatedEnabled = false;
136     bool                mIsNrDualConnectivityEnabled = true;
137     bool                mIsN1ModeEnabled = false;
138 };
139 
140 }  // namespace implementation
141 }  // namespace radio
142 }  // namespace hardware
143 }  // namespace android
144 }  // namespace aidl
145