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

Commit dc27ce48 authored by Shinru Han's avatar Shinru Han
Browse files

Query Apn protocol by roaming state

The roaming network protocol may be different than home network
protocol, select the correct protocol by roaming state.
Besides, carrier configuration may override the framework
roaming state, we should use the actual modem roaming state.

Bug: 110315058
Test: SUPL test on roaming Fi network and home network

Change-Id: Ie132b98dea25fd9762da793ada0543dccb9701e9
parent c03929b5
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -69,6 +69,7 @@ import android.os.WorkSource.WorkChain;
import android.provider.Settings;
import android.provider.Settings;
import android.provider.Telephony.Carriers;
import android.provider.Telephony.Carriers;
import android.telephony.CarrierConfigManager;
import android.telephony.CarrierConfigManager;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.SubscriptionManager.OnSubscriptionsChangedListener;
import android.telephony.TelephonyManager;
import android.telephony.TelephonyManager;
@@ -2507,13 +2508,20 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
        if (apn == null) {
        if (apn == null) {
            return APN_INVALID;
            return APN_INVALID;
        }
        }

        TelephonyManager phone = (TelephonyManager)
                mContext.getSystemService(Context.TELEPHONY_SERVICE);
        // Carrier configuration may override framework roaming state, we need to use the actual
        // modem roaming state instead of the framework roaming state.
        boolean isDataRoamingFromRegistration = phone.getServiceState().
                getDataRoamingFromRegistration();
        String projection = isDataRoamingFromRegistration ? Carriers.ROAMING_PROTOCOL :
                Carriers.PROTOCOL;
        String selection = String.format("current = 1 and apn = '%s' and carrier_enabled = 1", apn);
        String selection = String.format("current = 1 and apn = '%s' and carrier_enabled = 1", apn);
        Cursor cursor = null;
        Cursor cursor = null;
        try {
        try {
            cursor = mContext.getContentResolver().query(
            cursor = mContext.getContentResolver().query(
                    Carriers.CONTENT_URI,
                    Carriers.CONTENT_URI,
                    new String[]{Carriers.PROTOCOL},
                    new String[]{projection},
                    selection,
                    selection,
                    null,
                    null,
                    Carriers.DEFAULT_SORT_ORDER);
                    Carriers.DEFAULT_SORT_ORDER);