1 /*
2 * Copyright (C) 2017 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 <android-base/logging.h>
18 #include <radio_hidl_hal_utils_v1_0.h>
19
20 using namespace ::android::hardware::radio::V1_0;
21
22 /*
23 * Test IRadio.setGsmBroadcastConfig() for the response returned.
24 */
TEST_P(RadioHidlTest,setGsmBroadcastConfig)25 TEST_P(RadioHidlTest, setGsmBroadcastConfig) {
26 LOG(DEBUG) << "setGsmBroadcastConfig";
27 serial = GetRandomSerialNumber();
28
29 // Create GsmBroadcastSmsConfigInfo #1
30 GsmBroadcastSmsConfigInfo gbSmsConfig1;
31 gbSmsConfig1.fromServiceId = 4352;
32 gbSmsConfig1.toServiceId = 4354;
33 gbSmsConfig1.fromCodeScheme = 0;
34 gbSmsConfig1.toCodeScheme = 255;
35 gbSmsConfig1.selected = true;
36
37 // Create GsmBroadcastSmsConfigInfo #2
38 GsmBroadcastSmsConfigInfo gbSmsConfig2;
39 gbSmsConfig2.fromServiceId = 4356;
40 gbSmsConfig2.toServiceId = 4356;
41 gbSmsConfig2.fromCodeScheme = 0;
42 gbSmsConfig2.toCodeScheme = 255;
43 gbSmsConfig2.selected = true;
44
45 // Create GsmBroadcastSmsConfigInfo #3
46 GsmBroadcastSmsConfigInfo gbSmsConfig3;
47 gbSmsConfig3.fromServiceId = 4370;
48 gbSmsConfig3.toServiceId = 4379;
49 gbSmsConfig3.fromCodeScheme = 0;
50 gbSmsConfig3.toCodeScheme = 255;
51 gbSmsConfig3.selected = true;
52
53 // Create GsmBroadcastSmsConfigInfo #4
54 GsmBroadcastSmsConfigInfo gbSmsConfig4;
55 gbSmsConfig4.fromServiceId = 4383;
56 gbSmsConfig4.toServiceId = 4391;
57 gbSmsConfig4.fromCodeScheme = 0;
58 gbSmsConfig4.toCodeScheme = 255;
59 gbSmsConfig4.selected = true;
60
61 // Create GsmBroadcastSmsConfigInfo #5
62 GsmBroadcastSmsConfigInfo gbSmsConfig5;
63 gbSmsConfig5.fromServiceId = 4392;
64 gbSmsConfig5.toServiceId = 4392;
65 gbSmsConfig5.fromCodeScheme = 0;
66 gbSmsConfig5.toCodeScheme = 255;
67 gbSmsConfig5.selected = true;
68
69 android::hardware::hidl_vec<GsmBroadcastSmsConfigInfo> gsmBroadcastSmsConfigsInfoList = {
70 gbSmsConfig1, gbSmsConfig2, gbSmsConfig3, gbSmsConfig4, gbSmsConfig5};
71
72 radio->setGsmBroadcastConfig(serial, gsmBroadcastSmsConfigsInfoList);
73
74 EXPECT_EQ(std::cv_status::no_timeout, wait());
75 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
76 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
77
78 if (cardStatus.cardState == CardState::ABSENT) {
79 ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
80 {RadioError::NONE, RadioError::INVALID_ARGUMENTS,
81 RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE},
82 CHECK_GENERAL_ERROR));
83 }
84 LOG(DEBUG) << "setGsmBroadcastConfig finished";
85 }
86
87 /*
88 * Test IRadio.getGsmBroadcastConfig() for the response returned.
89 */
TEST_P(RadioHidlTest,getGsmBroadcastConfig)90 TEST_P(RadioHidlTest, getGsmBroadcastConfig) {
91 LOG(DEBUG) << "getGsmBroadcastConfig";
92 serial = GetRandomSerialNumber();
93
94 radio->getGsmBroadcastConfig(serial);
95
96 EXPECT_EQ(std::cv_status::no_timeout, wait());
97 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
98 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
99
100 if (cardStatus.cardState == CardState::ABSENT) {
101 ASSERT_TRUE(CheckAnyOfErrors(
102 radioRsp->rspInfo.error,
103 {RadioError::NONE, RadioError::INVALID_MODEM_STATE, RadioError::INVALID_STATE},
104 CHECK_GENERAL_ERROR));
105 }
106 LOG(DEBUG) << "getGsmBroadcastConfig finished";
107 }
108
109 /*
110 * Test IRadio.setCdmaBroadcastConfig() for the response returned.
111 */
TEST_P(RadioHidlTest,setCdmaBroadcastConfig)112 TEST_P(RadioHidlTest, setCdmaBroadcastConfig) {
113 LOG(DEBUG) << "setCdmaBroadcastConfig";
114 serial = GetRandomSerialNumber();
115
116 CdmaBroadcastSmsConfigInfo cbSmsConfig;
117 cbSmsConfig.serviceCategory = 4096;
118 cbSmsConfig.language = 1;
119 cbSmsConfig.selected = true;
120
121 android::hardware::hidl_vec<CdmaBroadcastSmsConfigInfo> cdmaBroadcastSmsConfigInfoList = {
122 cbSmsConfig};
123
124 radio->setCdmaBroadcastConfig(serial, cdmaBroadcastSmsConfigInfoList);
125
126 EXPECT_EQ(std::cv_status::no_timeout, wait());
127 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
128 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
129
130 if (cardStatus.cardState == CardState::ABSENT) {
131 ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
132 {RadioError::NONE, RadioError::INVALID_MODEM_STATE},
133 CHECK_GENERAL_ERROR));
134 }
135 LOG(DEBUG) << "setCdmaBroadcastConfig finished";
136 }
137
138 /*
139 * Test IRadio.getCdmaBroadcastConfig() for the response returned.
140 */
TEST_P(RadioHidlTest,getCdmaBroadcastConfig)141 TEST_P(RadioHidlTest, getCdmaBroadcastConfig) {
142 LOG(DEBUG) << "getCdmaBroadcastConfig";
143 serial = GetRandomSerialNumber();
144
145 radio->getCdmaBroadcastConfig(serial);
146
147 EXPECT_EQ(std::cv_status::no_timeout, wait());
148 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
149 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
150
151 if (cardStatus.cardState == CardState::ABSENT) {
152 ASSERT_TRUE(
153 CheckAnyOfErrors(radioRsp->rspInfo.error, {RadioError::NONE}, CHECK_GENERAL_ERROR));
154 }
155 LOG(DEBUG) << "getCdmaBroadcastConfig finished";
156 }
157
158 /*
159 * Test IRadio.setCdmaBroadcastActivation() for the response returned.
160 */
TEST_P(RadioHidlTest,setCdmaBroadcastActivation)161 TEST_P(RadioHidlTest, setCdmaBroadcastActivation) {
162 LOG(DEBUG) << "setCdmaBroadcastActivation";
163 serial = GetRandomSerialNumber();
164 bool activate = false;
165
166 radio->setCdmaBroadcastActivation(serial, activate);
167
168 EXPECT_EQ(std::cv_status::no_timeout, wait());
169 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
170 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
171
172 if (cardStatus.cardState == CardState::ABSENT) {
173 ASSERT_TRUE(CheckAnyOfErrors(radioRsp->rspInfo.error,
174 {RadioError::NONE, RadioError::INVALID_ARGUMENTS},
175 CHECK_GENERAL_ERROR));
176 }
177 LOG(DEBUG) << "setCdmaBroadcastActivation finished";
178 }
179
180 /*
181 * Test IRadio.setGsmBroadcastActivation() for the response returned.
182 */
TEST_P(RadioHidlTest,setGsmBroadcastActivation)183 TEST_P(RadioHidlTest, setGsmBroadcastActivation) {
184 LOG(DEBUG) << "setGsmBroadcastActivation";
185 serial = GetRandomSerialNumber();
186 bool activate = false;
187
188 radio->setGsmBroadcastActivation(serial, activate);
189
190 EXPECT_EQ(std::cv_status::no_timeout, wait());
191 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
192 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
193
194 if (cardStatus.cardState == CardState::ABSENT) {
195 ASSERT_TRUE(CheckAnyOfErrors(
196 radioRsp->rspInfo.error,
197 {RadioError::NONE, RadioError::INVALID_ARGUMENTS, RadioError::INVALID_MODEM_STATE,
198 RadioError::INVALID_STATE, RadioError::OPERATION_NOT_ALLOWED},
199 CHECK_GENERAL_ERROR));
200 }
201 LOG(DEBUG) << "setGsmBroadcastActivation finished";
202 }
203