Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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/Gtest.h> |
| 20 | #include <aidl/Vintf.h> |
| 21 | |
| 22 | #include <android/hardware/gnss/IGnss.h> |
| 23 | #include <binder/IServiceManager.h> |
| 24 | |
| 25 | #include <android/hardware/gnss/2.1/IGnss.h> |
Yu-Han Yang | 3a75dc0 | 2021-09-27 01:01:06 -0700 | [diff] [blame] | 26 | #include "GnssBatchingCallback.h" |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 27 | #include "GnssCallbackAidl.h" |
| 28 | #include "v2_1/gnss_hal_test_template.h" |
| 29 | |
| 30 | using IGnss_V2_1 = android::hardware::gnss::V2_1::IGnss; |
| 31 | |
| 32 | using android::ProcessState; |
| 33 | using android::sp; |
| 34 | using android::String16; |
| 35 | using IGnssAidl = android::hardware::gnss::IGnss; |
| 36 | using android::hardware::gnss::BlocklistedSource; |
| 37 | using android::hardware::gnss::IGnssConfiguration; |
| 38 | |
| 39 | // The main test class for GNSS HAL. |
Yu-Han Yang | 0483230 | 2020-11-20 09:51:18 -0800 | [diff] [blame] | 40 | class GnssHalTest : public android::hardware::gnss::common::GnssHalTestTemplate<IGnss_V2_1> { |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 41 | public: |
| 42 | GnssHalTest(){}; |
| 43 | ~GnssHalTest(){}; |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 44 | |
| 45 | struct ComparableBlocklistedSource { |
| 46 | android::hardware::gnss::BlocklistedSource id; |
| 47 | |
| 48 | ComparableBlocklistedSource() { |
| 49 | id.constellation = android::hardware::gnss::GnssConstellationType::UNKNOWN; |
| 50 | id.svid = 0; |
| 51 | } |
| 52 | |
| 53 | bool operator<(const ComparableBlocklistedSource& compare) const { |
| 54 | return ((id.svid < compare.id.svid) || ((id.svid == compare.id.svid) && |
| 55 | (id.constellation < compare.id.constellation))); |
| 56 | } |
| 57 | }; |
| 58 | |
| 59 | struct SignalCounts { |
| 60 | int observations; |
| 61 | float max_cn0_dbhz; |
| 62 | }; |
| 63 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 64 | virtual void SetUp() override; |
| 65 | virtual void SetUpGnssCallback() override; |
| 66 | |
Yu-Han Yang | 1afbd5f | 2021-11-24 16:39:13 -0800 | [diff] [blame] | 67 | void CheckLocation(const android::hardware::gnss::GnssLocation& location, |
| 68 | const bool check_speed); |
| 69 | void SetPositionMode(const int min_interval_msec, const bool low_power_mode); |
| 70 | bool StartAndCheckFirstLocation(const int min_interval_msec, const bool low_power_mode); |
| 71 | void StopAndClearLocations(); |
| 72 | void StartAndCheckLocations(int count); |
| 73 | |
| 74 | android::hardware::gnss::GnssConstellationType startLocationAndGetNonGpsConstellation( |
| 75 | const int locations_to_await, const int gnss_sv_info_list_timeout); |
| 76 | std::list<std::vector<android::hardware::gnss::IGnssCallback::GnssSvInfo>> convertToAidl( |
| 77 | const std::list<hidl_vec<android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo>>& |
| 78 | sv_info_list); |
| 79 | android::hardware::gnss::BlocklistedSource FindStrongFrequentNonGpsSource( |
| 80 | const std::list<hidl_vec<android::hardware::gnss::V2_1::IGnssCallback::GnssSvInfo>> |
| 81 | sv_info_list, |
| 82 | const int min_observations); |
| 83 | android::hardware::gnss::BlocklistedSource FindStrongFrequentNonGpsSource( |
| 84 | const std::list<std::vector<android::hardware::gnss::IGnssCallback::GnssSvInfo>> |
| 85 | sv_info_list, |
| 86 | const int min_observations); |
| 87 | |
Yu-Han Yang | 1e1a676 | 2020-09-30 17:01:53 -0700 | [diff] [blame] | 88 | sp<IGnssAidl> aidl_gnss_hal_; |
| 89 | sp<GnssCallbackAidl> aidl_gnss_cb_; // Primary callback interface |
| 90 | }; |