Fix Sim Setting OOB error.
+ Cleanup: deleted dead code. Bug: 18380862 Change-Id: Ie5dc44c6c0fe50cd9243a19050b6d79732d2d014
This commit is contained in:
@@ -115,8 +115,6 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
|
|
||||||
private PreferenceCategory mSimCards = null;
|
private PreferenceCategory mSimCards = null;
|
||||||
|
|
||||||
private int mNumSims;
|
|
||||||
|
|
||||||
public SimSettings() {
|
public SimSettings() {
|
||||||
super(DISALLOW_CONFIG_SIM);
|
super(DISALLOW_CONFIG_SIM);
|
||||||
}
|
}
|
||||||
@@ -144,13 +142,11 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
final int numSlots = tm.getSimCount();
|
final int numSlots = tm.getSimCount();
|
||||||
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
|
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
|
||||||
mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
|
mSelectableSubInfos = new ArrayList<SubscriptionInfo>();
|
||||||
mNumSims = 0;
|
|
||||||
for (int i = 0; i < numSlots; ++i) {
|
for (int i = 0; i < numSlots; ++i) {
|
||||||
final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
|
final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
|
||||||
mSimCards.addPreference(new SimPreference(getActivity(), sir, i));
|
mSimCards.addPreference(new SimPreference(getActivity(), sir, i));
|
||||||
mAvailableSubInfos.add(sir);
|
mAvailableSubInfos.add(sir);
|
||||||
if (sir != null) {
|
if (sir != null) {
|
||||||
mNumSims++;
|
|
||||||
mSelectableSubInfos.add(sir);
|
mSelectableSubInfos.add(sir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,13 +159,11 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
(TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
(TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
|
||||||
final int numSlots = tm.getSimCount();
|
final int numSlots = tm.getSimCount();
|
||||||
|
|
||||||
mNumSims = 0;
|
|
||||||
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
|
mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots);
|
||||||
for (int i = 0; i < numSlots; ++i) {
|
for (int i = 0; i < numSlots; ++i) {
|
||||||
final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
|
final SubscriptionInfo sir = Utils.findRecordBySlotId(i);
|
||||||
mAvailableSubInfos.add(sir);
|
mAvailableSubInfos.add(sir);
|
||||||
if (sir != null) {
|
if (sir != null) {
|
||||||
mNumSims++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,7 +202,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
} else if (sir == null) {
|
} else if (sir == null) {
|
||||||
simPref.setSummary(R.string.sim_selection_required_pref);
|
simPref.setSummary(R.string.sim_selection_required_pref);
|
||||||
}
|
}
|
||||||
simPref.setEnabled(mNumSims >= 1);
|
simPref.setEnabled(mSelectableSubInfos.size() >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCellularDataValues() {
|
private void updateCellularDataValues() {
|
||||||
@@ -222,7 +216,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
} else if (sir == null) {
|
} else if (sir == null) {
|
||||||
simPref.setSummary(R.string.sim_selection_required_pref);
|
simPref.setSummary(R.string.sim_selection_required_pref);
|
||||||
}
|
}
|
||||||
simPref.setEnabled(mNumSims >= 1);
|
simPref.setEnabled(mSelectableSubInfos.size() >= 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateCallValues() {
|
private void updateCallValues() {
|
||||||
@@ -315,8 +309,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] arr = new String[selectableSubInfoLength];
|
String[] arr = list.toArray(new String[0]);
|
||||||
arr = list.toArray(arr);
|
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
|
||||||
|
|
||||||
@@ -372,18 +365,14 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
holder = (ViewHolder) rowView.getTag();
|
holder = (ViewHolder) rowView.getTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDialogId == CALLS_PICK && position == 0) {
|
if (mDialogId == CALLS_PICK) {
|
||||||
holder.title.setText(getItem(position));
|
holder.title.setText(getItem(position));
|
||||||
holder.summary.setText("");
|
holder.summary.setText("");
|
||||||
holder.icon.setImageDrawable(getResources()
|
holder.icon.setImageDrawable(getResources()
|
||||||
.getDrawable(R.drawable.ic_live_help));
|
.getDrawable(R.drawable.ic_live_help));
|
||||||
holder.icon.setAlpha(OPACITY);
|
holder.icon.setAlpha(OPACITY);
|
||||||
} else {
|
} else {
|
||||||
if (mDialogId == CALLS_PICK && position != 0) {
|
sir = mSelectableSubInfos.get(position);
|
||||||
sir = mSelectableSubInfos.get(position - 1);
|
|
||||||
} else {
|
|
||||||
sir = mSelectableSubInfos.get(position);
|
|
||||||
}
|
|
||||||
holder.title.setText(sir.getDisplayName());
|
holder.title.setText(sir.getDisplayName());
|
||||||
holder.summary.setText(sir.getNumber());
|
holder.summary.setText(sir.getNumber());
|
||||||
holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
|
holder.icon.setImageBitmap(sir.createIconBitmap(mContext));
|
||||||
@@ -398,20 +387,6 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setActivity(Preference preference, SubscriptionInfo sir) {
|
|
||||||
final String key = preference.getKey();
|
|
||||||
|
|
||||||
if (key.equals(KEY_CELLULAR_DATA)) {
|
|
||||||
mCellularData = sir;
|
|
||||||
} else if (key.equals(KEY_CALLS)) {
|
|
||||||
mCalls = sir;
|
|
||||||
} else if (key.equals(KEY_SMS)) {
|
|
||||||
mSMS = sir;
|
|
||||||
}
|
|
||||||
|
|
||||||
updateActivitesCategory();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SimPreference extends Preference{
|
private class SimPreference extends Preference{
|
||||||
private SubscriptionInfo mSubInfoRecord;
|
private SubscriptionInfo mSubInfoRecord;
|
||||||
private int mSlotId;
|
private int mSlotId;
|
||||||
|
Reference in New Issue
Block a user