Don't handle click events on the emergency button in bouncer mode

This fixes a bug where the emergency call button was hidden, but not
gone.  This adds a call to setVisibility(INVISIBLE) when the alpha
is animated to 0 and restore it when bouncer mode is dismissed.

Fixes bug 7498389

Change-Id: I0898542ff7c666c8f41175a330b72d3450475739
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewHelper.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewHelper.java
index 294bc3d..3d59f8d 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewHelper.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardSecurityViewHelper.java
@@ -17,6 +17,7 @@
 package com.android.internal.policy.impl.keyguard;
 
 import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
 import android.animation.ObjectAnimator;
 import android.graphics.drawable.Drawable;
 import android.view.View;
@@ -27,7 +28,7 @@
 public class KeyguardSecurityViewHelper {
 
     public static void showBouncer(SecurityMessageDisplay securityMessageDisplay,
-            View ecaView, Drawable bouncerFrame, int duration) {
+            final View ecaView, Drawable bouncerFrame, int duration) {
         if (securityMessageDisplay != null) {
             securityMessageDisplay.showBouncer(duration);
         }
@@ -35,9 +36,23 @@
             if (duration > 0) {
                 Animator anim = ObjectAnimator.ofFloat(ecaView, "alpha", 0f);
                 anim.setDuration(duration);
+                anim.addListener(new AnimatorListenerAdapter() {
+                    private boolean mCanceled;
+                    @Override
+                    public void onAnimationCancel(Animator animation) {
+                        // Fail safe and show the emergency button in onAnimationEnd()
+                        mCanceled = true;
+                        ecaView.setAlpha(1f);
+                    }
+                    @Override
+                    public void onAnimationEnd(Animator animation) {
+                        ecaView.setVisibility(mCanceled ? View.VISIBLE : View.INVISIBLE);
+                    }
+                });
                 anim.start();
             } else {
                 ecaView.setAlpha(0f);
+                ecaView.setVisibility(View.INVISIBLE);
             }
         }
         if (bouncerFrame != null) {
@@ -57,6 +72,7 @@
             securityMessageDisplay.hideBouncer(duration);
         }
         if (ecaView != null) {
+            ecaView.setVisibility(View.VISIBLE);
             if (duration > 0) {
                 Animator anim = ObjectAnimator.ofFloat(ecaView, "alpha", 1f);
                 anim.setDuration(duration);