Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f4e1ef3 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "DO NOT MERGE: Call DeleteLocalRef on callObjectMethod's returned value" into sc-v2-dev

parents 606dede8 7a883af4
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -1115,15 +1115,16 @@ jobject GnssAntennaInfoCallback::translateSingleGnssAntennaInfo(
            env->NewObject(class_gnssAntennaInfoBuilder, method_gnssAntennaInfoBuilderCtor);

    // Set fields
    env->CallObjectMethod(gnssAntennaInfoBuilderObject,
    callObjectMethodIgnoringResult(env, gnssAntennaInfoBuilderObject,
                                   method_gnssAntennaInfoBuilderSetCarrierFrequencyMHz,
                                   gnssAntennaInfo.carrierFrequencyMHz);
    env->CallObjectMethod(gnssAntennaInfoBuilderObject,
                          method_gnssAntennaInfoBuilderSetPhaseCenterOffset, phaseCenterOffset);
    env->CallObjectMethod(gnssAntennaInfoBuilderObject,
    callObjectMethodIgnoringResult(env, gnssAntennaInfoBuilderObject,
                                   method_gnssAntennaInfoBuilderSetPhaseCenterOffset,
                                   phaseCenterOffset);
    callObjectMethodIgnoringResult(env, gnssAntennaInfoBuilderObject,
                                   method_gnssAntennaInfoBuilderSetPhaseCenterVariationCorrections,
                                   phaseCenterVariationCorrections);
    env->CallObjectMethod(gnssAntennaInfoBuilderObject,
    callObjectMethodIgnoringResult(env, gnssAntennaInfoBuilderObject,
                                   method_gnssAntennaInfoBuilderSetSignalGainCorrections,
                                   signalGainCorrections);

@@ -2707,7 +2708,7 @@ static SingleSatCorrection_V1_0 getSingleSatCorrection_1_0_withoutConstellation(
    jfloat eplMeters = env->CallFloatMethod(singleSatCorrectionObj, method_correctionSatEpl);
    jfloat eplUncMeters = env->CallFloatMethod(singleSatCorrectionObj, method_correctionSatEplUnc);
    uint16_t corrFlags = static_cast<uint16_t>(correctionFlags);
    jobject reflectingPlaneObj;
    jobject reflectingPlaneObj = nullptr;
    bool has_ref_plane = (corrFlags & GnssSingleSatCorrectionFlags::HAS_REFLECTING_PLANE) != 0;
    if (has_ref_plane) {
        reflectingPlaneObj =
@@ -2731,6 +2732,7 @@ static SingleSatCorrection_V1_0 getSingleSatCorrection_1_0_withoutConstellation(
                .azimuthDegrees = azimuthDegreeRefPlane,
        };
    }
    env->DeleteLocalRef(reflectingPlaneObj);

    SingleSatCorrection_V1_0 singleSatCorrection = {
            .singleSatCorrectionFlags = corrFlags,
@@ -2762,6 +2764,7 @@ static void getSingleSatCorrectionList_1_1(JNIEnv* env, jobject singleSatCorrect
        };

        list[i] = singleSatCorrection_1_1;
        env->DeleteLocalRef(singleSatCorrectionObj);
    }
}

@@ -2779,6 +2782,7 @@ static void getSingleSatCorrectionList_1_0(JNIEnv* env, jobject singleSatCorrect
        singleSatCorrection.constellation = static_cast<GnssConstellationType_V1_0>(constType),

        list[i] = singleSatCorrection;
        env->DeleteLocalRef(singleSatCorrectionObj);
    }
}

@@ -2849,6 +2853,7 @@ static jboolean android_location_gnss_hal_GnssNative_inject_measurement_correcti

    hidl_vec<SingleSatCorrection_V1_0> list(len);
    getSingleSatCorrectionList_1_0(env, singleSatCorrectionList, list);
    env->DeleteLocalRef(singleSatCorrectionList);
    measurementCorrections_1_0.satCorrections = list;

    auto result = gnssCorrectionsIface_V1_0->setCorrections(measurementCorrections_1_0);
+25 −23
Original line number Diff line number Diff line
@@ -335,22 +335,22 @@ void GnssMeasurementCallbackAidl::translateSingleGnssMeasurement(JNIEnv* env,
                                       satellitePvt.satClockInfo.satHardwareCodeBiasMeters,
                                       satellitePvt.satClockInfo.satTimeCorrectionMeters,
                                       satellitePvt.satClockInfo.satClkDriftMps);
            env->CallObjectMethod(satellitePvtBuilderObject,
            callObjectMethodIgnoringResult(env, satellitePvtBuilderObject,
                                           method_satellitePvtBuilderSetPositionEcef, positionEcef);
            env->CallObjectMethod(satellitePvtBuilderObject,
            callObjectMethodIgnoringResult(env, satellitePvtBuilderObject,
                                           method_satellitePvtBuilderSetVelocityEcef, velocityEcef);
            env->CallObjectMethod(satellitePvtBuilderObject, method_satellitePvtBuilderSetClockInfo,
                                  clockInfo);
            callObjectMethodIgnoringResult(env, satellitePvtBuilderObject,
                                           method_satellitePvtBuilderSetClockInfo, clockInfo);
        }

        if (satFlags & SatellitePvt::HAS_IONO) {
            env->CallObjectMethod(satellitePvtBuilderObject,
            callObjectMethodIgnoringResult(env, satellitePvtBuilderObject,
                                           method_satellitePvtBuilderSetIonoDelayMeters,
                                           satellitePvt.ionoDelayMeters);
        }

        if (satFlags & SatellitePvt::HAS_TROPO) {
            env->CallObjectMethod(satellitePvtBuilderObject,
            callObjectMethodIgnoringResult(env, satellitePvtBuilderObject,
                                           method_satellitePvtBuilderSetTropoDelayMeters,
                                           satellitePvt.tropoDelayMeters);
        }
@@ -380,15 +380,17 @@ void GnssMeasurementCallbackAidl::translateSingleGnssMeasurement(JNIEnv* env,
            jobject correlationVectorBuilderObject =
                    env->NewObject(class_correlationVectorBuilder,
                                   method_correlationVectorBuilderCtor);
            env->CallObjectMethod(correlationVectorBuilderObject,
                                  method_correlationVectorBuilderSetMagnitude, magnitudeArray);
            env->CallObjectMethod(correlationVectorBuilderObject,
            callObjectMethodIgnoringResult(env, correlationVectorBuilderObject,
                                           method_correlationVectorBuilderSetMagnitude,
                                           magnitudeArray);
            callObjectMethodIgnoringResult(
                    env, correlationVectorBuilderObject,
                    method_correlationVectorBuilderSetFrequencyOffsetMetersPerSecond,
                    correlationVector.frequencyOffsetMps);
            env->CallObjectMethod(correlationVectorBuilderObject,
            callObjectMethodIgnoringResult(env, correlationVectorBuilderObject,
                                           method_correlationVectorBuilderSetSamplingStartMeters,
                                           correlationVector.samplingStartM);
            env->CallObjectMethod(correlationVectorBuilderObject,
            callObjectMethodIgnoringResult(env, correlationVectorBuilderObject,
                                           method_correlationVectorBuilderSetSamplingWidthMeters,
                                           correlationVector.samplingWidthM);
            jobject correlationVectorObject =
+7 −0
Original line number Diff line number Diff line
@@ -82,6 +82,13 @@ void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName) {
    }
}

void callObjectMethodIgnoringResult(JNIEnv* env, jobject obj, jmethodID mid, ...) {
    va_list args;
    va_start(args, mid);
    env->DeleteLocalRef(env->CallObjectMethodV(obj, mid, args));
    va_end(args);
}

JavaObject::JavaObject(JNIEnv* env, jclass clazz, jmethodID defaultCtor)
      : env_(env), clazz_(clazz) {
    object_ = env_->NewObject(clazz_, defaultCtor);
+2 −0
Original line number Diff line number Diff line
@@ -48,6 +48,8 @@ jboolean checkAidlStatus(const android::binder::Status& status, const char* erro

void checkAndClearExceptionFromCallback(JNIEnv* env, const char* methodName);

void callObjectMethodIgnoringResult(JNIEnv* env, jobject obj, jmethodID mid, ...);

template <class T>
void logHidlError(hardware::Return<T>& result, const char* errorMessage) {
    ALOGE("%s HIDL transport error: %s", errorMessage, result.description().c_str());