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

Commit 2acfd34c authored by Mike Lockwood's avatar Mike Lockwood
Browse files

GpsLocationProvider: Fix race condition while bringing up APN for SUPL.



If handleUpdateNetworkState() is called before
ConnectivityManager.startUsingNetworkFeature() returns, then we will not
call native_agps_data_conn_open() to inform the GPS that the APN is up.
So we now set mAGpsDataConnectionState to AGPS_DATA_CONNECTION_OPENING
before calling ConnectivityManager.startUsingNetworkFeature() to avoid
this problem.

Change-Id: I5e1597d6494dc8ab68e608911c546a7a04f2ea07
Signed-off-by: default avatarMike Lockwood <lockwood@android.com>
parent dd62a056
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -1171,6 +1171,9 @@ 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:
                // Set mAGpsDataConnectionState before calling startUsingNetworkFeature
                //  to avoid a race condition with handleUpdateNetworkState()
                mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
                int result = mConnMgr.startUsingNetworkFeature(
                int result = mConnMgr.startUsingNetworkFeature(
                        ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
                        ConnectivityManager.TYPE_MOBILE, Phone.FEATURE_ENABLE_SUPL);
                if (result == Phone.APN_ALREADY_ACTIVE) {
                if (result == Phone.APN_ALREADY_ACTIVE) {
@@ -1179,11 +1182,13 @@ public class GpsLocationProvider implements LocationProviderInterface {
                        mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                        mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPEN;
                    } else {
                    } else {
                        Log.e(TAG, "mAGpsApn not set when receiving Phone.APN_ALREADY_ACTIVE");
                        Log.e(TAG, "mAGpsApn not set when receiving Phone.APN_ALREADY_ACTIVE");
                        mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
                        native_agps_data_conn_failed();
                        native_agps_data_conn_failed();
                    }
                    }
                } else if (result == Phone.APN_REQUEST_STARTED) {
                } else if (result == Phone.APN_REQUEST_STARTED) {
                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_OPENING;
                    // Nothing to do here
                } else {
                } else {
                    mAGpsDataConnectionState = AGPS_DATA_CONNECTION_CLOSED;
                    native_agps_data_conn_failed();
                    native_agps_data_conn_failed();
                }
                }
                break;
                break;