diff options
author | Pavel Zhamaitsiak <pavelz@google.com> | 2015-03-10 19:27:31 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-03-10 19:27:32 +0000 |
commit | 4c7a4101ca87668341a998d17e929f66973c53f5 (patch) | |
tree | bb56eba0c9ad9339171c523e8de50bdeb30b3a2c /src/com/android | |
parent | 248b8fd7bf46c80d06e36aa9328c6fd0e0d326ce (diff) | |
parent | 897b492d69a3a19d3ca888b84405af1172a1459d (diff) | |
download | packages_apps_Settings-4c7a4101ca87668341a998d17e929f66973c53f5.tar.gz packages_apps_Settings-4c7a4101ca87668341a998d17e929f66973c53f5.tar.bz2 packages_apps_Settings-4c7a4101ca87668341a998d17e929f66973c53f5.zip |
Merge "Show alerts in case of some IMS registration errors." into lmp-mr1-wfc-dev
Diffstat (limited to 'src/com/android')
-rw-r--r-- | src/com/android/settings/WifiCallingSettings.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java index 23fc2ea87..dacdc7b0a 100644 --- a/src/com/android/settings/WifiCallingSettings.java +++ b/src/com/android/settings/WifiCallingSettings.java @@ -16,7 +16,12 @@ package com.android.settings; +import android.app.Activity; +import android.app.AlertDialog; +import android.content.BroadcastReceiver; import android.content.Context; +import android.content.Intent; +import android.content.IntentFilter; import android.os.Bundle; import android.preference.ListPreference; import android.preference.Preference; @@ -28,6 +33,7 @@ import android.widget.Switch; import com.android.ims.ImsConfig; import com.android.ims.ImsManager; +import com.android.internal.telephony.imsphone.ImsPhone; import com.android.settings.widget.SwitchBar; /** @@ -104,6 +110,41 @@ public class WifiCallingSettings extends SettingsPreferenceFragment mSwitchBar.hide(); } + private void showAlert(Intent intent) { + Context context = getActivity(); + + CharSequence title = intent.getCharSequenceExtra(ImsPhone.EXTRA_KEY_ALERT_TITLE); + CharSequence message = intent.getCharSequenceExtra(ImsPhone.EXTRA_KEY_ALERT_MESSAGE); + + AlertDialog.Builder builder = new AlertDialog.Builder(context); + builder.setMessage(message) + .setTitle(title) + .setIcon(android.R.drawable.stat_sys_warning) + .setPositiveButton(android.R.string.ok, null); + AlertDialog dialog = builder.create(); + dialog.show(); + } + + private IntentFilter mIntentFilter; + + private BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { + @Override + public void onReceive(Context context, Intent intent) { + String action = intent.getAction(); + if (action.equals(ImsPhone.REGISTRATION_ERROR)) { + // If this fragment is active then we are immediately + // showing alert on screen. There is no need to add + // notification in this case. + // + // In order to communicate to ImsPhone that it should + // not show notification, we are changing result code here. + setResultCode(Activity.RESULT_CANCELED); + + showAlert(intent); + } + } + }; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -115,6 +156,9 @@ public class WifiCallingSettings extends SettingsPreferenceFragment mButtonWfcRoam = (SwitchPreference) findPreference(BUTTON_WFC_ROAM); mButtonWfcRoam.setOnPreferenceChangeListener(this); + + mIntentFilter = new IntentFilter(); + mIntentFilter.addAction(ImsPhone.REGISTRATION_ERROR); } @Override @@ -142,18 +186,29 @@ public class WifiCallingSettings extends SettingsPreferenceFragment mButtonWfcRoam.setChecked(wfcEnabled && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) && ImsManager.isWfcRoamingEnabledByUser(context)); + + context.registerReceiver(mIntentReceiver, mIntentFilter); + + Intent intent = getActivity().getIntent(); + if (intent.getBooleanExtra(ImsPhone.EXTRA_KEY_ALERT_SHOW, false)) { + showAlert(intent); + } } @Override public void onPause() { super.onPause(); + final Context context = getActivity(); + if (ImsManager.isWfcEnabledByPlatform(getActivity())) { TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); mSwitchBar.removeOnSwitchChangeListener(this); } + + context.unregisterReceiver(mIntentReceiver); } /** |