summaryrefslogtreecommitdiffstats
path: root/packages/Keyguard
diff options
context:
space:
mode:
authorAdrian Roos <roosa@google.com>2015-01-15 23:20:20 +0100
committerAdrian Roos <roosa@google.com>2015-02-03 19:12:23 +0100
commitc2e01683b34029729262e2fb346ceea4bfe4b4b6 (patch)
tree0c12607980e306a1b78e11d5c23dd2d2e90df910 /packages/Keyguard
parent5656036dd779fd81d89b755b871e85fa6d959c4f (diff)
downloadframeworks_base-c2e01683b34029729262e2fb346ceea4bfe4b4b6.zip
frameworks_base-c2e01683b34029729262e2fb346ceea4bfe4b4b6.tar.gz
frameworks_base-c2e01683b34029729262e2fb346ceea4bfe4b4b6.tar.bz2
Remove UI code from LockPatternUtils
Bug: 18931518 Change-Id: I951166f675731ec7a2bc51585e0a51e0cd92611d
Diffstat (limited to 'packages/Keyguard')
-rw-r--r--packages/Keyguard/src/com/android/keyguard/CarrierText.java8
-rw-r--r--packages/Keyguard/src/com/android/keyguard/EmergencyButton.java70
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java68
3 files changed, 92 insertions, 54 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/CarrierText.java b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
index d8b0c71..c023dc6 100644
--- a/packages/Keyguard/src/com/android/keyguard/CarrierText.java
+++ b/packages/Keyguard/src/com/android/keyguard/CarrierText.java
@@ -41,7 +41,8 @@ public class CarrierText extends TextView {
private static CharSequence mSeparator;
- private LockPatternUtils mLockPatternUtils;
+ private final boolean mIsEmergencyCallCapable;
+
private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
private KeyguardUpdateMonitorCallback mCallback = new KeyguardUpdateMonitorCallback() {
@@ -78,7 +79,8 @@ public class CarrierText extends TextView {
public CarrierText(Context context, AttributeSet attrs) {
super(context, attrs);
- mLockPatternUtils = new LockPatternUtils(mContext);
+ mIsEmergencyCallCapable = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_voice_capable);
boolean useAllCaps;
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs, R.styleable.CarrierText, 0, 0);
@@ -222,7 +224,7 @@ public class CarrierText extends TextView {
*/
private CharSequence makeCarrierStringOnEmergencyCapable(
CharSequence simMessage, CharSequence emergencyCallMessage) {
- if (mLockPatternUtils.isEmergencyCallCapable()) {
+ if (mIsEmergencyCallCapable) {
return concatenate(simMessage, emergencyCallMessage);
}
return simMessage;
diff --git a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
index 4a9440c..3627e3e 100644
--- a/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
+++ b/packages/Keyguard/src/com/android/keyguard/EmergencyButton.java
@@ -21,7 +21,7 @@ import android.content.Intent;
import android.os.PowerManager;
import android.os.SystemClock;
import android.os.UserHandle;
-import android.telephony.TelephonyManager;
+import android.telecom.TelecomManager;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
@@ -59,12 +59,19 @@ public class EmergencyButton extends Button {
private PowerManager mPowerManager;
private EmergencyButtonCallback mEmergencyButtonCallback;
+ private final boolean mIsVoiceCapable;
+ private final boolean mEnableEmergencyCallWhileSimLocked;
+
public EmergencyButton(Context context) {
this(context, null);
}
public EmergencyButton(Context context, AttributeSet attrs) {
super(context, attrs);
+ mIsVoiceCapable = context.getResources().getBoolean(
+ com.android.internal.R.bool.config_voice_capable);
+ mEnableEmergencyCallWhileSimLocked = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enable_emergency_call_while_sim_locked);
}
@Override
@@ -99,8 +106,8 @@ public class EmergencyButton extends Button {
// TODO: implement a shorter timeout once new PowerManager API is ready.
// should be the equivalent to the old userActivity(EMERGENCY_CALL_TIMEOUT)
mPowerManager.userActivity(SystemClock.uptimeMillis(), true);
- if (mLockPatternUtils.isInCall()) {
- mLockPatternUtils.resumeCall();
+ if (isInCall()) {
+ resumeCall();
if (mEmergencyButtonCallback != null) {
mEmergencyButtonCallback.onEmergencyButtonClickedWhenInCall();
}
@@ -116,24 +123,57 @@ public class EmergencyButton extends Button {
}
private void updateEmergencyCallButton() {
- boolean enabled = false;
- if (mLockPatternUtils.isInCall()) {
- enabled = true; // always show "return to call" if phone is off-hook
- } else if (mLockPatternUtils.isEmergencyCallCapable()) {
- final boolean simLocked = KeyguardUpdateMonitor.getInstance(mContext).isSimPinVoiceSecure();
- if (simLocked) {
- // Some countries can't handle emergency calls while SIM is locked.
- enabled = mLockPatternUtils.isEmergencyCallEnabledWhileSimLocked();
+ boolean visible = false;
+ if (mIsVoiceCapable) {
+ // Emergency calling requires voice capability.
+ if (isInCall()) {
+ visible = true; // always show "return to call" if phone is off-hook
+ } else {
+ final boolean simLocked = KeyguardUpdateMonitor.getInstance(mContext)
+ .isSimPinVoiceSecure();
+ if (simLocked) {
+ // Some countries can't handle emergency calls while SIM is locked.
+ visible = mEnableEmergencyCallWhileSimLocked;
+ } else {
+ // Only show if there is a secure screen (pin/pattern/SIM pin/SIM puk);
+ visible = mLockPatternUtils.isSecure();
+ }
+ }
+ }
+ if (visible) {
+ setVisibility(View.VISIBLE);
+
+ int textId;
+ if (isInCall()) {
+ textId = com.android.internal.R.string.lockscreen_return_to_call;
} else {
- // True if we need to show a secure screen (pin/pattern/SIM pin/SIM puk);
- // hides emergency button on "Slide" screen if device is not secure.
- enabled = mLockPatternUtils.isSecure();
+ textId = com.android.internal.R.string.lockscreen_emergency_call;
}
+ setText(textId);
+ } else {
+ setVisibility(View.GONE);
}
- mLockPatternUtils.updateEmergencyCallButtonState(this, enabled, false);
}
public void setCallback(EmergencyButtonCallback callback) {
mEmergencyButtonCallback = callback;
}
+
+ /**
+ * Resumes a call in progress.
+ */
+ private void resumeCall() {
+ getTelecommManager().showInCallScreen(false);
+ }
+
+ /**
+ * @return {@code true} if there is a call currently in progress.
+ */
+ private boolean isInCall() {
+ return getTelecommManager().isInCall();
+ }
+
+ private TelecomManager getTelecommManager() {
+ return (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+ }
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
index 107f417..3eb31ad 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardSecurityModel.java
@@ -17,20 +17,16 @@ package com.android.keyguard;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
-import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
import com.android.internal.telephony.IccCardConstants;
import com.android.internal.widget.LockPatternUtils;
-import java.util.List;
-
public class KeyguardSecurityModel {
/**
- * The different types of security available for {@link Mode#UnlockScreen}.
- * @see com.android.internal.policy.impl.LockPatternKeyguardView#getUnlockMode()
+ * The different types of security available.
+ * @see KeyguardSecurityContainer#showSecurityScreen
*/
public enum SecurityMode {
Invalid, // NULL state
@@ -42,12 +38,16 @@ public class KeyguardSecurityModel {
SimPuk // Unlock by entering a sim puk
}
- private Context mContext;
+ private final Context mContext;
+ private final boolean mIsPukScreenAvailable;
+
private LockPatternUtils mLockPatternUtils;
KeyguardSecurityModel(Context context) {
mContext = context;
mLockPatternUtils = new LockPatternUtils(context);
+ mIsPukScreenAvailable = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_enable_puk_unlock_screen);
}
void setLockPatternUtils(LockPatternUtils utils) {
@@ -56,39 +56,35 @@ public class KeyguardSecurityModel {
SecurityMode getSecurityMode() {
KeyguardUpdateMonitor monitor = KeyguardUpdateMonitor.getInstance(mContext);
- SecurityMode mode = SecurityMode.None;
+
if (SubscriptionManager.isValidSubscriptionId(
monitor.getNextSubIdForState(IccCardConstants.State.PIN_REQUIRED))) {
- mode = SecurityMode.SimPin;
- } else if (SubscriptionManager.isValidSubscriptionId(
- monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED))
- && mLockPatternUtils.isPukUnlockScreenEnable()) {
- mode = SecurityMode.SimPuk;
- } else {
- final int security = mLockPatternUtils.getKeyguardStoredPasswordQuality();
- switch (security) {
- case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
- case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
- mode = mLockPatternUtils.isLockPasswordEnabled() ?
- SecurityMode.PIN : SecurityMode.None;
- break;
- case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
- case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
- case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
- mode = mLockPatternUtils.isLockPasswordEnabled() ?
- SecurityMode.Password : SecurityMode.None;
- break;
+ return SecurityMode.SimPin;
+ }
+
+ if (mIsPukScreenAvailable && SubscriptionManager.isValidSubscriptionId(
+ monitor.getNextSubIdForState(IccCardConstants.State.PUK_REQUIRED))) {
+ return SecurityMode.SimPuk;
+ }
+
+ final int security = mLockPatternUtils.getActivePasswordQuality();
+ switch (security) {
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX:
+ return SecurityMode.PIN;
+
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHABETIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_ALPHANUMERIC:
+ case DevicePolicyManager.PASSWORD_QUALITY_COMPLEX:
+ return SecurityMode.Password;
- case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
- case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED:
- mode = mLockPatternUtils.isLockPatternEnabled() ?
- SecurityMode.Pattern : SecurityMode.None;
- break;
+ case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING:
+ return SecurityMode.Pattern;
+ case DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED:
+ return SecurityMode.None;
- default:
- throw new IllegalStateException("Unknown security quality:" + security);
- }
+ default:
+ throw new IllegalStateException("Unknown security quality:" + security);
}
- return mode;
}
}