summaryrefslogtreecommitdiffstats
path: root/policy
diff options
context:
space:
mode:
authorBrian Colonna <bcolonna@google.com>2011-11-04 13:08:40 -0400
committerBrian Colonna <bcolonna@google.com>2011-11-07 13:53:31 -0500
commit6233fbe5da2466da26245a35acc5129974dd5440 (patch)
tree9000d6632507e97a4c6e1da2adedc257d13638e2 /policy
parente4ca92421cc07c2f7f152b774dd1ac7a8944028b (diff)
downloadframeworks_base-6233fbe5da2466da26245a35acc5129974dd5440.zip
frameworks_base-6233fbe5da2466da26245a35acc5129974dd5440.tar.gz
frameworks_base-6233fbe5da2466da26245a35acc5129974dd5440.tar.bz2
Fix 5514230: preventing null window token from occurring
Sometimes the lockscreen view is recreated even though it has already been created (and therefore Face Unlock is already running). One example of this is when the lockscreen momentarily displays in landscape mode and then corrects itself into portrait mode. When lockscreen recreates itself, it removes the view and then later re-adds the view. During that time the window token is null and may be passed to Face Unlock when it tries to restart. The reason this doesn't happen *every* time the view is recreated is because the onServiceConnected() callback starts Face Unlock, and usually it runs after the view is re-added, but sometimes it runs before the view is re-added, resulting in this bug. An earlier fix put null-token checking inside of the Face Unlock service, which prevented crashing but Face Unlock was still unable to run. This fix makes the null token case not happen so Face Unlock can run every time. It accomplishes this by simply not restarting Face Unlock until the view has been re-added. This fix also replaces checking two flags everywhere to see if Face Unlock is being used and instead uses a single function call. Change-Id: Ib46f25f2a58ab2e70470337861c25ee81a858873
Diffstat (limited to 'policy')
-rw-r--r--policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java54
1 files changed, 27 insertions, 27 deletions
diff --git a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
index 81e1901..0f21bdb 100644
--- a/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
+++ b/policy/src/com/android/internal/policy/impl/LockPatternKeyguardView.java
@@ -360,8 +360,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
mHasOverlay = true;
// Continue showing FaceLock area until dialer comes up or call is resumed
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled() && mFaceLockServiceRunning) {
+ if (usingFaceLock() && mFaceLockServiceRunning) {
showFaceLockAreaWithTimeout(FACELOCK_VIEW_AREA_EMERGENCY_DIALER_TIMEOUT);
}
@@ -582,8 +581,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
bindToFaceLock();
// Show FaceLock area, but only for a little bit so lockpattern will become visible if
// FaceLock fails to start or crashes
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
showFaceLockAreaWithTimeout(FACELOCK_VIEW_AREA_SERVICE_TIMEOUT);
}
} else {
@@ -653,11 +651,10 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
((KeyguardScreen) mUnlockScreen).onResume();
}
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled() && !mHasOverlay) {
+ if (usingFaceLock() && !mHasOverlay) {
// Note that show() gets called before the screen turns off to set it up for next time
// it is turned on. We don't want to set a timeout on the FaceLock area here because it
- // may be gone by the time the screen is turned on again. We set the timout when the
+ // may be gone by the time the screen is turned on again. We set the timeout when the
// screen turns on instead.
showFaceLockArea();
} else {
@@ -854,7 +851,9 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
if (mode == Mode.UnlockScreen) {
final UnlockMode unlockMode = getUnlockMode();
if (force || mUnlockScreen == null || unlockMode != mUnlockScreenMode) {
+ boolean restartFaceLock = stopFaceLockIfRunning();
recreateUnlockScreen(unlockMode);
+ if (restartFaceLock) activateFaceLockIfAble();
}
}
@@ -1147,28 +1146,33 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
// Everything below pertains to FaceLock - might want to separate this out
- // Take care of FaceLock area when layout is created
+ // Indicates whether FaceLock is in use
+ private boolean usingFaceLock() {
+ return (mLockPatternUtils.usingBiometricWeak() &&
+ mLockPatternUtils.isBiometricWeakInstalled());
+ }
+
+ // Takes care of FaceLock area when layout is created
private void initializeFaceLockAreaView(View view) {
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
mFaceLockAreaView = view.findViewById(R.id.faceLockAreaView);
if (mFaceLockAreaView == null) {
Log.e(TAG, "Layout does not have faceLockAreaView and FaceLock is enabled");
- } else {
- if (mBoundToFaceLockService) {
- // If we are creating a layout when we are already bound to FaceLock, then we
- // are undergoing an orientation change. Stop FaceLock and restart it in the
- // new location.
- if (DEBUG) Log.d(TAG, "Restarting FL - creating view while already bound");
- stopAndUnbindFromFaceLock();
- activateFaceLockIfAble();
- }
}
} else {
mFaceLockAreaView = null; // Set to null if not using FaceLock
}
}
+ // Stops FaceLock if it is running and reports back whether it was running or not
+ private boolean stopFaceLockIfRunning() {
+ if (usingFaceLock() && mBoundToFaceLockService) {
+ stopAndUnbindFromFaceLock();
+ return true;
+ }
+ return false;
+ }
+
// Handles covering or exposing FaceLock area on the client side when FaceLock starts or stops
// This needs to be done in a handler because the call could be coming from a callback from the
// FaceLock service that is in a thread that can't modify the UI
@@ -1221,8 +1225,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
// Binds to FaceLock service. This call does not tell it to start, but it causes the service
// to call the onServiceConnected callback, which then starts FaceLock.
public void bindToFaceLock() {
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
if (!mBoundToFaceLockService) {
if (DEBUG) Log.d(TAG, "before bind to FaceLock service");
mContext.bindService(new Intent(IFaceLockInterface.class.getName()),
@@ -1238,8 +1241,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
// Tells FaceLock to stop and then unbinds from the FaceLock service
public void stopAndUnbindFromFaceLock() {
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
stopFaceLock();
if (mBoundToFaceLockService) {
@@ -1300,8 +1302,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
// Tells the FaceLock service to start displaying its UI and perform recognition
public void startFaceLock(IBinder windowToken, int x, int y, int h, int w)
{
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
synchronized (mFaceLockServiceRunningLock) {
if (!mFaceLockServiceRunning) {
if (DEBUG) Log.d(TAG, "Starting FaceLock");
@@ -1322,8 +1323,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase implements Handler
// Tells the FaceLock service to stop displaying its UI and stop recognition
public void stopFaceLock()
{
- if (mLockPatternUtils.usingBiometricWeak() &&
- mLockPatternUtils.isBiometricWeakInstalled()) {
+ if (usingFaceLock()) {
// Note that attempting to stop FaceLock when it's not running is not an issue.
// FaceLock can return, which stops it and then we try to stop it when the
// screen is turned off. That's why we check.