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 #define LOG_TAG "GnssNavMsgCbJni"
18
19 #include "GnssNavigationMessageCallback.h"
20
21 namespace android::gnss {
22
23 namespace {
24
25 jclass class_gnssNavigationMessage;
26 jmethodID method_reportNavigationMessages;
27 jmethodID method_gnssNavigationMessageCtor;
28
29 } // anonymous namespace
30
31 using binder::Status;
32 using hardware::Return;
33 using hardware::Void;
34
35 using GnssNavigationMessageAidl =
36 android::hardware::gnss::IGnssNavigationMessageCallback::GnssNavigationMessage;
37 using GnssNavigationMessageHidl =
38 android::hardware::gnss::V1_0::IGnssNavigationMessageCallback::GnssNavigationMessage;
39
GnssNavigationMessage_class_init_once(JNIEnv * env,jclass clazz)40 void GnssNavigationMessage_class_init_once(JNIEnv* env, jclass clazz) {
41 method_reportNavigationMessages =
42 env->GetMethodID(clazz, "reportNavigationMessage",
43 "(Landroid/location/GnssNavigationMessage;)V");
44
45 jclass gnssNavigationMessageClass = env->FindClass("android/location/GnssNavigationMessage");
46 class_gnssNavigationMessage = (jclass)env->NewGlobalRef(gnssNavigationMessageClass);
47 method_gnssNavigationMessageCtor =
48 env->GetMethodID(class_gnssNavigationMessage, "<init>", "()V");
49 }
50
gnssNavigationMessageCb(const GnssNavigationMessageAidl & message)51 Status GnssNavigationMessageCallbackAidl::gnssNavigationMessageCb(
52 const GnssNavigationMessageAidl& message) {
53 GnssNavigationMessageCallbackUtil::gnssNavigationMessageCbImpl(message);
54 return Status::ok();
55 }
56
gnssNavigationMessageCb(const GnssNavigationMessageHidl & message)57 Return<void> GnssNavigationMessageCallbackHidl::gnssNavigationMessageCb(
58 const GnssNavigationMessageHidl& message) {
59 GnssNavigationMessageCallbackUtil::gnssNavigationMessageCbImpl(message);
60 return Void();
61 }
62
63 } // namespace android::gnss
64