Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 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 | #include "GnssReplayUtils.h" |
| 18 | |
| 19 | namespace android { |
| 20 | namespace hardware { |
| 21 | namespace gnss { |
| 22 | namespace common { |
| 23 | |
George Burgess IV | f2493a3 | 2021-07-07 09:59:32 -0700 | [diff] [blame] | 24 | std::string ReplayUtils::getGnssPath() { |
Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 25 | char devname_value[PROPERTY_VALUE_MAX] = ""; |
| 26 | if (property_get("debug.location.gnss.devname", devname_value, NULL) > 0) { |
George Burgess IV | f2493a3 | 2021-07-07 09:59:32 -0700 | [diff] [blame] | 27 | return devname_value; |
Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 28 | } |
George Burgess IV | f2493a3 | 2021-07-07 09:59:32 -0700 | [diff] [blame] | 29 | return GNSS_PATH; |
Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | bool ReplayUtils::hasGnssDeviceFile() { |
| 33 | struct stat sb; |
George Burgess IV | f2493a3 | 2021-07-07 09:59:32 -0700 | [diff] [blame] | 34 | return stat(getGnssPath().c_str(), &sb) != -1; |
Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 35 | } |
| 36 | |
| 37 | bool ReplayUtils::isGnssRawMeasurement(const std::string& inputStr) { |
| 38 | // TODO: add more logic check to by pass invalid data. |
| 39 | return !inputStr.empty() && (inputStr.find("Raw") != std::string::npos); |
| 40 | } |
| 41 | |
| 42 | bool ReplayUtils::isNMEA(const std::string& inputStr) { |
Yuchen He | 3cbf5f3 | 2021-08-30 22:20:30 +0000 | [diff] [blame^] | 43 | return !inputStr.empty() && (inputStr.find("$GPRMC,", 0) != std::string::npos || |
| 44 | inputStr.find("$GPRMA,", 0) != std::string::npos); |
Yuchen He | 14a3018 | 2021-06-10 17:10:15 -0700 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | } // namespace common |
| 48 | } // namespace gnss |
| 49 | } // namespace hardware |
| 50 | } // namespace android |