Setupwizard: Fix msim NPE where sim only in slot 2

Change-Id: I919129185cb49c51f9f02d9718e116e7d02b0d2c
This commit is contained in:
cretin45 2015-04-27 13:20:13 -07:00
parent 676081a4ad
commit ac84dc0fce
2 changed files with 7 additions and 7 deletions

View File

@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
import com.android.internal.telephony.TelephonyIntents; import com.android.internal.telephony.TelephonyIntents;
@ -127,7 +128,7 @@ public class CMSetupWizardData extends AbstractSetupData {
ChooseDataSimPage chooseDataSimPage = ChooseDataSimPage chooseDataSimPage =
(ChooseDataSimPage) getPage(ChooseDataSimPage.TAG); (ChooseDataSimPage) getPage(ChooseDataSimPage.TAG);
if (chooseDataSimPage != null) { if (chooseDataSimPage != null) {
chooseDataSimPage.setHidden(!isSimInserted()); chooseDataSimPage.setHidden(!allSimsInserted());
} }
} }
@ -185,7 +186,7 @@ public class CMSetupWizardData extends AbstractSetupData {
return false; return false;
} }
} }
return true; return simSlotCount == SubscriptionManager.from(mContext).getActiveSubscriptionInfoCount();
} }
} }

View File

@ -124,9 +124,8 @@ public class ChooseDataSimPage extends SetupPage {
List<SubscriptionInfo> subInfoRecords = mSubscriptionManager.getActiveSubscriptionInfoList(); List<SubscriptionInfo> subInfoRecords = mSubscriptionManager.getActiveSubscriptionInfoList();
int simCount = subInfoRecords.size(); int simCount = subInfoRecords.size();
mSubInfoRecords = new SparseArray<SubscriptionInfo>(simCount); mSubInfoRecords = new SparseArray<SubscriptionInfo>(simCount);
for (int i = 0; i < simCount; i++) { for (SubscriptionInfo subInfoRecord : subInfoRecords) {
SubscriptionInfo subInfoRecord = subInfoRecords.get(i); mSubInfoRecords.put(subInfoRecord.getSimSlotIndex(), subInfoRecord);
mSubInfoRecords.put(subInfoRecord.getSubscriptionId(), subInfoRecord);
} }
mNameViews = new SparseArray<TextView>(simCount); mNameViews = new SparseArray<TextView>(simCount);
mSignalViews = new SparseArray<ImageView>(simCount); mSignalViews = new SparseArray<ImageView>(simCount);
@ -170,7 +169,7 @@ public class ChooseDataSimPage extends SetupPage {
mIsAttached = true; mIsAttached = true;
mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE); mPhone = (TelephonyManager)getActivity().getSystemService(Context.TELEPHONY_SERVICE);
for (int i = 0; i < mPhoneStateListeners.size(); i++) { for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i), mPhone.listen(mPhoneStateListeners.valueAt(i),
PhoneStateListener.LISTEN_SERVICE_STATE PhoneStateListener.LISTEN_SERVICE_STATE
| PhoneStateListener.LISTEN_SIGNAL_STRENGTHS); | PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
} }
@ -189,7 +188,7 @@ public class ChooseDataSimPage extends SetupPage {
super.onPause(); super.onPause();
mIsAttached = false; mIsAttached = false;
for (int i = 0; i < mPhoneStateListeners.size(); i++) { for (int i = 0; i < mPhoneStateListeners.size(); i++) {
mPhone.listen(mPhoneStateListeners.get(i), PhoneStateListener.LISTEN_NONE); mPhone.listen(mPhoneStateListeners.valueAt(i), PhoneStateListener.LISTEN_NONE);
} }
} }