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
This commit is contained in:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user