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

Commit 7fc2e746 authored by Kevin Tang's avatar Kevin Tang Committed by android-build-merger
Browse files

Merge "Merge "GnssLocationProvider: listening to conn lost event" into...

Merge "Merge "GnssLocationProvider: listening to conn lost event" into oc-dr1-dev am: 9564b4d1" into oc-dr1-dev-plus-aosp
am: 7904864f

Change-Id: I19f7da4ae70e4d9fd4a2de79d18020e70fb5fe7d
parents e01674d7 7904864f
Loading
Loading
Loading
Loading
+21 −9
Original line number Original line Diff line number Diff line
@@ -466,6 +466,11 @@ public class GnssLocationProvider implements LocationProviderInterface {
            // Always on, notify HAL so it can get data it needs
            // Always on, notify HAL so it can get data it needs
            sendMessage(UPDATE_NETWORK_STATE, 0 /*arg*/, network);
            sendMessage(UPDATE_NETWORK_STATE, 0 /*arg*/, network);
        }
        }

        @Override
        public void onLost(Network network) {
            sendMessage(UPDATE_NETWORK_STATE, 0 /*arg*/, network);
        }
    };
    };


    /**
    /**
@@ -802,11 +807,21 @@ public class GnssLocationProvider implements LocationProviderInterface {
    private void handleUpdateNetworkState(Network network) {
    private void handleUpdateNetworkState(Network network) {
        // retrieve NetworkInfo for this UID
        // retrieve NetworkInfo for this UID
        NetworkInfo info = mConnMgr.getNetworkInfo(network);
        NetworkInfo info = mConnMgr.getNetworkInfo(network);
        if (info == null) {

            return;
        boolean networkAvailable = false;
        boolean isConnected = false;
        int type = ConnectivityManager.TYPE_NONE;
        boolean isRoaming = false;
        String apnName = null;

        if (info != null) {
            networkAvailable = info.isAvailable() && TelephonyManager.getDefault().getDataEnabled();
            isConnected = info.isConnected();
            type = info.getType();
            isRoaming = info.isRoaming();
            apnName = info.getExtraInfo();
        }
        }


        boolean isConnected = info.isConnected();
        if (DEBUG) {
        if (DEBUG) {
            String message = String.format(
            String message = String.format(
                    "UpdateNetworkState, state=%s, connected=%s, info=%s, capabilities=%S",
                    "UpdateNetworkState, state=%s, connected=%s, info=%s, capabilities=%S",
@@ -818,8 +833,6 @@ public class GnssLocationProvider implements LocationProviderInterface {
        }
        }


        if (native_is_agps_ril_supported()) {
        if (native_is_agps_ril_supported()) {
            boolean dataEnabled = TelephonyManager.getDefault().getDataEnabled();
            boolean networkAvailable = info.isAvailable() && dataEnabled;
            String defaultApn = getSelectedApn();
            String defaultApn = getSelectedApn();
            if (defaultApn == null) {
            if (defaultApn == null) {
                defaultApn = "dummy-apn";
                defaultApn = "dummy-apn";
@@ -827,10 +840,10 @@ public class GnssLocationProvider implements LocationProviderInterface {


            native_update_network_state(
            native_update_network_state(
                    isConnected,
                    isConnected,
                    info.getType(),
                    type,
                    info.isRoaming(),
                    isRoaming,
                    networkAvailable,
                    networkAvailable,
                    info.getExtraInfo(),
                    apnName,
                    defaultApn);
                    defaultApn);
        } else if (DEBUG) {
        } else if (DEBUG) {
            Log.d(TAG, "Skipped network state update because GPS HAL AGPS-RIL is not  supported");
            Log.d(TAG, "Skipped network state update because GPS HAL AGPS-RIL is not  supported");
@@ -838,7 +851,6 @@ public class GnssLocationProvider implements LocationProviderInterface {


        if (mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
        if (mAGpsDataConnectionState == AGPS_DATA_CONNECTION_OPENING) {
            if (isConnected) {
            if (isConnected) {
                String apnName = info.getExtraInfo();
                if (apnName == null) {
                if (apnName == null) {
                    // assign a dummy value in the case of C2K as otherwise we will have a runtime
                    // assign a dummy value in the case of C2K as otherwise we will have a runtime
                    // exception in the following call to native_agps_data_conn_open
                    // exception in the following call to native_agps_data_conn_open