am 394686ef: Merge "Fix race condition for doze mode and wake-and-unlocking" into mnc-dr-dev
* commit '394686efbb51e7c05e230c4ad3695fadc3aa85a0': Fix race condition for doze mode and wake-and-unlocking
This commit is contained in:
@@ -409,6 +409,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
|
||||
private void handleFingerprintAuthFailed() {
|
||||
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||
notifyOnFingerprintWakeAndUnlockingFinished();
|
||||
}
|
||||
mFpWakeMode = FP_WAKE_NONE;
|
||||
releaseFingerprintWakeLock();
|
||||
handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
|
||||
}
|
||||
@@ -428,6 +432,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
|
||||
FINGERPRINT_WAKELOCK_TIMEOUT_MS);
|
||||
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||
notifyOnFingerprintWakeAndUnlockingStarted();
|
||||
}
|
||||
} else if (!mDeviceInteractive) {
|
||||
mFpWakeMode = FP_WAKE_TO_BOUNCER;
|
||||
} else {
|
||||
@@ -435,6 +442,24 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyOnFingerprintWakeAndUnlockingStarted() {
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onFingerprintWakeAndUnlockingStarted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyOnFingerprintWakeAndUnlockingFinished() {
|
||||
for (int i = 0; i < mCallbacks.size(); i++) {
|
||||
KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
|
||||
if (cb != null) {
|
||||
cb.onFingerprintWakeAndUnlockingFinished();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -891,6 +916,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
||||
cb.onScreenTurnedOn();
|
||||
}
|
||||
}
|
||||
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||
notifyOnFingerprintWakeAndUnlockingFinished();
|
||||
}
|
||||
mFpWakeMode = FP_WAKE_NONE;
|
||||
}
|
||||
|
||||
private void handleScreenTurnedOff() {
|
||||
|
||||
@@ -193,6 +193,17 @@ public class KeyguardUpdateMonitorCallback {
|
||||
*/
|
||||
public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }
|
||||
|
||||
/**
|
||||
* Called when we might be starting a wake-and-unlock sequence.
|
||||
*/
|
||||
public void onFingerprintWakeAndUnlockingStarted() { }
|
||||
|
||||
/**
|
||||
* Called when we're done with the wake-and-unlock sequence. This can either happen when we
|
||||
* figure out that the fingerprint didn't match, or when the phone is fully unlocked.
|
||||
*/
|
||||
public void onFingerprintWakeAndUnlockingFinished() { }
|
||||
|
||||
/**
|
||||
* Called when fingerprint provides help string (e.g. "Try again")
|
||||
* @param msgId
|
||||
|
||||
@@ -29,6 +29,7 @@ public interface DozeHost {
|
||||
void stopDozing();
|
||||
boolean isPowerSaveActive();
|
||||
boolean isNotificationLightOn();
|
||||
boolean isPulsingBlocked();
|
||||
|
||||
public interface Callback {
|
||||
void onNewNotifications();
|
||||
|
||||
@@ -255,6 +255,9 @@ public class DozeService extends DreamService {
|
||||
}
|
||||
|
||||
private void continuePulsing(int reason) {
|
||||
if (mHost.isPulsingBlocked()) {
|
||||
return;
|
||||
}
|
||||
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
||||
@Override
|
||||
public void onPulseStarted() {
|
||||
|
||||
@@ -100,6 +100,17 @@ public class DozeScrimController {
|
||||
mHandler.post(mPulseIn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aborts pulsing immediately.
|
||||
*/
|
||||
public void abortPulsing() {
|
||||
mHandler.removeCallbacks(mPulseIn);
|
||||
abortAnimations();
|
||||
mScrimController.setDozeBehindAlpha(1f);
|
||||
mScrimController.setDozeInFrontAlpha(1f);
|
||||
mPulseCallback = null;
|
||||
}
|
||||
|
||||
public void onScreenTurnedOn() {
|
||||
if (isPulsing()) {
|
||||
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
||||
|
||||
@@ -99,6 +99,7 @@ import com.android.internal.statusbar.NotificationVisibility;
|
||||
import com.android.internal.statusbar.StatusBarIcon;
|
||||
import com.android.keyguard.KeyguardHostView.OnDismissAction;
|
||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||
import com.android.keyguard.ViewMediatorCallback;
|
||||
import com.android.systemui.BatteryMeterView;
|
||||
import com.android.systemui.DemoMode;
|
||||
@@ -621,6 +622,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
startKeyguard();
|
||||
|
||||
mDozeServiceHost = new DozeServiceHost();
|
||||
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost);
|
||||
putComponent(DozeHost.class, mDozeServiceHost);
|
||||
putComponent(PhoneStatusBar.class, this);
|
||||
|
||||
@@ -4027,7 +4029,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
}
|
||||
}
|
||||
|
||||
private final class DozeServiceHost implements DozeHost {
|
||||
private final class DozeServiceHost extends KeyguardUpdateMonitorCallback implements DozeHost {
|
||||
// Amount of time to allow to update the time shown on the screen before releasing
|
||||
// the wakelock. This timeout is design to compensate for the fact that we don't
|
||||
// currently have a way to know when time display contents have actually been
|
||||
@@ -4039,6 +4041,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
|
||||
// Keeps the last reported state by fireNotificationLight.
|
||||
private boolean mNotificationLightOn;
|
||||
private boolean mWakeAndUnlocking;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -4100,6 +4103,22 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
||||
return mBatteryController != null && mBatteryController.isPowerSave();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPulsingBlocked() {
|
||||
return mWakeAndUnlocking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFingerprintWakeAndUnlockingStarted() {
|
||||
mWakeAndUnlocking = true;
|
||||
mDozeScrimController.abortPulsing();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFingerprintWakeAndUnlockingFinished() {
|
||||
mWakeAndUnlocking = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNotificationLightOn() {
|
||||
return mNotificationLightOn;
|
||||
|
||||
@@ -48,6 +48,8 @@ public class StatusBarKeyguardViewManager {
|
||||
// with the appear animations of the PIN/pattern/password views.
|
||||
private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320;
|
||||
|
||||
private static final long WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS = 200;
|
||||
|
||||
private static String TAG = "StatusBarKeyguardViewManager";
|
||||
|
||||
private final Context mContext;
|
||||
@@ -178,16 +180,16 @@ public class StatusBarKeyguardViewManager {
|
||||
|
||||
public void onScreenTurnedOn() {
|
||||
mScreenTurnedOn = true;
|
||||
mWakeAndUnlocking = false;
|
||||
if (mDeferScrimFadeOut) {
|
||||
mDeferScrimFadeOut = false;
|
||||
animateScrimControllerKeyguardFadingOut(0, 200);
|
||||
animateScrimControllerKeyguardFadingOut(0, WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS);
|
||||
updateStates();
|
||||
}
|
||||
mPhoneStatusBar.onScreenTurnedOn();
|
||||
}
|
||||
|
||||
public void onScreenTurnedOff() {
|
||||
mWakeAndUnlocking = false;
|
||||
mScreenTurnedOn = false;
|
||||
}
|
||||
|
||||
@@ -279,7 +281,12 @@ public class StatusBarKeyguardViewManager {
|
||||
mStatusBarWindowManager.setKeyguardFadingAway(true);
|
||||
if (mWakeAndUnlocking && !mScreenTurnedOn) {
|
||||
mDeferScrimFadeOut = true;
|
||||
} else {
|
||||
} else if (mWakeAndUnlocking){
|
||||
|
||||
// Screen is already on, don't defer with fading out.
|
||||
animateScrimControllerKeyguardFadingOut(0,
|
||||
WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS);
|
||||
} else {
|
||||
animateScrimControllerKeyguardFadingOut(delay, fadeoutDuration);
|
||||
}
|
||||
} else {
|
||||
@@ -292,7 +299,7 @@ public class StatusBarKeyguardViewManager {
|
||||
executeAfterKeyguardGoneAction();
|
||||
updateStates();
|
||||
}
|
||||
|
||||
mWakeAndUnlocking = false;
|
||||
}
|
||||
|
||||
private void animateScrimControllerKeyguardFadingOut(long delay, long duration) {
|
||||
|
||||
Reference in New Issue
Block a user