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

Commit 3d755752 authored by Sandeep Gutta's avatar Sandeep Gutta Committed by Linux Build Service Account
Browse files

Telephony(MSIM): Select preferred primary sub.

Add UI to select preferred primary sub.
It is used when two SIM cards inserted have same
priority as per policy.

Change-Id: I5726fe9f4df03e680dc2406854d08da77297444d
parent d6fb73a8
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -2869,4 +2869,6 @@
    <string name="write_settings_description" msgid="6868293938839954623">"此权限允许应用修改系统设置。"</string>
    <string name="write_settings_on" msgid="8230580416068832239">"允许"</string>
    <string name="write_settings_off" msgid="5156104383386336233">"不允许"</string>

    <string name="primary_sub_select_title">默认4G/3G SIM卡</string>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -6980,4 +6980,6 @@
    <string name="sub_activate_failed">Activation failed.</string>
    <string name="sub_deactivate_success">Successfully Deactivated.</string>
    <string name="sub_deactivate_failed">Deactivation failed.</string>
    <string name="primary_sub_select_title">Default 4G/3G Subscription</string>
</resources>
+7 −0
Original line number Diff line number Diff line
@@ -25,6 +25,13 @@
            android:key="sim_activities"
            android:title="@string/sim_pref_divider" >

        <Preference
            android:key="select_primary_sub"
            android:persistent="false"
            android:title="@string/primary_sub_select_title" >
            <intent android:action="codeaurora.intent.action.ACTION_LTE_CONFIGURE" />
        </Preference>

        <Preference android:key="sim_cellular_data"
            android:title="@string/cellular_data_title" />

+61 −5
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.Handler;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.preference.Preference;
import android.preference.PreferenceScreen;
import android.preference.PreferenceCategory;
@@ -58,7 +59,6 @@ import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.R;
import android.os.SystemProperties;
import com.android.internal.telephony.IExtTelephony;
import com.android.internal.telephony.TelephonyProperties;

@@ -82,6 +82,8 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    private static final String KEY_CALLS = "sim_calls";
    private static final String KEY_SMS = "sim_sms";
    public static final String EXTRA_SLOT_ID = "slot_id";
    private static final String SIM_ACTIVITIES_CATEGORY = "sim_activities";
    private static final String KEY_PRIMARY_SUB_SELECT = "select_primary_sub";

    /**
     * By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
@@ -102,10 +104,17 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    private boolean needUpdate = false;
    private int mPhoneCount = TelephonyManager.getDefault().getPhoneCount();
    private int[] mUiccProvisionStatus = new int[mPhoneCount];
    private Preference mPrimarySubSelect = null;

    static final String ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED =
    private static final String ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED =
            "org.codeaurora.intent.action.ACTION_UICC_MANUAL_PROVISION_STATUS_CHANGED";
    static final String EXTRA_NEW_PROVISION_STATE = "newProvisionState";
    private static final String EXTRA_NEW_PROVISION_STATE = "newProvisionState";
    private static final String CONFIG_LTE_SUB_SELECT_MODE = "config_lte_sub_select_mode";
    private static final String CONFIG_PRIMARY_SUB_SETABLE = "config_primary_sub_setable";
    private static final String CONFIG_CURRENT_PRIMARY_SUB = "config_current_primary_sub";
    // If this config set to '1' DDS option would be greyed out on UI.
    // For more info pls refere framework code.
    private static final String CONFIG_DISABLE_DDS_PREFERENCE = "config_disable_dds_preference";

    public SimSettings() {
        super(DISALLOW_CONFIG_SIM);
@@ -126,6 +135,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
                (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
        addPreferencesFromResource(R.xml.sim_settings);

        mPrimarySubSelect = (Preference) findPreference(KEY_PRIMARY_SUB_SELECT);
        mNumSlots = tm.getSimCount();
        mSimCards = (PreferenceCategory)findPreference(SIM_CARD_CATEGORY);
        mAvailableSubInfos = new ArrayList<SubscriptionInfo>(mNumSlots);
@@ -223,7 +233,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        } else if (sir == null) {
            simPref.setSummary(R.string.sim_selection_required_pref);
        }
        simPref.setEnabled(mSelectableSubInfos.size() > 1);
        simPref.setEnabled(mSelectableSubInfos.size() > 1 && !disableDds());
    }

    private void updateCallValues() {
@@ -248,6 +258,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        final TelephonyManager tm =
                (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
        tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
        initLTEPreference();
        updateSubscriptions();
    }

@@ -280,7 +291,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
                final boolean ecbMode = SystemProperties.getBoolean(
                        TelephonyProperties.PROPERTY_INECM_MODE, false);
                pref.setEnabled((state == TelephonyManager.CALL_STATE_IDLE) && !ecbMode
                        && (mSelectableSubInfos.size() > 1));
                        && (mSelectableSubInfos.size() > 1) && !disableDds());
            }
        }
    };
@@ -305,6 +316,8 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        } else if (findPreference(KEY_SMS) == preference) {
            intent.putExtra(SimDialogActivity.DIALOG_TYPE_KEY, SimDialogActivity.SMS_PICK);
            context.startActivity(intent);
        } else if (preference == mPrimarySubSelect) {
            startActivity(mPrimarySubSelect.getIntent());
        }

        return true;
@@ -887,4 +900,47 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            }
        }
    };

    // When primarycard feature enabled this provides menu option for user
    // to view/select current primary slot.
    private void initLTEPreference() {
        boolean isPrimarySubFeatureEnable =
                SystemProperties.getBoolean("persist.radio.primarycard", false);
        boolean primarySetable = Settings.Global.getInt(mContext.getContentResolver(),
                 CONFIG_PRIMARY_SUB_SETABLE, 0) == 1;

        log("isPrimarySubFeatureEnable :" + isPrimarySubFeatureEnable +
                " primarySetable :" + primarySetable);

        if (!isPrimarySubFeatureEnable || !primarySetable) {
            final PreferenceCategory simActivities =
                    (PreferenceCategory) findPreference(SIM_ACTIVITIES_CATEGORY);
            simActivities.removePreference(mPrimarySubSelect);
            return;
        }
        int currentPrimarySlot = Settings.Global.getInt(mContext.getContentResolver(),
                 CONFIG_CURRENT_PRIMARY_SUB, SubscriptionManager.INVALID_SIM_SLOT_INDEX);
        boolean isManualMode = Settings.Global.getInt(mContext.getContentResolver(),
                 CONFIG_LTE_SUB_SELECT_MODE, 1) == 0;

        log("init LTE primary slot : " + currentPrimarySlot + " isManualMode :" + isManualMode);

        if (SubscriptionManager.isValidSlotId(currentPrimarySlot)) {
            final SubscriptionInfo subInfo = mSubscriptionManager
                    .getActiveSubscriptionInfoForSimSlotIndex(currentPrimarySlot);
            CharSequence lteSummary = (subInfo == null ) ? null : subInfo.getDisplayName();
            mPrimarySubSelect.setSummary(lteSummary);
        } else {
            mPrimarySubSelect.setSummary("");
        }
        mPrimarySubSelect.setEnabled(isManualMode);
    }

    private boolean disableDds() {
        boolean disableDds = Settings.Global.getInt(mContext.getContentResolver(),
                CONFIG_DISABLE_DDS_PREFERENCE, 0) == 1;

        log(" config disable dds =  " + disableDds);
        return disableDds;
    }
}