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

Commit d67a1c3d authored by Hall Liu's avatar Hall Liu
Browse files

Replace TelephonyManager methods for mobile data

TelephonyManager had a minor refactor of some of the methods revolving
around mobile data. Change code in Settings to use the new ones instead.

Bug: 169367013
Test: existing unit tests, manual
Change-Id: I7ebae37373d53fb2c59b6b546232dbddf77398d4
parent 1044467d
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -90,12 +90,15 @@ public class DataDuringCallsPreferenceController extends TelephonyTogglePreferen

    @Override
    public boolean isChecked() {
        return mManager.isDataAllowedInVoiceCall();
        return mManager.isMobileDataPolicyEnabled(
                TelephonyManager.MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL);
    }

    @Override
    public boolean setChecked(boolean isChecked) {
        mManager.setDataAllowedDuringVoiceCall(isChecked);
        mManager.setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_DATA_ON_NON_DEFAULT_DURING_VOICE_CALL,
                isChecked);
        return true;
    }

+4 −1
Original line number Diff line number Diff line
@@ -88,7 +88,10 @@ public class MmsMessagePreferenceController extends TelephonyTogglePreferenceCon

    @Override
    public boolean setChecked(boolean isChecked) {
        return mTelephonyManager.setAlwaysAllowMmsData(isChecked);
        mTelephonyManager.setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, isChecked);
        return isChecked == mTelephonyManager.isMobileDataPolicyEnabled(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED);
    }

    @Override
+4 −2
Original line number Diff line number Diff line
@@ -115,9 +115,11 @@ public class MmsMessagePreferenceControllerTest {
    @Test
    public void setChecked_setDataIntoSubscriptionManager() {
        mController.setChecked(true);
        verify(mTelephonyManager).setAlwaysAllowMmsData(true);
        verify(mTelephonyManager).setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, true);

        mController.setChecked(false);
        verify(mTelephonyManager).setAlwaysAllowMmsData(false);
        verify(mTelephonyManager).setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, false);
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -111,9 +111,11 @@ public class MmsMessagePreferenceControllerTest {
    @Test
    public void setChecked_setDataIntoSubscriptionManager() {
        mController.setChecked(true);
        verify(mTelephonyManager).setAlwaysAllowMmsData(true);
        verify(mTelephonyManager).setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, true);

        mController.setChecked(false);
        verify(mTelephonyManager).setAlwaysAllowMmsData(false);
        verify(mTelephonyManager).setMobileDataPolicyEnabledStatus(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, false);
    }
}