Launch E911 address management activity at turning on Wifi Calling
Bug: 28404126 Change-Id: Id551d784d151e5f24cfcec96e6cf4b999f39ce0f
This commit is contained in:
@@ -1983,6 +1983,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
<!-- Wi-Fi Calling settings. Text displayed when Wi-Fi Calling is off -->
|
<!-- Wi-Fi Calling settings. Text displayed when Wi-Fi Calling is off -->
|
||||||
<string name="wifi_calling_off_explanation">When Wi-Fi calling is on, your phone can route calls via Wi-Fi networks or your carrier\u2019s network, depending on your preference and which signal is stronger. Before turning on this feature, check with your carrier regarding fees and other details.</string>
|
<string name="wifi_calling_off_explanation">When Wi-Fi calling is on, your phone can route calls via Wi-Fi networks or your carrier\u2019s network, depending on your preference and which signal is stronger. Before turning on this feature, check with your carrier regarding fees and other details.</string>
|
||||||
|
<string name="emergency_address_title">Update Emergency Address</string>
|
||||||
|
|
||||||
|
|
||||||
<!-- Sound and alerts settings -->
|
<!-- Sound and alerts settings -->
|
||||||
<skip/>
|
<skip/>
|
||||||
|
@@ -26,4 +26,10 @@
|
|||||||
android:entryValues="@array/wifi_calling_mode_values"
|
android:entryValues="@array/wifi_calling_mode_values"
|
||||||
android:dialogTitle="@string/wifi_calling_mode_dialog_title" />
|
android:dialogTitle="@string/wifi_calling_mode_dialog_title" />
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
android:key="emergency_address_key"
|
||||||
|
android:title="@string/emergency_address_title"
|
||||||
|
android:summary="@string/emergency_address_title">
|
||||||
|
</Preference>
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
@@ -26,10 +27,12 @@ import android.os.Bundle;
|
|||||||
import android.os.PersistableBundle;
|
import android.os.PersistableBundle;
|
||||||
import android.support.v7.preference.ListPreference;
|
import android.support.v7.preference.ListPreference;
|
||||||
import android.support.v7.preference.Preference;
|
import android.support.v7.preference.Preference;
|
||||||
|
import android.support.v7.preference.Preference.OnPreferenceClickListener;
|
||||||
import android.support.v7.preference.PreferenceScreen;
|
import android.support.v7.preference.PreferenceScreen;
|
||||||
import android.telephony.CarrierConfigManager;
|
import android.telephony.CarrierConfigManager;
|
||||||
import android.telephony.PhoneStateListener;
|
import android.telephony.PhoneStateListener;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Switch;
|
import android.widget.Switch;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -53,6 +56,9 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
|
|
||||||
//String keys for preference lookup
|
//String keys for preference lookup
|
||||||
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
private static final String BUTTON_WFC_MODE = "wifi_calling_mode";
|
||||||
|
private static final String PREFERENCE_EMERGENCY_ADDRESS = "emergency_address_key";
|
||||||
|
|
||||||
|
private static final int REQUEST_CHECK_WFC_EMERGENCY_ADDRESS = 1;
|
||||||
|
|
||||||
//UI objects
|
//UI objects
|
||||||
private SwitchBar mSwitchBar;
|
private SwitchBar mSwitchBar;
|
||||||
@@ -90,6 +96,22 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final OnPreferenceClickListener mUpdateAddressListener =
|
||||||
|
new OnPreferenceClickListener() {
|
||||||
|
/*
|
||||||
|
* Launch carrier emergency address managemnent activity
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean onPreferenceClick(Preference preference) {
|
||||||
|
final Context context = getActivity();
|
||||||
|
Intent carrierAppIntent = getCarrierActivityIntent(context);
|
||||||
|
if (carrierAppIntent != null) {
|
||||||
|
startActivity(carrierAppIntent);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityCreated(Bundle savedInstanceState) {
|
public void onActivityCreated(Bundle savedInstanceState) {
|
||||||
super.onActivityCreated(savedInstanceState);
|
super.onActivityCreated(savedInstanceState);
|
||||||
@@ -163,6 +185,9 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
|
mButtonWfcMode = (ListPreference) findPreference(BUTTON_WFC_MODE);
|
||||||
mButtonWfcMode.setOnPreferenceChangeListener(this);
|
mButtonWfcMode.setOnPreferenceChangeListener(this);
|
||||||
|
|
||||||
|
Preference mUpdateAddress = (Preference) findPreference(PREFERENCE_EMERGENCY_ADDRESS);
|
||||||
|
mUpdateAddress.setOnPreferenceClickListener(mUpdateAddressListener);
|
||||||
|
|
||||||
mIntentFilter = new IntentFilter();
|
mIntentFilter = new IntentFilter();
|
||||||
mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
|
mIntentFilter.addAction(ImsManager.ACTION_IMS_REGISTRATION_ERROR);
|
||||||
|
|
||||||
@@ -239,18 +264,78 @@ public class WifiCallingSettings extends SettingsPreferenceFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
public void onSwitchChanged(Switch switchView, boolean isChecked) {
|
||||||
final Context context = getActivity();
|
final Context context = getActivity();
|
||||||
|
Log.d(TAG, "onSwitchChanged(" + isChecked + ")");
|
||||||
|
|
||||||
ImsManager.setWfcSetting(context, isChecked);
|
if (!isChecked) {
|
||||||
|
updateWfcMode(context, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call address management activity before turning on WFC
|
||||||
|
Intent carrierAppIntent = getCarrierActivityIntent(context);
|
||||||
|
if (carrierAppIntent != null) {
|
||||||
|
startActivityForResult(carrierAppIntent, REQUEST_CHECK_WFC_EMERGENCY_ADDRESS);
|
||||||
|
} else {
|
||||||
|
updateWfcMode(context, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get the Intent to launch carrier emergency address management activity.
|
||||||
|
* Return null when no activity found.
|
||||||
|
*/
|
||||||
|
private static Intent getCarrierActivityIntent(Context context) {
|
||||||
|
// Retrive component name from carrirt config
|
||||||
|
CarrierConfigManager configManager = context.getSystemService(CarrierConfigManager.class);
|
||||||
|
if (configManager == null) return null;
|
||||||
|
|
||||||
|
PersistableBundle bundle = configManager.getConfig();
|
||||||
|
if (bundle == null) return null;
|
||||||
|
|
||||||
|
String carrierApp = bundle.getString(
|
||||||
|
CarrierConfigManager.KEY_WFC_EMERGENCY_ADDRESS_CARRIER_APP_STRING);
|
||||||
|
if (TextUtils.isEmpty(carrierApp)) return null;
|
||||||
|
|
||||||
|
ComponentName componentName = ComponentName.unflattenFromString(carrierApp);
|
||||||
|
if (componentName == null) return null;
|
||||||
|
|
||||||
|
// Build and return intent
|
||||||
|
Intent intent = new Intent();
|
||||||
|
intent.setComponent(componentName);
|
||||||
|
return intent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Turn on/off WFC mode with ImsManager and update UI accordingly
|
||||||
|
*/
|
||||||
|
private void updateWfcMode(Context context, boolean wfcEnabled) {
|
||||||
|
Log.i(TAG, "updateWfcMode(" + wfcEnabled + ")");
|
||||||
|
ImsManager.setWfcSetting(context, wfcEnabled);
|
||||||
|
|
||||||
int wfcMode = ImsManager.getWfcMode(context);
|
int wfcMode = ImsManager.getWfcMode(context);
|
||||||
updateButtonWfcMode(context, isChecked, wfcMode);
|
updateButtonWfcMode(context, wfcEnabled, wfcMode);
|
||||||
if (isChecked) {
|
if (wfcEnabled) {
|
||||||
MetricsLogger.action(getActivity(), getMetricsCategory(), wfcMode);
|
MetricsLogger.action(getActivity(), getMetricsCategory(), wfcMode);
|
||||||
} else {
|
} else {
|
||||||
MetricsLogger.action(getActivity(), getMetricsCategory(), -1);
|
MetricsLogger.action(getActivity(), getMetricsCategory(), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
|
||||||
|
final Context context = getActivity();
|
||||||
|
|
||||||
|
if (requestCode == REQUEST_CHECK_WFC_EMERGENCY_ADDRESS) {
|
||||||
|
Log.d(TAG, "WFC emergency address activity result = " + resultCode);
|
||||||
|
|
||||||
|
if (resultCode == Activity.RESULT_OK) {
|
||||||
|
updateWfcMode(context, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode) {
|
private void updateButtonWfcMode(Context context, boolean wfcEnabled, int wfcMode) {
|
||||||
mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
|
mButtonWfcMode.setSummary(getWfcModeSummary(context, wfcMode));
|
||||||
mButtonWfcMode.setEnabled(wfcEnabled);
|
mButtonWfcMode.setEnabled(wfcEnabled);
|
||||||
|
Reference in New Issue
Block a user