Fixed a potential bug where the keyguard could become empty

Bug: 21124013
Change-Id: Ia955b1426e13d47a8f191817d55615253012acb1
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
index 69198ed..cd90d27 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3460,6 +3460,7 @@
             mKeyguardIndicationController.setVisible(true);
             mNotificationPanel.resetViews();
             mKeyguardUserSwitcher.setKeyguard(true, fromShadeLocked);
+            mStatusBarView.removePendingHideExpandedRunnables();
         } else {
             mKeyguardIndicationController.setVisible(false);
             mKeyguardUserSwitcher.setKeyguard(false,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
index dfd280a..6a46924 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarView.java
@@ -42,6 +42,12 @@
     private ScrimController mScrimController;
     private float mMinFraction;
     private float mPanelFraction;
+    private Runnable mHideExpandedRunnable = new Runnable() {
+        @Override
+        public void run() {
+            mBar.makeExpandedInvisible();
+        }
+    };
 
     public PhoneStatusBarView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -118,15 +124,14 @@
                     + Log.getStackTraceString(new Throwable()));
         }
         // Close the status bar in the next frame so we can show the end of the animation.
-        postOnAnimation(new Runnable() {
-            @Override
-            public void run() {
-                mBar.makeExpandedInvisible();
-            }
-        });
+        postOnAnimation(mHideExpandedRunnable);
         mLastFullyOpenedPanel = null;
     }
 
+    public void removePendingHideExpandedRunnables() {
+        removeCallbacks(mHideExpandedRunnable);
+    }
+
     @Override
     public void onPanelFullyOpened(PanelView openPanel) {
         super.onPanelFullyOpened(openPanel);