Merge "GPS: Do not call sGpsInterface->init() multiple times" into gingerbread
This commit is contained in:
committed by
Android (Google) Code Review
commit
1c3ef78782
@ -1228,6 +1228,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
|
|||||||
private void reportAGpsStatus(int type, int status) {
|
private void reportAGpsStatus(int type, int status) {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case GPS_REQUEST_AGPS_DATA_CONN:
|
case GPS_REQUEST_AGPS_DATA_CONN:
|
||||||
|
if (DEBUG) Log.d(TAG, "GPS_REQUEST_AGPS_DATA_CONN");
|
||||||
// Set mAGpsDataConnectionState before calling startUsingNetworkFeature
|
// Set mAGpsDataConnectionState before calling startUsingNetworkFeature
|
||||||
// to avoid a race condition with handleUpdateNetworkState()
|
// to avoid a race condition with handleUpdateNetworkState()
|
||||||
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
|
mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
|
||||||
@ -1250,6 +1251,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GPS_RELEASE_AGPS_DATA_CONN:
|
case GPS_RELEASE_AGPS_DATA_CONN:
|
||||||
|
if (DEBUG) Log.d(TAG, "GPS_RELEASE_AGPS_DATA_CONN");
|
||||||
if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
|
if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
|
||||||
mConnMgr.stopUsingNetworkFeature(
|
mConnMgr.stopUsingNetworkFeature(
|
||||||
ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
|
ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
|
||||||
@ -1258,13 +1260,13 @@ public class GpsLocationProvider implements LocationProviderInterface {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GPS_AGPS_DATA_CONNECTED:
|
case GPS_AGPS_DATA_CONNECTED:
|
||||||
// Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
|
if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
|
||||||
break;
|
break;
|
||||||
case GPS_AGPS_DATA_CONN_DONE:
|
case GPS_AGPS_DATA_CONN_DONE:
|
||||||
// Log.d(TAG, "GPS_AGPS_DATA_CONN_DONE");
|
if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONN_DONE");
|
||||||
break;
|
break;
|
||||||
case GPS_AGPS_DATA_CONN_FAILED:
|
case GPS_AGPS_DATA_CONN_FAILED:
|
||||||
// Log.d(TAG, "GPS_AGPS_DATA_CONN_FAILED");
|
if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONN_FAILED");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,15 +238,25 @@ static const GpsInterface* get_gps_interface() {
|
|||||||
return interface;
|
return interface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const GpsInterface* GetGpsInterface() {
|
||||||
|
if (!sGpsInterface) {
|
||||||
|
sGpsInterface = get_gps_interface();
|
||||||
|
if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0) {
|
||||||
|
sGpsInterface = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sGpsInterface;
|
||||||
|
}
|
||||||
|
|
||||||
static const AGpsInterface* GetAGpsInterface()
|
static const AGpsInterface* GetAGpsInterface()
|
||||||
{
|
{
|
||||||
if (!sGpsInterface)
|
const GpsInterface* interface = GetGpsInterface();
|
||||||
sGpsInterface = get_gps_interface();
|
if (!interface)
|
||||||
if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!sAGpsInterface) {
|
if (!sAGpsInterface) {
|
||||||
sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
|
sAGpsInterface = (const AGpsInterface*)interface->get_extension(AGPS_INTERFACE);
|
||||||
if (sAGpsInterface)
|
if (sAGpsInterface)
|
||||||
sAGpsInterface->init(&sAGpsCallbacks);
|
sAGpsInterface->init(&sAGpsCallbacks);
|
||||||
}
|
}
|
||||||
@ -255,13 +265,12 @@ static const AGpsInterface* GetAGpsInterface()
|
|||||||
|
|
||||||
static const GpsNiInterface* GetNiInterface()
|
static const GpsNiInterface* GetNiInterface()
|
||||||
{
|
{
|
||||||
if (!sGpsInterface)
|
const GpsInterface* interface = GetGpsInterface();
|
||||||
sGpsInterface = get_gps_interface();
|
if (!interface)
|
||||||
if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!sGpsNiInterface) {
|
if (!sGpsNiInterface) {
|
||||||
sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
|
sGpsNiInterface = (const GpsNiInterface*)interface->get_extension(GPS_NI_INTERFACE);
|
||||||
if (sGpsNiInterface)
|
if (sGpsNiInterface)
|
||||||
sGpsNiInterface->init(&sGpsNiCallbacks);
|
sGpsNiInterface->init(&sGpsNiCallbacks);
|
||||||
}
|
}
|
||||||
@ -270,13 +279,12 @@ static const GpsNiInterface* GetNiInterface()
|
|||||||
|
|
||||||
static const AGpsRilInterface* GetAGpsRilInterface()
|
static const AGpsRilInterface* GetAGpsRilInterface()
|
||||||
{
|
{
|
||||||
if (!sGpsInterface)
|
const GpsInterface* interface = GetGpsInterface();
|
||||||
sGpsInterface = get_gps_interface();
|
if (!interface)
|
||||||
if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (!sAGpsRilInterface) {
|
if (!sAGpsRilInterface) {
|
||||||
sAGpsRilInterface = (const AGpsRilInterface*)sGpsInterface->get_extension(AGPS_RIL_INTERFACE);
|
sAGpsRilInterface = (const AGpsRilInterface*)interface->get_extension(AGPS_RIL_INTERFACE);
|
||||||
if (sAGpsRilInterface)
|
if (sAGpsRilInterface)
|
||||||
sAGpsRilInterface->init(&sAGpsRilCallbacks);
|
sAGpsRilInterface->init(&sAGpsRilCallbacks);
|
||||||
}
|
}
|
||||||
@ -297,9 +305,7 @@ static void android_location_GpsLocationProvider_class_init_native(JNIEnv* env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) {
|
static jboolean android_location_GpsLocationProvider_is_supported(JNIEnv* env, jclass clazz) {
|
||||||
if (!sGpsInterface)
|
return (sGpsInterface != NULL || get_gps_interface() != NULL);
|
||||||
sGpsInterface = get_gps_interface();
|
|
||||||
return (sGpsInterface != NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj)
|
static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject obj)
|
||||||
@ -308,13 +314,12 @@ static jboolean android_location_GpsLocationProvider_init(JNIEnv* env, jobject o
|
|||||||
if (!mCallbacksObj)
|
if (!mCallbacksObj)
|
||||||
mCallbacksObj = env->NewGlobalRef(obj);
|
mCallbacksObj = env->NewGlobalRef(obj);
|
||||||
|
|
||||||
if (!sGpsInterface)
|
const GpsInterface* interface = GetGpsInterface();
|
||||||
sGpsInterface = get_gps_interface();
|
if (!interface)
|
||||||
if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!sGpsDebugInterface)
|
if (!sGpsDebugInterface)
|
||||||
sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE);
|
sGpsDebugInterface = (const GpsDebugInterface*)interface->get_extension(GPS_DEBUG_INTERFACE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user