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

Commit 78e52aa7 authored by Jack Yu's avatar Jack Yu Committed by Amit Mahajan
Browse files

Disable DUN APN while roaming for certain carriers

Some carriers would like to use default APN for
tethering while the device is roaming. Added a new
carrier config to disable DUN APN while the device
is roaming.

Fix: 158546796
Test: DcTrackerTest
Merged-in: I38afd17475bbdb1dff80fbd82e70cf468dece652
Change-Id: I38afd17475bbdb1dff80fbd82e70cf468dece652
(cherry picked from commit a28bf2a4)
parent ac4baf8c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -1816,6 +1816,19 @@ public class DcTracker extends Handler {
        ArrayList<ApnSetting> dunCandidates = new ArrayList<ApnSetting>();
        ArrayList<ApnSetting> retDunSettings = new ArrayList<ApnSetting>();

        if (mPhone.getServiceState().getRoaming()) {
            CarrierConfigManager configManager = (CarrierConfigManager) mPhone.getContext()
                    .getSystemService(Context.CARRIER_CONFIG_SERVICE);
            if (configManager != null) {
                PersistableBundle b = configManager.getConfigForSubId(mPhone.getSubId());
                if (b != null) {
                    if (b.getBoolean(CarrierConfigManager.KEY_DISABLE_DUN_APN_WHILE_ROAMING)) {
                        return new ArrayList<>();
                    }
                }
            }
        }

        // Places to look for tether APN in order: TETHER_DUN_APN setting (to be deprecated soon),
        // APN database
        String apnData = Settings.Global.getString(mResolver, Settings.Global.TETHER_DUN_APN);
+20 −0
Original line number Diff line number Diff line
@@ -1380,6 +1380,26 @@ public class DcTrackerTest extends TelephonyTest {
        assertTrue(dunApnExpected.equals(dunApns.get(0)));
    }

    @Test
    @SmallTest
    public void testFetchDunApnWhileRoaming() {
        doReturn(true).when(mServiceState).getRoaming();
        mBundle.putBoolean(CarrierConfigManager.KEY_DISABLE_DUN_APN_WHILE_ROAMING, true);

        sendInitializationEvents();

        String dunApnString = "[ApnSettingV3]HOT mobile PC,pc.hotm,,,,,,,,,440,10,,DUN,,,true,"
                + "0,,,,,,,,";

        Settings.Global.putString(mContext.getContentResolver(),
                Settings.Global.TETHER_DUN_APN, dunApnString);
        // Expect empty DUN APN list
        assertEquals(0, mDct.fetchDunApns().size());

        Settings.Global.putString(mContext.getContentResolver(),
                Settings.Global.TETHER_DUN_APN, null);
    }

    // Test oos
    @Test
    @SmallTest