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 "GnssPsdsCbJni"
18  
19  #include "GnssPsdsCallback.h"
20  
21  #include <vector>
22  
23  #include "Utils.h"
24  
25  namespace android::gnss {
26  
27  namespace {
28  jmethodID method_psdsDownloadRequest;
29  } // anonymous namespace
30  
31  using binder::Status;
32  using hardware::Return;
33  using hardware::Void;
34  using hardware::gnss::PsdsType;
35  
GnssPsds_class_init_once(JNIEnv * env,jclass clazz)36  void GnssPsds_class_init_once(JNIEnv* env, jclass clazz) {
37      method_psdsDownloadRequest = env->GetMethodID(clazz, "psdsDownloadRequest", "(I)V");
38  }
39  
40  // Implementation of android::hardware::gnss::IGnssPsdsCallback
41  
downloadRequestCb(PsdsType psdsType)42  Status GnssPsdsCallbackAidl::downloadRequestCb(PsdsType psdsType) {
43      ALOGD("%s. psdsType: %d", __func__, static_cast<int32_t>(psdsType));
44      JNIEnv* env = getJniEnv();
45      env->CallVoidMethod(mCallbacksObj, method_psdsDownloadRequest, psdsType);
46      checkAndClearExceptionFromCallback(env, __FUNCTION__);
47      return Status::ok();
48  }
49  
50  // Implementation of android::hardware::gnss::V1_0::IGnssPsdsCallback
51  
downloadRequestCb()52  Return<void> GnssPsdsCallbackHidl::downloadRequestCb() {
53      JNIEnv* env = getJniEnv();
54      env->CallVoidMethod(mCallbacksObj, method_psdsDownloadRequest, /* psdsType= */ 1);
55      checkAndClearExceptionFromCallback(env, __FUNCTION__);
56      return Void();
57  }
58  
59  } // namespace android::gnss
60