Revert^2 "9/N Clean Up Keyguard Class Structure"
b00c929394
Change-Id: I42d17262a789d2eb106a924b442a9d3debcc35e4
This commit is contained in:
@@ -17,13 +17,11 @@
|
||||
package com.android.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockscreenCredential;
|
||||
import com.android.systemui.R;
|
||||
|
||||
@@ -31,8 +29,6 @@ import com.android.systemui.R;
|
||||
* Base class for PIN and password unlock screens.
|
||||
*/
|
||||
public abstract class KeyguardAbsKeyInputView extends KeyguardInputView {
|
||||
protected KeyguardSecurityCallback mCallback;
|
||||
protected SecurityMessageDisplay mSecurityMessageDisplay;
|
||||
protected View mEcaView;
|
||||
protected boolean mEnableHaptics;
|
||||
|
||||
@@ -53,19 +49,6 @@ public abstract class KeyguardAbsKeyInputView extends KeyguardInputView {
|
||||
mEnableHaptics = enableHaptics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
protected abstract int getPasswordTextViewId();
|
||||
protected abstract void resetState();
|
||||
|
||||
@@ -93,29 +76,6 @@ public abstract class KeyguardAbsKeyInputView extends KeyguardInputView {
|
||||
return mKeyDownListener != null && mKeyDownListener.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
if (colorState != null) {
|
||||
mSecurityMessageDisplay.setNextMessageColor(colorState);
|
||||
}
|
||||
mSecurityMessageDisplay.setMessage(message);
|
||||
}
|
||||
|
||||
protected abstract int getPromptReasonStringRes(int reason);
|
||||
|
||||
// Cause a VIRTUAL_KEY vibration
|
||||
@@ -127,11 +87,6 @@ public abstract class KeyguardAbsKeyInputView extends KeyguardInputView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setKeyDownListener(KeyDownListener keyDownListener) {
|
||||
mKeyDownListener = keyDownListener;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL;
|
||||
import static com.android.internal.util.LatencyTracker.ACTION_CHECK_CREDENTIAL_UNLOCKED;
|
||||
import static com.android.keyguard.KeyguardAbsKeyInputView.MINIMUM_PASSWORD_LENGTH_BEFORE_REPORT;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.SystemClock;
|
||||
@@ -38,7 +39,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
extends KeyguardInputViewController<T> {
|
||||
private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
|
||||
private final LockPatternUtils mLockPatternUtils;
|
||||
protected final KeyguardSecurityCallback mKeyguardSecurityCallback;
|
||||
private final LatencyTracker mLatencyTracker;
|
||||
private CountDownTimer mCountdownTimer;
|
||||
protected KeyguardMessageAreaController mMessageAreaController;
|
||||
@@ -59,7 +59,7 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
private final EmergencyButtonCallback mEmergencyButtonCallback = new EmergencyButtonCallback() {
|
||||
@Override
|
||||
public void onEmergencyButtonClickedWhenInCall() {
|
||||
mKeyguardSecurityCallback.reset();
|
||||
getKeyguardSecurityCallback().reset();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -73,7 +73,6 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
super(view, securityMode, keyguardSecurityCallback);
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
mLockPatternUtils = lockPatternUtils;
|
||||
mKeyguardSecurityCallback = keyguardSecurityCallback;
|
||||
mLatencyTracker = latencyTracker;
|
||||
KeyguardMessageArea kma = KeyguardMessageArea.findSecurityMessageDisplay(mView);
|
||||
mMessageAreaController = messageAreaControllerFactory.create(kma);
|
||||
@@ -112,6 +111,19 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
if (colorState != null) {
|
||||
mMessageAreaController.setNextMessageColor(colorState);
|
||||
}
|
||||
mMessageAreaController.setMessage(message);
|
||||
}
|
||||
|
||||
// Allow subclasses to override this behavior
|
||||
protected boolean shouldLockout(long deadline) {
|
||||
return deadline != 0;
|
||||
@@ -144,14 +156,14 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
void onPasswordChecked(int userId, boolean matched, int timeoutMs, boolean isValidPassword) {
|
||||
boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId;
|
||||
if (matched) {
|
||||
mKeyguardSecurityCallback.reportUnlockAttempt(userId, true, 0);
|
||||
getKeyguardSecurityCallback().reportUnlockAttempt(userId, true, 0);
|
||||
if (dismissKeyguard) {
|
||||
mDismissing = true;
|
||||
mKeyguardSecurityCallback.dismiss(true, userId);
|
||||
getKeyguardSecurityCallback().dismiss(true, userId);
|
||||
}
|
||||
} else {
|
||||
if (isValidPassword) {
|
||||
mKeyguardSecurityCallback.reportUnlockAttempt(userId, false, timeoutMs);
|
||||
getKeyguardSecurityCallback().reportUnlockAttempt(userId, false, timeoutMs);
|
||||
if (timeoutMs > 0) {
|
||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||
userId, timeoutMs);
|
||||
@@ -236,8 +248,8 @@ public abstract class KeyguardAbsKeyInputViewController<T extends KeyguardAbsKey
|
||||
}
|
||||
|
||||
protected void onUserInput() {
|
||||
mKeyguardSecurityCallback.userActivity();
|
||||
mKeyguardSecurityCallback.onUserInput();
|
||||
getKeyguardSecurityCallback().userActivity();
|
||||
getKeyguardSecurityCallback().onUserInput();
|
||||
mMessageAreaController.setMessage("");
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.android.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -25,7 +26,7 @@ import androidx.annotation.Nullable;
|
||||
/**
|
||||
* A Base class for all Keyguard password/pattern/pin related inputs.
|
||||
*/
|
||||
public abstract class KeyguardInputView extends LinearLayout implements KeyguardSecurityView {
|
||||
public abstract class KeyguardInputView extends LinearLayout {
|
||||
|
||||
public KeyguardInputView(Context context) {
|
||||
super(context);
|
||||
@@ -39,4 +40,16 @@ public abstract class KeyguardInputView extends LinearLayout implements Keyguard
|
||||
public KeyguardInputView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
abstract CharSequence getTitle();
|
||||
|
||||
boolean disallowInterceptTouch(MotionEvent event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void startAppearAnimation() {}
|
||||
|
||||
boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.keyguard;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.android.internal.util.LatencyTracker;
|
||||
@@ -37,18 +36,38 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
extends ViewController<T> implements KeyguardSecurityView {
|
||||
|
||||
private final SecurityMode mSecurityMode;
|
||||
private final KeyguardSecurityCallback mKeyguardSecurityCallback;
|
||||
private boolean mPaused;
|
||||
|
||||
|
||||
// The following is used to ignore callbacks from SecurityViews that are no longer current
|
||||
// (e.g. face unlock). This avoids unwanted asynchronous events from messing with the
|
||||
// state for the current security method.
|
||||
private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback() {
|
||||
@Override
|
||||
public void userActivity() { }
|
||||
@Override
|
||||
public void reportUnlockAttempt(int userId, boolean success, int timeoutMs) { }
|
||||
@Override
|
||||
public boolean isVerifyUnlockOnly() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void dismiss(boolean securityVerified, int targetUserId) { }
|
||||
@Override
|
||||
public void dismiss(boolean authenticated, int targetId,
|
||||
boolean bypassSecondaryLockScreen) { }
|
||||
@Override
|
||||
public void onUserInput() { }
|
||||
@Override
|
||||
public void reset() {}
|
||||
};
|
||||
|
||||
protected KeyguardInputViewController(T view, SecurityMode securityMode,
|
||||
KeyguardSecurityCallback keyguardSecurityCallback) {
|
||||
super(view);
|
||||
mSecurityMode = securityMode;
|
||||
mView.setKeyguardCallback(keyguardSecurityCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
mView.reset();
|
||||
mKeyguardSecurityCallback = keyguardSecurityCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -63,63 +82,40 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
return mSecurityMode;
|
||||
}
|
||||
|
||||
protected KeyguardSecurityCallback getKeyguardSecurityCallback() {
|
||||
if (mPaused) {
|
||||
return mNullCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
mView.setKeyguardCallback(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
mView.setLockPatternUtils(utils);
|
||||
return mKeyguardSecurityCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
mView.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mView.onPause();
|
||||
mPaused = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
mView.onResume(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return mView.needsInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mView.getCallback();
|
||||
mPaused = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
mView.showPromptReason(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
mView.showMessage(message, colorState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
mView.showUsabilityHint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
mView.startAppearAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return mView.startDisappearAnimation(finishRunnable);
|
||||
}
|
||||
@@ -129,16 +125,6 @@ public abstract class KeyguardInputViewController<T extends KeyguardInputView>
|
||||
return mView.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disallowInterceptTouch(MotionEvent event) {
|
||||
return mView.disallowInterceptTouch(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartingToHide() {
|
||||
mView.onStartingToHide();
|
||||
}
|
||||
|
||||
/** Finds the index of this view in the suppplied parent view. */
|
||||
public int getIndexIn(KeyguardSecurityViewFlipper view) {
|
||||
return view.indexOfChild(mView);
|
||||
|
||||
@@ -103,28 +103,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
new View[]{
|
||||
null, mEcaView, null
|
||||
}};
|
||||
|
||||
View cancelBtn = findViewById(R.id.cancel_button);
|
||||
if (cancelBtn != null) {
|
||||
cancelBtn.setOnClickListener(view -> {
|
||||
mCallback.reset();
|
||||
mCallback.onCancelClicked();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,11 +126,6 @@ public class KeyguardPINView extends KeyguardPinBasedInputView {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(final Runnable finishRunnable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startDisappearAnimation(boolean needsSlowUnlockTransition,
|
||||
final Runnable finishRunnable) {
|
||||
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_DEVICE_ADMIN;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_NONE;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
@@ -30,8 +37,7 @@ import com.android.systemui.R;
|
||||
* Displays an alphanumeric (latin-1) key entry for the user to enter
|
||||
* an unlock password
|
||||
*/
|
||||
public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
implements KeyguardSecurityView {
|
||||
public class KeyguardPasswordView extends KeyguardAbsKeyInputView {
|
||||
|
||||
private final int mDisappearYTranslation;
|
||||
|
||||
@@ -68,21 +74,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
return R.id.passwordEntry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getPromptReasonStringRes(int reason) {
|
||||
switch (reason) {
|
||||
@@ -138,10 +129,6 @@ public class KeyguardPasswordView extends KeyguardAbsKeyInputView
|
||||
mPasswordEntryDisabler.setInputEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWrongPasswordStringId() {
|
||||
return R.string.kg_wrong_password;
|
||||
|
||||
@@ -155,6 +155,11 @@ public class KeyguardPasswordViewController
|
||||
mPasswordEntry.setOnEditorActionListener(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetState() {
|
||||
mPasswordEntry.setTextOperationUser(UserHandle.of(KeyguardUpdateMonitor.getCurrentUser()));
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package com.android.keyguard;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.graphics.Rect;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
@@ -27,7 +26,6 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.internal.widget.LockPatternView;
|
||||
import com.android.settingslib.animation.AppearAnimationCreator;
|
||||
import com.android.settingslib.animation.AppearAnimationUtils;
|
||||
@@ -58,7 +56,6 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
private final Rect mLockPatternScreenBounds = new Rect();
|
||||
|
||||
private LockPatternView mLockPatternView;
|
||||
private KeyguardSecurityCallback mCallback;
|
||||
|
||||
/**
|
||||
* Keeps track of the last time we poked the wake lock during dispatching of the touch event.
|
||||
@@ -71,7 +68,6 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
KeyguardMessageArea mSecurityMessageDisplay;
|
||||
private View mEcaView;
|
||||
private ViewGroup mContainer;
|
||||
private int mDisappearYTranslation;
|
||||
|
||||
public KeyguardPatternView(Context context) {
|
||||
this(context, null);
|
||||
@@ -91,17 +87,6 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
(long) (125 * DISAPPEAR_MULTIPLIER_LOCKED), 1.2f /* translationScale */,
|
||||
0.6f /* delayScale */, AnimationUtils.loadInterpolator(
|
||||
mContext, android.R.interpolator.fast_out_linear_in));
|
||||
mDisappearYTranslation = getResources().getDimensionPixelSize(
|
||||
R.dimen.disappear_y_translation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
mCallback = callback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -148,46 +133,11 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disallowInterceptTouch(MotionEvent event) {
|
||||
boolean disallowInterceptTouch(MotionEvent event) {
|
||||
return !mLockPatternView.isEmpty()
|
||||
|| mLockPatternScreenBounds.contains((int) event.getRawX(), (int) event.getRawY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
enableClipping(false);
|
||||
setAlpha(1f);
|
||||
@@ -196,12 +146,7 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
0, mAppearAnimationUtils.getInterpolator());
|
||||
mAppearAnimationUtils.startAnimation2d(
|
||||
mLockPatternView.getCellStates(),
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
enableClipping(true);
|
||||
}
|
||||
},
|
||||
() -> enableClipping(true),
|
||||
this);
|
||||
if (!TextUtils.isEmpty(mSecurityMessageDisplay.getText())) {
|
||||
mAppearAnimationUtils.createAnimation(mSecurityMessageDisplay, 0,
|
||||
@@ -213,15 +158,6 @@ public class KeyguardPatternView extends KeyguardInputView
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #startDisappearAnimation(boolean, Runnable)}
|
||||
*/
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
// TODO(b/166448040): remove this when possible
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean startDisappearAnimation(boolean needsSlowUnlockTransition,
|
||||
final Runnable finishRunnable) {
|
||||
float durationMultiplier = needsSlowUnlockTransition ? DISAPPEAR_MULTIPLIER_LOCKED : 1f;
|
||||
|
||||
@@ -54,13 +54,12 @@ public class KeyguardPatternViewController
|
||||
private KeyguardMessageAreaController mMessageAreaController;
|
||||
private LockPatternView mLockPatternView;
|
||||
private CountDownTimer mCountdownTimer;
|
||||
private KeyguardSecurityCallback mCallback;
|
||||
private AsyncTask<?, ?, ?> mPendingLockCheck;
|
||||
|
||||
private EmergencyButtonCallback mEmergencyButtonCallback = new EmergencyButtonCallback() {
|
||||
@Override
|
||||
public void onEmergencyButtonClickedWhenInCall() {
|
||||
mCallback.reset();
|
||||
getKeyguardSecurityCallback().reset();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -88,8 +87,8 @@ public class KeyguardPatternViewController
|
||||
|
||||
@Override
|
||||
public void onPatternCellAdded(List<Cell> pattern) {
|
||||
mCallback.userActivity();
|
||||
mCallback.onUserInput();
|
||||
getKeyguardSecurityCallback().userActivity();
|
||||
getKeyguardSecurityCallback().onUserInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -141,8 +140,8 @@ public class KeyguardPatternViewController
|
||||
}
|
||||
});
|
||||
if (pattern.size() > MIN_PATTERN_BEFORE_POKE_WAKELOCK) {
|
||||
mCallback.userActivity();
|
||||
mCallback.onUserInput();
|
||||
getKeyguardSecurityCallback().userActivity();
|
||||
getKeyguardSecurityCallback().onUserInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,15 +149,15 @@ public class KeyguardPatternViewController
|
||||
boolean isValidPattern) {
|
||||
boolean dismissKeyguard = KeyguardUpdateMonitor.getCurrentUser() == userId;
|
||||
if (matched) {
|
||||
mCallback.reportUnlockAttempt(userId, true, 0);
|
||||
getKeyguardSecurityCallback().reportUnlockAttempt(userId, true, 0);
|
||||
if (dismissKeyguard) {
|
||||
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Correct);
|
||||
mCallback.dismiss(true, userId);
|
||||
getKeyguardSecurityCallback().dismiss(true, userId);
|
||||
}
|
||||
} else {
|
||||
mLockPatternView.setDisplayMode(LockPatternView.DisplayMode.Wrong);
|
||||
if (isValidPattern) {
|
||||
mCallback.reportUnlockAttempt(userId, false, timeoutMs);
|
||||
getKeyguardSecurityCallback().reportUnlockAttempt(userId, false, timeoutMs);
|
||||
if (timeoutMs > 0) {
|
||||
long deadline = mLockPatternUtils.setLockoutAttemptDeadline(
|
||||
userId, timeoutMs);
|
||||
@@ -213,8 +212,8 @@ public class KeyguardPatternViewController
|
||||
View cancelBtn = mView.findViewById(R.id.cancel_button);
|
||||
if (cancelBtn != null) {
|
||||
cancelBtn.setOnClickListener(view -> {
|
||||
mCallback.reset();
|
||||
mCallback.onCancelClicked();
|
||||
getKeyguardSecurityCallback().reset();
|
||||
getKeyguardSecurityCallback().onCancelClicked();
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -269,8 +268,8 @@ public class KeyguardPatternViewController
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
mCallback = callback;
|
||||
public boolean needsInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -16,6 +16,13 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_DEVICE_ADMIN;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_NONE;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_PREPARE_FOR_UPDATE;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_RESTART;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_TIMEOUT;
|
||||
import static com.android.keyguard.KeyguardSecurityView.PROMPT_REASON_USER_REQUEST;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.android.internal.util.LatencyTracker;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.systemui.R;
|
||||
|
||||
public class KeyguardPinViewController
|
||||
extends KeyguardPinBasedInputViewController<KeyguardPINView> {
|
||||
@@ -36,6 +39,19 @@ public class KeyguardPinViewController
|
||||
mKeyguardUpdateMonitor = keyguardUpdateMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onViewAttached() {
|
||||
super.onViewAttached();
|
||||
|
||||
View cancelBtn = mView.findViewById(R.id.cancel_button);
|
||||
if (cancelBtn != null) {
|
||||
cancelBtn.setOnClickListener(view -> {
|
||||
getKeyguardSecurityCallback().reset();
|
||||
getKeyguardSecurityCallback().onCancelClicked();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
void resetState() {
|
||||
super.resetState();
|
||||
|
||||
@@ -395,10 +395,6 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
||||
mSecurityViewFlipper = findViewById(R.id.view_flipper);
|
||||
}
|
||||
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
mSecurityViewFlipper.setLockPatternUtils(utils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WindowInsets onApplyWindowInsets(WindowInsets insets) {
|
||||
|
||||
@@ -498,16 +494,7 @@ public class KeyguardSecurityContainer extends FrameLayout {
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
mSecurityViewFlipper.reset();
|
||||
mDisappearAnimRunning = false;
|
||||
}
|
||||
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mSecurityViewFlipper.getCallback();
|
||||
}
|
||||
|
||||
public void showUsabilityHint() {
|
||||
mSecurityViewFlipper.showUsabilityHint();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ import com.android.systemui.shared.system.SysUiStatsLog;
|
||||
import com.android.systemui.statusbar.policy.KeyguardStateController;
|
||||
import com.android.systemui.util.ViewController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** Controller for {@link KeyguardSecurityContainer} */
|
||||
@@ -71,7 +68,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
private final UiEventLogger mUiEventLogger;
|
||||
private final KeyguardStateController mKeyguardStateController;
|
||||
private final KeyguardSecurityViewFlipperController mSecurityViewFlipperController;
|
||||
private final List<KeyguardInputViewController> mChildren = new ArrayList<>();
|
||||
|
||||
private SecurityCallback mSecurityCallback;
|
||||
private SecurityMode mCurrentSecurityMode = SecurityMode.Invalid;
|
||||
@@ -137,28 +133,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
}
|
||||
};
|
||||
|
||||
// The following is used to ignore callbacks from SecurityViews that are no longer current
|
||||
// (e.g. face unlock). This avoids unwanted asynchronous events from messing with the
|
||||
// state for the current security method.
|
||||
private KeyguardSecurityCallback mNullCallback = new KeyguardSecurityCallback() {
|
||||
@Override
|
||||
public void userActivity() { }
|
||||
@Override
|
||||
public void reportUnlockAttempt(int userId, boolean success, int timeoutMs) { }
|
||||
@Override
|
||||
public boolean isVerifyUnlockOnly() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void dismiss(boolean securityVerified, int targetUserId) { }
|
||||
@Override
|
||||
public void dismiss(boolean authenticated, int targetId,
|
||||
boolean bypassSecondaryLockScreen) { }
|
||||
@Override
|
||||
public void onUserInput() { }
|
||||
@Override
|
||||
public void reset() {}
|
||||
};
|
||||
|
||||
private SwipeListener mSwipeListener = new SwipeListener() {
|
||||
@Override
|
||||
@@ -189,7 +163,6 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
mUiEventLogger = uiEventLogger;
|
||||
mKeyguardStateController = keyguardStateController;
|
||||
mSecurityViewFlipperController = securityViewFlipperController;
|
||||
view.setLockPatternUtils(mLockPatternUtils);
|
||||
mAdminSecondaryLockScreenController = adminSecondaryLockScreenControllerFactory.create(
|
||||
mKeyguardSecurityCallback);
|
||||
}
|
||||
@@ -213,7 +186,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
public void onPause() {
|
||||
mAdminSecondaryLockScreenController.hide();
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecurityMode).onPause();
|
||||
getCurrentSecurityController().onPause();
|
||||
}
|
||||
mView.onPause();
|
||||
}
|
||||
@@ -237,13 +210,13 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
if (reason != PROMPT_REASON_NONE) {
|
||||
Log.i(TAG, "Strong auth required, reason: " + reason);
|
||||
}
|
||||
getSecurityView(mCurrentSecurityMode).showPromptReason(reason);
|
||||
getCurrentSecurityController().showPromptReason(reason);
|
||||
}
|
||||
}
|
||||
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecurityMode).showMessage(message, colorState);
|
||||
getCurrentSecurityController().showMessage(message, colorState);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,7 +240,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecurityMode).onResume(reason);
|
||||
getCurrentSecurityController().onResume(reason);
|
||||
}
|
||||
mView.onResume(
|
||||
mSecurityModel.getSecurityMode(KeyguardUpdateMonitor.getCurrentUser()),
|
||||
@@ -276,7 +249,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
|
||||
public void startAppearAnimation() {
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecurityMode).startAppearAnimation();
|
||||
getCurrentSecurityController().startAppearAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,8 +257,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
mView.startDisappearAnimation(getCurrentSecurityMode());
|
||||
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
return getSecurityView(mCurrentSecurityMode).startDisappearAnimation(
|
||||
onFinishRunnable);
|
||||
return getCurrentSecurityController().startDisappearAnimation(onFinishRunnable);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -293,7 +265,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
|
||||
public void onStartingToHide() {
|
||||
if (mCurrentSecurityMode != SecurityMode.None) {
|
||||
getSecurityView(mCurrentSecurityMode).onStartingToHide();
|
||||
getCurrentSecurityController().onStartingToHide();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -390,7 +362,7 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
}
|
||||
|
||||
public boolean needsInput() {
|
||||
return mSecurityViewFlipperController.needsInput();
|
||||
return getCurrentSecurityController().needsInput();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,21 +379,19 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
return;
|
||||
}
|
||||
|
||||
KeyguardInputViewController oldView = getSecurityView(mCurrentSecurityMode);
|
||||
KeyguardInputViewController newView = getSecurityView(securityMode);
|
||||
KeyguardInputViewController<KeyguardInputView> oldView = getCurrentSecurityController();
|
||||
|
||||
// Emulate Activity life cycle
|
||||
if (oldView != null) {
|
||||
oldView.onPause();
|
||||
oldView.setKeyguardCallback(mNullCallback); // ignore requests from old view
|
||||
}
|
||||
|
||||
KeyguardInputViewController<KeyguardInputView> newView = changeSecurityMode(securityMode);
|
||||
if (newView != null) {
|
||||
newView.onResume(KeyguardSecurityView.VIEW_REVEALED);
|
||||
newView.setKeyguardCallback(mKeyguardSecurityCallback);
|
||||
mSecurityViewFlipperController.show(newView);
|
||||
}
|
||||
|
||||
mCurrentSecurityMode = securityMode;
|
||||
mSecurityCallback.onSecurityModeChanged(
|
||||
securityMode, newView != null && newView.needsInput());
|
||||
}
|
||||
@@ -470,28 +440,14 @@ public class KeyguardSecurityContainerController extends ViewController<Keyguard
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
// no-op. This should never be reset.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
// We already have one of these.
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mView.getCallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
mView.showUsabilityHint();
|
||||
}
|
||||
|
||||
private KeyguardInputViewController getSecurityView(SecurityMode securityMode) {
|
||||
private KeyguardInputViewController<KeyguardInputView> getCurrentSecurityController() {
|
||||
return mSecurityViewFlipperController
|
||||
.getSecurityView(securityMode, mKeyguardSecurityCallback);
|
||||
.getSecurityView(mCurrentSecurityMode, mKeyguardSecurityCallback);
|
||||
}
|
||||
|
||||
private KeyguardInputViewController<KeyguardInputView> changeSecurityMode(
|
||||
SecurityMode securityMode) {
|
||||
mCurrentSecurityMode = securityMode;
|
||||
return getCurrentSecurityController();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,11 +18,9 @@ package com.android.keyguard;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
|
||||
public interface KeyguardSecurityView {
|
||||
static public final int SCREEN_ON = 1;
|
||||
static public final int VIEW_REVEALED = 2;
|
||||
int SCREEN_ON = 1;
|
||||
int VIEW_REVEALED = 2;
|
||||
|
||||
int PROMPT_REASON_NONE = 0;
|
||||
|
||||
@@ -62,18 +60,6 @@ public interface KeyguardSecurityView {
|
||||
*/
|
||||
int PROMPT_REASON_NON_STRONG_BIOMETRIC_TIMEOUT = 7;
|
||||
|
||||
/**
|
||||
* Interface back to keyguard to tell it when security
|
||||
* @param callback
|
||||
*/
|
||||
void setKeyguardCallback(KeyguardSecurityCallback callback);
|
||||
|
||||
/**
|
||||
* Set {@link LockPatternUtils} object. Useful for providing a mock interface.
|
||||
* @param utils
|
||||
*/
|
||||
void setLockPatternUtils(LockPatternUtils utils);
|
||||
|
||||
/**
|
||||
* Reset the view and prepare to take input. This should do things like clearing the
|
||||
* password or pattern and clear error messages.
|
||||
@@ -100,12 +86,6 @@ public interface KeyguardSecurityView {
|
||||
*/
|
||||
boolean needsInput();
|
||||
|
||||
/**
|
||||
* Get {@link KeyguardSecurityCallback} for the given object
|
||||
* @return KeyguardSecurityCallback
|
||||
*/
|
||||
KeyguardSecurityCallback getCallback();
|
||||
|
||||
/**
|
||||
* Show a string explaining why the security view needs to be solved.
|
||||
*
|
||||
@@ -122,12 +102,6 @@ public interface KeyguardSecurityView {
|
||||
*/
|
||||
void showMessage(CharSequence message, ColorStateList colorState);
|
||||
|
||||
/**
|
||||
* Instruct the view to show usability hints, if any.
|
||||
*
|
||||
*/
|
||||
void showUsabilityHint();
|
||||
|
||||
/**
|
||||
* Starts the animation which should run when the security view appears.
|
||||
*/
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.android.keyguard;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Rect;
|
||||
import android.util.AttributeSet;
|
||||
@@ -31,7 +30,6 @@ import android.view.ViewHierarchyEncoder;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ViewFlipper;
|
||||
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.systemui.R;
|
||||
|
||||
/**
|
||||
@@ -39,7 +37,7 @@ import com.android.systemui.R;
|
||||
* we can emulate {@link android.view.WindowManager.LayoutParams#FLAG_SLIPPERY} within a view
|
||||
* hierarchy.
|
||||
*/
|
||||
public class KeyguardSecurityViewFlipper extends ViewFlipper implements KeyguardSecurityView {
|
||||
public class KeyguardSecurityViewFlipper extends ViewFlipper {
|
||||
private static final String TAG = "KeyguardSecurityViewFlipper";
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
|
||||
@@ -69,111 +67,16 @@ public class KeyguardSecurityViewFlipper extends ViewFlipper implements Keyguard
|
||||
return result;
|
||||
}
|
||||
|
||||
KeyguardSecurityView getSecurityView() {
|
||||
KeyguardInputView getSecurityView() {
|
||||
View child = getChildAt(getDisplayedChild());
|
||||
if (child instanceof KeyguardSecurityView) {
|
||||
return (KeyguardSecurityView) child;
|
||||
if (child instanceof KeyguardInputView) {
|
||||
return (KeyguardInputView) child;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.setKeyguardCallback(callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.setLockPatternUtils(utils);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.onPause();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.onResume(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
return (ksv != null) ? ksv.needsInput() : false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
return (ksv != null) ? ksv.getCallback() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.showPromptReason(reason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.showMessage(message, colorState);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.showUsabilityHint();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
ksv.startAppearAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
return ksv.startDisappearAnimation(finishRunnable);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
KeyguardSecurityView ksv = getSecurityView();
|
||||
KeyguardInputView ksv = getSecurityView();
|
||||
if (ksv != null) {
|
||||
return ksv.getTitle();
|
||||
}
|
||||
|
||||
@@ -16,12 +16,10 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import android.content.res.ColorStateList;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
|
||||
import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.internal.widget.LockPatternUtils;
|
||||
import com.android.keyguard.KeyguardInputViewController.Factory;
|
||||
import com.android.keyguard.KeyguardSecurityModel.SecurityMode;
|
||||
import com.android.keyguard.dagger.KeyguardBouncerScope;
|
||||
@@ -38,12 +36,13 @@ import javax.inject.Inject;
|
||||
*/
|
||||
@KeyguardBouncerScope
|
||||
public class KeyguardSecurityViewFlipperController
|
||||
extends ViewController<KeyguardSecurityViewFlipper> implements KeyguardSecurityView {
|
||||
extends ViewController<KeyguardSecurityViewFlipper> {
|
||||
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
private static final String TAG = "KeyguardSecurityView";
|
||||
|
||||
private final List<KeyguardInputViewController> mChildren = new ArrayList<>();
|
||||
private final List<KeyguardInputViewController<KeyguardInputView>> mChildren =
|
||||
new ArrayList<>();
|
||||
private final LayoutInflater mLayoutInflater;
|
||||
private final Factory mKeyguardSecurityViewControllerFactory;
|
||||
|
||||
@@ -66,80 +65,19 @@ public class KeyguardSecurityViewFlipperController
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeyguardCallback(KeyguardSecurityCallback callback) {
|
||||
mView.setKeyguardCallback(callback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLockPatternUtils(LockPatternUtils utils) {
|
||||
mView.setLockPatternUtils(utils);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
for (KeyguardInputViewController child : mChildren) {
|
||||
for (KeyguardInputViewController<KeyguardInputView> child : mChildren) {
|
||||
child.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
mView.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
mView.onResume(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return mView.needsInput();
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyguardSecurityCallback getCallback() {
|
||||
return mView.getCallback();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPromptReason(int reason) {
|
||||
mView.showPromptReason(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showMessage(CharSequence message, ColorStateList colorState) {
|
||||
mView.showMessage(message, colorState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
mView.showUsabilityHint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
mView.startAppearAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return mView.startDisappearAnimation(finishRunnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mView.getTitle();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
KeyguardInputViewController getSecurityView(SecurityMode securityMode,
|
||||
KeyguardInputViewController<KeyguardInputView> getSecurityView(SecurityMode securityMode,
|
||||
KeyguardSecurityCallback keyguardSecurityCallback) {
|
||||
KeyguardInputViewController childController = null;
|
||||
for (KeyguardInputViewController mChild : mChildren) {
|
||||
if (mChild.getSecurityMode() == securityMode) {
|
||||
childController = mChild;
|
||||
KeyguardInputViewController<KeyguardInputView> childController = null;
|
||||
for (KeyguardInputViewController<KeyguardInputView> child : mChildren) {
|
||||
if (child.getSecurityMode() == securityMode) {
|
||||
childController = child;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -162,6 +100,11 @@ public class KeyguardSecurityViewFlipperController
|
||||
}
|
||||
}
|
||||
|
||||
if (childController == null) {
|
||||
childController = new NullKeyguardInputViewController(
|
||||
securityMode, keyguardSecurityCallback);
|
||||
}
|
||||
|
||||
return childController;
|
||||
}
|
||||
|
||||
@@ -178,10 +121,28 @@ public class KeyguardSecurityViewFlipperController
|
||||
}
|
||||
|
||||
/** Makes the supplied child visible if it is contained win this view, */
|
||||
public void show(KeyguardInputViewController childController) {
|
||||
public void show(KeyguardInputViewController<KeyguardInputView> childController) {
|
||||
int index = childController.getIndexIn(mView);
|
||||
if (index != -1) {
|
||||
mView.setDisplayedChild(index);
|
||||
}
|
||||
}
|
||||
|
||||
private static class NullKeyguardInputViewController
|
||||
extends KeyguardInputViewController<KeyguardInputView> {
|
||||
protected NullKeyguardInputViewController(SecurityMode securityMode,
|
||||
KeyguardSecurityCallback keyguardSecurityCallback) {
|
||||
super(null, securityMode, keyguardSecurityCallback);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsInput() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartingToHide() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,31 +68,11 @@ public class KeyguardSimPinView extends KeyguardPinBasedInputView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
// noop.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return getContext().getString(
|
||||
|
||||
@@ -106,7 +106,7 @@ public class KeyguardSimPinViewController
|
||||
|
||||
@Override
|
||||
public boolean startDisappearAnimation(Runnable finishRunnable) {
|
||||
return mView.startDisappearAnimation(finishRunnable);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +137,7 @@ public class KeyguardSimPinViewController
|
||||
mMessageAreaController.setMessage(
|
||||
com.android.systemui.R.string.kg_invalid_sim_pin_hint);
|
||||
mView.resetPasswordText(true /* animate */, true /* announce */);
|
||||
mKeyguardSecurityCallback.userActivity();
|
||||
getKeyguardSecurityCallback().userActivity();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ public class KeyguardSimPinViewController
|
||||
mKeyguardUpdateMonitor.reportSimUnlocked(mSubId);
|
||||
mRemainingAttempts = -1;
|
||||
mShowDefaultMessage = true;
|
||||
mKeyguardSecurityCallback.dismiss(
|
||||
getKeyguardSecurityCallback().dismiss(
|
||||
true, KeyguardUpdateMonitor.getCurrentUser());
|
||||
} else {
|
||||
mShowDefaultMessage = false;
|
||||
@@ -186,7 +186,7 @@ public class KeyguardSimPinViewController
|
||||
+ " attemptsRemaining=" + result.getAttemptsRemaining());
|
||||
}
|
||||
}
|
||||
mKeyguardSecurityCallback.userActivity();
|
||||
getKeyguardSecurityCallback().userActivity();
|
||||
mCheckSimPinThread = null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.keyguard;
|
||||
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
@@ -31,8 +30,6 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
private static final boolean DEBUG = KeyguardConstants.DEBUG;
|
||||
public static final String TAG = "KeyguardSimPukView";
|
||||
|
||||
private ProgressDialog mSimUnlockProgressDialog = null;
|
||||
|
||||
public KeyguardSimPukView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -89,23 +86,6 @@ public class KeyguardSimPukView extends KeyguardPinBasedInputView {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showUsabilityHint() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
// dismiss the dialog.
|
||||
if (mSimUnlockProgressDialog != null) {
|
||||
mSimUnlockProgressDialog.dismiss();
|
||||
mSimUnlockProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume(int reason) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startAppearAnimation() {
|
||||
// noop.
|
||||
|
||||
@@ -69,7 +69,7 @@ public class KeyguardSimPukViewController
|
||||
if (simState == TelephonyManager.SIM_STATE_READY) {
|
||||
mRemainingAttempts = -1;
|
||||
mShowDefaultMessage = true;
|
||||
mKeyguardSecurityCallback.dismiss(true, KeyguardUpdateMonitor.getCurrentUser());
|
||||
getKeyguardSecurityCallback().dismiss(true, KeyguardUpdateMonitor.getCurrentUser());
|
||||
} else {
|
||||
resetState();
|
||||
}
|
||||
@@ -273,7 +273,7 @@ public class KeyguardSimPukViewController
|
||||
mRemainingAttempts = -1;
|
||||
mShowDefaultMessage = true;
|
||||
|
||||
mKeyguardSecurityCallback.dismiss(
|
||||
getKeyguardSecurityCallback().dismiss(
|
||||
true, KeyguardUpdateMonitor.getCurrentUser());
|
||||
} else {
|
||||
mShowDefaultMessage = false;
|
||||
@@ -362,6 +362,15 @@ public class KeyguardSimPukViewController
|
||||
return mRemainingAttemptsDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
// dismiss the dialog.
|
||||
if (mSimUnlockProgressDialog != null) {
|
||||
mSimUnlockProgressDialog.dismiss();
|
||||
mSimUnlockProgressDialog = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Since the IPC can block, we want to run the request in a separate thread
|
||||
* with a callback.
|
||||
|
||||
@@ -67,10 +67,12 @@ public abstract class ViewController<T extends View> {
|
||||
}
|
||||
mInited = true;
|
||||
|
||||
if (mView.isAttachedToWindow()) {
|
||||
mOnAttachStateListener.onViewAttachedToWindow(mView);
|
||||
if (mView != null) {
|
||||
if (mView.isAttachedToWindow()) {
|
||||
mOnAttachStateListener.onViewAttachedToWindow(mView);
|
||||
}
|
||||
mView.addOnAttachStateChangeListener(mOnAttachStateListener);
|
||||
}
|
||||
mView.addOnAttachStateChangeListener(mOnAttachStateListener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user