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

Commit 748b413e authored by Mike Lockwood's avatar Mike Lockwood Committed by Android Git Automerger
Browse files

am 1c3ef787: Merge "GPS: Do not call sGpsInterface->init() multiple times" into gingerbread

Merge commit '1c3ef787' into gingerbread-plus-aosp

* commit '1c3ef787':
  GPS: Do not call sGpsInterface->init() multiple times
parents 833db408 1c3ef787
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1228,6 +1228,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
    private void reportAGpsStatus(int type, int status) {
        switch (status) {
            case GPS_REQUEST_AGPS_DATA_CONN:
                if (DEBUG) Log.d(TAG, "GPS_REQUEST_AGPS_DATA_CONN");
                // Set mAGpsDataConnectionState before calling startUsingNetworkFeature
                //  to avoid a race condition with handleUpdateNetworkState()
                mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
@@ -1250,6 +1251,7 @@ public class GpsLocationProvider implements LocationProviderInterface {
                }
                break;
            case GPS_RELEASE_AGPS_DATA_CONN:
                if (DEBUG) Log.d(TAG, "GPS_RELEASE_AGPS_DATA_CONN");
                if (mAGpsDataConnectionState != AGPS_DATA_CONNECTION_CLOSED) {
                    mConnMgr.stopUsingNetworkFeature(
                            ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
@@ -1258,13 +1260,13 @@ public class GpsLocationProvider implements LocationProviderInterface {
                }
                break;
            case GPS_AGPS_DATA_CONNECTED:
                // Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
                if (DEBUG) Log.d(TAG, "GPS_AGPS_DATA_CONNECTED");
                break;
            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;
            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;
        }
    }
+24 −19
Original line number Diff line number Diff line
@@ -238,15 +238,25 @@ static const GpsInterface* get_gps_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()
{
    if (!sGpsInterface)
        sGpsInterface = get_gps_interface();
    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
    const GpsInterface* interface = GetGpsInterface();
    if (!interface)
        return NULL;

    if (!sAGpsInterface) {
        sAGpsInterface = (const AGpsInterface*)sGpsInterface->get_extension(AGPS_INTERFACE);
        sAGpsInterface = (const AGpsInterface*)interface->get_extension(AGPS_INTERFACE);
        if (sAGpsInterface)
            sAGpsInterface->init(&sAGpsCallbacks);
    }
@@ -255,13 +265,12 @@ static const AGpsInterface* GetAGpsInterface()

static const GpsNiInterface* GetNiInterface()
{
    if (!sGpsInterface)
        sGpsInterface = get_gps_interface();
    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
    const GpsInterface* interface = GetGpsInterface();
    if (!interface)
        return NULL;

    if (!sGpsNiInterface) {
       sGpsNiInterface = (const GpsNiInterface*)sGpsInterface->get_extension(GPS_NI_INTERFACE);
       sGpsNiInterface = (const GpsNiInterface*)interface->get_extension(GPS_NI_INTERFACE);
        if (sGpsNiInterface)
           sGpsNiInterface->init(&sGpsNiCallbacks);
    }
@@ -270,13 +279,12 @@ static const GpsNiInterface* GetNiInterface()

static const AGpsRilInterface* GetAGpsRilInterface()
{
    if (!sGpsInterface)
        sGpsInterface = get_gps_interface();
    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
    const GpsInterface* interface = GetGpsInterface();
    if (!interface)
        return NULL;

    if (!sAGpsRilInterface) {
       sAGpsRilInterface = (const AGpsRilInterface*)sGpsInterface->get_extension(AGPS_RIL_INTERFACE);
       sAGpsRilInterface = (const AGpsRilInterface*)interface->get_extension(AGPS_RIL_INTERFACE);
        if (sAGpsRilInterface)
            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) {
    if (!sGpsInterface)
        sGpsInterface = get_gps_interface();
    return (sGpsInterface != NULL);
    return (sGpsInterface != NULL || get_gps_interface() != NULL);
}

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)
        mCallbacksObj = env->NewGlobalRef(obj);

    if (!sGpsInterface)
        sGpsInterface = get_gps_interface();
    if (!sGpsInterface || sGpsInterface->init(&sGpsCallbacks) != 0)
    const GpsInterface* interface = GetGpsInterface();
    if (!interface)
        return false;

    if (!sGpsDebugInterface)
       sGpsDebugInterface = (const GpsDebugInterface*)sGpsInterface->get_extension(GPS_DEBUG_INTERFACE);
       sGpsDebugInterface = (const GpsDebugInterface*)interface->get_extension(GPS_DEBUG_INTERFACE);

    return true;
}