Enabling history and paging by default

- Removing associated tuner flags

Change-Id: Ia69bf273489b0079c389e7feb1428071569092d5
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 9b74a80..f71a71a 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1171,31 +1171,11 @@
     <!-- Option to use new paging layout in quick settings [CHAR LIMIT=60] -->
     <string name="qs_paging" translatable="false">Use the new Quick Settings</string>
 
-    <!-- Toggles paging recents via the recents button. DO NOT TRANSLATE -->
-    <string name="overview_page_on_toggle">Enable paging</string>
-    <!-- Description for the toggle for fast-toggling recents via the recents button. DO NOT TRANSLATE -->
-    <string name="overview_page_on_toggle_desc">Enable paging via the Overview button</string>
-
     <!-- Toggles fast-toggling recents via the recents button. DO NOT TRANSLATE -->
     <string name="overview_fast_toggle_via_button">Enable fast toggle</string>
     <!-- Description for the toggle for fast-toggling recents via the recents button. DO NOT TRANSLATE -->
     <string name="overview_fast_toggle_via_button_desc">Enable launch timeout while paging</string>
 
-    <!-- Toggles fullscreen screenshots. DO NOT TRANSLATE -->
-    <string name="overview_fullscreen_thumbnails">Enable fullscreen screenshots</string>
-    <!-- Description for the toggle for fullscreen screenshots. DO NOT TRANSLATE -->
-    <string name="overview_fullscreen_thumbnails_desc">Enable fullscreen screenshots in Overview. Restart required.</string>
-
-    <!-- Toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
-    <string name="overview_nav_bar_gesture">Enable navigation bar gesture</string>
-    <!-- Description for the toggle to enable the Overview nav bar gesture. DO NOT TRANSLATE -->
-    <string name="overview_nav_bar_gesture_desc">Enables the gesture to enter Overview by swiping up on the Nav bar</string>
-
-    <!-- Toggle to show the history view in Overview. DO NOT TRANSLATE -->
-    <string name="overview_show_history">Show History</string>
-    <!-- Description for the toggle to show the history view in Overview. DO NOT TRANSLATE -->
-    <string name="overview_show_history_desc">Enables the history view to see more recent tasks</string>
-
     <!-- Toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
     <string name="overview_initial_state_paging">Initialize to paging</string>
     <!-- Description for the toggle to set the initial scroll state to be paging or stack. DO NOT TRANSLATE -->
diff --git a/packages/SystemUI/res/xml/tuner_prefs.xml b/packages/SystemUI/res/xml/tuner_prefs.xml
index e31927e..43359b3 100644
--- a/packages/SystemUI/res/xml/tuner_prefs.xml
+++ b/packages/SystemUI/res/xml/tuner_prefs.xml
@@ -73,11 +73,6 @@
         android:title="@string/overview" >
 
         <com.android.systemui.tuner.TunerSwitch
-            android:key="overview_page_on_toggle"
-            android:title="@string/overview_page_on_toggle"
-            android:summary="@string/overview_page_on_toggle_desc" />
-
-        <com.android.systemui.tuner.TunerSwitch
             android:key="overview_initial_state_paging"
             android:title="@string/overview_initial_state_paging"
             android:summary="@string/overview_initial_state_paging_desc" />
@@ -87,21 +82,6 @@
             android:title="@string/overview_fast_toggle_via_button"
             android:summary="@string/overview_fast_toggle_via_button_desc" />
 
-        <com.android.systemui.tuner.TunerSwitch
-            android:key="overview_nav_bar_gesture"
-            android:title="@string/overview_nav_bar_gesture"
-            android:summary="@string/overview_nav_bar_gesture_desc" />
-
-        <com.android.systemui.tuner.TunerSwitch
-            android:key="overview_fullscreen_thumbnails"
-            android:title="@string/overview_fullscreen_thumbnails"
-            android:summary="@string/overview_fullscreen_thumbnails_desc" />
-
-        <com.android.systemui.tuner.TunerSwitch
-            android:key="overview_show_history"
-            android:title="@string/overview_show_history"
-            android:summary="@string/overview_show_history_desc" />
-
     </PreferenceScreen>
 
     <SwitchPreference
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
index 03b3788..4ab0740 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivityLaunchState.java
@@ -53,31 +53,26 @@
      */
     public int getInitialFocusTaskIndex(int numTasks) {
         RecentsDebugFlags flags = Recents.getDebugFlags();
-        if (flags.isPageOnToggleEnabled() && !launchedWithAltTab) {
-            // If we are fast toggling, then focus the next task depending on when you are on home
-            // or coming in from another app
+        if (launchedWithAltTab) {
+            if (launchedFromAppWithThumbnail) {
+                // If alt-tabbing from another app, focus the next task
+                return numTasks - 2;
+            } else {
+                // If alt-tabbing from home, focus the first task
+                return numTasks - 1;
+            }
+        } else {
             if (launchedFromHome) {
                 return numTasks - 1;
             } else {
                 if (flags.isFastToggleRecentsEnabled() || !flags.isInitialStatePaging()) {
+                    // If we are not fast-toggling or are starting in the non-focused mode, then
+                    // we should assume the front most task has focus
                     return numTasks - 1;
                 } else {
                     return numTasks - 2;
                 }
             }
         }
-
-        if (launchedWithAltTab && launchedFromAppWithThumbnail) {
-            // If alt-tabbing from another app, focus the next task
-            return numTasks - 2;
-        } else if ((launchedWithAltTab && launchedFromHome) ||
-                (!launchedWithAltTab && launchedFromAppWithThumbnail)) {
-            // If alt-tabbing from home, or launching from an app normally, focus that task
-            return numTasks - 1;
-        } else {
-            // Otherwise, we are launching recents from home normally, focus no tasks so that we
-            // know to return home
-            return -1;
-        }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index 53c10b7..7547570f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -143,16 +143,13 @@
             int rightInset, Rect searchBarBounds, Rect taskStackBounds) {
         if (hasTransposedNavBar) {
             // In landscape phones, the search bar appears on the left, but we overlay it on top
-            int swInset = getInsetToSmallestWidth(windowBounds.right - rightInset -
-                    windowBounds.left);
-            taskStackBounds.set(windowBounds.left + swInset, windowBounds.top + topInset,
-                    windowBounds.right - swInset - rightInset, windowBounds.bottom);
+            taskStackBounds.set(windowBounds.left, windowBounds.top + topInset,
+                    windowBounds.right - rightInset, windowBounds.bottom);
         } else {
             // In portrait, the search bar appears on the top (which already has the inset)
-            int swInset = getInsetToSmallestWidth(windowBounds.right - windowBounds.left);
             int top = searchBarBounds.isEmpty() ? topInset : 0;
-            taskStackBounds.set(windowBounds.left + swInset, searchBarBounds.bottom + top,
-                    windowBounds.right - swInset - rightInset, windowBounds.bottom);
+            taskStackBounds.set(windowBounds.left, searchBarBounds.bottom + top,
+                    windowBounds.right - rightInset, windowBounds.bottom);
         }
     }
 
@@ -173,15 +170,4 @@
                     windowBounds.right, windowBounds.top + topInset + searchBarSize);
         }
     }
-
-    /**
-     * Constrain the width of the landscape stack to the smallest width of the device.
-     */
-    private int getInsetToSmallestWidth(int availableWidth) {
-        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
-        if (!debugFlags.isFullscreenThumbnailsEnabled() && (availableWidth > smallestWidth)) {
-            return (availableWidth - smallestWidth) / 2;
-        }
-        return 0;
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
index d778886..40c84ba 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsDebugFlags.java
@@ -26,10 +26,7 @@
  */
 public class RecentsDebugFlags implements TunerService.Tunable {
 
-    private static final String KEY_FAST_TOGGLE = "overview_fast_toggle";
-    private static final String KEY_PAGE_ON_TOGGLE = "overview_page_on_toggle";
-    private static final String KEY_FULLSCREEN_THUMBNAILS = "overview_fullscreen_thumbnails";
-    private static final String KEY_SHOW_HISTORY = "overview_show_history";
+    private static final String KEY_FAST_TOGGLE = "overview_fast_toggle_via_button";
     private static final String KEY_INITIAL_STATE_PAGING = "overview_initial_state_paging";
 
     public static class Static {
@@ -52,9 +49,6 @@
     }
 
     private boolean mFastToggleRecents;
-    private boolean mPageOnToggle;
-    private boolean mUseFullscreenThumbnails;
-    private boolean mShowHistory;
     private boolean mInitialStatePaging;
 
     /**
@@ -64,36 +58,14 @@
     public RecentsDebugFlags(Context context) {
         // Register all our flags, this will also call onTuningChanged() for each key, which will
         // initialize the current state of each flag
-        TunerService.get(context).addTunable(this, KEY_FAST_TOGGLE, KEY_PAGE_ON_TOGGLE,
-                KEY_FULLSCREEN_THUMBNAILS, KEY_SHOW_HISTORY, KEY_INITIAL_STATE_PAGING);
+        TunerService.get(context).addTunable(this, KEY_FAST_TOGGLE, KEY_INITIAL_STATE_PAGING);
     }
 
     /**
      * @return whether we are enabling fast toggling.
      */
     public boolean isFastToggleRecentsEnabled() {
-        return mPageOnToggle && mFastToggleRecents;
-    }
-
-    /**
-     * @return whether the recents button toggles pages.
-     */
-    public boolean isPageOnToggleEnabled() {
-        return mPageOnToggle;
-    }
-
-    /**
-     * @return whether we should show fullscreen thumbnails
-     */
-    public boolean isFullscreenThumbnailsEnabled() {
-        return mUseFullscreenThumbnails;
-    }
-
-    /**
-     * @return whether we should show the history
-     */
-    public boolean isHistoryEnabled() {
-        return mShowHistory;
+        return mFastToggleRecents;
     }
 
     /**
@@ -110,18 +82,6 @@
                 mFastToggleRecents = (newValue != null) &&
                         (Integer.parseInt(newValue) != 0);
                 break;
-            case KEY_PAGE_ON_TOGGLE:
-                mPageOnToggle = (newValue != null) &&
-                        (Integer.parseInt(newValue) != 0);
-                break;
-            case KEY_FULLSCREEN_THUMBNAILS:
-                mUseFullscreenThumbnails = (newValue != null) &&
-                        (Integer.parseInt(newValue) != 0);
-                break;
-            case KEY_SHOW_HISTORY:
-                mShowHistory = (newValue != null) &&
-                        (Integer.parseInt(newValue) != 0);
-                break;
             case KEY_INITIAL_STATE_PAGING:
                 mInitialStatePaging = (newValue != null) &&
                         (Integer.parseInt(newValue) != 0);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index 2a4017a..0678aae 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -333,7 +333,7 @@
                 RecentsConfiguration config = Recents.getConfiguration();
                 RecentsActivityLaunchState launchState = config.getLaunchState();
                 RecentsDebugFlags flags = Recents.getDebugFlags();
-                if (flags.isPageOnToggleEnabled() && !launchState.launchedWithAltTab) {
+                if (!launchState.launchedWithAltTab) {
                     // Notify recents to move onto the next task
                     EventBus.getDefault().post(new IterateRecentsEvent());
                 } else {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
index 1845bf9..dae6e94 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/model/RecentsTaskLoadPlan.java
@@ -152,14 +152,12 @@
             // This task is only shown in the stack if it statisfies the historical time or min
             // number of tasks constraints. Freeform tasks are also always shown.
             boolean isStackTask = true;
-            if (debugFlags.isHistoryEnabled()) {
-                boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
-                isStackTask = isFreeformTask || (!isHistoricalTask(t) ||
-                        (t.lastActiveTime >= lastStackActiveTime &&
-                                i >= (taskCount - MIN_NUM_TASKS)));
-                if (isStackTask && newLastStackActiveTime < 0) {
-                    newLastStackActiveTime = t.lastActiveTime;
-                }
+            boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
+            isStackTask = isFreeformTask || (!isHistoricalTask(t) ||
+                    (t.lastActiveTime >= lastStackActiveTime &&
+                            i >= (taskCount - MIN_NUM_TASKS)));
+            if (isStackTask && newLastStackActiveTime < 0) {
+                newLastStackActiveTime = t.lastActiveTime;
             }
 
             // Load the label, icon, and color
@@ -192,7 +190,7 @@
                 stackTasks.add(task);
             }
         }
-        if (debugFlags.isHistoryEnabled() && newLastStackActiveTime != -1) {
+        if (newLastStackActiveTime != -1) {
             Prefs.putLong(mContext, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
                     newLastStackActiveTime);
         }
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 501cbc0..21c08d1 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -599,15 +599,6 @@
         hideHistoryButton(100);
     }
 
-    public final void onBusEvent(DebugFlagsChangedEvent event) {
-        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
-        if (!debugFlags.isHistoryEnabled()) {
-            hideHistoryButton(100);
-        } else {
-            showHistoryButton(100);
-        }
-    }
-
     /**
      * Shows the history button.
      */
@@ -620,11 +611,6 @@
 
     private void showHistoryButton(final int duration,
             final ReferenceCountedTrigger postHideHistoryAnimationTrigger) {
-        RecentsDebugFlags debugFlags = Recents.getDebugFlags();
-        if (!debugFlags.isHistoryEnabled()) {
-            return;
-        }
-
         mHistoryButton.setVisibility(View.VISIBLE);
         mHistoryButton.setAlpha(0f);
         mHistoryButton.setText(getContext().getString(R.string.recents_history_label_format,
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
index f599f52..de944fc 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java
@@ -355,9 +355,7 @@
                 / (taskStackBounds.height() - mSystemInsets.bottom);
         int width = mStackRect.width();
         int minHeight = mStackRect.height() - mFocusedPeekHeight - mStackBottomOffset;
-        int height = debugFlags.isFullscreenThumbnailsEnabled()
-                ? (int) Math.min(width / aspect, minHeight)
-                : width;
+        int height = (int) Math.min(width / aspect, minHeight);
         mTaskRect.set(mStackRect.left, mStackRect.top,
                 mStackRect.left + width, mStackRect.top + height);
 
@@ -499,8 +497,7 @@
     public float getDefaultFocusState() {
         RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
         RecentsDebugFlags debugFlags = Recents.getDebugFlags();
-        if (launchState.launchedWithAltTab ||
-                (debugFlags.isPageOnToggleEnabled() && debugFlags.isInitialStatePaging())) {
+        if (launchState.launchedWithAltTab || debugFlags.isInitialStatePaging()) {
             return 1f;
         }
         return 0f;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
index 61479bf..67b2946 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -669,12 +669,7 @@
 
             if (scrollToTask) {
                 // TODO: Center the newly focused task view, only if not freeform
-                RecentsDebugFlags debugFlags = Recents.getDebugFlags();
                 float newScroll = mLayoutAlgorithm.getStackScrollForTask(newFocusedTask);
-                if (!debugFlags.isFullscreenThumbnailsEnabled()) {
-                    newScroll -= 0.5f;
-                }
-                newScroll = mStackScroller.getBoundedStackScroll(newScroll);
                 if (Float.compare(newScroll, mStackScroller.getStackScroll()) != 0) {
                     mStackScroller.animateScroll(mStackScroller.getStackScroll(), newScroll,
                             focusTaskRunnable);
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 90a5d3f..67596f7 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -493,6 +493,9 @@
     // Used to indicate that an app transition should be animated.
     private static final boolean ANIMATE = true;
 
+    // Determines whether to take full screen screenshots
+    static final boolean TAKE_FULLSCREEN_SCREENSHOTS = true;
+
     private static native int nativeMigrateToBoost();
     private static native int nativeMigrateFromBoost();
     private boolean mIsBoosted = false;
@@ -1276,7 +1279,6 @@
     boolean mAlwaysFinishActivities = false;
     boolean mForceResizableActivities;
     boolean mSupportsFreeformWindowManagement;
-    boolean mTakeFullscreenScreenshots;
     IActivityController mController = null;
     String mProfileApp = null;
     ProcessRecord mProfileProc = null;
@@ -12013,13 +12015,9 @@
                 mContext.getPackageManager().hasSystemFeature(FEATURE_FREEFORM_WINDOW_MANAGEMENT);
 
         final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
-        final String fsScreenshots = Settings.Secure.getString(resolver,
-                "overview_fullscreen_thumbnails");
         final boolean waitForDebugger = Settings.Global.getInt(resolver, WAIT_FOR_DEBUGGER, 0) != 0;
         final boolean alwaysFinishActivities =
                 Settings.Global.getInt(resolver, ALWAYS_FINISH_ACTIVITIES, 0) != 0;
-        final boolean takeFullscreenScreenshots = fsScreenshots != null &&
-                Integer.parseInt(fsScreenshots) != 0;
         final boolean forceRtl = Settings.Global.getInt(resolver, DEVELOPMENT_FORCE_RTL, 0) != 0;
         final int defaultForceResizable = Build.IS_DEBUGGABLE ? 1 : 0;
         final boolean forceResizable = Settings.Global.getInt(
@@ -12040,7 +12038,6 @@
             mAlwaysFinishActivities = alwaysFinishActivities;
             mForceResizableActivities = forceResizable;
             mSupportsFreeformWindowManagement = freeformWindowManagement || forceResizable;
-            mTakeFullscreenScreenshots = takeFullscreenScreenshots;
             // This happens before any activities are started, so we can
             // change mConfiguration in-place.
             updateConfigurationLocked(configuration, null, true);
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index ffa6a4d..0d645d0 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -862,7 +862,7 @@
             // When this flag is set, we currently take the fullscreen screenshot of the activity
             // but scaled to half the size.  This gives us a "good-enough" fullscreen thumbnail to
             // use within SystemUI while keeping memory usage low.
-            if (mService.mTakeFullscreenScreenshots) {
+            if (ActivityManagerService.TAKE_FULLSCREEN_SCREENSHOTS) {
                 w = h = -1;
                 scale = 0.5f;
             }