Improve video calling setting visiblity behavior.
+ Use ImsManager helpers to determine whether the Enhanced 4G LTE
setting has been set, and whether the device is Enhanced 4G LTE
capable.
+ Update logic in CallFeaturesSetting for visibility of the setting.
If device is capable, but the setting is off, show a dialog with
a button which will send them to Network settings.
- Remove helper in ImsUtil which is no longer needed.
Bug: 16014284
Change-Id: If2c89bb59d1ef7456e5adc2ebc1aea1488947ee7
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 88020fc..96291d0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1228,9 +1228,9 @@
<string name="enable_video_calling_title">Turn on video calling</string>
<!-- Message for dialog shown when the user tries to turn on video calling but enhanced 4G LTE
- is disabled. -->
+ is disabled. They have to turn on Enhanced 4G LTE capability in network settings first. -->
<string name="enable_video_calling_dialog_msg">
- To turn on video calling, you need to enable Enhanced 4G LTE Mode in system settings.
+ To turn on video calling, you need to enable Enhanced 4G LTE Mode in network settings.
</string>
<!-- Label for action button in dialog which opens mobile network settings, for video calling
diff --git a/src/com/android/phone/CallFeaturesSetting.java b/src/com/android/phone/CallFeaturesSetting.java
index b7f2d55..5d4b023 100644
--- a/src/com/android/phone/CallFeaturesSetting.java
+++ b/src/com/android/phone/CallFeaturesSetting.java
@@ -57,6 +57,7 @@
import android.view.WindowManager;
import android.widget.ListAdapter;
+import com.android.ims.ImsManager;
import com.android.internal.telephony.CallForwardInfo;
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.Phone;
@@ -499,7 +500,27 @@
saveVoiceMailAndForwardingNumber(newProviderKey, newProviderSettings);
}
} else if (preference == mEnableVideoCalling) {
- PhoneGlobals.getInstance().phoneMgr.enableVideoCalling((boolean) objValue);
+ if (ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext())) {
+ PhoneGlobals.getInstance().phoneMgr.enableVideoCalling((boolean) objValue);
+ } else {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ DialogInterface.OnClickListener networkSettingsClickListener =
+ new Dialog.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ startActivity(new Intent(mPhone.getContext(),
+ com.android.phone.MobileNetworkSettings.class));
+ }
+ };
+ builder.setMessage(getResources().getString(
+ R.string.enable_video_calling_dialog_msg))
+ .setNeutralButton(getResources().getString(
+ R.string.enable_video_calling_dialog_settings),
+ networkSettingsClickListener)
+ .setPositiveButton(android.R.string.ok, null)
+ .show();
+ return false;
+ }
}
// always let the preference setting proceed.
return true;
@@ -1482,8 +1503,7 @@
mButtonHAC = (CheckBoxPreference) findPreference(BUTTON_HAC_KEY);
mButtonTTY = (ListPreference) findPreference(BUTTON_TTY_KEY);
mVoicemailProviders = (ListPreference) findPreference(BUTTON_VOICEMAIL_PROVIDER_KEY);
- CheckBoxPreference mEnableVideoCalling =
- (CheckBoxPreference) findPreference(ENABLE_VIDEO_CALLING_KEY);
+ mEnableVideoCalling = (CheckBoxPreference) findPreference(ENABLE_VIDEO_CALLING_KEY);
if (mVoicemailProviders != null) {
mVoicemailProviders.setOnPreferenceChangeListener(this);
@@ -1597,9 +1617,11 @@
BUTTON_VOICEMAIL_NOTIFICATION_VIBRATE_KEY, false));
}
- if (ImsUtil.isImsEnabled(mPhone.getContext()) && ENABLE_VT_FLAG) {
- mEnableVideoCalling.setChecked(
- PhoneGlobals.getInstance().phoneMgr.isVideoCallingEnabled());
+ if (ImsManager.isVtEnabledByPlatform(mPhone.getContext()) && ENABLE_VT_FLAG) {
+ boolean currentValue =
+ ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext())
+ ? PhoneGlobals.getInstance().phoneMgr.isVideoCallingEnabled() : false;
+ mEnableVideoCalling.setChecked(currentValue);
mEnableVideoCalling.setOnPreferenceChangeListener(this);
} else {
prefSet.removePreference(mEnableVideoCalling);
diff --git a/src/com/android/phone/ImsUtil.java b/src/com/android/phone/ImsUtil.java
index 4f7eb7f..c3d780b 100644
--- a/src/com/android/phone/ImsUtil.java
+++ b/src/com/android/phone/ImsUtil.java
@@ -16,18 +16,10 @@
package com.android.phone;
-import android.app.PendingIntent;
-import android.content.Context;
-import android.content.Intent;
-import android.provider.Settings.SettingNotFoundException;
-import android.util.Log;
-
-import com.android.internal.telephony.Phone;
import com.android.phone.PhoneGlobals;
public class ImsUtil {
- private static final String TAG = ImsUtil.class.getSimpleName();
private static boolean sImsPhoneSupported = false;
private ImsUtil() {
@@ -45,30 +37,4 @@
return sImsPhoneSupported;
}
-
- /**
- * @see MobileNetworkSettings#setIMS
- * @param context The context to get the content resolver from.
- * @return Whether IMS is turned on by the user system setting.
- */
- static boolean isImsEnabled(Context context) {
- int value = 0;
- try {
- value = android.provider.Settings.Global.getInt(
- context.getContentResolver(),
- android.provider.Settings.Global.ENHANCED_4G_MODE_ENABLED);
- } catch (SettingNotFoundException e) {
- return false;
- }
-
- switch (value) {
- case 0:
- return false;
- case 1:
- return true;
- default:
- Log.wtf(TAG,"Unexpected value for ENHANCED_4G_MODE_ENABLED: " + value);
- return false;
- }
- }
}
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 58b8599..b6a4498 100644
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -53,6 +53,7 @@
import android.util.Log;
import android.util.Pair;
+import com.android.ims.ImsManager;
import com.android.internal.telephony.CallManager;
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.Connection;
@@ -2084,7 +2085,8 @@
// enabled video calling, if IMS is disabled we aren't able to support video calling.
// In the long run, we may instead need to check if there exists a connection service
// which can support video calling.
- return mTelephonySharedPreferences.getBoolean(PREF_ENABLE_VIDEO_CALLING, true)
- && ImsUtil.isImsEnabled(mPhone.getContext());
+ return ImsManager.isVtEnabledByPlatform(mPhone.getContext())
+ && ImsManager.isEnhanced4gLteModeSettingEnabledByUser(mPhone.getContext())
+ && mTelephonySharedPreferences.getBoolean(PREF_ENABLE_VIDEO_CALLING, true);
}
}