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 "chre/platform/platform_gnss.h"
18
19 #include <cinttypes>
20
21 #include "chre/core/event_loop_manager.h"
22 #include "chre/platform/shared/pal_system_api.h"
23 #include "chre/platform/log.h"
24
25 namespace chre {
26
PlatformGnss()27 PlatformGnss::PlatformGnss() {
28 mGnssApi = chrePalGnssGetApi(CHRE_PAL_GNSS_API_CURRENT_VERSION);
29 if (mGnssApi != nullptr) {
30 mGnssCallbacks.requestStateResync =
31 PlatformGnssBase::requestStateResyncCallback;
32 mGnssCallbacks.locationStatusChangeCallback =
33 PlatformGnssBase::locationStatusChangeCallback;
34 mGnssCallbacks.locationEventCallback =
35 PlatformGnssBase::locationEventCallback;
36 mGnssCallbacks.measurementStatusChangeCallback =
37 PlatformGnssBase::measurementStatusChangeCallback;
38 mGnssCallbacks.measurementEventCallback =
39 PlatformGnssBase::measurementEventCallback;
40 if (!mGnssApi->open(&gChrePalSystemApi, &mGnssCallbacks)) {
41 LOGE("GNSS PAL open returned false");
42 mGnssApi = nullptr;
43 }
44 } else {
45 LOGW("Requested GNSS PAL (version %08" PRIx32 ") not found",
46 CHRE_PAL_GNSS_API_CURRENT_VERSION);
47 }
48 }
49
~PlatformGnss()50 PlatformGnss::~PlatformGnss() {
51 if (mGnssApi != nullptr) {
52 mGnssApi->close();
53 }
54 }
55
getCapabilities()56 uint32_t PlatformGnss::getCapabilities() {
57 if (mGnssApi != nullptr) {
58 return mGnssApi->getCapabilities();
59 } else {
60 return CHRE_GNSS_CAPABILITIES_NONE;
61 }
62 }
63
requestStateResyncCallback()64 void PlatformGnssBase::requestStateResyncCallback() {
65 // TODO: Implement this.
66 }
67
locationStatusChangeCallback(bool enabled,uint8_t errorCode)68 void PlatformGnssBase::locationStatusChangeCallback(bool enabled,
69 uint8_t errorCode) {
70 // TODO: Implement this.
71 }
72
locationEventCallback(struct chreGnssLocationEvent * event)73 void PlatformGnssBase::locationEventCallback(
74 struct chreGnssLocationEvent *event) {
75 // TODO: Implement this.
76 }
77
measurementStatusChangeCallback(bool enabled,uint8_t errorCode)78 void PlatformGnssBase::measurementStatusChangeCallback(bool enabled,
79 uint8_t errorCode) {
80 // TODO: Implement this.
81 }
82
measurementEventCallback(struct chreGnssDataEvent * event)83 void PlatformGnssBase::measurementEventCallback(
84 struct chreGnssDataEvent *event) {
85 // TODO: Implement this.
86 }
87
88 } // namespace chre
89