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

Commit f3f7d6af authored by cretin45's avatar cretin45 Committed by Brint E. Kriebel
Browse files

Settings: Add config for not allowing calls/sms being set to > slot 1

This is a requirement of a vendor. The default is false.

Change-Id: If3e0755c4ba3d33e3ac2d331182bc740688b8a23
parent e12d24c2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -97,4 +97,6 @@
         preferred application install location settings-->
    <bool name="config_hide_app_install_location" translatable="false">true</bool>

    <!-- Some vendors don't want to allow non slot 0 to be set to default for calls/sms -->
    <bool name="config_hardcodeDefaultMobileNetworks">false</bool>
</resources>
+11 −1
Original line number Diff line number Diff line
@@ -96,6 +96,8 @@ public class MultiSimEnablerPreference extends SwitchPreference implements
    private static final int PROGRESS_DLG_TIME_OUT = 30000;
    private static final int MSG_DELAY_TIME = 2000;

    private boolean mExplicitlyDisabled = false;

    private SubscriptionManager mSubscriptionManager;

    private int[] mTintArr;
@@ -124,6 +126,9 @@ public class MultiSimEnablerPreference extends SwitchPreference implements

        boolean isSubValid = isCurrentSubValid();
        setEnabled(isSubValid);
        if (mSwitch != null) {
            mSwitch.setEnabled(!mExplicitlyDisabled);
        }

        logd("update() isSubValid "  + isSubValid);
        if (isSubValid) {
@@ -214,6 +219,11 @@ public class MultiSimEnablerPreference extends SwitchPreference implements
        builder.show();
    }

    public void setExplicitlyDisabled(boolean disabled) {
        super.setEnabled(!disabled);
        mExplicitlyDisabled = disabled;
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
@@ -226,7 +236,7 @@ public class MultiSimEnablerPreference extends SwitchPreference implements

    @Override
    public boolean onPreferenceChange(Preference pref, Object newValue) {
        if (mClicking) {
        if (mClicking || mExplicitlyDisabled) {
            return false;
        }

+15 −3
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    private PhoneStateListener[] mPhoneStateListener;
    private boolean mDataDisableToastDisplayed = false;
    private SubscriptionManager mSubscriptionManager;
    private boolean mHardcodeDefaultMobileNetworks = false;

    public SimSettings() {
        super(DISALLOW_CONFIG_SIM);
@@ -112,6 +113,9 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            mSubInfoList = mSubscriptionManager.getActiveSubscriptionInfoList();
        }

        mHardcodeDefaultMobileNetworks = getResources()
                .getBoolean(R.bool.config_hardcodeDefaultMobileNetworks);

        mNumSlots = tm.getSimCount();
        mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
        mCallState = new int[mPhoneCount];
@@ -197,9 +201,13 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        for (int i = 0; i < mNumSlots; ++i) {
            final SubscriptionInfo sir = findRecordBySlotId(i);
            if (mNumSlots > 1) {
                mSimEnablers.add(i, new MultiSimEnablerPreference(
                        getActivity(), sir, mHandler, i));
                simEnablers.addPreference(mSimEnablers.get(i));
                MultiSimEnablerPreference multiSimEnablerPreference =
                        new MultiSimEnablerPreference(getActivity(), sir, mHandler, i);
                mSimEnablers.add(multiSimEnablerPreference);
                simEnablers.addPreference(multiSimEnablerPreference);
                if (mHardcodeDefaultMobileNetworks && i == 0) {
                    multiSimEnablerPreference.setExplicitlyDisabled(true);
                }
            } else {
                removePreference(SIM_ENABLER_CATEGORY);
            }
@@ -478,6 +486,10 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        for (int i = 0; i < subAvailableSize; ++i) {
            final SubscriptionInfo sir = mAvailableSubInfos.get(i);
            if(sir != null){
                if (i > 0 && (keyPref.equals(KEY_CALLS) || keyPref.equals(KEY_SMS)) &&
                        mHardcodeDefaultMobileNetworks) {
                    continue;
                }
                simPref.addItem(sir.getDisplayName().toString(), sir);
            }
        }