From 82ff3d5c568b698995c3360595065cff10eaf384 Mon Sep 17 00:00:00 2001 From: xinhe Date: Wed, 7 Jan 2015 17:41:51 -0800 Subject: set softAP on a specified band, including both 2.4 and 5 GHz band Bug:18929692 Change-Id: I455e9b17e5091596beb0246ccfd981c5d2b932f0 --- src/com/android/settings/wifi/WifiApDialog.java | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/com/android/settings/wifi/WifiApDialog.java b/src/com/android/settings/wifi/WifiApDialog.java index fb8026a..352ae14 100644 --- a/src/com/android/settings/wifi/WifiApDialog.java +++ b/src/com/android/settings/wifi/WifiApDialog.java @@ -32,9 +32,13 @@ import android.widget.CheckBox; import android.widget.EditText; import android.widget.Spinner; import android.widget.TextView; +import android.widget.RadioGroup; +import android.widget.RadioButton; import com.android.settings.R; +import android.util.Log; + /** * Dialog to configure the SSID and security settings * for Access Point operation @@ -53,8 +57,12 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, private TextView mSsid; private int mSecurityTypeIndex = OPEN_INDEX; private EditText mPassword; + private RadioGroup mChannel; + private RadioButton mChannel2G; + private RadioButton mChannel5G; WifiConfiguration mWifiConfig; + private static final String TAG = "WifiApDialog"; public WifiApDialog(Context context, DialogInterface.OnClickListener listener, WifiConfiguration wifiConfig) { @@ -85,6 +93,16 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, */ config.SSID = mSsid.getText().toString(); + //obtain the band configure + if (mChannel2G.isChecked()) { + config.apBand = 0; + } else if(mChannel5G.isChecked()) { + config.apBand = 1; + } else { + Log.e("TAG", "AP band configure error!"); + return null; + } + switch (mSecurityTypeIndex) { case OPEN_INDEX: config.allowedKeyManagement.set(KeyMgmt.NONE); @@ -118,15 +136,25 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mSsid = (TextView) mView.findViewById(R.id.ssid); mPassword = (EditText) mView.findViewById(R.id.password); + mChannel = (RadioGroup) mView.findViewById(R.id.choose_channel); + mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band); + mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band); + setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener); setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.wifi_cancel), mListener); if (mWifiConfig != null) { mSsid.setText(mWifiConfig.SSID); + if (mWifiConfig.apBand == 0) { + mChannel2G.setChecked(true); + } else { + mChannel5G.setChecked(true); + } + mSecurity.setSelection(mSecurityTypeIndex); if (mSecurityTypeIndex == WPA2_INDEX) { - mPassword.setText(mWifiConfig.preSharedKey); + mPassword.setText(mWifiConfig.preSharedKey); } } -- cgit v1.1 From d51b9525c913b4a34a8ea1f2cf18b0f8555da51a Mon Sep 17 00:00:00 2001 From: xinhe Date: Mon, 23 Feb 2015 17:10:08 -0800 Subject: Do not provide 5GHz option for softap if there is no country code available Bug:19414134 Change-Id: I3899d9daa33eca5d2c5528c2e4da97b02d019160 --- src/com/android/settings/wifi/WifiApDialog.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/com/android/settings/wifi/WifiApDialog.java b/src/com/android/settings/wifi/WifiApDialog.java index 352ae14..eee3db9 100644 --- a/src/com/android/settings/wifi/WifiApDialog.java +++ b/src/com/android/settings/wifi/WifiApDialog.java @@ -22,6 +22,7 @@ import android.content.DialogInterface; import android.net.wifi.WifiConfiguration; import android.net.wifi.WifiConfiguration.AuthAlgorithm; import android.net.wifi.WifiConfiguration.KeyMgmt; +import android.net.wifi.WifiManager; import android.os.Bundle; import android.text.Editable; import android.text.InputType; @@ -62,6 +63,8 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, private RadioButton mChannel5G; WifiConfiguration mWifiConfig; + WifiManager mWifiManager; + private static final String TAG = "WifiApDialog"; public WifiApDialog(Context context, DialogInterface.OnClickListener listener, @@ -72,6 +75,7 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, if (wifiConfig != null) { mSecurityTypeIndex = getSecurityTypeIndex(wifiConfig); } + mWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); } public static int getSecurityTypeIndex(WifiConfiguration wifiConfig) { @@ -140,6 +144,17 @@ public class WifiApDialog extends AlertDialog implements View.OnClickListener, mChannel2G = (RadioButton) mView.findViewById(R.id.ap_2G_band); mChannel5G = (RadioButton) mView.findViewById(R.id.ap_5G_band); + String countryCode = mWifiManager.getCountryCode(); + if (!mWifiManager.is5GHzBandSupported() || countryCode == null) { + //If no country code, 5GHz AP is forbidden + Log.e(TAG," NO country code, forbid 5GHz"); + mChannel5G.setVisibility(View.INVISIBLE); + mWifiConfig.apBand = 0; + } else { + mChannel5G.setVisibility(View.VISIBLE); + } + + setButton(BUTTON_SUBMIT, context.getString(R.string.wifi_save), mListener); setButton(DialogInterface.BUTTON_NEGATIVE, context.getString(R.string.wifi_cancel), mListener); -- cgit v1.1 From 4ab32563f1cd7d018ee7cdaec8d5a527964a05b9 Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Mon, 23 Feb 2015 15:34:07 -0800 Subject: Add Wi-Fi Calling preference screen Change-Id: Ie89902b55c5c4184236636f5039b3246a9c0bda5 --- src/com/android/settings/Settings.java | 1 + src/com/android/settings/SettingsActivity.java | 4 +- src/com/android/settings/WifiCallingSettings.java | 220 +++++++++++++++++++++ src/com/android/settings/WirelessSettings.java | 17 ++ src/com/android/settings/search/Ranking.java | 2 + .../settings/search/SearchIndexableResources.java | 8 + 6 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 src/com/android/settings/WifiCallingSettings.java (limited to 'src') diff --git a/src/com/android/settings/Settings.java b/src/com/android/settings/Settings.java index 84bf615..ebb7491 100644 --- a/src/com/android/settings/Settings.java +++ b/src/com/android/settings/Settings.java @@ -101,5 +101,6 @@ public class Settings extends SettingsActivity { public static class TopLevelSettings extends SettingsActivity { /* empty */ } public static class ApnSettingsActivity extends SettingsActivity { /* empty */ } + public static class WifiCallingSettingsActivity extends SettingsActivity { /* empty */ } } diff --git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java index dc5675c..cbffa86 100644 --- a/src/com/android/settings/SettingsActivity.java +++ b/src/com/android/settings/SettingsActivity.java @@ -112,6 +112,7 @@ import com.android.settings.wifi.AdvancedWifiSettings; import com.android.settings.wifi.SavedAccessPointsWifiSettings; import com.android.settings.wifi.WifiSettings; import com.android.settings.wifi.p2p.WifiP2pSettings; +import com.android.settings.WifiCallingSettings; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; @@ -302,7 +303,8 @@ public class SettingsActivity extends Activity AppNotificationSettings.class.getName(), OtherSoundSettings.class.getName(), QuickLaunchSettings.class.getName(), - ApnSettings.class.getName() + ApnSettings.class.getName(), + WifiCallingSettings.class.getName() }; diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java new file mode 100644 index 0000000..6b64fdf --- /dev/null +++ b/src/com/android/settings/WifiCallingSettings.java @@ -0,0 +1,220 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.settings; + +import android.content.Context; +import android.os.Bundle; +import android.preference.ListPreference; +import android.preference.Preference; +import android.preference.SwitchPreference; +import android.telephony.PhoneStateListener; +import android.telephony.TelephonyManager; +import android.util.Log; +import android.widget.Switch; + +import com.android.ims.ImsConfig; +import com.android.ims.ImsManager; +import com.android.settings.search.Indexable; +import com.android.settings.widget.SwitchBar; + +/** + * "Wi-Fi Calling settings" screen. This preference screen lets you + * enable/disable Wi-Fi Calling, change mode, enable/disable + * handover while on roaming. + */ +public class WifiCallingSettings extends SettingsPreferenceFragment + implements SwitchBar.OnSwitchChangeListener, + Preference.OnPreferenceChangeListener, Indexable { + + private static final String TAG = "WifiCallingSettings"; + + //String keys for preference lookup + private static final String BUTTON_WFC_MODE = "wifi_calling_mode"; + private static final String BUTTON_WFC_ROAM = "wifi_calling_roam"; + + //UI objects + private SwitchBar mSwitchBar; + private Switch mSwitch; + private ListPreference mButtonWfcMode; + private SwitchPreference mButtonWfcRoam; + + private final PhoneStateListener mPhoneStateListener = new PhoneStateListener() { + /* + * Enable/disable controls when in/out of a call and depending on + * TTY mode and TTY support over VoLTE. + * @see android.telephony.PhoneStateListener#onCallStateChanged(int, + * java.lang.String) + */ + @Override + public void onCallStateChanged(int state, String incomingNumber) { + final SettingsActivity activity = (SettingsActivity) getActivity(); + boolean isNonTtyOrTtyOnVolteEnabled = ImsManager + .isNonTtyOrTtyOnVolteEnabled(activity); + final SwitchBar switchBar = activity.getSwitchBar(); + boolean isWfcEnabled = switchBar.getSwitch().isChecked() + && isNonTtyOrTtyOnVolteEnabled; + + switchBar.setEnabled((state == TelephonyManager.CALL_STATE_IDLE) + && isNonTtyOrTtyOnVolteEnabled); + + Preference pref = getPreferenceScreen().findPreference(BUTTON_WFC_MODE); + int wfcMode = ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY; + if (pref != null) { + pref.setEnabled(isWfcEnabled + && (state == TelephonyManager.CALL_STATE_IDLE)); + ListPreference prefWfcMode = (ListPreference) pref; + wfcMode = Integer.valueOf(prefWfcMode.getValue()).intValue(); + } + pref = getPreferenceScreen().findPreference(BUTTON_WFC_ROAM); + if (pref != null) { + pref.setEnabled(isWfcEnabled + && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) + && (state == TelephonyManager.CALL_STATE_IDLE)); + } + } + }; + + @Override + public void onActivityCreated(Bundle savedInstanceState) { + super.onActivityCreated(savedInstanceState); + + final SettingsActivity activity = (SettingsActivity) getActivity(); + + mSwitchBar = activity.getSwitchBar(); + mSwitch = mSwitchBar.getSwitch(); + mSwitchBar.show(); + } + + @Override + public void onDestroyView() { + super.onDestroyView(); + mSwitchBar.hide(); + } + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.wifi_calling_settings); + + mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE); + mButtonWfcMode.setOnPreferenceChangeListener(this); + + mButtonWfcRoam = (SwitchPreference) findPreference(BUTTON_WFC_ROAM); + mButtonWfcRoam.setOnPreferenceChangeListener(this); + } + + @Override + public void onResume() { + super.onResume(); + + final Context context = getActivity(); + + if (ImsManager.isWfcEnabledByPlatform(context)) { + TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_CALL_STATE); + + mSwitchBar.addOnSwitchChangeListener(this); + } + + // NOTE: Buttons will be enabled/disabled in mPhoneStateListener + boolean wfcEnabled = ImsManager.isWfcEnabledByUser(context) + && ImsManager.isNonTtyOrTtyOnVolteEnabled(context); + mSwitch.setChecked(wfcEnabled); + + int wfcMode = ImsManager.getWfcMode(context); + mButtonWfcMode.setValue(Integer.toString(wfcMode)); + mButtonWfcMode.setSummary(getWfcModeSummary(context, ImsManager.getWfcMode(context))); + + mButtonWfcRoam.setChecked(wfcEnabled + && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) + && ImsManager.isWfcRoamingEnabledByUser(context)); + } + + @Override + public void onPause() { + super.onPause(); + + if (ImsManager.isWfcEnabledByPlatform(getActivity())) { + TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); + tm.listen(mPhoneStateListener, PhoneStateListener.LISTEN_NONE); + + mSwitchBar.removeOnSwitchChangeListener(this); + } + } + + /** + * Listens to the state change of the switch. + */ + @Override + public void onSwitchChanged(Switch switchView, boolean isChecked) { + final Context context = getActivity(); + + ImsManager.setWfcSetting(context, isChecked); + + mButtonWfcMode.setEnabled(isChecked); + boolean wfcHandoffEnabled = (ImsManager.getWfcMode(context) + != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY); + mButtonWfcRoam.setEnabled(isChecked && wfcHandoffEnabled); + mButtonWfcRoam.setChecked(isChecked && wfcHandoffEnabled + && ImsManager.isWfcRoamingEnabledByUser(context)); + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + final Context context = getActivity(); + if (preference == mButtonWfcMode) { + mButtonWfcMode.setValue((String) newValue); + int buttonMode = Integer.valueOf((String) newValue); + int currentMode = ImsManager.getWfcMode(context); + if (buttonMode != currentMode) { + ImsManager.setWfcMode(context, buttonMode); + mButtonWfcMode.setSummary(getWfcModeSummary(context, buttonMode)); + } + boolean wfcHandoffEnabled = + (buttonMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY); + mButtonWfcRoam.setEnabled(wfcHandoffEnabled); + mButtonWfcRoam.setChecked(wfcHandoffEnabled && + ImsManager.isWfcRoamingEnabledByUser(context)); + } else if (preference == mButtonWfcRoam) { + SwitchPreference wfcRoamPref = (SwitchPreference) preference; + wfcRoamPref.setChecked(!wfcRoamPref.isChecked()); + ImsManager.setWfcRoamingSetting(context, wfcRoamPref.isChecked()); + } + return true; + } + + static int getWfcModeSummary(Context context, int wfcMode) { + int resId = R.string.wifi_calling_off_summary; + if (ImsManager.isWfcEnabledByUser(context)) { + switch (wfcMode) { + case ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY: + resId = R.string.wfc_mode_wifi_only_summary; + break; + case ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED: + resId = R.string.wfc_mode_cellular_preferred_summary; + break; + case ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED: + resId = R.string.wfc_mode_wifi_preferred_summary; + break; + default: + Log.e(TAG, "Unexpected WFC mode value: " + wfcMode); + } + } + return resId; + } +} diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java index e9c39d9..9152870 100644 --- a/src/com/android/settings/WirelessSettings.java +++ b/src/com/android/settings/WirelessSettings.java @@ -47,6 +47,8 @@ import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; +import com.android.ims.ImsConfig; +import com.android.ims.ImsManager; import com.android.internal.telephony.SmsApplication; import com.android.internal.telephony.SmsApplication.SmsApplicationData; import com.android.internal.telephony.TelephonyIntents; @@ -54,6 +56,7 @@ import com.android.internal.telephony.TelephonyProperties; import com.android.settings.nfc.NfcEnabler; import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.Indexable; +import com.android.settings.WifiCallingSettings; import java.util.ArrayList; import java.util.Arrays; @@ -76,6 +79,7 @@ public class WirelessSettings extends SettingsPreferenceFragment private static final String KEY_SMS_APPLICATION = "sms_application"; private static final String KEY_TOGGLE_NSD = "toggle_nsd"; //network service discovery private static final String KEY_CELL_BROADCAST_SETTINGS = "cell_broadcast_settings"; + private static final String KEY_WFC_SETTINGS = "wifi_calling_settings"; public static final String EXIT_ECM_RESULT = "exit_ecm_result"; public static final int REQUEST_CODE_EXIT_ECM = 1; @@ -95,6 +99,7 @@ public class WirelessSettings extends SettingsPreferenceFragment private static final String SAVED_MANAGE_MOBILE_PLAN_MSG = "mManageMobilePlanMessage"; private AppListPreference mSmsApplicationPreference; + private PreferenceScreen mButtonWfc; /** * Invoked on each preference click in this hierarchy, overrides @@ -282,6 +287,12 @@ public class WirelessSettings extends SettingsPreferenceFragment initSmsApplicationSetting(); } + if (ImsManager.isWfcEnabledByPlatform(activity)) { + mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS); + } else { + removePreference(KEY_WFC_SETTINGS); + } + // Remove NSD checkbox by default getPreferenceScreen().removePreference(nsd); //mNsdEnabler = new NsdEnabler(activity, nsd); @@ -423,6 +434,12 @@ public class WirelessSettings extends SettingsPreferenceFragment if (mNsdEnabler != null) { mNsdEnabler.resume(); } + + final Context context = getActivity(); + if (ImsManager.isWfcEnabledByPlatform(context)) { + mButtonWfc.setSummary(WifiCallingSettings.getWfcModeSummary( + context, ImsManager.getWfcMode(context))); + } } @Override diff --git a/src/com/android/settings/search/Ranking.java b/src/com/android/settings/search/Ranking.java index 6abbc3d..0022338 100644 --- a/src/com/android/settings/search/Ranking.java +++ b/src/com/android/settings/search/Ranking.java @@ -47,6 +47,7 @@ import com.android.settings.voice.VoiceInputSettings; import com.android.settings.wifi.AdvancedWifiSettings; import com.android.settings.wifi.SavedAccessPointsWifiSettings; import com.android.settings.wifi.WifiSettings; +import com.android.settings.WifiCallingSettings; import java.util.HashMap; @@ -104,6 +105,7 @@ public final class Ranking { // Other wireless settinfs sRankMap.put(WirelessSettings.class.getName(), RANK_WIRELESS); + sRankMap.put(WifiCallingSettings.class.getName(), RANK_WIRELESS); // Home sRankMap.put(HomeSettings.class.getName(), RANK_HOME); diff --git a/src/com/android/settings/search/SearchIndexableResources.java b/src/com/android/settings/search/SearchIndexableResources.java index 502480d..d774469 100644 --- a/src/com/android/settings/search/SearchIndexableResources.java +++ b/src/com/android/settings/search/SearchIndexableResources.java @@ -49,6 +49,7 @@ import com.android.settings.voice.VoiceInputSettings; import com.android.settings.wifi.AdvancedWifiSettings; import com.android.settings.wifi.SavedAccessPointsWifiSettings; import com.android.settings.wifi.WifiSettings; +import com.android.settings.WifiCallingSettings; import java.util.Collection; import java.util.HashMap; @@ -270,6 +271,13 @@ public final class SearchIndexableResources { NO_DATA_RES_ID, DeviceInfoSettings.class.getName(), R.drawable.ic_settings_about)); + + sResMap.put(WifiCallingSettings.class.getName(), + new SearchIndexableResource( + Ranking.getRankForClassName(WifiCallingSettings.class.getName()), + R.xml.wifi_calling_settings, + WifiCallingSettings.class.getName(), + R.drawable.ic_settings_wireless)); } private SearchIndexableResources() { -- cgit v1.1 From 171d147905776a8442b43de83d3e8d5c34b8c644 Mon Sep 17 00:00:00 2001 From: Santos Cordon Date: Fri, 6 Feb 2015 05:38:06 -0800 Subject: Update Multi-SIM setting to use getSubIdForPhoneAccount API. Settings app should not be parsing the subId direction from the phone account. Instead this CL updates the settings app to use a new API to grab the sub ID. Change-Id: Iefd1831b04c061168fa2b135a2d296a27e3d4e92 --- src/com/android/settings/sim/SimDialogActivity.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/com/android/settings/sim/SimDialogActivity.java b/src/com/android/settings/sim/SimDialogActivity.java index 3170dae..4566662 100644 --- a/src/com/android/settings/sim/SimDialogActivity.java +++ b/src/com/android/settings/sim/SimDialogActivity.java @@ -29,6 +29,7 @@ import android.telecom.PhoneAccountHandle; import android.telecom.TelecomManager; import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionManager; +import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Log; import android.view.KeyEvent; @@ -210,6 +211,7 @@ public class SimDialogActivity extends Activity { ArrayList callsSubInfoList = new ArrayList(); if (id == CALLS_PICK) { final TelecomManager telecomManager = TelecomManager.from(context); + final TelephonyManager telephonyManager = TelephonyManager.from(context); final Iterator phoneAccounts = telecomManager.getCallCapablePhoneAccounts().listIterator(); @@ -219,13 +221,9 @@ public class SimDialogActivity extends Activity { final PhoneAccount phoneAccount = telecomManager.getPhoneAccount(phoneAccounts.next()); list.add((String)phoneAccount.getLabel()); - // Added check to add entry into callsSubInforList only if phoneAccountId is int - // Todo : Might have to change it later based on b/18904714 - if (phoneAccount.hasCapabilities(PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) && - TextUtils.isDigitsOnly(phoneAccount.getAccountHandle().getId())) { - final String phoneAccountId = phoneAccount.getAccountHandle().getId(); - final SubscriptionInfo sir = Utils.findRecordBySubId(context, - Integer.parseInt(phoneAccountId)); + int subId = telephonyManager.getSubIdForPhoneAccount(phoneAccount); + if (subId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) { + final SubscriptionInfo sir = Utils.findRecordBySubId(context, subId); callsSubInfoList.add(sir); } else { callsSubInfoList.add(null); -- cgit v1.1 From 71099329cc0443ce4517480c86f81ed6b4e33ff2 Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Mon, 2 Mar 2015 15:01:03 -0800 Subject: Wi-Fi calling settings cleanup Bug: 19573771 Change-Id: Idcbbdc962238f0a32fd7adf4d6b8409d6e6ffd37 --- src/com/android/settings/WifiCallingSettings.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java index 6b64fdf..2e8fb74 100644 --- a/src/com/android/settings/WifiCallingSettings.java +++ b/src/com/android/settings/WifiCallingSettings.java @@ -28,7 +28,6 @@ import android.widget.Switch; import com.android.ims.ImsConfig; import com.android.ims.ImsManager; -import com.android.settings.search.Indexable; import com.android.settings.widget.SwitchBar; /** @@ -38,7 +37,7 @@ import com.android.settings.widget.SwitchBar; */ public class WifiCallingSettings extends SettingsPreferenceFragment implements SwitchBar.OnSwitchChangeListener, - Preference.OnPreferenceChangeListener, Indexable { + Preference.OnPreferenceChangeListener { private static final String TAG = "WifiCallingSettings"; -- cgit v1.1 From 248b8fd7bf46c80d06e36aa9328c6fd0e0d326ce Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Mon, 9 Mar 2015 16:58:39 -0700 Subject: Update Wi-Fi Calling mode when WFC is enabled/disabled Bug: 19644042 Change-Id: Ie9cfe8c7f416985e4f78d48159d83191a19ac599 --- src/com/android/settings/WifiCallingSettings.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java index 2e8fb74..23fc2ea 100644 --- a/src/com/android/settings/WifiCallingSettings.java +++ b/src/com/android/settings/WifiCallingSettings.java @@ -137,7 +137,7 @@ public class WifiCallingSettings extends SettingsPreferenceFragment int wfcMode = ImsManager.getWfcMode(context); mButtonWfcMode.setValue(Integer.toString(wfcMode)); - mButtonWfcMode.setSummary(getWfcModeSummary(context, ImsManager.getWfcMode(context))); + mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); mButtonWfcRoam.setChecked(wfcEnabled && (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY) @@ -165,9 +165,10 @@ public class WifiCallingSettings extends SettingsPreferenceFragment ImsManager.setWfcSetting(context, isChecked); + int wfcMode = ImsManager.getWfcMode(context); + mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode)); mButtonWfcMode.setEnabled(isChecked); - boolean wfcHandoffEnabled = (ImsManager.getWfcMode(context) - != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY); + boolean wfcHandoffEnabled = (wfcMode != ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY); mButtonWfcRoam.setEnabled(isChecked && wfcHandoffEnabled); mButtonWfcRoam.setChecked(isChecked && wfcHandoffEnabled && ImsManager.isWfcRoamingEnabledByUser(context)); -- cgit v1.1 From 897b492d69a3a19d3ca888b84405af1172a1459d Mon Sep 17 00:00:00 2001 From: Pavel Zhamaitsiak Date: Fri, 6 Mar 2015 16:02:53 -0800 Subject: Show alerts in case of some IMS registration errors. Change-Id: I7019c6f0bae66190d190babd83ebcdd780e5b8a0 --- src/com/android/settings/WifiCallingSettings.java | 55 +++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'src') diff --git a/src/com/android/settings/WifiCallingSettings.java b/src/com/android/settings/WifiCallingSettings.java index 2e8fb74..f3daf41 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); } /** -- cgit v1.1