Dismiss BiometricPrompt when screen turns off
Fixes: 131761855
Test: Follow instructions in bug
Change-Id: If3ee6cd9dd515a4e42177b079019b3622570d66f
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
index 45c19ad..e66a8fa 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java
@@ -31,7 +31,9 @@
import android.view.WindowManager;
import com.android.internal.os.SomeArgs;
+import com.android.systemui.Dependency;
import com.android.systemui.SystemUI;
+import com.android.systemui.keyguard.WakefulnessLifecycle;
import com.android.systemui.statusbar.CommandQueue;
/**
@@ -58,6 +60,7 @@
private IBiometricServiceReceiverInternal mReceiver;
private boolean mDialogShowing;
private Callback mCallback = new Callback();
+ private WakefulnessLifecycle mWakefulnessLifecycle;
private Handler mHandler = new Handler(Looper.getMainLooper()) {
@Override
@@ -133,6 +136,16 @@
}
}
+ final WakefulnessLifecycle.Observer mWakefulnessObserver = new WakefulnessLifecycle.Observer() {
+ @Override
+ public void onStartedGoingToSleep() {
+ if (mDialogShowing) {
+ if (DEBUG) Log.d(TAG, "User canceled due to screen off");
+ mHandler.obtainMessage(MSG_USER_CANCELED).sendToTarget();
+ }
+ }
+ };
+
@Override
public void start() {
final PackageManager pm = mContext.getPackageManager();
@@ -141,6 +154,8 @@
|| pm.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
getComponent(CommandQueue.class).addCallback(this);
mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
+ mWakefulnessLifecycle = Dependency.get(WakefulnessLifecycle.class);
+ mWakefulnessLifecycle.addObserver(mWakefulnessObserver);
}
}