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

Commit b1dd4299 authored by Michael W's avatar Michael W
Browse files

SetupWizard: Fix a few possible NPEs

* Accessing SparseArrays with zero-based indexes can fail due to non-used
  indexes
* mCheckBoxes and mRows should always be accessed with the key they were
  added
-> use keyAt(index) when iterating the SparseArray
-> use the simSlotIndex when iterating the subInfoRecords

BUGBASH-318
BUGBASH-610 (partially)

Change-Id: Ib831c3623dafa5bd7d0c95acfa69f4a686644be6
parent fe4f0107
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -327,12 +327,12 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {
    private void setDataSubChecked(SubscriptionInfo subInfoRecord) {
        if (mIsAttached) {
            for (int i = 0; i < mCheckBoxes.size(); i++) {
                if (subInfoRecord.getSimSlotIndex() == i) {
                    mCheckBoxes.get(i).setChecked(true);
                int key = mCheckBoxes.keyAt(i);
                if (subInfoRecord.getSimSlotIndex() == key) {
                    mCheckBoxes.get(key).setChecked(true);
                } else {
                    mCheckBoxes.get(i).setChecked(false);
                    mCheckBoxes.get(key).setChecked(false);
                }

            }
        }
    }
@@ -341,7 +341,8 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {
        if (mIsAttached) {
            for (int i = 0; i < mSubInfoRecords.size(); i++) {
                SubscriptionInfo subInfoRecord = mSubInfoRecords.valueAt(i);
                mCheckBoxes.get(i).setChecked(SubscriptionManager.getDefaultDataSubscriptionId()
                int slot = subInfoRecord.getSimSlotIndex();
                mCheckBoxes.get(slot).setChecked(SubscriptionManager.getDefaultDataSubscriptionId()
                        == subInfoRecord.getSubscriptionId());
                if (LOGV) {
                    Log.v(TAG, "updateCurrentDataSub{" +
@@ -363,7 +364,7 @@ public class ChooseDataSimActivity extends BaseSetupWizardActivity {

    private void enableRows(boolean enabled) {
        for (int i = 0; i < mRows.size(); i++) {
            final View v =  mRows.get(i);
            final View v =  mRows.get(mRows.keyAt(i));
            v.setEnabled(enabled);
            final SubscriptionInfo subInfoRecord = (SubscriptionInfo)v.getTag();
            if (subInfoRecord != null) {