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 "AGnssRilCbJni"
18
19 #include "AGnssRilCallback.h"
20
21 namespace android::gnss {
22
23 jmethodID method_requestSetID;
24 jmethodID method_requestRefLocation;
25
26 using binder::Status;
27 using hardware::Return;
28 using hardware::Void;
29
AGnssRil_class_init_once(JNIEnv * env,jclass clazz)30 void AGnssRil_class_init_once(JNIEnv* env, jclass clazz) {
31 method_requestSetID = env->GetMethodID(clazz, "requestSetID", "(I)V");
32 method_requestRefLocation = env->GetMethodID(clazz, "requestRefLocation", "()V");
33 }
34
requestSetIdCb(int setIdflag)35 Status AGnssRilCallbackAidl::requestSetIdCb(int setIdflag) {
36 AGnssRilCallbackUtil::requestSetIdCb(setIdflag);
37 return Status::ok();
38 }
39
requestRefLocCb()40 Status AGnssRilCallbackAidl::requestRefLocCb() {
41 AGnssRilCallbackUtil::requestRefLocCb();
42 return Status::ok();
43 }
44
requestSetIdCb(uint32_t setIdflag)45 Return<void> AGnssRilCallback_V1_0::requestSetIdCb(uint32_t setIdflag) {
46 AGnssRilCallbackUtil::requestSetIdCb(setIdflag);
47 return Void();
48 }
49
requestRefLocCb()50 Return<void> AGnssRilCallback_V1_0::requestRefLocCb() {
51 AGnssRilCallbackUtil::requestRefLocCb();
52 return Void();
53 }
54
requestSetIdCb(int setIdflag)55 void AGnssRilCallbackUtil::requestSetIdCb(int setIdflag) {
56 ALOGD("%s. setIdflag: %d, ", __func__, setIdflag);
57 JNIEnv* env = getJniEnv();
58 env->CallVoidMethod(mCallbacksObj, method_requestSetID, setIdflag);
59 checkAndClearExceptionFromCallback(env, __FUNCTION__);
60 }
61
requestRefLocCb()62 void AGnssRilCallbackUtil::requestRefLocCb() {
63 ALOGD("%s.", __func__);
64 JNIEnv* env = getJniEnv();
65 env->CallVoidMethod(mCallbacksObj, method_requestRefLocation);
66 checkAndClearExceptionFromCallback(env, __FUNCTION__);
67 }
68
69 } // namespace android::gnss
70