Add support to pass password in Call barring
- Adding password support for call barring over IMS
Test: Manual
Bug: 112248618
Change-Id: If86291fa3aa74e34fdb715cc4c6d832b5cc32600
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 edff1e3..d54b89b 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);