From ef752b69444b1d63e2b177e0589d2bf4e5383845 Mon Sep 17 00:00:00 2001 From: destradaa Date: Fri, 17 Apr 2015 13:10:47 -0700 Subject: Avoid performing work in the platform when GPS HAL does not support a feature. b/19271554 Prevents accessing and computing data in cases when we know that the result cannot be used by the GPS HAL, because the required interface is not supported. Change-Id: I74bf1719f2c8ab7fbfe1244ebe0bebe3ed55ba24 --- ...android_server_location_GpsLocationProvider.cpp | 46 ++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'services/core/jni') diff --git a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp index 0cd6eb5..3804e1d 100644 --- a/services/core/jni/com_android_server_location_GpsLocationProvider.cpp +++ b/services/core/jni/com_android_server_location_GpsLocationProvider.cpp @@ -509,13 +509,22 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env, } } -static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* /* env */, - jclass /* clazz */) { - if (sGpsInterface != NULL) { - return JNI_TRUE; - } else { - return JNI_FALSE; - } +static jboolean android_location_GpsLocationProvider_is_supported( + JNIEnv* /* env */, jclass /* clazz */) +{ + return (sGpsInterface != NULL) ? JNI_TRUE : JNI_FALSE; +} + +static jboolean android_location_GpsLocationProvider_is_agps_ril_supported( + JNIEnv* /* env */, jclass /* clazz */) +{ + return (sAGpsRilInterface != NULL) ? JNI_TRUE : JNI_FALSE; +} + +static jboolean android_location_gpsLocationProvider_is_gnss_configuration_supported( + JNIEnv* /* env */, jclass /* jclazz */) +{ + return (sGnssConfigurationInterface != NULL) ? JNI_TRUE : JNI_FALSE; } static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj) @@ -715,14 +724,10 @@ static void android_location_GpsLocationProvider_inject_location(JNIEnv* /* env sGpsInterface->inject_location(latitude, longitude, accuracy); } -static jboolean android_location_GpsLocationProvider_supports_xtra(JNIEnv* /* env */, - jobject /* obj */) +static jboolean android_location_GpsLocationProvider_supports_xtra( + JNIEnv* /* env */, jobject /* obj */) { - if (sGpsXtraInterface != NULL) { - return JNI_TRUE; - } else { - return JNI_FALSE; - } + return (sGpsXtraInterface != NULL) ? JNI_TRUE : JNI_FALSE; } static void android_location_GpsLocationProvider_inject_xtra_data(JNIEnv* env, jobject /* obj */, @@ -844,13 +849,10 @@ static void android_location_GpsLocationProvider_update_network_state(JNIEnv* en } } -static jboolean android_location_GpsLocationProvider_is_geofence_supported(JNIEnv* /* env */, - jobject /* obj */) +static jboolean android_location_GpsLocationProvider_is_geofence_supported( + JNIEnv* /* env */, jobject /* obj */) { - if (sGpsGeofencingInterface != NULL) { - return JNI_TRUE; - } - return JNI_FALSE; + return (sGpsGeofencingInterface != NULL) ? JNI_TRUE : JNI_FALSE; } static jboolean android_location_GpsLocationProvider_add_geofence(JNIEnv* /* env */, @@ -1436,6 +1438,10 @@ static JNINativeMethod sMethods[] = { /* name, signature, funcPtr */ {"class_init_native", "()V", (void *)android_location_GpsLocationProvider_class_init_native}, {"native_is_supported", "()Z", (void*)android_location_GpsLocationProvider_is_supported}, + {"native_is_agps_ril_supported", "()Z", + (void*)android_location_GpsLocationProvider_is_agps_ril_supported}, + {"native_is_gnss_configuration_supported", "()Z", + (void*)android_location_gpsLocationProvider_is_gnss_configuration_supported}, {"native_init", "()Z", (void*)android_location_GpsLocationProvider_init}, {"native_cleanup", "()V", (void*)android_location_GpsLocationProvider_cleanup}, {"native_set_position_mode", -- cgit v1.1