diff options
author | Amit Mahajan <amitmahajan@google.com> | 2015-01-15 16:03:32 -0800 |
---|---|---|
committer | Amit Mahajan <amitmahajan@google.com> | 2015-01-21 14:44:25 -0800 |
commit | d756a6bcf4fe09b561481eb6ed5368bd7b21ca76 (patch) | |
tree | e2c1821ca234a32d03e39ccc3325c4aa1aa01910 /src/java/com | |
parent | 45736edd9628b9c58068b8c85d54e19834415a8c (diff) | |
download | android_frameworks_opt_telephony-d756a6bcf4fe09b561481eb6ed5368bd7b21ca76.tar.gz android_frameworks_opt_telephony-d756a6bcf4fe09b561481eb6ed5368bd7b21ca76.tar.bz2 android_frameworks_opt_telephony-d756a6bcf4fe09b561481eb6ed5368bd7b21ca76.zip |
Change to append subId to network selection related sharedPreferences.
Bug: 19023266
Change-Id: Ia7b2ac5b37d5abb1231288caf923336bf0bec9e1
Diffstat (limited to 'src/java/com')
3 files changed, 49 insertions, 20 deletions
diff --git a/src/java/com/android/internal/telephony/PhoneBase.java b/src/java/com/android/internal/telephony/PhoneBase.java index 6f2db0717..ce69689ec 100644 --- a/src/java/com/android/internal/telephony/PhoneBase.java +++ b/src/java/com/android/internal/telephony/PhoneBase.java @@ -906,16 +906,22 @@ public abstract class PhoneBase extends Handler implements Phone { } private void updateSavedNetworkOperator(NetworkSelectMessage nsm) { - // open the shared preferences editor, and write the value. - // nsm.operatorNumeric is "" if we're in automatic.selection. - SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); - SharedPreferences.Editor editor = sp.edit(); - editor.putString(NETWORK_SELECTION_KEY, nsm.operatorNumeric); - editor.putString(NETWORK_SELECTION_NAME_KEY, nsm.operatorAlphaLong); - - // commit and log the result. - if (!editor.commit()) { - Rlog.e(LOG_TAG, "failed to commit network selection preference"); + int subId = getSubId(); + if (SubscriptionManager.isValidSubscriptionId(subId)) { + // open the shared preferences editor, and write the value. + // nsm.operatorNumeric is "" if we're in automatic.selection. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); + SharedPreferences.Editor editor = sp.edit(); + editor.putString(NETWORK_SELECTION_KEY + subId, nsm.operatorNumeric); + editor.putString(NETWORK_SELECTION_NAME_KEY + subId, nsm.operatorAlphaLong); + + // commit and log the result. + if (!editor.commit()) { + Rlog.e(LOG_TAG, "failed to commit network selection preference"); + } + } else { + Rlog.e(LOG_TAG, "Cannot update network selection preference due to invalid subId " + + subId); } } @@ -946,7 +952,7 @@ public abstract class PhoneBase extends Handler implements Phone { private String getSavedNetworkSelection() { // open the shared preferences and search with our key. SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getContext()); - return sp.getString(NETWORK_SELECTION_KEY, ""); + return sp.getString(NETWORK_SELECTION_KEY + getSubId(), ""); } /** diff --git a/src/java/com/android/internal/telephony/ServiceStateTracker.java b/src/java/com/android/internal/telephony/ServiceStateTracker.java index ea8f68207..5877eda3b 100644 --- a/src/java/com/android/internal/telephony/ServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/ServiceStateTracker.java @@ -21,6 +21,7 @@ import static com.android.internal.telephony.TelephonyProperties.PROPERTY_ICC_OP import android.app.PendingIntent; import android.content.Context; import android.content.IntentFilter; +import android.content.SharedPreferences; import android.os.AsyncResult; import android.os.Handler; import android.os.Message; @@ -28,6 +29,7 @@ import android.os.Registrant; import android.os.RegistrantList; import android.os.SystemClock; import android.os.SystemProperties; +import android.preference.PreferenceManager; import android.telephony.CellInfo; import android.telephony.Rlog; import android.telephony.ServiceState; @@ -251,12 +253,19 @@ public abstract class ServiceStateTracker extends Handler { if (previousSubId != subId) { previousSubId = subId; if (SubscriptionManager.isValidSubscriptionId(subId)) { - int networkType = PhoneFactory.calculatePreferredNetworkType( - mPhoneBase.getContext(), subId); + Context context = mPhoneBase.getContext(); + int networkType = PhoneFactory.calculatePreferredNetworkType(context, subId); mCi.setPreferredNetworkType(networkType, null); mPhoneBase.notifyCallForwardingIndicator(); + boolean skipRestoringSelection = context.getResources().getBoolean( + com.android.internal.R.bool.skip_restoring_network_selection); + if (!skipRestoringSelection) { + // restore the previous network selection. + mPhoneBase.restoreSavedNetworkSelection(null); + } + mPhoneBase.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE, ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology())); @@ -265,6 +274,27 @@ public abstract class ServiceStateTracker extends Handler { mCurPlmn, mCurShowSpn, mCurSpn); mSpnUpdatePending = false; } + + // Remove old network selection sharedPreferences since SP key names are now + // changed to include subId. This will be done only once when upgrading from an + // older build that did not include subId in the names. + SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences( + context); + String oldNetworkSelectionName = sp.getString(PhoneBase. + NETWORK_SELECTION_NAME_KEY, ""); + String oldNetworkSelection = sp.getString(PhoneBase.NETWORK_SELECTION_KEY, + ""); + if (!TextUtils.isEmpty(oldNetworkSelectionName) || + !TextUtils.isEmpty(oldNetworkSelection)) { + SharedPreferences.Editor editor = sp.edit(); + editor.putString(PhoneBase.NETWORK_SELECTION_NAME_KEY + subId, + oldNetworkSelectionName); + editor.putString(PhoneBase.NETWORK_SELECTION_KEY + subId, + oldNetworkSelection); + editor.remove(PhoneBase.NETWORK_SELECTION_NAME_KEY); + editor.remove(PhoneBase.NETWORK_SELECTION_KEY); + editor.commit(); + } } } } diff --git a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 12dafa257..19c16b1be 100755 --- a/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -315,13 +315,6 @@ final class GsmServiceStateTracker extends ServiceStateTracker { break; case EVENT_SIM_READY: - boolean skipRestoringSelection = mPhone.getContext().getResources().getBoolean( - com.android.internal.R.bool.skip_restoring_network_selection); - - if (!skipRestoringSelection) { - // restore the previous network selection. - mPhone.restoreSavedNetworkSelection(null); - } pollState(); // Signal strength polling stops when radio is off queueNextSignalStrengthPoll(); |