am 270826a8: Merge "Fix 5555408: allow emergency button to be disabled on SIM/PUK unlock screen" into ics-mr1
* commit '270826a8878b5470d48d93ca3d518ac93860870d':
Fix 5555408: allow emergency button to be disabled on SIM/PUK unlock screen
diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java
index 17b8acf..89f9d4e 100644
--- a/core/java/com/android/internal/widget/LockPatternUtils.java
+++ b/core/java/com/android/internal/widget/LockPatternUtils.java
@@ -25,14 +25,11 @@
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
-import android.hardware.Camera;
-import android.hardware.Camera.CameraInfo;
import android.os.FileObserver;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemClock;
-import android.os.SystemProperties;
import android.os.storage.IMountService;
import android.provider.Settings;
import android.security.KeyStore;
@@ -41,7 +38,6 @@
import android.util.Log;
import android.view.View;
import android.widget.Button;
-import android.widget.TextView;
import java.io.File;
import java.io.FileNotFoundException;
@@ -968,6 +964,11 @@
com.android.internal.R.bool.config_enable_puk_unlock_screen);
}
+ public boolean isEmergencyCallEnabledWhileSimLocked() {
+ return mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enable_emergency_call_while_sim_locked);
+ }
+
/**
* @return A formatted string of the next alarm (for showing on the lock screen),
* or null if there is no next alarm.
@@ -1031,12 +1032,10 @@
* {@link TelephonyManager#CALL_STATE_IDLE}
* {@link TelephonyManager#CALL_STATE_RINGING}
* {@link TelephonyManager#CALL_STATE_OFFHOOK}
- * @param showIfCapable indicates whether the button should be shown if emergency calls are
- * possible on the device
+ * @param shown indicates whether the given screen wants the emergency button to show at all
*/
- public void updateEmergencyCallButtonState(Button button, int phoneState,
- boolean showIfCapable) {
- if (isEmergencyCallCapable() && showIfCapable) {
+ public void updateEmergencyCallButtonState(Button button, int phoneState, boolean shown) {
+ if (isEmergencyCallCapable() && shown) {
button.setVisibility(View.VISIBLE);
} else {
button.setVisibility(View.GONE);
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
old mode 100644
new mode 100755
index 8b07e34..767cafe
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -453,6 +453,11 @@
If unlock screen is disabled, the puk should be unlocked through Emergency Dialer -->
<bool name="config_enable_puk_unlock_screen">true</bool>
+ <!-- Enable emergency call when sim is locked or puk locked. Some countries/carriers do not
+ allow emergency calls to be placed without the IMSI, which is locked in the SIM.
+ If so, this should be set to 'false' in an overlay. -->
+ <bool name="config_enable_emergency_call_while_sim_locked">true</bool>
+
<!-- Control the behavior when the user long presses the home button.
0 - Nothing
1 - Recent apps dialog
diff --git a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
index dafbdcf..a7da96e 100644
--- a/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/KeyguardStatusViewManager.java
@@ -91,7 +91,7 @@
private LockPatternUtils mLockPatternUtils;
private KeyguardUpdateMonitor mUpdateMonitor;
private Button mEmergencyCallButton;
- private boolean mUnlockDisabledDueToSimState;
+ private boolean mEmergencyButtonEnabledBecauseSimLocked;
// Shadowed text values
private CharSequence mCarrierText;
@@ -101,9 +101,10 @@
private CharSequence mOwnerInfoText;
private boolean mShowingStatus;
private KeyguardScreenCallback mCallback;
- private final boolean mShowEmergencyButtonByDefault;
+ private final boolean mEmergencyCallButtonEnabledInScreen;
private CharSequence mPlmn;
private CharSequence mSpn;
+ protected int mPhoneState;
private class TransientTextManager {
private TextView mTextView;
@@ -154,9 +155,17 @@
}
};
+ /**
+ *
+ * @param view the containing view of all widgets
+ * @param updateMonitor the update monitor to use
+ * @param lockPatternUtils lock pattern util object
+ * @param callback used to invoke emergency dialer
+ * @param emergencyButtonEnabledInScreen whether emergency button is enabled by default
+ */
public KeyguardStatusViewManager(View view, KeyguardUpdateMonitor updateMonitor,
LockPatternUtils lockPatternUtils, KeyguardScreenCallback callback,
- boolean showEmergencyButtonByDefault) {
+ boolean emergencyButtonEnabledInScreen) {
if (DEBUG) Log.v(TAG, "KeyguardStatusViewManager()");
mContainer = view;
mDateFormatString = getContext().getString(R.string.full_wday_month_day_no_year);
@@ -171,7 +180,7 @@
mOwnerInfoView = (TextView) findViewById(R.id.propertyOf);
mTransportView = (TransportControlView) findViewById(R.id.transport);
mEmergencyCallButton = (Button) findViewById(R.id.emergencyCallButton);
- mShowEmergencyButtonByDefault = showEmergencyButtonByDefault;
+ mEmergencyCallButtonEnabledInScreen = emergencyButtonEnabledInScreen;
// Hide transport control view until we know we need to show it.
if (mTransportView != null) {
@@ -452,12 +461,12 @@
*
* @param simState
*/
- private void updateCarrierTextWithSimStatus(State simState) {
+ private void updateCarrierStateWithSimStatus(State simState) {
if (DEBUG) Log.d(TAG, "updateCarrierTextWithSimStatus(), simState = " + simState);
CharSequence carrierText = null;
int carrierHelpTextId = 0;
- mUnlockDisabledDueToSimState = false;
+ mEmergencyButtonEnabledBecauseSimLocked = false;
mStatus = getStatusForIccState(simState);
mSimState = simState;
switch (mStatus) {
@@ -479,32 +488,35 @@
case SimPermDisabled:
carrierText = getContext().getText(R.string.lockscreen_missing_sim_message_short);
carrierHelpTextId = R.string.lockscreen_permanent_disabled_sim_instructions;
- mUnlockDisabledDueToSimState = true;
+ mEmergencyButtonEnabledBecauseSimLocked = true;
break;
case SimMissingLocked:
carrierText = makeCarierString(mPlmn,
getContext().getText(R.string.lockscreen_missing_sim_message_short));
carrierHelpTextId = R.string.lockscreen_missing_sim_instructions;
- mUnlockDisabledDueToSimState = true;
+ mEmergencyButtonEnabledBecauseSimLocked = true;
break;
case SimLocked:
carrierText = makeCarierString(mPlmn,
getContext().getText(R.string.lockscreen_sim_locked_message));
+ mEmergencyButtonEnabledBecauseSimLocked = true;
break;
case SimPukLocked:
carrierText = makeCarierString(mPlmn,
getContext().getText(R.string.lockscreen_sim_puk_locked_message));
if (!mLockPatternUtils.isPukUnlockScreenEnable()) {
- mUnlockDisabledDueToSimState = true;
+ // This means we're showing the PUK unlock screen
+ mEmergencyButtonEnabledBecauseSimLocked = true;
}
break;
}
setCarrierText(carrierText);
setCarrierHelpText(carrierHelpTextId);
+ updateEmergencyCallButtonState(mPhoneState);
}
private View findViewById(int id) {
@@ -569,9 +581,12 @@
private void updateEmergencyCallButtonState(int phoneState) {
if (mEmergencyCallButton != null) {
- boolean showIfCapable = mShowEmergencyButtonByDefault || mUnlockDisabledDueToSimState;
+ boolean enabledBecauseSimLocked =
+ mLockPatternUtils.isEmergencyCallEnabledWhileSimLocked()
+ && mEmergencyButtonEnabledBecauseSimLocked;
+ boolean shown = mEmergencyCallButtonEnabledInScreen || enabledBecauseSimLocked;
mLockPatternUtils.updateEmergencyCallButtonState(mEmergencyCallButton,
- phoneState, showIfCapable);
+ phoneState, shown);
}
}
@@ -594,7 +609,7 @@
public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
mPlmn = plmn;
mSpn = spn;
- updateCarrierTextWithSimStatus(mSimState);
+ updateCarrierStateWithSimStatus(mSimState);
}
public void onRingerModeChanged(int state) {
@@ -602,6 +617,7 @@
}
public void onPhoneStateChanged(int phoneState) {
+ mPhoneState = phoneState;
updateEmergencyCallButtonState(phoneState);
}
@@ -618,7 +634,7 @@
private SimStateCallback mSimStateCallback = new SimStateCallback() {
public void onSimStateChanged(State simState) {
- updateCarrierTextWithSimStatus(simState);
+ updateCarrierStateWithSimStatus(simState);
}
};
diff --git a/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
index 6acd1c5..47a7157 100644
--- a/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimPukUnlockScreen.java
@@ -106,7 +106,7 @@
mHeaderText.setSelected(true);
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
- lockpatternutils, callback, true);
+ lockpatternutils, callback, false);
mPinText.setFocusableInTouchMode(true);
mPinText.setOnFocusChangeListener(this);
diff --git a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
index 184748a..99e1ce1 100644
--- a/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
+++ b/policy/src/com/android/internal/policy/impl/SimUnlockScreen.java
@@ -100,7 +100,7 @@
mOkButton.setOnClickListener(this);
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
- lockpatternutils, callback, true);
+ lockpatternutils, callback, false);
setFocusableInTouchMode(true);
}