diff options
author | Stuart Scott <stuartscott@google.com> | 2015-04-20 17:56:48 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-20 17:56:49 +0000 |
commit | 0ce64e26c03e5d826bbb4bc041b8ca59b6c19b8b (patch) | |
tree | 39f8e0320143b06d75158b81fefaf82276d2b138 /src/com/android/settings | |
parent | e5112fe7665eca3dc47b5bb8bd2f22de77a44c44 (diff) | |
parent | f51d00635028c0b87dd431c33c932ad20202d032 (diff) | |
download | packages_apps_Settings-0ce64e26c03e5d826bbb4bc041b8ca59b6c19b8b.zip packages_apps_Settings-0ce64e26c03e5d826bbb4bc041b8ca59b6c19b8b.tar.gz packages_apps_Settings-0ce64e26c03e5d826bbb4bc041b8ca59b6c19b8b.tar.bz2 |
Merge "Correct the way settings deals with subscriptions."
Diffstat (limited to 'src/com/android/settings')
-rw-r--r-- | src/com/android/settings/ApnSettings.java | 2 | ||||
-rw-r--r-- | src/com/android/settings/DataUsageSummary.java | 32 | ||||
-rw-r--r-- | src/com/android/settings/IccLockSettings.java | 8 | ||||
-rw-r--r-- | src/com/android/settings/Utils.java | 43 | ||||
-rw-r--r-- | src/com/android/settings/deviceinfo/ImeiInformation.java | 6 | ||||
-rw-r--r-- | src/com/android/settings/deviceinfo/SimStatus.java | 17 | ||||
-rw-r--r-- | src/com/android/settings/sim/SimDialogActivity.java | 6 | ||||
-rw-r--r-- | src/com/android/settings/sim/SimSettings.java | 25 |
8 files changed, 31 insertions, 108 deletions
diff --git a/src/com/android/settings/ApnSettings.java b/src/com/android/settings/ApnSettings.java index 68cfb60..1b32b86 100644 --- a/src/com/android/settings/ApnSettings.java +++ b/src/com/android/settings/ApnSettings.java @@ -146,7 +146,7 @@ public class ApnSettings extends SettingsPreferenceFragment implements setHasOptionsMenu(true); } - mSubscriptionInfo = Utils.findRecordBySubId(activity, subId); + mSubscriptionInfo = SubscriptionManager.from(activity).getActiveSubscriptionInfo(subId); } @Override diff --git a/src/com/android/settings/DataUsageSummary.java b/src/com/android/settings/DataUsageSummary.java index 6e72ef7..27a486c 100644 --- a/src/com/android/settings/DataUsageSummary.java +++ b/src/com/android/settings/DataUsageSummary.java @@ -717,9 +717,9 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable int simCount = mTelephonyManager.getSimCount(); - for (int i = 0; i < simCount; i++) { - final SubscriptionInfo sir = Utils.findRecordBySlotId(context, i); - if (sir != null) { + List<SubscriptionInfo> sirs = mSubscriptionManager.getActiveSubscriptionInfoList(); + if (sirs != null) { + for (SubscriptionInfo sir : sirs) { addMobileTab(context, sir, (simCount > 1)); } } @@ -880,8 +880,8 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable if (mCurrentTab != null && mCurrentTab.length() > TAB_MOBILE.length() ){ final int slotId = Integer.parseInt(mCurrentTab.substring(TAB_MOBILE.length(), mCurrentTab.length())); - final SubscriptionInfo sir = com.android.settings.Utils.findRecordBySlotId(context, - slotId); + final SubscriptionInfo sir = mSubscriptionManager + .getActiveSubscriptionInfoForSimSlotIndex(slotId); if (sir != null) { seriesColor = sir.getIconTint(); @@ -1245,8 +1245,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable return; } - final SubscriptionInfo nextSir = mSubscriptionManager.getActiveSubscriptionInfo( - mSubscriptionManager.getDefaultDataSubId()); + final SubscriptionInfo nextSir = mSubscriptionManager.getDefaultDataSubscriptionInfo(); // If the device is single SIM or is enabling data on the active data SIM then forgo // the pop-up. @@ -2784,22 +2783,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable return -1; } - //SUB SELECT - private boolean isMobileDataAvailable(long subId) { - int[] subIds = SubscriptionManager.getSubId(PhoneConstants.SUB1); - 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; + private boolean isMobileDataAvailable(int subId) { + return mSubscriptionManager.getActiveSubscriptionInfo(subId) != null; } } diff --git a/src/com/android/settings/IccLockSettings.java b/src/com/android/settings/IccLockSettings.java index 0e47afb..168d3c8 100644 --- a/src/com/android/settings/IccLockSettings.java +++ b/src/com/android/settings/IccLockSettings.java @@ -212,14 +212,15 @@ public class IccLockSettings extends InstrumentedPreferenceActivity mTabHost.setOnTabChangedListener(mTabListener); mTabHost.clearAllTabs(); + SubscriptionManager sm = SubscriptionManager.from(this); for (int i = 0; i < numSims; ++i) { - final SubscriptionInfo subInfo = Utils.findRecordBySlotId(this, i); + final SubscriptionInfo subInfo = sm.getActiveSubscriptionInfoForSimSlotIndex(i); mTabHost.addTab(buildTabSpec(String.valueOf(i), String.valueOf(subInfo == null ? context.getString(R.string.sim_editor_title, i + 1) : subInfo.getDisplayName()))); } - final SubscriptionInfo sir = Utils.findRecordBySlotId(getBaseContext(), 0); + final SubscriptionInfo sir = sm.getActiveSubscriptionInfoForSimSlotIndex(0); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); @@ -476,7 +477,8 @@ public class IccLockSettings extends InstrumentedPreferenceActivity @Override public void onTabChanged(String tabId) { final int slotId = Integer.parseInt(tabId); - final SubscriptionInfo sir = Utils.findRecordBySlotId(getBaseContext(), slotId); + final SubscriptionInfo sir = SubscriptionManager.from(getBaseContext()) + .getActiveSubscriptionInfoForSimSlotIndex(slotId); mPhone = (sir == null) ? null : PhoneFactory.getPhone(SubscriptionManager.getPhoneId(sir.getSubscriptionId())); diff --git a/src/com/android/settings/Utils.java b/src/com/android/settings/Utils.java index dc4b484..d05160c 100644 --- a/src/com/android/settings/Utils.java +++ b/src/com/android/settings/Utils.java @@ -1029,49 +1029,6 @@ public final class Utils { } /** - * finds a record with subId. - * Since the number of SIMs are few, an array is fine. - */ - public static SubscriptionInfo findRecordBySubId(Context context, final int subId) { - final List<SubscriptionInfo> subInfoList = - SubscriptionManager.from(context).getActiveSubscriptionInfoList(); - if (subInfoList != null) { - final int subInfoLength = subInfoList.size(); - - for (int i = 0; i < subInfoLength; ++i) { - final SubscriptionInfo sir = subInfoList.get(i); - if (sir != null && sir.getSubscriptionId() == subId) { - return sir; - } - } - } - - return null; - } - - /** - * finds a record with slotId. - * Since the number of SIMs are few, an array is fine. - */ - public static SubscriptionInfo findRecordBySlotId(Context context, final int slotId) { - final List<SubscriptionInfo> subInfoList = - SubscriptionManager.from(context).getActiveSubscriptionInfoList(); - if (subInfoList != null) { - final int subInfoLength = subInfoList.size(); - - for (int i = 0; i < subInfoLength; ++i) { - final SubscriptionInfo sir = subInfoList.get(i); - if (sir.getSimSlotIndex() == slotId) { - //Right now we take the first subscription on a SIM. - return sir; - } - } - } - - return null; - } - - /** * Queries for the UserInfo of a user. Returns null if the user doesn't exist (was removed). * @param userManager Instance of UserManager * @param checkUser The user to check the existence of. diff --git a/src/com/android/settings/deviceinfo/ImeiInformation.java b/src/com/android/settings/deviceinfo/ImeiInformation.java index c4f4bbb..d82e6c9 100644 --- a/src/com/android/settings/deviceinfo/ImeiInformation.java +++ b/src/com/android/settings/deviceinfo/ImeiInformation.java @@ -89,10 +89,8 @@ public class ImeiInformation extends InstrumentedPreferenceActivity { removePreferenceFromScreen(KEY_ICC_ID); } } else { - setSummaryText(KEY_IMEI, phone.getDeviceId()); - setSummaryText(KEY_IMEI_SV, - ((TelephonyManager) getSystemService(TELEPHONY_SERVICE)) - .getDeviceSoftwareVersion(phoneId)); + setSummaryText(KEY_IMEI, phone.getImei()); + setSummaryText(KEY_IMEI_SV, phone.getDeviceSvn()); // device is not CDMA, do not display CDMA features // check Null in case no specified preference in overlay xml removePreferenceFromScreen(KEY_PRL_VERSION); diff --git a/src/com/android/settings/deviceinfo/SimStatus.java b/src/com/android/settings/deviceinfo/SimStatus.java index c52f385..4fa5673 100644 --- a/src/com/android/settings/deviceinfo/SimStatus.java +++ b/src/com/android/settings/deviceinfo/SimStatus.java @@ -132,9 +132,9 @@ public class SimStatus extends InstrumentedPreferenceActivity { @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); + mTelephonyManager = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); - mSelectableSubInfos = new ArrayList<SubscriptionInfo>(); - mTelephonyManager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); + mSelectableSubInfos = SubscriptionManager.from(this).getActiveSubscriptionInfoList(); addPreferencesFromResource(R.xml.device_info_sim_status); @@ -143,13 +143,6 @@ public class SimStatus extends InstrumentedPreferenceActivity { // Note - missing in zaku build, be careful later... mSignalStrength = findPreference(KEY_SIGNAL_STRENGTH); - for (int i = 0; i < mTelephonyManager.getSimCount(); i++) { - final SubscriptionInfo sir = Utils.findRecordBySlotId(this, i); - if (sir != null) { - mSelectableSubInfos.add(sir); - } - } - mSir = mSelectableSubInfos.size() > 0 ? mSelectableSubInfos.get(0) : null; if (mSelectableSubInfos.size() > 1) { setContentView(R.layout.sim_information); @@ -351,10 +344,8 @@ public class SimStatus extends InstrumentedPreferenceActivity { } // If formattedNumber is null or empty, it'll display as "Unknown". setSummaryText(KEY_PHONE_NUMBER, formattedNumber); - final String imei = mPhone.getPhoneType() == TelephonyManager.PHONE_TYPE_CDMA - ? mPhone.getImei() : mPhone.getDeviceId(); - setSummaryText(KEY_IMEI, imei); - setSummaryText(KEY_IMEI_SV, mTelephonyManager.getDeviceSoftwareVersion(/*slotId*/)); + setSummaryText(KEY_IMEI, mPhone.getImei()); + setSummaryText(KEY_IMEI_SV, mPhone.getDeviceSvn()); if (!mShowLatestAreaInfo) { removePreferenceFromScreen(KEY_LATEST_AREA_INFO); diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java index 97762c4..03a9daf 100644 --- a/src/com/android/settings/sim/SimDialogActivity.java +++ b/src/com/android/settings/sim/SimDialogActivity.java @@ -80,7 +80,8 @@ public class SimDialogActivity extends Activity { private void displayPreferredDialog(final int slotId) { final Resources res = getResources(); final Context context = getApplicationContext(); - final SubscriptionInfo sir = Utils.findRecordBySlotId(context, slotId); + final SubscriptionInfo sir = SubscriptionManager.from(context) + .getActiveSubscriptionInfoForSimSlotIndex(slotId); if (sir != null) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); @@ -214,7 +215,8 @@ public class SimDialogActivity extends Activity { list.add((String)phoneAccount.getLabel()); int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount); if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { - final SubscriptionInfo sir = Utils.findRecordBySubId(context, subId); + final SubscriptionInfo sir = SubscriptionManager.from(context) + .getActiveSubscriptionInfo(subId); callsSubInfoList.add(sir); } else { callsSubInfoList.add(null); diff --git a/src/com/android/settings/sim/SimSettings.java b/src/com/android/settings/sim/SimSettings.java index 91dadbb..184e882 100644 --- a/src/com/android/settings/sim/SimSettings.java +++ b/src/com/android/settings/sim/SimSettings.java @@ -151,7 +151,10 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots); mSelectableSubInfos = new ArrayList<SubscriptionInfo>(); for (int i = 0; i < numSlots; ++i) { - final SubscriptionInfo sir = Utils.findRecordBySlotId(getActivity(), i); + // Less efficient than getActiveSubscriptionInfoList but we need to show a disable + // preference if the slot is empty + final SubscriptionInfo sir = mSubscriptionManager + .getActiveSubscriptionInfoForSimSlotIndex(i); SimPreference simPreference = new SimPreference(getActivity(), sir, i); simPreference.setOrder(i-numSlots); mSimCards.addPreference(simPreference); @@ -165,17 +168,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable } private void updateAvailableSubInfos(){ - final TelephonyManager tm = - (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE); - final int numSlots = tm.getSimCount(); - - mAvailableSubInfos = new ArrayList<SubscriptionInfo>(numSlots); - for (int i = 0; i < numSlots; ++i) { - final SubscriptionInfo sir = Utils.findRecordBySlotId(getActivity(), i); - mAvailableSubInfos.add(sir); - if (sir != null) { - } - } + mAvailableSubInfos = mSubscriptionManager.getActiveSubscriptionInfoList(); } private void updateAllOptions() { @@ -203,8 +196,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable private void updateSmsValues() { final Preference simPref = findPreference(KEY_SMS); - final SubscriptionInfo sir = Utils.findRecordBySubId(getActivity(), - mSubscriptionManager.getDefaultSmsSubId()); + final SubscriptionInfo sir = mSubscriptionManager.getDefaultSmsSubscriptionInfo(); simPref.setTitle(R.string.sms_messages_title); if (DBG) log("[updateSmsValues] mSubInfoList=" + mSubInfoList); @@ -218,8 +210,7 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable private void updateCellularDataValues() { final Preference simPref = findPreference(KEY_CELLULAR_DATA); - final SubscriptionInfo sir = Utils.findRecordBySubId(getActivity(), - mSubscriptionManager.getDefaultDataSubId()); + final SubscriptionInfo sir = mSubscriptionManager.getDefaultDataSubscriptionInfo(); simPref.setTitle(R.string.cellular_data_title); if (DBG) log("[updateCellularDataValues] mSubInfoList=" + mSubInfoList); @@ -396,14 +387,12 @@ public class SimSettings extends RestrictedSettingsFragment implements Indexable mSubInfoRecord.setDisplayName(displayName); mSubscriptionManager.setDisplayName(displayName, subId, SubscriptionManager.NAME_SOURCE_USER_INPUT); - Utils.findRecordBySubId(getActivity(), subId).setDisplayName(displayName); final int tintSelected = tintSpinner.getSelectedItemPosition(); int subscriptionId = mSubInfoRecord.getSubscriptionId(); int tint = mTintArr[tintSelected]; mSubInfoRecord.setIconTint(tint); mSubscriptionManager.setIconTint(tint, subscriptionId); - Utils.findRecordBySubId(getActivity(), subscriptionId).setIconTint(tint); updateAllOptions(); update(); |