Disable the search bar in Recents.

Change-Id: I7abc37ded03c653469316a441d173df8b3910df2
diff --git a/packages/SystemUI/src/com/android/systemui/recents/Constants.java b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
index a4acf83..2307f1a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/Constants.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/Constants.java
@@ -41,8 +41,8 @@
             public static final boolean EnableDismissAll = false;
             // Enables debug mode
             public static final boolean EnableDebugMode = false;
-            // Enables the search bar layout
-            public static final boolean EnableSearchLayout = true;
+            // Enables the search bar integration
+            public static final boolean EnableSearchBar = false;
             // Enables the thumbnail alpha on the front-most task
             public static final boolean EnableThumbnailAlphaOnFrontmost = false;
             // Enables all system stacks to show up in the same recents stack
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index d0876fa..b641aaf 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -248,15 +248,19 @@
                 mEmptyView = mEmptyViewStub.inflate();
             }
             mEmptyView.setVisibility(View.VISIBLE);
-            mRecentsView.setSearchBarVisibility(View.GONE);
+            if (Constants.DebugFlags.App.EnableSearchBar) {
+                mRecentsView.setSearchBarVisibility(View.GONE);
+            }
         } else {
             if (mEmptyView != null) {
                 mEmptyView.setVisibility(View.GONE);
             }
-            if (mRecentsView.hasValidSearchBar()) {
-                mRecentsView.setSearchBarVisibility(View.VISIBLE);
-            } else {
-                refreshSearchWidgetView();
+            if (Constants.DebugFlags.App.EnableSearchBar) {
+                if (mRecentsView.hasValidSearchBar()) {
+                    mRecentsView.setSearchBarVisibility(View.VISIBLE);
+                } else {
+                    refreshSearchWidgetView();
+                }
             }
         }
 
@@ -349,7 +353,9 @@
         mConfig = RecentsConfiguration.reinitialize(this, ssp);
 
         // Initialize the widget host (the host id is static and does not change)
-        mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId);
+        if (Constants.DebugFlags.App.EnableSearchBar) {
+            mAppWidgetHost = new RecentsAppWidgetHost(this, Constants.Values.App.AppWidgetHostId);
+        }
 
         // Set the Recents layout
         setContentView(R.layout.recents);
@@ -364,12 +370,16 @@
         inflateDebugOverlay();
 
         // Bind the search app widget when we first start up
-        mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost);
+        if (Constants.DebugFlags.App.EnableSearchBar) {
+            mSearchWidgetInfo = ssp.getOrBindSearchAppWidget(this, mAppWidgetHost);
+        }
 
         // Register the broadcast receiver to handle messages when the screen is turned off
         IntentFilter filter = new IntentFilter();
         filter.addAction(Intent.ACTION_SCREEN_OFF);
-        filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
+        if (Constants.DebugFlags.App.EnableSearchBar) {
+            filter.addAction(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED);
+        }
         registerReceiver(mSystemBroadcastReceiver, filter);
     }
 
@@ -475,7 +485,9 @@
         unregisterReceiver(mSystemBroadcastReceiver);
 
         // Stop listening for widget package changes if there was one bound
-        mAppWidgetHost.stopListening();
+        if (Constants.DebugFlags.App.EnableSearchBar) {
+            mAppWidgetHost.stopListening();
+        }
     }
 
     public void onEnterAnimationTriggered() {
@@ -484,20 +496,22 @@
         ViewAnimation.TaskViewEnterContext ctx = new ViewAnimation.TaskViewEnterContext(t);
         mRecentsView.startEnterRecentsAnimation(ctx);
 
-        if (mSearchWidgetInfo != null) {
-            final WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks> cbRef =
-                    new WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks>(
-                            RecentsActivity.this);
-            ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
-                @Override
-                public void run() {
-                    // Start listening for widget package changes if there is one bound
-                    RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks cb = cbRef.get();
-                    if (cb != null) {
-                        mAppWidgetHost.startListening(cb);
+        if (Constants.DebugFlags.App.EnableSearchBar) {
+            if (mSearchWidgetInfo != null) {
+                final WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks> cbRef =
+                        new WeakReference<RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks>(
+                                RecentsActivity.this);
+                ctx.postAnimationTrigger.addLastDecrementRunnable(new Runnable() {
+                    @Override
+                    public void run() {
+                        // Start listening for widget package changes if there is one bound
+                        RecentsAppWidgetHost.RecentsAppWidgetHostCallbacks cb = cbRef.get();
+                        if (cb != null) {
+                            mAppWidgetHost.startListening(cb);
+                        }
                     }
-                }
-            });
+                });
+            }
         }
 
         // Animate the SystemUI scrim views
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index dfe7e96..6646508 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -327,7 +327,8 @@
             taskStackBounds.set(0, topInset, windowWidth - rightInset, windowHeight);
         } else {
             // In portrait, the search bar appears on the top (which already has the inset)
-            taskStackBounds.set(0, searchBarBounds.bottom, windowWidth, windowHeight);
+            int top = searchBarBounds.isEmpty() ? topInset : 0;
+            taskStackBounds.set(0, searchBarBounds.bottom + top, windowWidth, windowHeight);
         }
     }
 
@@ -338,13 +339,18 @@
     public void getSearchBarBounds(int windowWidth, int windowHeight, int topInset,
             Rect searchBarSpaceBounds) {
         // Return empty rects if search is not enabled
-        int searchBarSize = searchBarSpaceHeightPx;
-        if (isLandscape && hasTransposedSearchBar) {
-            // In landscape, the search bar appears on the left
-            searchBarSpaceBounds.set(0, topInset, searchBarSize, windowHeight);
+        if (!Constants.DebugFlags.App.EnableSearchBar) {
+            searchBarSpaceBounds.set(0, 0, 0, 0);
+            return;
         } else {
-            // In portrait, the search bar appears on the top
-            searchBarSpaceBounds.set(0, topInset, windowWidth, topInset + searchBarSize);
+        int searchBarSize = searchBarSpaceHeightPx;
+            if (isLandscape && hasTransposedSearchBar) {
+                // In landscape, the search bar appears on the left
+                searchBarSpaceBounds.set(0, topInset, searchBarSize, windowHeight);
+            } else {
+                // In portrait, the search bar appears on the top
+                searchBarSpaceBounds.set(0, topInset, windowWidth, topInset + searchBarSize);
+            }
         }
     }
 }