Merge "Make velocity tracker used in panel dependent on config."
diff --git a/core/java/com/android/internal/widget/SwipeDismissLayout.java b/core/java/com/android/internal/widget/SwipeDismissLayout.java
index bcfa036..002573e 100644
--- a/core/java/com/android/internal/widget/SwipeDismissLayout.java
+++ b/core/java/com/android/internal/widget/SwipeDismissLayout.java
@@ -35,7 +35,7 @@
 public class SwipeDismissLayout extends FrameLayout {
     private static final String TAG = "SwipeDismissLayout";
 
-    private static final float DISMISS_MIN_DRAG_WIDTH_RATIO = .4f;
+    private static final float DISMISS_MIN_DRAG_WIDTH_RATIO = .33f;
 
     public interface OnDismissedListener {
         void onDismissed(SwipeDismissLayout layout);
diff --git a/data/keyboards/Vendor_046d_Product_c21d.kl b/data/keyboards/Vendor_046d_Product_c21d.kl
new file mode 100644
index 0000000..3fbdecc
--- /dev/null
+++ b/data/keyboards/Vendor_046d_Product_c21d.kl
@@ -0,0 +1,36 @@
+# Copyright (C) 2014 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Logitech F310
+
+key 304 BUTTON_A
+key 305 BUTTON_B
+key 307 BUTTON_X
+key 308 BUTTON_Y
+key 310 BUTTON_L1
+key 311 BUTTON_R1
+key 315 BUTTON_START
+key 314 BACK
+key 316 HOME
+key 317 BUTTON_THUMBL
+key 318 BUTTON_THUMBR
+
+axis 0x00 X
+axis 0x01 Y
+axis 0x03 Z
+axis 0x04 RZ
+axis 0x05 GAS
+axis 0x02 BRAKE
+axis 0x10 HAT_X
+axis 0x11 HAT_Y
diff --git a/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml b/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
index 59b1caf..fd27aaf 100644
--- a/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
+++ b/packages/SystemUI/res/layout/qs_zen_mode_detail_condition.xml
@@ -40,7 +40,7 @@
 
     <ImageView
         android:id="@android:id/button1"
-        android:src="@drawable/ic_qs_plus"
+        android:src="@drawable/ic_qs_minus"
         android:layout_width="64dp"
         android:layout_height="64dp"
         android:layout_alignParentEnd="true"
@@ -50,10 +50,10 @@
 
     <ImageView
         android:id="@android:id/button2"
-        android:src="@drawable/ic_qs_minus"
+        android:src="@drawable/ic_qs_plus"
         android:layout_width="64dp"
         android:layout_height="64dp"
         android:layout_alignParentEnd="true"
         android:padding="@dimen/qs_panel_padding" />
 
-</RelativeLayout>
\ No newline at end of file
+</RelativeLayout>
diff --git a/packages/SystemUI/res/layout/recents_task_view.xml b/packages/SystemUI/res/layout/recents_task_view.xml
index 97051ff..7de421c 100644
--- a/packages/SystemUI/res/layout/recents_task_view.xml
+++ b/packages/SystemUI/res/layout/recents_task_view.xml
@@ -40,7 +40,7 @@
             android:layout_height="wrap_content"
             android:layout_gravity="center_vertical|left"
             android:layout_marginStart="@dimen/recents_task_view_application_icon_size"
-            android:layout_marginEnd="8dp"
+            android:layout_marginEnd="@dimen/recents_task_view_application_icon_size"
             android:textSize="22sp"
             android:textColor="#ffffffff"
             android:text="@string/recents_empty_message"
diff --git a/packages/SystemUI/res/values/config.xml b/packages/SystemUI/res/values/config.xml
index 73b52ae..0bd4f18 100644
--- a/packages/SystemUI/res/values/config.xml
+++ b/packages/SystemUI/res/values/config.xml
@@ -113,9 +113,9 @@
     <!-- The min animation duration for animating views that are newly visible. -->
     <integer name="recents_filter_animate_new_views_min_duration">125</integer>
     <!-- The min animation duration for animating the task bar in. -->
-    <integer name="recents_animate_task_bar_enter_duration">200</integer>
+    <integer name="recents_animate_task_bar_enter_duration">225</integer>
     <!-- The min animation duration for animating the task bar out. -->
-    <integer name="recents_animate_task_bar_exit_duration">150</integer>
+    <integer name="recents_animate_task_bar_exit_duration">175</integer>
     <!-- The animation duration for animating in the info pane. -->
     <integer name="recents_animate_task_view_info_pane_duration">150</integer>
     <!-- The animation duration for animating the removal of a task view. -->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/ZenModeDetail.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/ZenModeDetail.java
index 2edefe7..f30f791 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/ZenModeDetail.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/ZenModeDetail.java
@@ -49,7 +49,7 @@
 public class ZenModeDetail extends RelativeLayout {
     private static final String TAG = "ZenModeDetail";
     private static final Intent ZEN_SETTINGS = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
-    private static final int[] MINUTES = new int[] { 15, 30, 45, 60, 120, 180, 240 };
+    private static final int[] MINUTES = new int[] { 15, 30, 45, 60, 120, 180, 240, 480 };
 
     private final H mHandler = new H();
 
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
index e7119f6..befe8b4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java
@@ -313,7 +313,13 @@
                     Console.AnsiRed);
         }
         super.onStart();
-        mAppWidgetHost.startListening();
+
+        // Start listening for widget package changes if there is one bound
+        RecentsConfiguration config = RecentsConfiguration.getInstance();
+        if (config.searchBarAppWidgetId >= 0) {
+            mAppWidgetHost.startListening();
+        }
+
         mVisible = true;
     }
 
@@ -382,7 +388,12 @@
         }
         super.onStop();
 
-        mAppWidgetHost.stopListening();
+        // Stop listening for widget package changes if there was one bound
+        RecentsConfiguration config = RecentsConfiguration.getInstance();
+        if (config.searchBarAppWidgetId >= 0) {
+            mAppWidgetHost.stopListening();
+        }
+
         mVisible = false;
         mTaskLaunched = false;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
index d899c7b..03f7e36 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsConfiguration.java
@@ -16,11 +16,13 @@
 
 package com.android.systemui.recents;
 
+import android.content.ContentResolver;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Rect;
+import android.provider.Settings;
 import android.util.DisplayMetrics;
 import android.util.TypedValue;
 import android.view.animation.AnimationUtils;
@@ -68,6 +70,8 @@
     public boolean launchedFromAltTab;
     public boolean launchedWithThumbnailAnimation;
 
+    public boolean developerOptionsEnabled;
+
     /** Private constructor */
     private RecentsConfiguration() {}
 
@@ -140,6 +144,11 @@
         defaultBezierInterpolator = AnimationUtils.loadInterpolator(context,
                         com.android.internal.R.interpolator.fast_out_slow_in);
 
+        // Check if the developer options are enabled
+        ContentResolver cr = context.getContentResolver();
+        developerOptionsEnabled = Settings.Global.getInt(cr,
+                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
+
         // Update the search widget id
         SharedPreferences settings = context.getSharedPreferences(context.getPackageName(), 0);
         searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1);
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 60c442a..2b08b19 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
@@ -1113,6 +1113,11 @@
     }
 
     @Override
+    public void onTaskFocused(TaskView tv) {
+        // Do nothing
+    }
+
+    @Override
     public void onTaskDismissed(TaskView tv) {
         Task task = tv.getTask();
         // Remove the task from the view
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
index b423a3c..8575661 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java
@@ -18,15 +18,14 @@
 
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
-import android.content.ContentResolver;
 import android.content.Context;
 import android.graphics.Canvas;
 import android.graphics.Outline;
+import android.graphics.Paint;
 import android.graphics.Path;
 import android.graphics.Point;
 import android.graphics.Rect;
 import android.graphics.RectF;
-import android.provider.Settings;
 import android.util.AttributeSet;
 import android.view.MotionEvent;
 import android.view.View;
@@ -45,6 +44,7 @@
     interface TaskViewCallbacks {
         public void onTaskIconClicked(TaskView tv);
         public void onTaskAppInfoClicked(TaskView tv);
+        public void onTaskFocused(TaskView tv);
         public void onTaskDismissed(TaskView tv);
 
         // public void onTaskViewReboundToTask(TaskView tv, Task t);
@@ -227,7 +227,7 @@
         mBarView.setAlpha(0f);
         mBarView.animate()
                 .alpha(1f)
-                .setStartDelay(250)
+                .setStartDelay(300)
                 .setInterpolator(config.defaultBezierInterpolator)
                 .setDuration(config.taskBarEnterAnimDuration)
                 .withLayer()
@@ -345,6 +345,8 @@
     public void setFocusedTask() {
         mIsFocused = true;
         requestFocus();
+        invalidate();
+        mCb.onTaskFocused(this);
     }
 
     /**
@@ -355,6 +357,7 @@
         super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
         if (!gainFocus) {
             mIsFocused = false;
+            invalidate();
         }
     }
 
@@ -383,10 +386,8 @@
             mBarView.mApplicationIcon.setOnClickListener(this);
             mBarView.mDismissButton.setOnClickListener(this);
             if (Constants.DebugFlags.App.EnableDevAppInfoOnLongPress) {
-                ContentResolver cr = getContext().getContentResolver();
-                boolean devOptsEnabled = Settings.Global.getInt(cr,
-                        Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
-                if (devOptsEnabled) {
+                RecentsConfiguration config = RecentsConfiguration.getInstance();
+                if (config.developerOptionsEnabled) {
                     mBarView.mApplicationIcon.setOnLongClickListener(this);
                 }
             }
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 63a4f52..1a0dd82 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -5815,13 +5815,13 @@
         }
 
         Bitmap bm = Bitmap.createBitmap(width, height, force565 ? Config.RGB_565 : rawss.getConfig());
+        bm.eraseColor(0xFF000000);
         frame.scale(scale);
         Matrix matrix = new Matrix();
         ScreenRotationAnimation.createRotationMatrix(rot, dw, dh, matrix);
         // TODO: Test for RTL vs. LTR and use frame.right-width instead of -frame.left
         matrix.postTranslate(-FloatMath.ceil(frame.left), -FloatMath.ceil(frame.top));
         Canvas canvas = new Canvas(bm);
-        canvas.drawColor(0xFF000000);
         canvas.drawBitmap(rawss, matrix, null);
         canvas.setBitmap(null);
 
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index e746c1a..c88382c 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -1224,7 +1224,7 @@
             // Only a window that was on a non-default display can be detached from it.
             return false;
         }
-        return getDisplayContent().isDefaultDisplay;
+        return displayContent.isDefaultDisplay;
     }
 
     public void setShowToOwnerOnlyLocked(boolean showToOwnerOnly) {