• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 <aidl/android/hardware/radio/modem/BnRadioModemIndication.h>
20 #include <aidl/android/hardware/radio/modem/BnRadioModemResponse.h>
21 #include <aidl/android/hardware/radio/modem/IRadioModem.h>
22 #include <aidl/android/hardware/radio/modem/ImeiInfo.h>
23 
24 #include "radio_aidl_hal_utils.h"
25 
26 using namespace aidl::android::hardware::radio::modem;
27 
28 class RadioModemTest;
29 
30 /* Callback class for radio modem response */
31 class RadioModemResponse : public BnRadioModemResponse {
32   protected:
33     RadioServiceTest& parent_modem;
34 
35   public:
36     RadioModemResponse(RadioServiceTest& parent_modem);
37     virtual ~RadioModemResponse() = default;
38 
39     RadioResponseInfo rspInfo;
40     bool isModemEnabled;
41     bool enableModemResponseToggle = false;
42 
43     virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override;
44 
45     virtual ndk::ScopedAStatus enableModemResponse(const RadioResponseInfo& info) override;
46 
47     virtual ndk::ScopedAStatus getBasebandVersionResponse(const RadioResponseInfo& info,
48                                                           const std::string& version) override;
49 
50     virtual ndk::ScopedAStatus getDeviceIdentityResponse(const RadioResponseInfo& info,
51                                                          const std::string& imei,
52                                                          const std::string& imeisv,
53                                                          const std::string& esn,
54                                                          const std::string& meid) override;
55 
56     virtual ndk::ScopedAStatus getImeiResponse(const RadioResponseInfo& info,
57             const std::optional<ImeiInfo>& config) override;
58 
59     virtual ndk::ScopedAStatus getHardwareConfigResponse(
60             const RadioResponseInfo& info, const std::vector<HardwareConfig>& config) override;
61 
62     virtual ndk::ScopedAStatus getModemActivityInfoResponse(
63             const RadioResponseInfo& info, const ActivityStatsInfo& activityInfo) override;
64 
65     virtual ndk::ScopedAStatus getModemStackStatusResponse(const RadioResponseInfo& info,
66                                                            const bool enabled) override;
67 
68     virtual ndk::ScopedAStatus getRadioCapabilityResponse(const RadioResponseInfo& info,
69                                                           const RadioCapability& rc) override;
70 
71     virtual ndk::ScopedAStatus nvReadItemResponse(const RadioResponseInfo& info,
72                                                   const std::string& result) override;
73 
74     virtual ndk::ScopedAStatus nvResetConfigResponse(const RadioResponseInfo& info) override;
75 
76     virtual ndk::ScopedAStatus nvWriteCdmaPrlResponse(const RadioResponseInfo& info) override;
77 
78     virtual ndk::ScopedAStatus nvWriteItemResponse(const RadioResponseInfo& info) override;
79 
80     virtual ndk::ScopedAStatus requestShutdownResponse(const RadioResponseInfo& info) override;
81 
82     virtual ndk::ScopedAStatus sendDeviceStateResponse(const RadioResponseInfo& info) override;
83 
84     virtual ndk::ScopedAStatus setRadioCapabilityResponse(const RadioResponseInfo& info,
85                                                           const RadioCapability& rc) override;
86 
87     virtual ndk::ScopedAStatus setRadioPowerResponse(const RadioResponseInfo& info) override;
88 };
89 
90 /* Callback class for radio modem indication */
91 class RadioModemIndication : public BnRadioModemIndication {
92   protected:
93     RadioServiceTest& parent_modem;
94 
95   public:
96     RadioModemIndication(RadioServiceTest& parent_modem);
97     virtual ~RadioModemIndication() = default;
98 
99     virtual ndk::ScopedAStatus hardwareConfigChanged(
100             RadioIndicationType type, const std::vector<HardwareConfig>& configs) override;
101 
102     virtual ndk::ScopedAStatus modemReset(RadioIndicationType type,
103                                           const std::string& reason) override;
104 
105     virtual ndk::ScopedAStatus radioCapabilityIndication(RadioIndicationType type,
106                                                          const RadioCapability& rc) override;
107 
108     virtual ndk::ScopedAStatus radioStateChanged(RadioIndicationType type,
109                                                  RadioState radioState) override;
110 
111     virtual ndk::ScopedAStatus rilConnected(RadioIndicationType type) override;
112 
113     virtual ndk::ScopedAStatus onImeiMappingChanged(RadioIndicationType type,
114             const ::aidl::android::hardware::radio::modem::ImeiInfo& imeiInfo) override;
115 };
116 
117 // The main test class for Radio AIDL Modem.
118 class RadioModemTest : public RadioServiceTest {
119   public:
120     void SetUp() override;
121 
122     /* radio modem service handle */
123     std::shared_ptr<IRadioModem> radio_modem;
124     /* radio modem response handle */
125     std::shared_ptr<RadioModemResponse> radioRsp_modem;
126     /* radio modem indication handle */
127     std::shared_ptr<RadioModemIndication> radioInd_modem;
128 };
129