summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jorim Jaggi <jjaggi@google.com> 2015-04-28 13:45:11 -0700
committer Jorim Jaggi <jjaggi@google.com> 2015-04-28 13:46:37 -0700
commitea65706d89dc1ab3f295eb53dca548ea39fcb456 (patch)
tree80acb2d8089dea27b58497e53c8ff9aac36e2b0b
parent27267d6869a4e970e7575f36d0de75e8cb663952 (diff)
Only listen for fingerprint if needed.
Clean up fingerprint listening lifecycle. Only listen for fingerprint if both screen is turned on and Keyguard is actually showing (not occluded). Change-Id: I169ce9df308b96487ed9dc5c8ad8f1c301f2ef93
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java5
2 files changed, 20 insertions, 11 deletions
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 1eec53250a07..c55dd4b74188 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -669,7 +669,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
cb.onScreenTurnedOn();
}
}
- startListeningForFingerprint();
+ updateFingerprintListeningState();
}
protected void handleScreenTurnedOff(int arg1) {
@@ -681,7 +681,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
cb.onScreenTurnedOff(arg1);
}
}
- stopListeningForFingerprint();
+ updateFingerprintListeningState();
}
/**
@@ -754,14 +754,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCHING,
newUserId, 0, reply));
mSwitchingUser = true;
- stopListeningForFingerprint();
+ updateFingerprintListeningState();
}
@Override
public void onUserSwitchComplete(int newUserId) throws RemoteException {
mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_SWITCH_COMPLETE,
newUserId, 0));
mSwitchingUser = false;
- startListeningForFingerprint();
+ updateFingerprintListeningState();
}
@Override
public void onForegroundProfileSwitch(int newProfileId) {
@@ -777,7 +777,20 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
trustManager.registerTrustListener(this);
mFpm = (FingerprintManager) context.getSystemService(Context.FINGERPRINT_SERVICE);
- startListeningForFingerprint();
+ updateFingerprintListeningState();
+ }
+
+ private void updateFingerprintListeningState() {
+ boolean shouldListenForFingerprint = shouldListenForFingerprint();
+ if (mFingerprintDetectionRunning && !shouldListenForFingerprint) {
+ stopListeningForFingerprint();
+ } else if (!mFingerprintDetectionRunning && shouldListenForFingerprint) {
+ startListeningForFingerprint();
+ }
+ }
+
+ private boolean shouldListenForFingerprint() {
+ return mScreenOn && mKeyguardIsVisible && !mSwitchingUser;
}
private void startListeningForFingerprint() {
@@ -794,7 +807,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
}
}
- public void stopListeningForFingerprint() {
+ private void stopListeningForFingerprint() {
if (DEBUG) Log.v(TAG, "stopListeningForFingerprint()");
if (isFingerprintDetectionRunning()) {
mFingerprintCancelSignal.cancel();
@@ -1052,6 +1065,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
cb.onKeyguardVisibilityChangedRaw(isShowing);
}
}
+ updateFingerprintListeningState();
}
/**
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index b828e78a8c57..81068a0654d3 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -1393,14 +1393,9 @@ public class KeyguardViewMediator extends SystemUI {
updateActivityLockScreenState();
adjustStatusBarLocked();
sendUserPresentBroadcast();
- maybeStopListeningForFingerprint();
}
}
- private void maybeStopListeningForFingerprint() {
- mUpdateMonitor.stopListeningForFingerprint();
- }
-
private void adjustStatusBarLocked() {
if (mStatusBarManager == null) {
mStatusBarManager = (StatusBarManager)