From 670db2c696251370c4806ee3ecc3c7d6370b38e8 Mon Sep 17 00:00:00 2001 From: John Wang Date: Fri, 22 Jan 2010 12:32:40 -0800 Subject: Updated emergency string when locale changes. For bug 2352094. --- .../telephony/gsm/GsmServiceStateTracker.java | 28 +++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java index 5034e16..bc7b7fa 100644 --- a/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java +++ b/telephony/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java @@ -20,9 +20,12 @@ import android.app.AlarmManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; +import android.content.res.Resources; import android.database.ContentObserver; import android.os.AsyncResult; import android.os.Handler; @@ -166,6 +169,16 @@ final class GsmServiceStateTracker extends ServiceStateTracker { static final int MAX_NUM_DATA_STATE_READS = 15; + private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + if (intent.getAction().equals(Intent.ACTION_LOCALE_CHANGED)) { + // update emergency string whenever locale changed + updateSpnDisplay(); + } + } + }; + private ContentObserver mAutoTimeObserver = new ContentObserver(new Handler()) { @Override public void onChange(boolean selfChange) { @@ -211,6 +224,11 @@ final class GsmServiceStateTracker extends ServiceStateTracker { mAutoTimeObserver); setSignalStrengthDefaultValues(); mNeedToRegForSimLoaded = true; + + // Monitor locale change + IntentFilter filter = new IntentFilter(); + filter.addAction(Intent.ACTION_LOCALE_CHANGED); + phone.getContext().registerReceiver(mIntentReceiver, filter); } public void dispose() { @@ -558,20 +576,18 @@ final class GsmServiceStateTracker extends ServiceStateTracker { // For emergency calls only, pass the EmergencyCallsOnly string via EXTRA_PLMN if (mEmergencyOnly && cm.getRadioState().isOn()) { - plmn = phone.getContext().getText(com.android.internal.R.string.emergency_calls_only).toString(); + plmn = Resources.getSystem(). + getText(com.android.internal.R.string.emergency_calls_only).toString(); } if (rule != curSpnRule || !TextUtils.equals(spn, curSpn) || !TextUtils.equals(plmn, curPlmn)) { - boolean showSpn = - (rule & SIMRecords.SPN_RULE_SHOW_SPN) == SIMRecords.SPN_RULE_SHOW_SPN; + boolean showSpn = mEmergencyOnly + || (rule & SIMRecords.SPN_RULE_SHOW_SPN) == SIMRecords.SPN_RULE_SHOW_SPN; boolean showPlmn = (rule & SIMRecords.SPN_RULE_SHOW_PLMN) == SIMRecords.SPN_RULE_SHOW_PLMN; - if (mEmergencyOnly) - showPlmn = true; - Intent intent = new Intent(Intents.SPN_STRINGS_UPDATED_ACTION); intent.putExtra(Intents.EXTRA_SHOW_SPN, showSpn); intent.putExtra(Intents.EXTRA_SPN, spn); -- cgit v1.1