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() {
|
private void handleFingerprintAuthFailed() {
|
||||||
|
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||||
|
notifyOnFingerprintWakeAndUnlockingFinished();
|
||||||
|
}
|
||||||
|
mFpWakeMode = FP_WAKE_NONE;
|
||||||
releaseFingerprintWakeLock();
|
releaseFingerprintWakeLock();
|
||||||
handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
|
handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
|
||||||
}
|
}
|
||||||
@@ -428,6 +432,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
}
|
}
|
||||||
mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
|
mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
|
||||||
FINGERPRINT_WAKELOCK_TIMEOUT_MS);
|
FINGERPRINT_WAKELOCK_TIMEOUT_MS);
|
||||||
|
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||||
|
notifyOnFingerprintWakeAndUnlockingStarted();
|
||||||
|
}
|
||||||
} else if (!mDeviceInteractive) {
|
} else if (!mDeviceInteractive) {
|
||||||
mFpWakeMode = FP_WAKE_TO_BOUNCER;
|
mFpWakeMode = FP_WAKE_TO_BOUNCER;
|
||||||
} else {
|
} 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() {
|
private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -891,6 +916,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
|
|||||||
cb.onScreenTurnedOn();
|
cb.onScreenTurnedOn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
|
||||||
|
notifyOnFingerprintWakeAndUnlockingFinished();
|
||||||
|
}
|
||||||
|
mFpWakeMode = FP_WAKE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleScreenTurnedOff() {
|
private void handleScreenTurnedOff() {
|
||||||
|
|||||||
@@ -193,6 +193,17 @@ public class KeyguardUpdateMonitorCallback {
|
|||||||
*/
|
*/
|
||||||
public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }
|
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")
|
* Called when fingerprint provides help string (e.g. "Try again")
|
||||||
* @param msgId
|
* @param msgId
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ public interface DozeHost {
|
|||||||
void stopDozing();
|
void stopDozing();
|
||||||
boolean isPowerSaveActive();
|
boolean isPowerSaveActive();
|
||||||
boolean isNotificationLightOn();
|
boolean isNotificationLightOn();
|
||||||
|
boolean isPulsingBlocked();
|
||||||
|
|
||||||
public interface Callback {
|
public interface Callback {
|
||||||
void onNewNotifications();
|
void onNewNotifications();
|
||||||
|
|||||||
@@ -255,6 +255,9 @@ public class DozeService extends DreamService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void continuePulsing(int reason) {
|
private void continuePulsing(int reason) {
|
||||||
|
if (mHost.isPulsingBlocked()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onPulseStarted() {
|
public void onPulseStarted() {
|
||||||
|
|||||||
@@ -100,6 +100,17 @@ public class DozeScrimController {
|
|||||||
mHandler.post(mPulseIn);
|
mHandler.post(mPulseIn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aborts pulsing immediately.
|
||||||
|
*/
|
||||||
|
public void abortPulsing() {
|
||||||
|
mHandler.removeCallbacks(mPulseIn);
|
||||||
|
abortAnimations();
|
||||||
|
mScrimController.setDozeBehindAlpha(1f);
|
||||||
|
mScrimController.setDozeInFrontAlpha(1f);
|
||||||
|
mPulseCallback = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void onScreenTurnedOn() {
|
public void onScreenTurnedOn() {
|
||||||
if (isPulsing()) {
|
if (isPulsing()) {
|
||||||
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
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.internal.statusbar.StatusBarIcon;
|
||||||
import com.android.keyguard.KeyguardHostView.OnDismissAction;
|
import com.android.keyguard.KeyguardHostView.OnDismissAction;
|
||||||
import com.android.keyguard.KeyguardUpdateMonitor;
|
import com.android.keyguard.KeyguardUpdateMonitor;
|
||||||
|
import com.android.keyguard.KeyguardUpdateMonitorCallback;
|
||||||
import com.android.keyguard.ViewMediatorCallback;
|
import com.android.keyguard.ViewMediatorCallback;
|
||||||
import com.android.systemui.BatteryMeterView;
|
import com.android.systemui.BatteryMeterView;
|
||||||
import com.android.systemui.DemoMode;
|
import com.android.systemui.DemoMode;
|
||||||
@@ -621,6 +622,7 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
startKeyguard();
|
startKeyguard();
|
||||||
|
|
||||||
mDozeServiceHost = new DozeServiceHost();
|
mDozeServiceHost = new DozeServiceHost();
|
||||||
|
KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mDozeServiceHost);
|
||||||
putComponent(DozeHost.class, mDozeServiceHost);
|
putComponent(DozeHost.class, mDozeServiceHost);
|
||||||
putComponent(PhoneStatusBar.class, this);
|
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
|
// 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
|
// 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
|
// 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.
|
// Keeps the last reported state by fireNotificationLight.
|
||||||
private boolean mNotificationLightOn;
|
private boolean mNotificationLightOn;
|
||||||
|
private boolean mWakeAndUnlocking;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -4100,6 +4103,22 @@ public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
|
|||||||
return mBatteryController != null && mBatteryController.isPowerSave();
|
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
|
@Override
|
||||||
public boolean isNotificationLightOn() {
|
public boolean isNotificationLightOn() {
|
||||||
return mNotificationLightOn;
|
return mNotificationLightOn;
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public class StatusBarKeyguardViewManager {
|
|||||||
// with the appear animations of the PIN/pattern/password views.
|
// with the appear animations of the PIN/pattern/password views.
|
||||||
private static final long NAV_BAR_SHOW_DELAY_BOUNCER = 320;
|
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 static String TAG = "StatusBarKeyguardViewManager";
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@@ -178,16 +180,16 @@ public class StatusBarKeyguardViewManager {
|
|||||||
|
|
||||||
public void onScreenTurnedOn() {
|
public void onScreenTurnedOn() {
|
||||||
mScreenTurnedOn = true;
|
mScreenTurnedOn = true;
|
||||||
mWakeAndUnlocking = false;
|
|
||||||
if (mDeferScrimFadeOut) {
|
if (mDeferScrimFadeOut) {
|
||||||
mDeferScrimFadeOut = false;
|
mDeferScrimFadeOut = false;
|
||||||
animateScrimControllerKeyguardFadingOut(0, 200);
|
animateScrimControllerKeyguardFadingOut(0, WAKE_AND_UNLOCK_SCRIM_FADEOUT_DURATION_MS);
|
||||||
updateStates();
|
updateStates();
|
||||||
}
|
}
|
||||||
mPhoneStatusBar.onScreenTurnedOn();
|
mPhoneStatusBar.onScreenTurnedOn();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onScreenTurnedOff() {
|
public void onScreenTurnedOff() {
|
||||||
|
mWakeAndUnlocking = false;
|
||||||
mScreenTurnedOn = false;
|
mScreenTurnedOn = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,7 +281,12 @@ public class StatusBarKeyguardViewManager {
|
|||||||
mStatusBarWindowManager.setKeyguardFadingAway(true);
|
mStatusBarWindowManager.setKeyguardFadingAway(true);
|
||||||
if (mWakeAndUnlocking && !mScreenTurnedOn) {
|
if (mWakeAndUnlocking && !mScreenTurnedOn) {
|
||||||
mDeferScrimFadeOut = true;
|
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);
|
animateScrimControllerKeyguardFadingOut(delay, fadeoutDuration);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -292,7 +299,7 @@ public class StatusBarKeyguardViewManager {
|
|||||||
executeAfterKeyguardGoneAction();
|
executeAfterKeyguardGoneAction();
|
||||||
updateStates();
|
updateStates();
|
||||||
}
|
}
|
||||||
|
mWakeAndUnlocking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void animateScrimControllerKeyguardFadingOut(long delay, long duration) {
|
private void animateScrimControllerKeyguardFadingOut(long delay, long duration) {
|
||||||
|
|||||||
Reference in New Issue
Block a user