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

Commit 5216eeaa authored by tom hsu's avatar tom hsu Committed by Tom Hsu
Browse files

[Settings] Fix MMS message UI is no consistency between UI and real state.

Bug: 285253872
Bug: 281566495
Test: Manual test passed.
Change-Id: I805490fd5c4417e88c38a047f99ef626c16f600a
parent 1d279af2
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -31,18 +31,16 @@ import com.android.settingslib.core.lifecycle.events.OnStart;
import com.android.settingslib.core.lifecycle.events.OnStop;

/**
 * Preference controller for "Mobile data"
 * Preference controller for "MMS messages"
 */
public class MmsMessagePreferenceController extends TelephonyTogglePreferenceController implements
        LifecycleObserver, OnStart, OnStop {
    private TelephonyManager mTelephonyManager;
    private SubscriptionManager mSubscriptionManager;
    private MobileDataContentObserver mMobileDataContentObserver;
    private PreferenceScreen mScreen;

    public MmsMessagePreferenceController(Context context, String key) {
        super(context, key);
        mSubscriptionManager = context.getSystemService(SubscriptionManager.class);
        mMobileDataContentObserver = new MobileDataContentObserver(
                new Handler(Looper.getMainLooper()));
        mMobileDataContentObserver.setOnMobileDataChangedListener(() -> refreshPreference());
@@ -88,12 +86,15 @@ public class MmsMessagePreferenceController extends TelephonyTogglePreferenceCon

    @Override
    public boolean setChecked(boolean isChecked) {
        if (mTelephonyManager == null) {
            return false;
        }
        mTelephonyManager.setMobileDataPolicyEnabled(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED, isChecked);
        return isChecked == mTelephonyManager.isMobileDataPolicyEnabled(
                TelephonyManager.MOBILE_DATA_POLICY_MMS_ALWAYS_ALLOWED);
        return true;
    }


    @Override
    public boolean isChecked() {
        return mTelephonyManager != null && mTelephonyManager.isDataEnabledForApn(