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

Commit f4bc5676 authored by Roshan Pius's avatar Roshan Pius
Browse files

LocaleTracker: Remove usage of WifiManager.setCountryCode

WifiManager.setCountryCode() is being removed.

Bug: 140744935
Test: Manual tests
Change-Id: I5b41baf23e88fa1df37479adf4ac45f50111053a
parent 9d031705
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.WifiManager;
import android.os.AsyncResult;
import android.os.Build;
import android.os.Handler;
@@ -491,20 +490,6 @@ public class LocaleTracker extends Handler {
            TelephonyManager.setTelephonyProperty(mPhone.getPhoneId(),
                    TelephonyProperties.PROPERTY_OPERATOR_ISO_COUNTRY, mCurrentCountryIso);

            // Set the country code for wifi. This sets allowed wifi channels based on the
            // country of the carrier we see. If we can't see any, reset to 0 so we don't
            // broadcast on forbidden channels.
            WifiManager wifiManager = (WifiManager) mPhone.getContext()
                    .getSystemService(Context.WIFI_SERVICE);
            if (wifiManager != null) {
                wifiManager.setCountryCode(countryIso);
            } else {
                msg = "Wifi manager is not available.";
                log(msg);
                mLocalLog.log(msg);
            }


            Intent intent = new Intent(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED);
            intent.putExtra(TelephonyManager.EXTRA_NETWORK_COUNTRY, countryIso);
            SubscriptionManager.putPhoneIdAndSubIdExtra(intent, mPhone.getPhoneId());
+0 −10
Original line number Diff line number Diff line
@@ -25,9 +25,7 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiManager;
import android.os.AsyncResult;
import android.os.HandlerThread;
import android.os.Message;
@@ -61,7 +59,6 @@ public class LocaleTrackerTest extends TelephonyTest {
    private LocaleTracker mLocaleTracker;

    private CellInfoGsm mCellInfo;
    private WifiManager mWifiManager;

    private class LocaleTrackerTestHandler extends HandlerThread {

@@ -90,7 +87,6 @@ public class LocaleTrackerTest extends TelephonyTest {

        // This is a workaround to bypass setting system properties, which causes access violation.
        doReturn(-1).when(mPhone).getPhoneId();
        mWifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);

        mCellInfo = new CellInfoGsm();
        mCellInfo.setCellIdentity(new CellIdentityGsm(
@@ -132,17 +128,11 @@ public class LocaleTrackerTest extends TelephonyTest {
    }

    private void verifyCountryCodeNotified(String[] countryCodes) {
        ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class);
        verify(mWifiManager, times(countryCodes.length)).setCountryCode(
                stringArgumentCaptor.capture());
        List<String> strs = stringArgumentCaptor.getAllValues();

        ArgumentCaptor<Intent> intentArgumentCaptor = ArgumentCaptor.forClass(Intent.class);
        verify(mContext, times(countryCodes.length)).sendBroadcast(intentArgumentCaptor.capture());
        List<Intent> intents = intentArgumentCaptor.getAllValues();

        for (int i = 0; i < countryCodes.length; i++) {
            assertEquals(countryCodes[i], strs.get(i));
            assertEquals(TelephonyManager.ACTION_NETWORK_COUNTRY_CHANGED,
                    intents.get(i).getAction());
            assertEquals(countryCodes[i], intents.get(i).getStringExtra(