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

Commit 4a8f44db authored by Mengjun Leng's avatar Mengjun Leng Committed by Linux Build Service Account
Browse files

Settings: Support cellular data enabled on both SUBs

The property "persist.radio.carrier_mode" is used to control
some carriers have restricting DDS requirement.

If the property is enabled for class a, when user enables
cellular data, do not change DDS to its slot, and do not
disable cellular data on other slot.

Change-Id: I4e730b2d21011334ea0706b8fffa0f0e55e498ff
CRs-Fixed: 1032075
parent 31a58b31
Loading
Loading
Loading
Loading
+10 −4
Original line number Original line Diff line number Diff line
@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.Looper;
import android.os.Looper;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
import android.os.SystemProperties;
import android.provider.Settings.Global;
import android.provider.Settings.Global;
import android.support.v7.preference.PreferenceViewHolder;
import android.support.v7.preference.PreferenceViewHolder;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionInfo;
@@ -44,12 +45,15 @@ import java.util.List;
public class CellDataPreference extends CustomDialogPreference implements TemplatePreference {
public class CellDataPreference extends CustomDialogPreference implements TemplatePreference {


    private static final String TAG = "CellDataPreference";
    private static final String TAG = "CellDataPreference";
    private static final String CARRIER_MODE_CT_CLASS_A = "ct_class_a";


    public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    public int mSubId = SubscriptionManager.INVALID_SUBSCRIPTION_ID;
    public boolean mChecked;
    public boolean mChecked;
    public boolean mMultiSimDialog;
    public boolean mMultiSimDialog;
    private TelephonyManager mTelephonyManager;
    private TelephonyManager mTelephonyManager;
    private SubscriptionManager mSubscriptionManager;
    private SubscriptionManager mSubscriptionManager;
    private String mCarrierMode = SystemProperties.get("persist.radio.carrier_mode", "default");
    private boolean mIsCTClassA = mCarrierMode.equals(CARRIER_MODE_CT_CLASS_A);


    public CellDataPreference(Context context, AttributeSet attrs) {
    public CellDataPreference(Context context, AttributeSet attrs) {
        super(context, attrs, android.R.attr.switchPreferenceStyle);
        super(context, attrs, android.R.attr.switchPreferenceStyle);
@@ -122,7 +126,7 @@ public class CellDataPreference extends CustomDialogPreference implements Templa
                    (nextSir != null && currentSir != null &&
                    (nextSir != null && currentSir != null &&
                            currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
                            currentSir.getSubscriptionId() == nextSir.getSubscriptionId())) {
                setMobileDataEnabled(false);
                setMobileDataEnabled(false);
                if (nextSir != null && currentSir != null &&
                if (nextSir != null && currentSir != null && !mIsCTClassA &&
                        currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
                        currentSir.getSubscriptionId() == nextSir.getSubscriptionId()) {
                    disableDataForOtherSubscriptions(mSubId);
                    disableDataForOtherSubscriptions(mSubId);
                }
                }
@@ -167,7 +171,7 @@ public class CellDataPreference extends CustomDialogPreference implements Templa
    @Override
    @Override
    protected void onPrepareDialogBuilder(AlertDialog.Builder builder,
    protected void onPrepareDialogBuilder(AlertDialog.Builder builder,
            DialogInterface.OnClickListener listener) {
            DialogInterface.OnClickListener listener) {
        if (mMultiSimDialog) {
        if (mMultiSimDialog && !mIsCTClassA) {
            showMultiSimDialog(builder, listener);
            showMultiSimDialog(builder, listener);
        } else {
        } else {
            showDisableDialog(builder, listener);
            showDisableDialog(builder, listener);
@@ -217,9 +221,11 @@ public class CellDataPreference extends CustomDialogPreference implements Templa
            return;
            return;
        }
        }
        if (mMultiSimDialog) {
        if (mMultiSimDialog) {
            if (!mIsCTClassA) {
                mSubscriptionManager.setDefaultDataSubId(mSubId);
                mSubscriptionManager.setDefaultDataSubId(mSubId);
            setMobileDataEnabled(true);
                disableDataForOtherSubscriptions(mSubId);
                disableDataForOtherSubscriptions(mSubId);
            }
            setMobileDataEnabled(true);
        } else {
        } else {
            // TODO: extend to modify policy enabled flag.
            // TODO: extend to modify policy enabled flag.
            setMobileDataEnabled(false);
            setMobileDataEnabled(false);