blob: fe850b13a0529a1611e336ba06279a63cb8e6e4e [file] [log] [blame]
Hridya Valsaraju29dc1e02016-10-21 14:41:12 -07001/*
2 * Copyright (C) 2016 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#ifndef android_hardware_gnss_V1_0_GnssNi_H_
18#define android_hardware_gnss_V1_0_GnssNi_H_
19
20#include <ThreadCreationWrapper.h>
21#include <android/hardware/gnss/1.0/IGnssNi.h>
22#include <hidl/Status.h>
23#include <hardware/gps.h>
24
25namespace android {
26namespace hardware {
27namespace gnss {
28namespace V1_0 {
29namespace implementation {
30
31using ::android::hardware::gnss::V1_0::IGnssNi;
32using ::android::hardware::gnss::V1_0::IGnssNiCallback;
33using ::android::hardware::Return;
34using ::android::hardware::Void;
35using ::android::hardware::hidl_vec;
36using ::android::hardware::hidl_string;
37using ::android::sp;
38
39/*
40 * Extended interface for Network-initiated (NI) support. This interface is used to respond to
41 * NI notifications originating from the HAL. Also contains wrapper methods to allow methods from
42 * IGnssNiCallback interface to be passed into the conventional implementation of the GNSS HAL.
43 */
44struct GnssNi : public IGnssNi {
45 GnssNi(const GpsNiInterface* gpsNiIface);
46 ~GnssNi();
47
48 /*
49 * Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
50 * These declarations were generated from IGnssNi.hal.
51 */
52 Return<void> setCallback(const sp<IGnssNiCallback>& callback) override;
53 Return<void> respond(int32_t notifId,
54 IGnssNiCallback::GnssUserResponseType userResponse) override;
55
56 /*
57 * Callback methods to be passed into the conventional GNSS HAL by the default
58 * implementation. These methods are not part of the IGnssNi base class.
59 */
60 static pthread_t createThreadCb(const char* name, void (*start)(void*), void* arg);
61 static void niNotifyCb(GpsNiNotification* notification);
62
63 /*
64 * Holds function pointers to the callback methods.
65 */
66 static GpsNiCallbacks sGnssNiCb;
67
68 private:
69 const GpsNiInterface* mGnssNiIface = nullptr;
70 static sp<IGnssNiCallback> sGnssNiCbIface;
71 static std::vector<std::unique_ptr<ThreadFuncArgs>> sThreadFuncArgsList;
72 static bool sInterfaceExists;
73};
74
75} // namespace implementation
76} // namespace V1_0
77} // namespace gnss
78} // namespace hardware
79} // namespace android
80
81#endif // android_hardware_gnss_V1_0_GnssNi_H_