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

Commit 98523c8b authored by PauloftheWest's avatar PauloftheWest
Browse files

Added Cellular Data for Multi-Sim Data Usage

+ Bug Fix: SimSettings would crash if a SIM was not in the first slot.

Change-Id: Iee75ea78dde72dc7d2d588caff1ddd451347a8f5
parent 917aaf9e
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -941,7 +941,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
            mMobileDataEnabled = null;
        } else {
            //SUB SELECT
            isEnable = mTelephonyManager.getDataEnabled() && isMobileDataAvailable(subId);
            isEnable = mTelephonyManager.getDataEnabled()
                && (subId == SubscriptionManager.getDefaultDataSubId());
        }
        return isEnable;
    }
@@ -2594,8 +2595,21 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
        }

        //SUB SELECT
        private boolean isMobileDataAvailable(int subId) {
        private boolean isMobileDataAvailable(long subId) {
            int[] subIds = SubscriptionManager.getSubId(PhoneConstants.SUB1);
            return subIds[0] == subId;
            if (subIds != null && subIds[0] == subId) {
                return true;
            }

            subIds = SubscriptionManager.getSubId(PhoneConstants.SUB2);
            if (subIds != null && subIds[0] == subId) {
                return true;
            }

            subIds = SubscriptionManager.getSubId(PhoneConstants.SUB3);
            if (subIds != null && subIds[0] == subId) {
                return true;
            }
            return false;
        }
}
+11 −7
Original line number Diff line number Diff line
@@ -121,9 +121,11 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
     * By UX design we use only one Subscription Information(SubInfo) record per SIM slot.
     * mAvalableSubInfos is the list of SubInfos we present to the user.
     * mSubInfoList is the list of all SubInfos.
     * mSelectableSubInfos is the list of SubInfos that a user can select for data, calls, and SMS.
     */
    private List<SubInfoRecord> mAvailableSubInfos = null;
    private List<SubInfoRecord> mSubInfoList = null;
    private List<SubInfoRecord> mSelectableSubInfos = null;

    private SubInfoRecord mCellularData = null;
    private SubInfoRecord mCalls = null;
@@ -186,6 +188,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable

        final int numSlots = tm.getSimCount();
        mAvailableSubInfos = new ArrayList<SubInfoRecord>(numSlots);
        mSelectableSubInfos = new ArrayList<SubInfoRecord>();
        mNumSims = 0;
        for (int i = 0; i < numSlots; ++i) {
            final SubInfoRecord sir = findRecordBySlotId(i);
@@ -193,6 +196,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
            mAvailableSubInfos.add(sir);
            if (sir != null) {
                mNumSims++;
                mSelectableSubInfos.add(sir);
            }
        }

@@ -345,7 +349,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
    @Override
    public Dialog onCreateDialog(final int id) {
        final ArrayList<String> list = new ArrayList<String>();
        final int availableSubInfoLength = mAvailableSubInfos.size();
        final int selectableSubInfoLength = mSelectableSubInfos.size();

        final DialogInterface.OnClickListener selectionListener =
                new DialogInterface.OnClickListener() {
@@ -355,18 +359,18 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
                        final SubInfoRecord sir;

                        if (id == DATA_PICK) {
                            sir = mAvailableSubInfos.get(value);
                            sir = mSelectableSubInfos.get(value);
                            SubscriptionManager.setDefaultDataSubId(sir.subId);
                        } else if (id == CALLS_PICK) {
                            if (value != 0) {
                                sir = mAvailableSubInfos.get(value -1);
                                sir = mSelectableSubInfos.get(value -1);
                                SubscriptionManager.setDefaultVoiceSubId(sir.subId);
                            } else {
                                SubscriptionManager
                                    .setDefaultVoiceSubId(SubscriptionManager.ASK_USER_SUB_ID);
                            }
                        } else if (id == SMS_PICK) {
                            sir = mAvailableSubInfos.get(value);
                            sir = mSelectableSubInfos.get(value);
                            SubscriptionManager.setDefaultSmsSubId(sir.subId);
                        }

@@ -377,12 +381,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
        if (id == CALLS_PICK) {
            list.add(getResources().getString(R.string.sim_calls_ask_first_prefs_title));
        }
        for (int i = 0; i < availableSubInfoLength; ++i) {
            final SubInfoRecord sir = mAvailableSubInfos.get(i);
        for (int i = 0; i < selectableSubInfoLength; ++i) {
            final SubInfoRecord sir = mSelectableSubInfos.get(i);
            list.add(sir.displayName);
        }

        String[] arr = new String[availableSubInfoLength];
        String[] arr = new String[selectableSubInfoLength];
        arr = list.toArray(arr);

        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());