Merge "Add support for rejecting Telecom call with a specified reason."
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 6ac95c3..39daea8 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1843,8 +1843,6 @@
<string name="messageCallBarring">Enter password</string>
<!-- Call barring settings screen, section heading -->
<string name="call_barring_settings">Call barring settings</string>
- <!-- Call barring settings screen, deactivate all call barring settings -->
- <string name="call_barring_deactivate_all_no_password">Deactivate all call barring settings?</string>
<!-- In-call screen: error message shown when the user attempts to place a call, but the network
does not have enough resources (e.g. it is busy) and the call cannot be placed. -->
<string name="callFailed_NetworkBusy">Network is busy. Please try your call again later.</string>
diff --git a/src/com/android/phone/CallBarringDeselectAllPreference.java b/src/com/android/phone/CallBarringDeselectAllPreference.java
index e9310f8..7191937 100644
--- a/src/com/android/phone/CallBarringDeselectAllPreference.java
+++ b/src/com/android/phone/CallBarringDeselectAllPreference.java
@@ -19,12 +19,9 @@
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
-import android.util.Log;
import android.view.View;
import android.widget.EditText;
-import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.phone.settings.fdn.EditPinPreference;
/**
@@ -34,9 +31,6 @@
private static final String LOG_TAG = "CallBarringDeselectAllPreference";
private static final boolean DBG = (PhoneGlobals.DBG_LEVEL >= 2);
- private boolean mShowPassword;
- private Phone mPhone;
-
/**
* CallBarringDeselectAllPreference constructor.
*
@@ -49,28 +43,10 @@
@Override
protected void showDialog(Bundle state) {
- // Finds out if the password field should be shown or not.
- ImsPhone imsPhone = mPhone != null ? (ImsPhone) mPhone.getImsPhone() : null;
- mShowPassword = !(imsPhone != null && imsPhone.isUtEnabled());
-
- // Selects dialog message depending on if the password field is shown or not.
- setDialogMessage(getContext().getString(mShowPassword
- ? R.string.messageCallBarring : R.string.call_barring_deactivate_all_no_password));
-
- if (DBG) {
- Log.d(LOG_TAG, "showDialog: mShowPassword: " + mShowPassword);
- }
-
+ setDialogMessage(getContext().getString(R.string.messageCallBarring));
super.showDialog(state);
}
- void init(Phone phone) {
- if (DBG) {
- Log.d(LOG_TAG, "init: phoneId = " + phone.getPhoneId());
- }
- mPhone = phone;
- }
-
@Override
protected void onBindDialogView(View view) {
super.onBindDialogView(view);
@@ -78,20 +54,7 @@
final EditText editText = (EditText) view.findViewById(android.R.id.edit);
if (editText != null) {
// Hide the input-text-line if the password is not shown.
- editText.setVisibility(mShowPassword ? View.VISIBLE : View.GONE);
+ editText.setVisibility(View.VISIBLE);
}
}
-
- @Override
- protected boolean needInputMethod() {
- // Input method should only be displayed if the password-field is shown.
- return mShowPassword;
- }
-
- /**
- * Returns whether the password field is shown.
- */
- boolean isPasswordShown() {
- return mShowPassword;
- }
}
diff --git a/src/com/android/phone/CallBarringEditPreference.java b/src/com/android/phone/CallBarringEditPreference.java
index 4b89cd9..4541926 100644
--- a/src/com/android/phone/CallBarringEditPreference.java
+++ b/src/com/android/phone/CallBarringEditPreference.java
@@ -38,7 +38,6 @@
import com.android.internal.telephony.CommandException;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
-import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.phone.settings.fdn.EditPinPreference;
import java.lang.ref.WeakReference;
@@ -57,10 +56,7 @@
private CharSequence mDisableText;
private CharSequence mSummaryOn;
private CharSequence mSummaryOff;
- private CharSequence mDialogMessageEnabled;
- private CharSequence mDialogMessageDisabled;
private int mButtonClicked;
- private boolean mShowPassword;
private final MyHandler mHandler = new MyHandler(this);
private Phone mPhone;
private TimeConsumingPreferenceListener mTcpListener;
@@ -90,10 +86,6 @@
typedArray = context.obtainStyledAttributes(attrs,
R.styleable.CallBarringEditPreference, 0, R.style.EditPhoneNumberPreference);
mFacility = typedArray.getString(R.styleable.CallBarringEditPreference_facility);
- mDialogMessageEnabled = typedArray.getString(
- R.styleable.CallBarringEditPreference_dialogMessageEnabledNoPwd);
- mDialogMessageDisabled = typedArray.getString(
- R.styleable.CallBarringEditPreference_dialogMessageDisabledNoPwd);
typedArray.recycle();
}
@@ -130,29 +122,8 @@
}
@Override
- protected boolean needInputMethod() {
- // Input method should only be displayed if the password-field is shown.
- return mShowPassword;
- }
-
- void setInputMethodNeeded(boolean needed) {
- mShowPassword = needed;
- }
-
- @Override
protected void showDialog(Bundle state) {
- setShowPassword();
- if (mShowPassword) {
- setDialogMessage(getContext().getString(R.string.messageCallBarring));
- } else {
- setDialogMessage(mIsActivated ? mDialogMessageEnabled : mDialogMessageDisabled);
- }
-
- if (DBG) {
- Log.d(LOG_TAG, "showDialog: mShowPassword: " + mShowPassword
- + ", mIsActivated: " + mIsActivated);
- }
-
+ setDialogMessage(getContext().getString(R.string.messageCallBarring));
super.showDialog(state);
}
@@ -204,8 +175,7 @@
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
editText.setKeyListener(DigitsKeyListener.getInstance());
- // Hide the input-text-line if the password is not shown.
- editText.setVisibility(mShowPassword ? View.VISIBLE : View.GONE);
+ editText.setVisibility(View.VISIBLE);
}
}
@@ -217,17 +187,14 @@
+ positiveResult);
}
if (mButtonClicked != DialogInterface.BUTTON_NEGATIVE) {
- String password = null;
- if (mShowPassword) {
- password = getEditText().getText().toString();
+ String password = getEditText().getText().toString();
- // Check if the password is valid.
- if (password == null || password.length() != PW_LENGTH) {
- Toast.makeText(getContext(),
- getContext().getString(R.string.call_barring_right_pwd_number),
- Toast.LENGTH_SHORT).show();
- return;
- }
+ // Check if the password is valid.
+ if (password == null || password.length() != PW_LENGTH) {
+ Toast.makeText(getContext(),
+ getContext().getString(R.string.call_barring_right_pwd_number),
+ Toast.LENGTH_SHORT).show();
+ return;
}
if (DBG) {
@@ -254,11 +221,6 @@
notifyDependencyChange(shouldDisableDependents());
}
- private void setShowPassword() {
- ImsPhone imsPhone = mPhone != null ? (ImsPhone) mPhone.getImsPhone() : null;
- mShowPassword = !(imsPhone != null && imsPhone.isUtEnabled());
- }
-
@Override
public boolean shouldDisableDependents() {
return mIsActivated;
@@ -310,16 +272,6 @@
pref.mTcpListener.onFinished(pref, false);
} else {
pref.mTcpListener.onFinished(pref, true);
- ImsPhone imsPhone = pref.mPhone != null
- ? (ImsPhone) pref.mPhone.getImsPhone() : null;
- if (!pref.mShowPassword && (imsPhone == null || !imsPhone.isUtEnabled())) {
- // Re-enable password when rejected from NW and modem would perform CSFB
- pref.mShowPassword = true;
- if (DBG) {
- Log.d(LOG_TAG,
- "handleGetCallBarringResponse: mShowPassword changed for CSFB");
- }
- }
}
// Unsuccessful query for call barring.
diff --git a/src/com/android/phone/GsmUmtsCallBarringOptions.java b/src/com/android/phone/GsmUmtsCallBarringOptions.java
index 3c9cd84..30e9b5c 100644
--- a/src/com/android/phone/GsmUmtsCallBarringOptions.java
+++ b/src/com/android/phone/GsmUmtsCallBarringOptions.java
@@ -37,7 +37,6 @@
import com.android.internal.telephony.CommandsInterface;
import com.android.internal.telephony.GsmCdmaPhone;
import com.android.internal.telephony.Phone;
-import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.phone.settings.fdn.EditPinPreference;
import java.util.ArrayList;
@@ -75,7 +74,6 @@
private static final String DIALOG_PW_ENTRY_KEY = "dialog_pw_enter_key";
private static final String KEY_STATUS = "toggle";
private static final String PREFERENCE_ENABLED_KEY = "PREFERENCE_ENABLED";
- private static final String PREFERENCE_SHOW_PASSWORD_KEY = "PREFERENCE_SHOW_PASSWORD";
private static final String SAVED_BEFORE_LOAD_COMPLETED_KEY = "PROGRESS_SHOWING";
private CallBarringEditPreference mButtonBAOC;
@@ -141,16 +139,13 @@
return;
}
- String password = null;
- if (mButtonDisableAll.isPasswordShown()) {
- password = mButtonDisableAll.getText();
- // Validate the length of password first, before submitting it to the
- // RIL for CB disable.
- if (!validatePassword(password)) {
- mButtonDisableAll.setText("");
- displayMessage(R.string.call_barring_right_pwd_number);
- return;
- }
+ String password = mButtonDisableAll.getText();
+ // Validate the length of password first, before submitting it to the
+ // RIL for CB disable.
+ if (!validatePassword(password)) {
+ mButtonDisableAll.setText("");
+ displayMessage(R.string.call_barring_right_pwd_number);
+ return;
}
// Submit the disable all request
@@ -417,34 +412,18 @@
mPreferences.add(mButtonBAIC);
mPreferences.add(mButtonBAICr);
- // Find out if password is currently used.
- boolean usePassword = true;
- boolean useDisableaAll = true;
-
- ImsPhone imsPhone = mPhone != null ? (ImsPhone) mPhone.getImsPhone() : null;
- if (imsPhone != null && imsPhone.isUtEnabled()) {
- usePassword = false;
- useDisableaAll = false;
- }
-
// Find out if the sim card is ready.
boolean isSimReady = TelephonyManager.from(this).getSimState(
SubscriptionManager.getSlotIndex(mPhone.getSubId()))
== TelephonyManager.SIM_STATE_READY;
- // Deactivate all option is unavailable when sim card is not ready or Ut is enabled.
- if (isSimReady && useDisableaAll) {
+ // Deactivate all option and Change password option are unavailable
+ // when sim card is not ready.
+ if (isSimReady) {
mButtonDisableAll.setEnabled(true);
- mButtonDisableAll.init(mPhone);
- } else {
- mButtonDisableAll.setEnabled(false);
- }
-
- // Change password option is unavailable when sim card is not ready or when the password is
- // not used.
- if (isSimReady && usePassword) {
mButtonChangePW.setEnabled(true);
} else {
+ mButtonDisableAll.setEnabled(false);
mButtonChangePW.setEnabled(false);
mButtonChangePW.setSummary(R.string.call_barring_change_pwd_description_disabled);
}
@@ -472,8 +451,6 @@
pref.handleCallBarringResult(bundle.getBoolean(KEY_STATUS));
pref.init(this, true, mPhone);
pref.setEnabled(bundle.getBoolean(PREFERENCE_ENABLED_KEY, pref.isEnabled()));
- pref.setInputMethodNeeded(bundle.getBoolean(PREFERENCE_SHOW_PASSWORD_KEY,
- pref.needInputMethod()));
}
}
mPwChangeState = mIcicle.getInt(PW_CHANGE_STATE_KEY);
@@ -513,7 +490,6 @@
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_STATUS, pref.mIsActivated);
bundle.putBoolean(PREFERENCE_ENABLED_KEY, pref.isEnabled());
- bundle.putBoolean(PREFERENCE_SHOW_PASSWORD_KEY, pref.needInputMethod());
outState.putParcelable(pref.getKey(), bundle);
}
outState.putInt(PW_CHANGE_STATE_KEY, mPwChangeState);
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 096d14f..f11da4b 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -4656,6 +4656,27 @@
}
/**
+ * Toggle IMS disable and enable for the framework to reset it. See {@link #enableIms(int)} and
+ * {@link #disableIms(int)}.
+ * @param slotIndex device slot.
+ */
+ public void resetIms(int slotIndex) {
+ enforceModifyPermission();
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ if (mImsResolver == null) {
+ // may happen if the does not support IMS.
+ return;
+ }
+ mImsResolver.disableIms(slotIndex);
+ mImsResolver.enableIms(slotIndex);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
* Enables IMS for the framework. This will trigger IMS registration and ImsFeature capability
* status updates, if not already enabled.
*/
@@ -5129,21 +5150,81 @@
final long identity = Binder.clearCallingIdentity();
try {
- if (DBG) log("setPreferredNetworkType: subId " + subId + " type " + networkType);
- Boolean success = (Boolean) sendRequest(
- CMD_SET_PREFERRED_NETWORK_TYPE, networkType, subId);
- if (DBG) log("setPreferredNetworkType: " + (success ? "ok" : "fail"));
- if (success) {
- Settings.Global.putInt(mApp.getContentResolver(),
- Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType);
- }
- return success;
+ Settings.Global.putInt(mApp.getContentResolver(),
+ Settings.Global.PREFERRED_NETWORK_MODE + subId, networkType);
+ return setPreferredNetworkTypesInternal(subId);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
/**
+ * Get the allowed network types that store in the telephony provider.
+ *
+ * @param subId the id of the subscription.
+ * @return allowedNetworkTypes the allowed network types.
+ */
+ @Override
+ public long getAllowedNetworkTypes(int subId) {
+ TelephonyPermissions
+ .enforeceCallingOrSelfReadPrivilegedPhoneStatePermissionOrCarrierPrivilege(
+ mApp, subId, "getAllowedNetworkTypes");
+
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ return SubscriptionManager.getLongSubscriptionProperty(
+ subId, SubscriptionManager.ALLOWED_NETWORK_TYPES, -1, mApp);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ /**
+ * Set the allowed network types.
+ *
+ * @param subId the id of the subscription.
+ * @param allowedNetworkTypes the allowed network types.
+ * @return true on success; false on any failure.
+ */
+ @Override
+ public boolean setAllowedNetworkTypes(int subId, long allowedNetworkTypes) {
+ TelephonyPermissions.enforceCallingOrSelfModifyPermissionOrCarrierPrivilege(
+ mApp, subId, "setAllowedNetworkTypes");
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ SubscriptionManager.setSubscriptionProperty(subId,
+ SubscriptionManager.ALLOWED_NETWORK_TYPES,
+ String.valueOf(allowedNetworkTypes));
+ return setPreferredNetworkTypesInternal(subId);
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ }
+
+ private boolean setPreferredNetworkTypesInternal(int subId) {
+ long networkTypeBitMask = RadioAccessFamily.getRafFromNetworkType(
+ Settings.Global.getInt(mApp.getContentResolver(),
+ Settings.Global.PREFERRED_NETWORK_MODE + subId,
+ RILConstants.PREFERRED_NETWORK_MODE));
+ long allowedNetworkTypes = SubscriptionManager.getLongSubscriptionProperty(
+ subId, SubscriptionManager.ALLOWED_NETWORK_TYPES, -1, mApp);
+ int networkMode = RadioAccessFamily.getNetworkTypeFromRaf(
+ (int) (networkTypeBitMask & allowedNetworkTypes));
+
+ if (DBG) {
+ log("setPreferredNetworkTypesInternal: subId " + subId
+ + " networkTypes " + networkTypeBitMask
+ + " allowedNetworkTypes " + allowedNetworkTypes
+ + " networkMode " + networkMode);
+ }
+
+ Boolean success = (Boolean) sendRequest(
+ CMD_SET_PREFERRED_NETWORK_TYPE, networkMode, subId);
+ if (DBG) log("setPreferredNetworkTypesInternal: " + (success ? "ok" : "fail"));
+ return success;
+ }
+
+ /**
* Check whether DUN APN is required for tethering with subId.
*
* @param subId the id of the subscription to require tethering.