blob: 1a80ecf44cf32c163ce749cf308b0c41cbb24aed [file] [log] [blame]
Wyatt Riley6c26ed72017-02-21 17:21:53 -08001/*
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#define LOG_TAG "VtsHalGnssV1_0TargetTest"
18#include <android/hardware/gnss/1.0/IGnss.h>
Dan Shi47e47832019-10-10 11:17:22 -070019#include <gtest/gtest.h>
20#include <hidl/GtestPrinter.h>
21#include <hidl/ServiceManagement.h>
Steven Moreland4e7a3072017-04-06 12:15:23 -070022#include <log/log.h>
Wyatt Riley6c26ed72017-02-21 17:21:53 -080023
Wyatt Riley6c26ed72017-02-21 17:21:53 -080024#include <chrono>
25#include <condition_variable>
26#include <mutex>
27
28using android::hardware::Return;
29using android::hardware::Void;
30
31using android::hardware::gnss::V1_0::GnssLocation;
32using android::hardware::gnss::V1_0::GnssLocationFlags;
33using android::hardware::gnss::V1_0::IGnss;
34using android::hardware::gnss::V1_0::IGnssCallback;
Wyatt Rileyc1399592017-03-22 14:08:26 -070035using android::hardware::gnss::V1_0::IGnssDebug;
36using android::hardware::gnss::V1_0::IGnssMeasurement;
Wyatt Riley6c26ed72017-02-21 17:21:53 -080037using android::sp;
38
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -070039#define TIMEOUT_SEC 2 // for basic commands/responses
Wyatt Riley6c26ed72017-02-21 17:21:53 -080040
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -070041// for command line argument on how strictly to run the test
42bool sAgpsIsPresent = false; // if SUPL or XTRA assistance available
Wyatt Riley94c7a042017-06-15 17:16:24 -070043bool sSignalIsWeak = false; // if GNSS signals are weak (e.g. light indoor)
Wyatt Rileyc1399592017-03-22 14:08:26 -070044
Wyatt Riley6c26ed72017-02-21 17:21:53 -080045// The main test class for GNSS HAL.
Dan Shi47e47832019-10-10 11:17:22 -070046class GnssHalTest : public testing::TestWithParam<std::string> {
Wyatt Riley6c26ed72017-02-21 17:21:53 -080047 public:
48 virtual void SetUp() override {
Wyatt Riley917640b2017-03-16 16:25:55 -070049 // Clean between tests
50 capabilities_called_count_ = 0;
51 location_called_count_ = 0;
52 info_called_count_ = 0;
Wyatt Riley6ec696b2017-06-19 14:42:34 -070053 notify_count_ = 0;
Wyatt Riley6c26ed72017-02-21 17:21:53 -080054
Dan Shi47e47832019-10-10 11:17:22 -070055 gnss_hal_ = IGnss::getService(GetParam());
Wyatt Riley6c26ed72017-02-21 17:21:53 -080056 ASSERT_NE(gnss_hal_, nullptr);
57
58 gnss_cb_ = new GnssCallback(*this);
59 ASSERT_NE(gnss_cb_, nullptr);
60
61 auto result = gnss_hal_->setCallback(gnss_cb_);
62 if (!result.isOk()) {
Wyatt Riley917640b2017-03-16 16:25:55 -070063 ALOGE("result of failed setCallback %s", result.description().c_str());
Wyatt Riley6c26ed72017-02-21 17:21:53 -080064 }
65
66 ASSERT_TRUE(result.isOk());
67 ASSERT_TRUE(result);
68
Wyatt Riley917640b2017-03-16 16:25:55 -070069 /*
70 * At least one callback should trigger - it may be capabilites, or
71 * system info first, so wait again if capabilities not received.
Wyatt Riley6c26ed72017-02-21 17:21:53 -080072 */
Wyatt Riley917640b2017-03-16 16:25:55 -070073 EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC));
74 if (capabilities_called_count_ == 0) {
75 EXPECT_EQ(std::cv_status::no_timeout, wait(TIMEOUT_SEC));
76 }
77
78 /*
79 * Generally should be 1 capabilites callback -
80 * or possibly 2 in some recovery cases (default cached & refreshed)
81 */
82 EXPECT_GE(capabilities_called_count_, 1);
83 EXPECT_LE(capabilities_called_count_, 2);
84
85 /*
86 * Clear notify/waiting counter, allowing up till the timeout after
87 * the last reply for final startup messages to arrive (esp. system
88 * info.)
89 */
90 while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) {
91 }
Wyatt Riley6c26ed72017-02-21 17:21:53 -080092 }
93
94 virtual void TearDown() override {
95 if (gnss_hal_ != nullptr) {
96 gnss_hal_->cleanup();
97 }
Wyatt Riley6ec696b2017-06-19 14:42:34 -070098 if (notify_count_ > 0) {
99 ALOGW("%d unprocessed callbacks discarded", notify_count_);
100 }
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800101 }
102
103 /* Used as a mechanism to inform the test that a callback has occurred */
104 inline void notify() {
105 std::unique_lock<std::mutex> lock(mtx_);
Wyatt Riley6ec696b2017-06-19 14:42:34 -0700106 notify_count_++;
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800107 cv_.notify_one();
108 }
109
110 /* Test code calls this function to wait for a callback */
111 inline std::cv_status wait(int timeoutSeconds) {
112 std::unique_lock<std::mutex> lock(mtx_);
113
114 std::cv_status status = std::cv_status::no_timeout;
115 auto now = std::chrono::system_clock::now();
Wyatt Riley6ec696b2017-06-19 14:42:34 -0700116 while (notify_count_ == 0) {
117 status = cv_.wait_until(lock, now + std::chrono::seconds(timeoutSeconds));
118 if (status == std::cv_status::timeout) return status;
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800119 }
Wyatt Riley6ec696b2017-06-19 14:42:34 -0700120 notify_count_--;
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800121 return status;
122 }
123
Wyatt Riley94c7a042017-06-15 17:16:24 -0700124 /*
125 * StartAndGetSingleLocation:
126 * Helper function to get one Location and check fields
127 *
128 * returns true if a location was successfully generated
129 */
130 bool StartAndGetSingleLocation(bool checkAccuracies) {
131 auto result = gnss_hal_->start();
132
133 EXPECT_TRUE(result.isOk());
134 EXPECT_TRUE(result);
135
136 /*
137 * GPS signals initially optional for this test, so don't expect fast fix,
138 * or no timeout, unless signal is present
139 */
140 int firstGnssLocationTimeoutSeconds = sAgpsIsPresent ? 15 : 45;
141 if (sSignalIsWeak) {
142 // allow more time for weak signals
143 firstGnssLocationTimeoutSeconds += 30;
144 }
145
146 wait(firstGnssLocationTimeoutSeconds);
147 if (sAgpsIsPresent) {
148 EXPECT_EQ(location_called_count_, 1);
149 }
150 if (location_called_count_ > 0) {
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700151 // don't require speed on first fix
152 CheckLocation(last_location_, checkAccuracies, false);
Wyatt Riley94c7a042017-06-15 17:16:24 -0700153 return true;
154 }
155 return false;
156 }
157
158 /*
159 * StopAndClearLocations:
160 * Helper function to stop locations
161 *
162 * returns true if a location was successfully generated
163 */
164 void StopAndClearLocations() {
165 auto result = gnss_hal_->stop();
166
167 EXPECT_TRUE(result.isOk());
168 EXPECT_TRUE(result);
169
170 /*
171 * Clear notify/waiting counter, allowing up till the timeout after
172 * the last reply for final startup messages to arrive (esp. system
173 * info.)
174 */
175 while (wait(TIMEOUT_SEC) == std::cv_status::no_timeout) {
176 }
177 }
178
179 /*
180 * CheckLocation:
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700181 * Helper function to vet Location fields
Wyatt Riley94c7a042017-06-15 17:16:24 -0700182 */
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700183 void CheckLocation(GnssLocation& location, bool checkAccuracies, bool checkSpeed) {
Wyatt Riley94c7a042017-06-15 17:16:24 -0700184 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_LAT_LONG);
185 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_ALTITUDE);
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700186 if (checkSpeed) {
187 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED);
188 }
Wyatt Riley94c7a042017-06-15 17:16:24 -0700189 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_HORIZONTAL_ACCURACY);
190 // New uncertainties available in O must be provided,
191 // at least when paired with modern hardware (2017+)
192 if (checkAccuracies) {
193 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY);
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700194 if (checkSpeed) {
195 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY);
196 if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
197 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY);
198 }
Wyatt Riley94c7a042017-06-15 17:16:24 -0700199 }
200 }
201 EXPECT_GE(location.latitudeDegrees, -90.0);
202 EXPECT_LE(location.latitudeDegrees, 90.0);
203 EXPECT_GE(location.longitudeDegrees, -180.0);
204 EXPECT_LE(location.longitudeDegrees, 180.0);
205 EXPECT_GE(location.altitudeMeters, -1000.0);
206 EXPECT_LE(location.altitudeMeters, 30000.0);
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700207 if (checkSpeed) {
208 EXPECT_GE(location.speedMetersPerSec, 0.0);
209 EXPECT_LE(location.speedMetersPerSec, 5.0); // VTS tests are stationary.
Wyatt Riley94c7a042017-06-15 17:16:24 -0700210
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700211 // Non-zero speeds must be reported with an associated bearing
212 if (location.speedMetersPerSec > 0.0) {
213 EXPECT_TRUE(location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING);
214 }
Wyatt Riley94c7a042017-06-15 17:16:24 -0700215 }
216
217 /*
218 * Tolerating some especially high values for accuracy estimate, in case of
219 * first fix with especially poor geometry (happens occasionally)
220 */
221 EXPECT_GT(location.horizontalAccuracyMeters, 0.0);
222 EXPECT_LE(location.horizontalAccuracyMeters, 250.0);
223
224 /*
225 * Some devices may define bearing as -180 to +180, others as 0 to 360.
226 * Both are okay & understandable.
227 */
228 if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING) {
229 EXPECT_GE(location.bearingDegrees, -180.0);
230 EXPECT_LE(location.bearingDegrees, 360.0);
231 }
232 if (location.gnssLocationFlags & GnssLocationFlags::HAS_VERTICAL_ACCURACY) {
233 EXPECT_GT(location.verticalAccuracyMeters, 0.0);
234 EXPECT_LE(location.verticalAccuracyMeters, 500.0);
235 }
236 if (location.gnssLocationFlags & GnssLocationFlags::HAS_SPEED_ACCURACY) {
237 EXPECT_GT(location.speedAccuracyMetersPerSecond, 0.0);
238 EXPECT_LE(location.speedAccuracyMetersPerSecond, 50.0);
239 }
240 if (location.gnssLocationFlags & GnssLocationFlags::HAS_BEARING_ACCURACY) {
241 EXPECT_GT(location.bearingAccuracyDegrees, 0.0);
242 EXPECT_LE(location.bearingAccuracyDegrees, 360.0);
243 }
244
245 // Check timestamp > 1.48e12 (47 years in msec - 1970->2017+)
246 EXPECT_GT(location.timestamp, 1.48e12);
247 }
248
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800249 /* Callback class for data & Event. */
250 class GnssCallback : public IGnssCallback {
Wyatt Riley917640b2017-03-16 16:25:55 -0700251 public:
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800252 GnssHalTest& parent_;
253
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800254 GnssCallback(GnssHalTest& parent) : parent_(parent){};
255
256 virtual ~GnssCallback() = default;
257
258 // Dummy callback handlers
259 Return<void> gnssStatusCb(
Steven Moreland4b523952017-03-08 19:20:30 -0800260 const IGnssCallback::GnssStatusValue /* status */) override {
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800261 return Void();
262 }
263 Return<void> gnssSvStatusCb(
Steven Moreland4b523952017-03-08 19:20:30 -0800264 const IGnssCallback::GnssSvStatus& /* svStatus */) override {
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800265 return Void();
266 }
267 Return<void> gnssNmeaCb(
Steven Moreland4b523952017-03-08 19:20:30 -0800268 int64_t /* timestamp */,
269 const android::hardware::hidl_string& /* nmea */) override {
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800270 return Void();
271 }
272 Return<void> gnssAcquireWakelockCb() override { return Void(); }
273 Return<void> gnssReleaseWakelockCb() override { return Void(); }
274 Return<void> gnssRequestTimeCb() override { return Void(); }
275
276 // Actual (test) callback handlers
277 Return<void> gnssLocationCb(const GnssLocation& location) override {
278 ALOGI("Location received");
279 parent_.location_called_count_++;
280 parent_.last_location_ = location;
281 parent_.notify();
282 return Void();
283 }
284
285 Return<void> gnssSetCapabilitesCb(uint32_t capabilities) override {
286 ALOGI("Capabilities received %d", capabilities);
287 parent_.capabilities_called_count_++;
288 parent_.last_capabilities_ = capabilities;
289 parent_.notify();
290 return Void();
291 }
292
293 Return<void> gnssSetSystemInfoCb(
294 const IGnssCallback::GnssSystemInfo& info) override {
295 ALOGI("Info received, year %d", info.yearOfHw);
296 parent_.info_called_count_++;
297 parent_.last_info_ = info;
298 parent_.notify();
299 return Void();
300 }
301 };
302
303 sp<IGnss> gnss_hal_; // GNSS HAL to call into
304 sp<IGnssCallback> gnss_cb_; // Primary callback interface
305
306 /* Count of calls to set the following items, and the latest item (used by
307 * test.)
308 */
309 int capabilities_called_count_;
310 uint32_t last_capabilities_;
311
312 int location_called_count_;
313 GnssLocation last_location_;
314
315 int info_called_count_;
316 IGnssCallback::GnssSystemInfo last_info_;
317
318 private:
319 std::mutex mtx_;
320 std::condition_variable cv_;
Wyatt Riley6ec696b2017-06-19 14:42:34 -0700321 int notify_count_;
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800322};
323
324/*
325 * SetCallbackCapabilitiesCleanup:
326 * Sets up the callback, awaits the capabilities, and calls cleanup
327 *
328 * Since this is just the basic operation of SetUp() and TearDown(),
Wyatt Riley917640b2017-03-16 16:25:55 -0700329 * the function definition is intentionally empty
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800330 */
Dan Shi47e47832019-10-10 11:17:22 -0700331TEST_P(GnssHalTest, SetCallbackCapabilitiesCleanup) {}
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800332
Wyatt Riley917640b2017-03-16 16:25:55 -0700333/*
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800334 * GetLocation:
335 * Turns on location, waits 45 second for at least 5 locations,
336 * and checks them for reasonable validity.
337 */
Dan Shi47e47832019-10-10 11:17:22 -0700338TEST_P(GnssHalTest, GetLocation) {
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800339#define MIN_INTERVAL_MSEC 500
340#define PREFERRED_ACCURACY 0 // Ideally perfect (matches GnssLocationProvider)
341#define PREFERRED_TIME_MSEC 0 // Ideally immediate
342
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800343#define LOCATION_TIMEOUT_SUBSEQUENT_SEC 3
344#define LOCATIONS_TO_CHECK 5
345
Wyatt Riley917640b2017-03-16 16:25:55 -0700346 bool checkMoreAccuracies =
347 (info_called_count_ > 0 && last_info_.yearOfHw >= 2017);
348
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800349 auto result = gnss_hal_->setPositionMode(
350 IGnss::GnssPositionMode::MS_BASED,
351 IGnss::GnssPositionRecurrence::RECURRENCE_PERIODIC, MIN_INTERVAL_MSEC,
352 PREFERRED_ACCURACY, PREFERRED_TIME_MSEC);
353
354 ASSERT_TRUE(result.isOk());
Wyatt Rileyc1399592017-03-22 14:08:26 -0700355 EXPECT_TRUE(result);
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800356
Wyatt Rileyc1399592017-03-22 14:08:26 -0700357 /*
358 * GPS signals initially optional for this test, so don't expect no timeout
359 * yet
360 */
Wyatt Riley94c7a042017-06-15 17:16:24 -0700361 bool gotLocation = StartAndGetSingleLocation(checkMoreAccuracies);
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800362
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -0700363 if (gotLocation) {
364 for (int i = 1; i < LOCATIONS_TO_CHECK; i++) {
Wyatt Riley94c7a042017-06-15 17:16:24 -0700365 EXPECT_EQ(std::cv_status::no_timeout, wait(LOCATION_TIMEOUT_SUBSEQUENT_SEC));
366 EXPECT_EQ(location_called_count_, i + 1);
Wyatt Rileyadca98d2017-10-26 16:37:30 -0700367 CheckLocation(last_location_, checkMoreAccuracies, true);
Wyatt Riley917640b2017-03-16 16:25:55 -0700368 }
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800369 }
370
Wyatt Riley94c7a042017-06-15 17:16:24 -0700371 StopAndClearLocations();
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800372}
373
Wyatt Rileyc1399592017-03-22 14:08:26 -0700374/*
375 * InjectDelete:
376 * Ensures that calls to inject and/or delete information state are handled.
Wyatt Rileyc1399592017-03-22 14:08:26 -0700377 */
Dan Shi47e47832019-10-10 11:17:22 -0700378TEST_P(GnssHalTest, InjectDelete) {
Wyatt Rileyc1399592017-03-22 14:08:26 -0700379 // confidently, well north of Alaska
380 auto result = gnss_hal_->injectLocation(80.0, -170.0, 1000.0);
381
Wyatt Rileyc1399592017-03-22 14:08:26 -0700382 ASSERT_TRUE(result.isOk());
383 EXPECT_TRUE(result);
384
385 // fake time, but generally reasonable values (time in Aug. 2018)
386 result = gnss_hal_->injectTime(1534567890123L, 123456L, 10000L);
387
388 ASSERT_TRUE(result.isOk());
389 EXPECT_TRUE(result);
390
Yu-Han Yang66fb7a12018-07-02 10:41:28 -0700391 auto resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_POSITION);
392
393 ASSERT_TRUE(resultVoid.isOk());
394
395 resultVoid = gnss_hal_->deleteAidingData(IGnss::GnssAidingData::DELETE_TIME);
Wyatt Rileyc1399592017-03-22 14:08:26 -0700396
397 ASSERT_TRUE(resultVoid.isOk());
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -0700398
399 // Ensure we can get a good location after a bad injection has been deleted
Wyatt Riley94c7a042017-06-15 17:16:24 -0700400 StartAndGetSingleLocation(false);
401
402 StopAndClearLocations();
Wyatt Rileyc1399592017-03-22 14:08:26 -0700403}
404
405/*
406 * GetAllExtentions:
407 * Tries getting all optional extensions, and ensures a valid return
408 * null or actual extension, no crash.
409 * Confirms year-based required extensions (Measurement & Debug) are present
410 */
Dan Shi47e47832019-10-10 11:17:22 -0700411TEST_P(GnssHalTest, GetAllExtensions) {
Wyatt Rileyc1399592017-03-22 14:08:26 -0700412 // Basic call-is-handled checks
413 auto gnssXtra = gnss_hal_->getExtensionXtra();
414 ASSERT_TRUE(gnssXtra.isOk());
415
416 auto gnssRil = gnss_hal_->getExtensionAGnssRil();
417 ASSERT_TRUE(gnssRil.isOk());
418
419 auto gnssAgnss = gnss_hal_->getExtensionAGnss();
420 ASSERT_TRUE(gnssAgnss.isOk());
421
422 auto gnssNi = gnss_hal_->getExtensionGnssNi();
423 ASSERT_TRUE(gnssNi.isOk());
424
425 auto gnssNavigationMessage = gnss_hal_->getExtensionGnssNavigationMessage();
426 ASSERT_TRUE(gnssNavigationMessage.isOk());
427
428 auto gnssConfiguration = gnss_hal_->getExtensionGnssConfiguration();
429 ASSERT_TRUE(gnssConfiguration.isOk());
430
431 auto gnssGeofencing = gnss_hal_->getExtensionGnssGeofencing();
432 ASSERT_TRUE(gnssGeofencing.isOk());
433
434 auto gnssBatching = gnss_hal_->getExtensionGnssBatching();
435 ASSERT_TRUE(gnssBatching.isOk());
436
437 // Verifying, in some cases, that these return actual extensions
438 auto gnssMeasurement = gnss_hal_->getExtensionGnssMeasurement();
439 ASSERT_TRUE(gnssMeasurement.isOk());
440 if (last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS) {
441 sp<IGnssMeasurement> iGnssMeas = gnssMeasurement;
442 EXPECT_NE(iGnssMeas, nullptr);
443 }
444
445 auto gnssDebug = gnss_hal_->getExtensionGnssDebug();
446 ASSERT_TRUE(gnssDebug.isOk());
447 if (info_called_count_ > 0 && last_info_.yearOfHw >= 2017) {
448 sp<IGnssDebug> iGnssDebug = gnssDebug;
449 EXPECT_NE(iGnssDebug, nullptr);
450 }
451}
452
453/*
454 * MeasurementCapabilities:
455 * Verifies that modern hardware supports measurement capabilities.
456 */
Dan Shi47e47832019-10-10 11:17:22 -0700457TEST_P(GnssHalTest, MeasurementCapabilites) {
Wyatt Rileyc1399592017-03-22 14:08:26 -0700458 if (info_called_count_ > 0 && last_info_.yearOfHw >= 2016) {
459 EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::MEASUREMENTS);
460 }
461}
462
Vishal Agarwal2910e642018-06-05 18:42:01 -0700463/*
464 * SchedulingCapabilities:
465 * Verifies that 2018+ hardware supports Scheduling capabilities.
466 */
Dan Shi47e47832019-10-10 11:17:22 -0700467TEST_P(GnssHalTest, SchedulingCapabilities) {
Vishal Agarwal2910e642018-06-05 18:42:01 -0700468 if (info_called_count_ > 0 && last_info_.yearOfHw >= 2018) {
469 EXPECT_TRUE(last_capabilities_ & IGnssCallback::Capabilities::SCHEDULING);
470 }
471}
472
Dan Shi47e47832019-10-10 11:17:22 -0700473INSTANTIATE_TEST_SUITE_P(
474 PerInstance, GnssHalTest,
475 testing::ValuesIn(android::hardware::getAllHalInstanceNames(IGnss::descriptor)),
476 android::hardware::PrintInstanceNameToString);
477
Wyatt Riley6c26ed72017-02-21 17:21:53 -0800478int main(int argc, char** argv) {
479 ::testing::InitGoogleTest(&argc, argv);
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -0700480 /*
481 * These arguments not used by automated VTS testing.
482 * Only for use in manual testing, when wanting to run
483 * stronger tests that require the presence of GPS signal.
484 */
485 for (int i = 1; i < argc; i++) {
Zhuoyao Zhang989afba2018-02-08 20:53:56 -0800486 if (strcmp(argv[i], "-agps") == 0) {
487 sAgpsIsPresent = true;
488 } else if (strcmp(argv[i], "-weak") == 0) {
489 sSignalIsWeak = true;
Wyatt Riley0ee0cfb2017-04-04 12:34:53 -0700490 }
491 }
Dan Shi47e47832019-10-10 11:17:22 -0700492
493 return RUN_ALL_TESTS();
494}