/* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // Define LOG_TAG before to overwrite the default value. #define LOG_TAG "GnssAntInfoCbJni" #include "GnssAntennaInfoCallback.h" #include "Utils.h" namespace android::gnss { using android::hardware::hidl_vec; using android::hardware::Return; using android::hardware::Void; using binder::Status; using IGnssAntennaInfoCallbackAidl = android::hardware::gnss::IGnssAntennaInfoCallback; using IGnssAntennaInfoCallback_V2_1 = android::hardware::gnss::V2_1::IGnssAntennaInfoCallback; namespace { jclass class_gnssAntennaInfoBuilder; jclass class_phaseCenterOffset; jclass class_sphericalCorrections; jclass class_arrayList; jclass class_doubleArray; jmethodID method_reportAntennaInfo; jmethodID method_gnssAntennaInfoBuilderCtor; jmethodID method_phaseCenterOffsetCtor; jmethodID method_sphericalCorrectionsCtor; jmethodID method_arrayListCtor; jmethodID method_arrayListAdd; jmethodID method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz; jmethodID method_gnssAntennaInfoBuilderSetPhaseCenterOffset; jmethodID method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections; jmethodID method_gnssAntennaInfoBuilderSetSignalGainCorrections; jmethodID method_gnssAntennaInfoBuilderBuild; } // anonymous namespace void GnssAntennaInfo_class_init_once(JNIEnv* env, jclass& clazz) { method_reportAntennaInfo = env->GetMethodID(clazz, "reportAntennaInfo", "(Ljava/util/List;)V"); jclass gnssAntennaInfoBuilder = env->FindClass("android/location/GnssAntennaInfo$Builder"); class_gnssAntennaInfoBuilder = (jclass)env->NewGlobalRef(gnssAntennaInfoBuilder); method_gnssAntennaInfoBuilderCtor = env->GetMethodID(class_gnssAntennaInfoBuilder, "", "()V"); method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz = env->GetMethodID(class_gnssAntennaInfoBuilder, "setCarrierFrequencyMHz", "(D)Landroid/location/GnssAntennaInfo$Builder;"); method_gnssAntennaInfoBuilderSetPhaseCenterOffset = env->GetMethodID(class_gnssAntennaInfoBuilder, "setPhaseCenterOffset", "(Landroid/location/GnssAntennaInfo$PhaseCenterOffset;)" "Landroid/location/GnssAntennaInfo$Builder;"); method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections = env->GetMethodID(class_gnssAntennaInfoBuilder, "setPhaseCenterVariationCorrections", "(Landroid/location/GnssAntennaInfo$SphericalCorrections;)" "Landroid/location/GnssAntennaInfo$Builder;"); method_gnssAntennaInfoBuilderSetSignalGainCorrections = env->GetMethodID(class_gnssAntennaInfoBuilder, "setSignalGainCorrections", "(Landroid/location/GnssAntennaInfo$SphericalCorrections;)" "Landroid/location/GnssAntennaInfo$Builder;"); method_gnssAntennaInfoBuilderBuild = env->GetMethodID(class_gnssAntennaInfoBuilder, "build", "()Landroid/location/GnssAntennaInfo;"); jclass phaseCenterOffsetClass = env->FindClass("android/location/GnssAntennaInfo$PhaseCenterOffset"); class_phaseCenterOffset = (jclass)env->NewGlobalRef(phaseCenterOffsetClass); method_phaseCenterOffsetCtor = env->GetMethodID(class_phaseCenterOffset, "", "(DDDDDD)V"); jclass sphericalCorrectionsClass = env->FindClass("android/location/GnssAntennaInfo$SphericalCorrections"); class_sphericalCorrections = (jclass)env->NewGlobalRef(sphericalCorrectionsClass); method_sphericalCorrectionsCtor = env->GetMethodID(class_sphericalCorrections, "", "([[D[[D)V"); jclass arrayListClass = env->FindClass("java/util/ArrayList"); class_arrayList = (jclass)env->NewGlobalRef(arrayListClass); method_arrayListCtor = env->GetMethodID(class_arrayList, "", "()V"); method_arrayListAdd = env->GetMethodID(class_arrayList, "add", "(Ljava/lang/Object;)Z"); jclass doubleArrayClass = env->FindClass("[D"); class_doubleArray = (jclass)env->NewGlobalRef(doubleArrayClass); } binder::Status GnssAntennaInfoCallbackAidl::gnssAntennaInfoCb( const std::vector& gnssAntennaInfos) { GnssAntennaInfoCallbackUtil::translateAndReportGnssAntennaInfo(gnssAntennaInfos); return Status::ok(); } Return GnssAntennaInfoCallback_V2_1::gnssAntennaInfoCb( const hidl_vec& gnssAntennaInfos) { GnssAntennaInfoCallbackUtil::translateAndReportGnssAntennaInfo(gnssAntennaInfos); return Void(); } template