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.h>
18 #include <cinttypes>
19
20 #include "chre/util/nanoapp/log.h"
21
22 #define LOG_TAG "[GnssWorld]"
23
24 #ifdef CHRE_NANOAPP_INTERNAL
25 namespace chre {
26 namespace {
27 #endif // CHRE_NANOAPP_INTERNAL
28
nanoappStart()29 bool nanoappStart() {
30 LOGI("App started as instance %" PRIu32, chreGetInstanceId());
31
32 const char *gnssCapabilitiesStr;
33 uint32_t gnssCapabilities = chreGnssGetCapabilities();
34 switch (gnssCapabilities) {
35 case CHRE_GNSS_CAPABILITIES_LOCATION
36 | CHRE_GNSS_CAPABILITIES_MEASUREMENTS:
37 gnssCapabilitiesStr = "LOCATION | MEASUREMENTS";
38 break;
39 case CHRE_GNSS_CAPABILITIES_LOCATION:
40 gnssCapabilitiesStr = "LOCATION";
41 break;
42 case CHRE_GNSS_CAPABILITIES_MEASUREMENTS:
43 gnssCapabilitiesStr = "MEASUREMENTS";
44 break;
45 case CHRE_GNSS_CAPABILITIES_NONE:
46 gnssCapabilitiesStr = "NONE";
47 break;
48 default:
49 gnssCapabilitiesStr = "INVALID";
50 }
51
52 LOGI("Detected GNSS support as: %s (%" PRIu32 ")",
53 gnssCapabilitiesStr, gnssCapabilities);
54 return true;
55 }
56
nanoappHandleEvent(uint32_t senderInstanceId,uint16_t eventType,const void * eventData)57 void nanoappHandleEvent(uint32_t senderInstanceId,
58 uint16_t eventType,
59 const void *eventData) {
60 // TODO: Implement this.
61 }
62
nanoappEnd()63 void nanoappEnd() {
64 LOGI("Stopped");
65 }
66
67 #ifdef CHRE_NANOAPP_INTERNAL
68 } // anonymous namespace
69 } // namespace chre
70
71 #include "chre/util/nanoapp/app_id.h"
72 #include "chre/platform/static_nanoapp_init.h"
73
74 CHRE_STATIC_NANOAPP_INIT(GnssWorld, chre::kGnssWorldAppId, 0);
75 #endif // CHRE_NANOAPP_INTERNAL
76