Merge "Fix 5555408: allow emergency button to be disabled on SIM/PUK unlock screen" into ics-mr1
This commit is contained in:
@@ -25,14 +25,11 @@ import android.content.ContentResolver;
|
||||
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.text.TextUtils;
|
||||
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 @@ public class LockPatternUtils {
|
||||
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 @@ public class LockPatternUtils {
|
||||
* {@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);
|
||||
|
||||
5
core/res/res/values/config.xml
Normal file → Executable file
5
core/res/res/values/config.xml
Normal file → Executable file
@@ -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
|
||||
|
||||
@@ -91,7 +91,7 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
*
|
||||
* @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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
|
||||
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 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
public void onRefreshCarrierInfo(CharSequence plmn, CharSequence spn) {
|
||||
mPlmn = plmn;
|
||||
mSpn = spn;
|
||||
updateCarrierTextWithSimStatus(mSimState);
|
||||
updateCarrierStateWithSimStatus(mSimState);
|
||||
}
|
||||
|
||||
public void onRingerModeChanged(int state) {
|
||||
@@ -602,6 +617,7 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
}
|
||||
|
||||
public void onPhoneStateChanged(int phoneState) {
|
||||
mPhoneState = phoneState;
|
||||
updateEmergencyCallButtonState(phoneState);
|
||||
}
|
||||
|
||||
@@ -618,7 +634,7 @@ class KeyguardStatusViewManager implements OnClickListener {
|
||||
private SimStateCallback mSimStateCallback = new SimStateCallback() {
|
||||
|
||||
public void onSimStateChanged(State simState) {
|
||||
updateCarrierTextWithSimStatus(simState);
|
||||
updateCarrierStateWithSimStatus(simState);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SimPukUnlockScreen extends LinearLayout implements KeyguardScreen,
|
||||
mHeaderText.setSelected(true);
|
||||
|
||||
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
|
||||
lockpatternutils, callback, true);
|
||||
lockpatternutils, callback, false);
|
||||
|
||||
mPinText.setFocusableInTouchMode(true);
|
||||
mPinText.setOnFocusChangeListener(this);
|
||||
|
||||
@@ -100,7 +100,7 @@ public class SimUnlockScreen extends LinearLayout implements KeyguardScreen, Vie
|
||||
mOkButton.setOnClickListener(this);
|
||||
|
||||
mKeyguardStatusViewManager = new KeyguardStatusViewManager(this, updateMonitor,
|
||||
lockpatternutils, callback, true);
|
||||
lockpatternutils, callback, false);
|
||||
|
||||
setFocusableInTouchMode(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user