Merge "Add GnssGeofence AIDL HAL (frameworks/base)"

This commit is contained in:
TreeHugger Robot
2021-11-22 22:39:29 +00:00
committed by Android (Google) Code Review

View File

@@ -29,6 +29,8 @@
#include <android/hardware/gnss/2.1/IGnssMeasurement.h>
#include <android/hardware/gnss/BnGnss.h>
#include <android/hardware/gnss/BnGnssCallback.h>
#include <android/hardware/gnss/BnGnssGeofence.h>
#include <android/hardware/gnss/BnGnssGeofenceCallback.h>
#include <android/hardware/gnss/BnGnssMeasurementCallback.h>
#include <android/hardware/gnss/BnGnssPowerIndicationCallback.h>
#include <android/hardware/gnss/BnGnssPsdsCallback.h>
@@ -191,6 +193,9 @@ using android::hardware::gnss::IGnssPowerIndicationCallback;
using android::hardware::gnss::PsdsType;
using IGnssAidl = android::hardware::gnss::IGnss;
using IGnssCallbackAidl = android::hardware::gnss::IGnssCallback;
using IGnssBatchingAidl = android::hardware::gnss::IGnssBatching;
using IGnssGeofenceAidl = android::hardware::gnss::IGnssGeofence;
using IGnssGeofenceCallbackAidl = android::hardware::gnss::IGnssGeofenceCallback;
using IGnssPsdsAidl = android::hardware::gnss::IGnssPsds;
using IGnssPsdsCallbackAidl = android::hardware::gnss::IGnssPsdsCallback;
using IGnssConfigurationAidl = android::hardware::gnss::IGnssConfiguration;
@@ -216,6 +221,8 @@ sp<IGnss_V1_1> gnssHal_V1_1 = nullptr;
sp<IGnss_V2_0> gnssHal_V2_0 = nullptr;
sp<IGnss_V2_1> gnssHal_V2_1 = nullptr;
sp<IGnssAidl> gnssHalAidl = nullptr;
sp<IGnssBatchingAidl> gnssBatchingAidlIface = nullptr;
sp<IGnssGeofenceAidl> gnssGeofenceAidlIface = nullptr;
sp<IGnssPsdsAidl> gnssPsdsAidlIface = nullptr;
sp<IGnssXtra> gnssXtraIface = nullptr;
sp<IAGnssRil_V1_0> agnssRilIface = nullptr;
@@ -709,35 +716,25 @@ Return<void> GnssXtraCallback::downloadRequestCb() {
return Void();
}
/*
* GnssGeofenceCallback class implements the callback methods for the
* IGnssGeofence interface.
*/
struct GnssGeofenceCallback : public IGnssGeofenceCallback {
// Methods from ::android::hardware::gps::V1_0::IGnssGeofenceCallback follow.
Return<void> gnssGeofenceTransitionCb(
int32_t geofenceId,
const GnssLocation_V1_0& location,
GeofenceTransition transition,
hardware::gnss::V1_0::GnssUtcTime timestamp) override;
Return<void>
gnssGeofenceStatusCb(
GeofenceAvailability status,
const GnssLocation_V1_0& location) override;
Return<void> gnssGeofenceAddCb(int32_t geofenceId,
GeofenceStatus status) override;
Return<void> gnssGeofenceRemoveCb(int32_t geofenceId,
GeofenceStatus status) override;
Return<void> gnssGeofencePauseCb(int32_t geofenceId,
GeofenceStatus status) override;
Return<void> gnssGeofenceResumeCb(int32_t geofenceId,
GeofenceStatus status) override;
/** Util class for GnssGeofenceCallback methods. */
struct GnssGeofenceCallbackUtil {
template <class T>
static void gnssGeofenceTransitionCb(int geofenceId, const T& location, int transition,
int64_t timestampMillis);
template <class T>
static void gnssGeofenceStatusCb(int availability, const T& lastLocation);
static void gnssGeofenceAddCb(int geofenceId, int status);
static void gnssGeofenceRemoveCb(int geofenceId, int status);
static void gnssGeofencePauseCb(int geofenceId, int status);
static void gnssGeofenceResumeCb(int geofenceId, int status);
private:
GnssGeofenceCallbackUtil() = delete;
};
Return<void> GnssGeofenceCallback::gnssGeofenceTransitionCb(
int32_t geofenceId, const GnssLocation_V1_0& location,
GeofenceTransition transition,
hardware::gnss::V1_0::GnssUtcTime timestamp) {
template <class T>
void GnssGeofenceCallbackUtil::gnssGeofenceTransitionCb(int geofenceId, const T& location,
int transition, int64_t timestamp) {
JNIEnv* env = getJniEnv();
jobject jLocation = translateGnssLocation(env, location);
@@ -751,27 +748,22 @@ Return<void> GnssGeofenceCallback::gnssGeofenceTransitionCb(
checkAndClearExceptionFromCallback(env, __FUNCTION__);
env->DeleteLocalRef(jLocation);
return Void();
}
Return<void>
GnssGeofenceCallback::gnssGeofenceStatusCb(GeofenceAvailability status,
const GnssLocation_V1_0& location) {
template <class T>
void GnssGeofenceCallbackUtil::gnssGeofenceStatusCb(int availability, const T& lastLocation) {
JNIEnv* env = getJniEnv();
jobject jLocation = translateGnssLocation(env, location);
jobject jLocation = translateGnssLocation(env, lastLocation);
env->CallVoidMethod(mCallbacksObj, method_reportGeofenceStatus, status,
jLocation);
env->CallVoidMethod(mCallbacksObj, method_reportGeofenceStatus, availability, jLocation);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
env->DeleteLocalRef(jLocation);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceAddCb(int32_t geofenceId,
GeofenceStatus status) {
void GnssGeofenceCallbackUtil::gnssGeofenceAddCb(int geofenceId, int status) {
JNIEnv* env = getJniEnv();
if (status != IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS) {
if (status != IGnssGeofenceCallbackAidl::OPERATION_SUCCESS) {
ALOGE("%s: Error in adding a Geofence: %d\n", __func__, status);
}
@@ -780,13 +772,11 @@ Return<void> GnssGeofenceCallback::gnssGeofenceAddCb(int32_t geofenceId,
geofenceId,
status);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceRemoveCb(int32_t geofenceId,
GeofenceStatus status) {
void GnssGeofenceCallbackUtil::gnssGeofenceRemoveCb(int geofenceId, int status) {
JNIEnv* env = getJniEnv();
if (status != IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS) {
if (status != IGnssGeofenceCallbackAidl::OPERATION_SUCCESS) {
ALOGE("%s: Error in removing a Geofence: %d\n", __func__, status);
}
@@ -794,13 +784,11 @@ Return<void> GnssGeofenceCallback::gnssGeofenceRemoveCb(int32_t geofenceId,
method_reportGeofenceRemoveStatus,
geofenceId, status);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofencePauseCb(int32_t geofenceId,
GeofenceStatus status) {
void GnssGeofenceCallbackUtil::gnssGeofencePauseCb(int geofenceId, int status) {
JNIEnv* env = getJniEnv();
if (status != IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS) {
if (status != IGnssGeofenceCallbackAidl::OPERATION_SUCCESS) {
ALOGE("%s: Error in pausing Geofence: %d\n", __func__, status);
}
@@ -808,13 +796,11 @@ Return<void> GnssGeofenceCallback::gnssGeofencePauseCb(int32_t geofenceId,
method_reportGeofencePauseStatus,
geofenceId, status);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceResumeCb(int32_t geofenceId,
GeofenceStatus status) {
void GnssGeofenceCallbackUtil::gnssGeofenceResumeCb(int geofenceId, int status) {
JNIEnv* env = getJniEnv();
if (status != IGnssGeofenceCallback::GeofenceStatus::OPERATION_SUCCESS) {
if (status != IGnssGeofenceCallbackAidl::OPERATION_SUCCESS) {
ALOGE("%s: Error in resuming Geofence: %d\n", __func__, status);
}
@@ -822,6 +808,104 @@ Return<void> GnssGeofenceCallback::gnssGeofenceResumeCb(int32_t geofenceId,
method_reportGeofenceResumeStatus,
geofenceId, status);
checkAndClearExceptionFromCallback(env, __FUNCTION__);
}
/*
* GnssGeofenceCallbackAidl class implements the callback methods for the IGnssGeofence AIDL
* interface.
*/
struct GnssGeofenceCallbackAidl : public android::hardware::gnss::BnGnssGeofenceCallback {
Status gnssGeofenceTransitionCb(int geofenceId, const GnssLocationAidl& location,
int transition, int64_t timestampMillis) override;
Status gnssGeofenceStatusCb(int availability, const GnssLocationAidl& lastLocation) override;
Status gnssGeofenceAddCb(int geofenceId, int status) override;
Status gnssGeofenceRemoveCb(int geofenceId, int status) override;
Status gnssGeofencePauseCb(int geofenceId, int status) override;
Status gnssGeofenceResumeCb(int geofenceId, int status) override;
};
Status GnssGeofenceCallbackAidl::gnssGeofenceTransitionCb(int geofenceId,
const GnssLocationAidl& location,
int transition, int64_t timestampMillis) {
GnssGeofenceCallbackUtil::gnssGeofenceTransitionCb(geofenceId, location, transition,
timestampMillis);
return Status::ok();
}
Status GnssGeofenceCallbackAidl::gnssGeofenceStatusCb(int availability,
const GnssLocationAidl& lastLocation) {
GnssGeofenceCallbackUtil::gnssGeofenceStatusCb(availability, lastLocation);
return Status::ok();
}
Status GnssGeofenceCallbackAidl::gnssGeofenceAddCb(int geofenceId, int status) {
GnssGeofenceCallbackUtil::gnssGeofenceAddCb(geofenceId, status);
return Status::ok();
}
Status GnssGeofenceCallbackAidl::gnssGeofenceRemoveCb(int geofenceId, int status) {
GnssGeofenceCallbackUtil::gnssGeofenceRemoveCb(geofenceId, status);
return Status::ok();
}
Status GnssGeofenceCallbackAidl::gnssGeofencePauseCb(int geofenceId, int status) {
GnssGeofenceCallbackUtil::gnssGeofencePauseCb(geofenceId, status);
return Status::ok();
}
Status GnssGeofenceCallbackAidl::gnssGeofenceResumeCb(int geofenceId, int status) {
GnssGeofenceCallbackUtil::gnssGeofenceResumeCb(geofenceId, status);
return Status::ok();
}
/*
* GnssGeofenceCallback class implements the callback methods for the
* IGnssGeofence HIDL interface.
*/
struct GnssGeofenceCallback : public IGnssGeofenceCallback {
// Methods from ::android::hardware::gps::V1_0::IGnssGeofenceCallback follow.
Return<void> gnssGeofenceTransitionCb(int32_t geofenceId, const GnssLocation_V1_0& location,
GeofenceTransition transition,
hardware::gnss::V1_0::GnssUtcTime timestamp) override;
Return<void> gnssGeofenceStatusCb(GeofenceAvailability status,
const GnssLocation_V1_0& location) override;
Return<void> gnssGeofenceAddCb(int32_t geofenceId, GeofenceStatus status) override;
Return<void> gnssGeofenceRemoveCb(int32_t geofenceId, GeofenceStatus status) override;
Return<void> gnssGeofencePauseCb(int32_t geofenceId, GeofenceStatus status) override;
Return<void> gnssGeofenceResumeCb(int32_t geofenceId, GeofenceStatus status) override;
};
Return<void> GnssGeofenceCallback::gnssGeofenceTransitionCb(
int32_t geofenceId, const GnssLocation_V1_0& location, GeofenceTransition transition,
hardware::gnss::V1_0::GnssUtcTime timestamp) {
GnssGeofenceCallbackUtil::gnssGeofenceTransitionCb(geofenceId, location, (int)transition,
(int64_t)timestamp);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceStatusCb(GeofenceAvailability availability,
const GnssLocation_V1_0& location) {
GnssGeofenceCallbackUtil::gnssGeofenceStatusCb((int)availability, location);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceAddCb(int32_t geofenceId, GeofenceStatus status) {
GnssGeofenceCallbackUtil::gnssGeofenceAddCb(geofenceId, (int)status);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceRemoveCb(int32_t geofenceId, GeofenceStatus status) {
GnssGeofenceCallbackUtil::gnssGeofenceRemoveCb(geofenceId, (int)status);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofencePauseCb(int32_t geofenceId, GeofenceStatus status) {
GnssGeofenceCallbackUtil::gnssGeofencePauseCb(geofenceId, (int)status);
return Void();
}
Return<void> GnssGeofenceCallback::gnssGeofenceResumeCb(int32_t geofenceId, GeofenceStatus status) {
GnssGeofenceCallbackUtil::gnssGeofenceResumeCb(geofenceId, (int)status);
return Void();
}
@@ -1279,11 +1363,13 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
android_location_gnss_hal_GnssNative_set_gps_service_handle();
}
if (gnssHal == nullptr) {
if (gnssHal == nullptr && gnssHalAidl == nullptr) {
ALOGE("Unable to get GPS service\n");
return;
}
// TODO: linkToDeath for AIDL HAL
gnssHalDeathRecipient = new GnssDeathRecipient();
hardware::Return<bool> linked = gnssHal->linkToDeath(gnssHalDeathRecipient, /*cookie*/ 0);
if (!linked.isOk()) {
@@ -1303,7 +1389,7 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
} else {
ALOGD("Unable to get a handle to PSDS AIDL interface.");
}
} else {
} else if (gnssHal != nullptr) {
auto gnssXtra = gnssHal->getExtensionXtra();
if (!gnssXtra.isOk()) {
ALOGD("Unable to get a handle to Xtra");
@@ -1320,7 +1406,7 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
agnssRilIface_V2_0 = agnssRil_V2_0;
agnssRilIface = agnssRilIface_V2_0;
}
} else {
} else if (gnssHal != nullptr) {
auto agnssRil_V1_0 = gnssHal->getExtensionAGnssRil();
if (!agnssRil_V1_0.isOk()) {
ALOGD("Unable to get a handle to AGnssRil");
@@ -1336,7 +1422,7 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
} else {
agnssIface_V2_0 = agnss_V2_0;
}
} else {
} else if (gnssHal != nullptr) {
auto agnss_V1_0 = gnssHal->getExtensionAGnss();
if (!agnss_V1_0.isOk()) {
ALOGD("Unable to get a handle to AGnss");
@@ -1345,11 +1431,13 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
}
}
auto gnssNavigationMessage = gnssHal->getExtensionGnssNavigationMessage();
if (!gnssNavigationMessage.isOk()) {
ALOGD("Unable to get a handle to GnssNavigationMessage");
} else {
gnssNavigationMessageIface = gnssNavigationMessage;
if (gnssHal != nullptr) {
auto gnssNavigationMessage = gnssHal->getExtensionGnssNavigationMessage();
if (!gnssNavigationMessage.isOk()) {
ALOGD("Unable to get a handle to GnssNavigationMessage");
} else {
gnssNavigationMessageIface = gnssNavigationMessage;
}
}
// Allow all causal combinations between IGnss.hal and IGnssMeasurement.hal. That means,
@@ -1387,12 +1475,12 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
std::make_unique<android::gnss::GnssMeasurement_V1_1>(gnssMeasurement);
}
}
if (gnssMeasurementIface == nullptr) {
auto gnssMeasurement = gnssHal->getExtensionGnssMeasurement();
if (checkHidlReturn(gnssMeasurement, "Unable to get a handle to GnssMeasurement_V1_0")) {
gnssMeasurementIface =
std::make_unique<android::gnss::GnssMeasurement_V1_0>(gnssMeasurement);
}
if (gnssHal != nullptr && gnssMeasurementIface == nullptr) {
auto gnssMeasurement = gnssHal->getExtensionGnssMeasurement();
if (checkHidlReturn(gnssMeasurement, "Unable to get a handle to GnssMeasurement_V1_0")) {
gnssMeasurementIface =
std::make_unique<android::gnss::GnssMeasurement_V1_0>(gnssMeasurement);
}
}
if (gnssHal_V2_1 != nullptr) {
@@ -1434,7 +1522,7 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
gnssDebugIface = gnssDebugIface_V2_0;
}
}
if (gnssDebugIface == nullptr) {
if (gnssHal != nullptr && gnssDebugIface == nullptr) {
auto gnssDebug = gnssHal->getExtensionGnssDebug();
if (!gnssDebug.isOk()) {
ALOGD("Unable to get a handle to GnssDebug");
@@ -1443,11 +1531,13 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
}
}
auto gnssNi = gnssHal->getExtensionGnssNi();
if (!gnssNi.isOk()) {
ALOGD("Unable to get a handle to GnssNi");
} else {
gnssNiIface = gnssNi;
if (gnssHal != nullptr) {
auto gnssNi = gnssHal->getExtensionGnssNi();
if (!gnssNi.isOk()) {
ALOGD("Unable to get a handle to GnssNi");
} else {
gnssNiIface = gnssNi;
}
}
if (gnssHalAidl != nullptr) {
@@ -1488,11 +1578,17 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
}
}
auto gnssGeofencing = gnssHal->getExtensionGnssGeofencing();
if (!gnssGeofencing.isOk()) {
ALOGD("Unable to get a handle to GnssGeofencing");
} else {
gnssGeofencingIface = gnssGeofencing;
if (gnssHalAidl != nullptr && gnssHalAidl->getInterfaceVersion() >= 2) {
sp<IGnssGeofenceAidl> gnssGeofenceAidl;
auto status = gnssHalAidl->getExtensionGnssGeofence(&gnssGeofenceAidl);
if (checkAidlStatus(status, "Unable to get a handle to GnssGeofence interface.")) {
gnssGeofenceAidlIface = gnssGeofenceAidl;
}
} else if (gnssHal != nullptr) {
auto gnssGeofencing = gnssHal->getExtensionGnssGeofencing();
if (checkHidlReturn(gnssGeofencing, "Unable to get a handle to GnssGeofencing")) {
gnssGeofencingIface = gnssGeofencing;
}
}
if (gnssHalAidl != nullptr && gnssHalAidl->getInterfaceVersion() >= 2) {
@@ -1507,7 +1603,7 @@ static void android_location_gnss_hal_GnssNative_init_once(JNIEnv* env, jobject
gnssBatchingIface = std::make_unique<gnss::GnssBatching_V2_0>(gnssBatching_V2_0);
}
}
if (gnssBatchingIface == nullptr) {
if (gnssHal != nullptr && gnssBatchingIface == nullptr) {
auto gnssBatching_V1_0 = gnssHal->getExtensionGnssBatching();
if (checkHidlReturn(gnssBatching_V1_0, "Unable to get a handle to GnssBatching")) {
gnssBatchingIface = std::make_unique<gnss::GnssBatching_V1_0>(gnssBatching_V1_0);
@@ -1568,7 +1664,7 @@ static jboolean android_location_gnss_hal_GnssNative_init(JNIEnv* /* env */, jcl
/*
* Fail if the main interface fails to initialize
*/
if (gnssHal == nullptr) {
if (gnssHal == nullptr && gnssHalAidl == nullptr) {
ALOGE("Unable to initialize GNSS HAL.");
return JNI_FALSE;
}
@@ -1583,7 +1679,7 @@ static jboolean android_location_gnss_hal_GnssNative_init(JNIEnv* /* env */, jcl
result = gnssHal_V2_0->setCallback_2_0(gnssCbIface);
} else if (gnssHal_V1_1 != nullptr) {
result = gnssHal_V1_1->setCallback_1_1(gnssCbIface);
} else {
} else if (gnssHal != nullptr) {
result = gnssHal->setCallback(gnssCbIface);
}
@@ -1630,10 +1726,18 @@ static jboolean android_location_gnss_hal_GnssNative_init(JNIEnv* /* env */, jcl
}
// Set IGnssGeofencing.hal callback.
sp<IGnssGeofenceCallback> gnssGeofencingCbIface = new GnssGeofenceCallback();
if (gnssGeofencingIface != nullptr) {
if (gnssGeofenceAidlIface != nullptr) {
sp<IGnssGeofenceCallbackAidl> gnssGeofenceCallbackAidl = new GnssGeofenceCallbackAidl();
auto status = gnssGeofenceAidlIface->setCallback(gnssGeofenceCallbackAidl);
if (!checkAidlStatus(status, "IGnssGeofenceAidl setCallback() failed.")) {
gnssGeofenceAidlIface = nullptr;
}
} else if (gnssGeofencingIface != nullptr) {
sp<IGnssGeofenceCallback> gnssGeofencingCbIface = new GnssGeofenceCallback();
auto status = gnssGeofencingIface->setCallback(gnssGeofencingCbIface);
checkHidlReturn(status, "IGnssGeofencing setCallback() failed.");
if (!checkHidlReturn(status, "IGnssGeofencing setCallback() failed.")) {
gnssGeofencingIface = nullptr;
}
} else {
ALOGI("Unable to initialize IGnssGeofencing interface.");
}
@@ -1693,12 +1797,15 @@ static jboolean android_location_gnss_hal_GnssNative_init(JNIEnv* /* env */, jcl
}
static void android_location_gnss_hal_GnssNative_cleanup(JNIEnv* /* env */, jclass) {
if (gnssHal == nullptr) {
return;
if (gnssHalAidl != nullptr) {
auto status = gnssHalAidl->close();
checkAidlStatus(status, "IGnssAidl close() failed.");
}
auto result = gnssHal->cleanup();
checkHidlReturn(result, "IGnss cleanup() failed.");
if (gnssHal != nullptr) {
auto result = gnssHal->cleanup();
checkHidlReturn(result, "IGnss cleanup() failed.");
}
}
static jboolean android_location_gnss_hal_GnssNative_set_position_mode(
@@ -2177,57 +2284,85 @@ static void android_location_GnssNetworkConnectivityHandler_update_network_state
static jboolean android_location_gnss_hal_GnssNative_is_geofence_supported(JNIEnv* /* env */,
jclass) {
return (gnssGeofencingIface != nullptr) ? JNI_TRUE : JNI_FALSE;
if (gnssGeofencingIface == nullptr && gnssGeofenceAidlIface == nullptr) {
return JNI_FALSE;
}
return JNI_TRUE;
}
static jboolean android_location_gnss_hal_GnssNative_add_geofence(
JNIEnv* /* env */, jclass, jint geofenceId, jdouble latitude, jdouble longitude,
jdouble radius, jint last_transition, jint monitor_transition,
jint notification_responsiveness, jint unknown_timer) {
if (gnssGeofencingIface == nullptr) {
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
if (gnssGeofenceAidlIface != nullptr) {
auto status =
gnssGeofenceAidlIface->addGeofence(geofenceId, latitude, longitude, radius,
last_transition, monitor_transition,
notification_responsiveness, unknown_timer);
return checkAidlStatus(status, "IGnssGeofenceAidl addGeofence() failed.");
}
auto result = gnssGeofencingIface->addGeofence(
geofenceId, latitude, longitude, radius,
static_cast<IGnssGeofenceCallback::GeofenceTransition>(last_transition),
monitor_transition, notification_responsiveness, unknown_timer);
return checkHidlReturn(result, "IGnssGeofencing addGeofence() failed.");
if (gnssGeofencingIface != nullptr) {
auto result = gnssGeofencingIface
->addGeofence(geofenceId, latitude, longitude, radius,
static_cast<IGnssGeofenceCallback::GeofenceTransition>(
last_transition),
monitor_transition, notification_responsiveness,
unknown_timer);
return checkHidlReturn(result, "IGnssGeofencing addGeofence() failed.");
}
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
}
static jboolean android_location_gnss_hal_GnssNative_remove_geofence(JNIEnv* /* env */, jclass,
jint geofenceId) {
if (gnssGeofencingIface == nullptr) {
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
if (gnssGeofenceAidlIface != nullptr) {
auto status = gnssGeofenceAidlIface->removeGeofence(geofenceId);
return checkAidlStatus(status, "IGnssGeofenceAidl removeGeofence() failed.");
}
auto result = gnssGeofencingIface->removeGeofence(geofenceId);
return checkHidlReturn(result, "IGnssGeofencing removeGeofence() failed.");
if (gnssGeofencingIface != nullptr) {
auto result = gnssGeofencingIface->removeGeofence(geofenceId);
return checkHidlReturn(result, "IGnssGeofencing removeGeofence() failed.");
}
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
}
static jboolean android_location_gnss_hal_GnssNative_pause_geofence(JNIEnv* /* env */, jclass,
jint geofenceId) {
if (gnssGeofencingIface == nullptr) {
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
if (gnssGeofenceAidlIface != nullptr) {
auto status = gnssGeofenceAidlIface->pauseGeofence(geofenceId);
return checkAidlStatus(status, "IGnssGeofenceAidl pauseGeofence() failed.");
}
auto result = gnssGeofencingIface->pauseGeofence(geofenceId);
return checkHidlReturn(result, "IGnssGeofencing pauseGeofence() failed.");
if (gnssGeofencingIface != nullptr) {
auto result = gnssGeofencingIface->pauseGeofence(geofenceId);
return checkHidlReturn(result, "IGnssGeofencing pauseGeofence() failed.");
}
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
}
static jboolean android_location_gnss_hal_GnssNative_resume_geofence(JNIEnv* /* env */, jclass,
jint geofenceId,
jint monitor_transition) {
if (gnssGeofencingIface == nullptr) {
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
if (gnssGeofenceAidlIface != nullptr) {
auto status = gnssGeofenceAidlIface->resumeGeofence(geofenceId, monitor_transition);
return checkAidlStatus(status, "IGnssGeofenceAidl resumeGeofence() failed.");
}
auto result = gnssGeofencingIface->resumeGeofence(geofenceId, monitor_transition);
return checkHidlReturn(result, "IGnssGeofencing resumeGeofence() failed.");
if (gnssGeofencingIface != nullptr) {
auto result = gnssGeofencingIface->resumeGeofence(geofenceId, monitor_transition);
return checkHidlReturn(result, "IGnssGeofencing resumeGeofence() failed.");
}
ALOGE("%s: IGnssGeofencing interface not available.", __func__);
return JNI_FALSE;
}
static jboolean android_location_gnss_hal_GnssNative_is_antenna_info_supported(JNIEnv* env,