Fixing bug where search bar is not updated when search package is first installed.

- Fixing issue where we weren't disabling HW layers when you don't finish a swipe-to-dismiss
- Preventing tapping on a task that is currently being dismissed
- Adding a debug trigger for internal testing
- Minor refactoring

Change-Id: Id7dcc8a4b5a080402c2761cd555b8a882498ad29
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 4370653..3856311 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -24,6 +24,7 @@
 import android.content.Intent;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
+import android.graphics.Paint;
 import android.graphics.Rect;
 import android.net.Uri;
 import android.os.UserHandle;
@@ -60,6 +61,7 @@
 
     RecentsConfiguration mConfig;
     LayoutInflater mInflater;
+    Paint mDebugModePaint;
 
     // The space partitioning root of this container
     SpaceNode mBSP;
@@ -107,6 +109,15 @@
             addView(stackView);
             mHasTasks |= (stack.getTaskCount() > 0);
         }
+
+        // Enable debug mode drawing
+        if (mConfig.debugModeEnabled) {
+            mDebugModePaint = new Paint();
+            mDebugModePaint.setColor(0xFFff0000);
+            mDebugModePaint.setStyle(Paint.Style.STROKE);
+            mDebugModePaint.setStrokeWidth(5f);
+            setWillNotDraw(false);
+        }
     }
 
     /** Launches the focused task from the first stack if possible */
@@ -322,6 +333,29 @@
         }
     }
 
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        // Debug mode drawing
+        if (mConfig.debugModeEnabled) {
+            canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), mDebugModePaint);
+        }
+    }
+
+    @Override
+    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+        if (Console.Enabled) {
+            Console.log(Constants.Log.UI.MeasureAndLayout,
+                    "[RecentsView|fitSystemWindows]", "insets: " + insets, Console.AnsiGreen);
+        }
+
+        // Update the configuration with the latest system insets and trigger a relayout
+        mConfig.updateSystemInsets(insets.getSystemWindowInsets());
+        requestLayout();
+
+        return insets.consumeSystemWindowInsets(false, false, false, true);
+    }
+
     /** Notifies each task view of the user interaction. */
     public void onUserInteraction() {
         // Get the first stack view
@@ -354,29 +388,6 @@
         }
     }
 
-    @Override
-    protected void dispatchDraw(Canvas canvas) {
-        if (Console.Enabled) {
-            Console.log(Constants.Log.UI.Draw, "[RecentsView|dispatchDraw]", "",
-                    Console.AnsiPurple);
-        }
-        super.dispatchDraw(canvas);
-    }
-
-    @Override
-    public WindowInsets onApplyWindowInsets(WindowInsets insets) {
-        if (Console.Enabled) {
-            Console.log(Constants.Log.UI.MeasureAndLayout,
-                    "[RecentsView|fitSystemWindows]", "insets: " + insets, Console.AnsiGreen);
-        }
-
-        // Update the configuration with the latest system insets and trigger a relayout
-        mConfig.updateSystemInsets(insets.getSystemWindowInsets());
-        requestLayout();
-
-        return insets.consumeSystemWindowInsets(false, false, false, true);
-    }
-
     /** Unfilters any filtered stacks */
     public boolean unfilterFilteredStacks() {
         if (mBSP != null) {