1 /*
2  * Copyright (C) 2022 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 "MeasurementCorrectionsCbJni"
18 
19 #include "MeasurementCorrectionsCallback.h"
20 
21 namespace android::gnss {
22 
23 namespace {
24 jmethodID method_setSubHalMeasurementCorrectionsCapabilities;
25 }
26 
MeasurementCorrectionsCallback_class_init_once(JNIEnv * env,jclass clazz)27 void MeasurementCorrectionsCallback_class_init_once(JNIEnv* env, jclass clazz) {
28     method_setSubHalMeasurementCorrectionsCapabilities =
29             env->GetMethodID(clazz, "setSubHalMeasurementCorrectionsCapabilities", "(I)V");
30 }
31 
32 using binder::Status;
33 using hardware::Return;
34 
35 // Implementation of MeasurementCorrectionsCallbackAidl class.
36 
setCapabilitiesCb(const int capabilities)37 Status MeasurementCorrectionsCallbackAidl::setCapabilitiesCb(const int capabilities) {
38     MeasurementCorrectionsCallbackUtil::setCapabilitiesCb(capabilities);
39     return Status::ok();
40 }
41 
42 // Implementation of MeasurementCorrectionsCallbackHidl class.
43 
setCapabilitiesCb(uint32_t capabilities)44 Return<void> MeasurementCorrectionsCallbackHidl::setCapabilitiesCb(uint32_t capabilities) {
45     MeasurementCorrectionsCallbackUtil::setCapabilitiesCb(capabilities);
46     return hardware::Void();
47 }
48 
49 // Implementation of MeasurementCorrectionsCallbackUtil class.
50 
setCapabilitiesCb(uint32_t capabilities)51 void MeasurementCorrectionsCallbackUtil::setCapabilitiesCb(uint32_t capabilities) {
52     ALOGD("%s: %du\n", __func__, capabilities);
53     JNIEnv* env = getJniEnv();
54     env->CallVoidMethod(mCallbacksObj, method_setSubHalMeasurementCorrectionsCapabilities,
55                         capabilities);
56     checkAndClearExceptionFromCallback(env, __FUNCTION__);
57 }
58 
59 } // namespace android::gnss
60