blob: e3f4ff82a070b8dffced16afd7a944de6ce06748 [file] [log] [blame]
Yuchen He14a30182021-06-10 17:10:15 -07001/*
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
19namespace android {
20namespace hardware {
21namespace gnss {
22namespace common {
23
George Burgess IVf2493a32021-07-07 09:59:32 -070024std::string ReplayUtils::getGnssPath() {
Yuchen He14a30182021-06-10 17:10:15 -070025 char devname_value[PROPERTY_VALUE_MAX] = "";
26 if (property_get("debug.location.gnss.devname", devname_value, NULL) > 0) {
George Burgess IVf2493a32021-07-07 09:59:32 -070027 return devname_value;
Yuchen He14a30182021-06-10 17:10:15 -070028 }
George Burgess IVf2493a32021-07-07 09:59:32 -070029 return GNSS_PATH;
Yuchen He14a30182021-06-10 17:10:15 -070030}
31
32bool ReplayUtils::hasGnssDeviceFile() {
33 struct stat sb;
George Burgess IVf2493a32021-07-07 09:59:32 -070034 return stat(getGnssPath().c_str(), &sb) != -1;
Yuchen He14a30182021-06-10 17:10:15 -070035}
36
37bool 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
42bool ReplayUtils::isNMEA(const std::string& inputStr) {
Yuchen He3cbf5f32021-08-30 22:20:30 +000043 return !inputStr.empty() && (inputStr.find("$GPRMC,", 0) != std::string::npos ||
44 inputStr.find("$GPRMA,", 0) != std::string::npos);
Yuchen He14a30182021-06-10 17:10:15 -070045}
46
47} // namespace common
48} // namespace gnss
49} // namespace hardware
50} // namespace android