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

Commit e21d27c5 authored by tom hsu's avatar tom hsu Committed by Automerger Merge Worker
Browse files

[Settings] Fix MMS message UI is no consistency between UI and real state. am: 5216eeaa

parents ec895b08 5216eeaa
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(