Merge "Tweaking layout to make two-task stacks to closer match design." into nyc-dev
diff --git a/api/current.txt b/api/current.txt
index 3bd607b..ebda35c 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -299,13 +299,13 @@
     field public static final int backgroundTint = 16843883; // 0x101046b
     field public static final int backgroundTintMode = 16843884; // 0x101046c
     field public static final int backupAgent = 16843391; // 0x101027f
-    field public static final int backupInForeground = 16844058; // 0x101051a
+    field public static final int backupInForeground = 16844059; // 0x101051b
     field public static final int banner = 16843762; // 0x10103f2
     field public static final int baseline = 16843548; // 0x101031c
     field public static final int baselineAlignBottom = 16843042; // 0x1010122
     field public static final int baselineAligned = 16843046; // 0x1010126
     field public static final int baselineAlignedChildIndex = 16843047; // 0x1010127
-    field public static final int bitmap = 16844054; // 0x1010516
+    field public static final int bitmap = 16844055; // 0x1010517
     field public static final int borderlessButtonStyle = 16843563; // 0x101032b
     field public static final int bottom = 16843184; // 0x10101b0
     field public static final int bottomBright = 16842957; // 0x10100cd
@@ -324,7 +324,7 @@
     field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
     field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
     field public static final int buttonBarStyle = 16843566; // 0x101032e
-    field public static final int buttonGravity = 16844030; // 0x10104fe
+    field public static final int buttonGravity = 16844031; // 0x10104ff
     field public static final int buttonStyle = 16842824; // 0x1010048
     field public static final int buttonStyleInset = 16842826; // 0x101004a
     field public static final int buttonStyleSmall = 16842825; // 0x1010049
@@ -335,9 +335,9 @@
     field public static final int calendarTextColor = 16843931; // 0x101049b
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
-    field public static final int canControlMagnification = 16844039; // 0x1010507
-    field public static final int canPerformGestures = 16844045; // 0x101050d
-    field public static final int canRecord = 16844060; // 0x101051c
+    field public static final int canControlMagnification = 16844040; // 0x1010508
+    field public static final int canPerformGestures = 16844046; // 0x101050e
+    field public static final int canRecord = 16844061; // 0x101051d
     field public static final int canRequestEnhancedWebAccessibility = 16843736; // 0x10103d8
     field public static final int canRequestFilterKeyEvents = 16843737; // 0x10103d9
     field public static final int canRequestTouchExplorationMode = 16843735; // 0x10103d7
@@ -377,7 +377,7 @@
     field public static final int codes = 16843330; // 0x1010242
     field public static final int collapseColumns = 16843083; // 0x101014b
     field public static final int collapseContentDescription = 16843984; // 0x10104d0
-    field public static final int collapseIcon = 16844031; // 0x10104ff
+    field public static final int collapseIcon = 16844032; // 0x1010500
     field public static final int color = 16843173; // 0x10101a5
     field public static final int colorAccent = 16843829; // 0x1010435
     field public static final int colorActivatedHighlight = 16843664; // 0x1010390
@@ -414,18 +414,18 @@
     field public static final int contentAuthority = 16843408; // 0x1010290
     field public static final int contentDescription = 16843379; // 0x1010273
     field public static final int contentInsetEnd = 16843860; // 0x1010454
-    field public static final int contentInsetEndWithActions = 16844067; // 0x1010523
+    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
     field public static final int contentInsetLeft = 16843861; // 0x1010455
     field public static final int contentInsetRight = 16843862; // 0x1010456
     field public static final int contentInsetStart = 16843859; // 0x1010453
-    field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
+    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
     field public static final int contextClickable = 16844007; // 0x10104e7
-    field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
+    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
     field public static final int controlX1 = 16843772; // 0x10103fc
     field public static final int controlX2 = 16843774; // 0x10103fe
     field public static final int controlY1 = 16843773; // 0x10103fd
     field public static final int controlY2 = 16843775; // 0x10103ff
-    field public static final int countDown = 16844059; // 0x101051b
+    field public static final int countDown = 16844060; // 0x101051c
     field public static final int country = 16843962; // 0x10104ba
     field public static final int cropToPadding = 16843043; // 0x1010123
     field public static final int cursorVisible = 16843090; // 0x1010152
@@ -443,7 +443,7 @@
     field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
     field public static final int debuggable = 16842767; // 0x101000f
     field public static final int defaultHeight = 16844021; // 0x10104f5
-    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
+    field public static final int defaultToDeviceProtectedStorage = 16844037; // 0x1010505
     field public static final int defaultValue = 16843245; // 0x10101ed
     field public static final int defaultWidth = 16844020; // 0x10104f4
     field public static final int delay = 16843212; // 0x10101cc
@@ -463,7 +463,7 @@
     field public static final int dialogTheme = 16843528; // 0x1010308
     field public static final int dialogTitle = 16843250; // 0x10101f2
     field public static final int digits = 16843110; // 0x1010166
-    field public static final int directBootAware = 16844037; // 0x1010505
+    field public static final int directBootAware = 16844038; // 0x1010506
     field public static final int direction = 16843217; // 0x10101d1
     field public static final deprecated int directionDescriptions = 16843681; // 0x10103a1
     field public static final int directionPriority = 16843218; // 0x10101d2
@@ -511,12 +511,12 @@
     field public static final int elevation = 16843840; // 0x1010440
     field public static final int ellipsize = 16842923; // 0x10100ab
     field public static final int ems = 16843096; // 0x1010158
-    field public static final int enableVrMode = 16844069; // 0x1010525
+    field public static final int enableVrMode = 16844072; // 0x1010528
     field public static final int enabled = 16842766; // 0x101000e
     field public static final int end = 16843996; // 0x10104dc
     field public static final int endColor = 16843166; // 0x101019e
-    field public static final int endX = 16844050; // 0x1010512
-    field public static final int endY = 16844051; // 0x1010513
+    field public static final int endX = 16844051; // 0x1010513
+    field public static final int endY = 16844052; // 0x1010514
     field public static final deprecated int endYear = 16843133; // 0x101017d
     field public static final int enterFadeDuration = 16843532; // 0x101030c
     field public static final int entries = 16842930; // 0x10100b2
@@ -536,7 +536,7 @@
     field public static final int expandableListViewStyle = 16842863; // 0x101006f
     field public static final int expandableListViewWhiteStyle = 16843446; // 0x10102b6
     field public static final int exported = 16842768; // 0x1010010
-    field public static final int externalService = 16844046; // 0x101050e
+    field public static final int externalService = 16844047; // 0x101050f
     field public static final int extraTension = 16843371; // 0x101026b
     field public static final int extractNativeLibs = 16844010; // 0x10104ea
     field public static final int factor = 16843219; // 0x10101d3
@@ -561,7 +561,7 @@
     field public static final int fillBefore = 16843196; // 0x10101bc
     field public static final int fillColor = 16843780; // 0x1010404
     field public static final int fillEnabled = 16843343; // 0x101024f
-    field public static final int fillType = 16844062; // 0x101051e
+    field public static final int fillType = 16844064; // 0x1010520
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
     field public static final int filterTouchesWhenObscured = 16843460; // 0x10102c4
@@ -577,7 +577,7 @@
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
-    field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
+    field public static final int forceHasOverlappingRendering = 16844068; // 0x1010524
     field public static final int foreground = 16843017; // 0x1010109
     field public static final int foregroundGravity = 16843264; // 0x1010200
     field public static final int foregroundTint = 16843885; // 0x101046d
@@ -654,8 +654,8 @@
     field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
     field public static final int horizontalSpacing = 16843028; // 0x1010114
     field public static final int host = 16842792; // 0x1010028
-    field public static final int hotSpotX = 16844055; // 0x1010517
-    field public static final int hotSpotY = 16844056; // 0x1010518
+    field public static final int hotSpotX = 16844056; // 0x1010518
+    field public static final int hotSpotY = 16844057; // 0x1010519
     field public static final int hyphenationFrequency = 16843998; // 0x10104de
     field public static final int icon = 16842754; // 0x1010002
     field public static final int iconPreview = 16843337; // 0x1010249
@@ -742,7 +742,7 @@
     field public static final int label = 16842753; // 0x1010001
     field public static final int labelFor = 16843718; // 0x10103c6
     field public static final int labelTextSize = 16843317; // 0x1010235
-    field public static final int languageTag = 16844040; // 0x1010508
+    field public static final int languageTag = 16844041; // 0x1010509
     field public static final int largeHeap = 16843610; // 0x101035a
     field public static final int largeScreens = 16843398; // 0x1010286
     field public static final int largestWidthLimitDp = 16843622; // 0x1010366
@@ -800,7 +800,7 @@
     field public static final int layout_y = 16843136; // 0x1010180
     field public static final int left = 16843181; // 0x10101ad
     field public static final int letterSpacing = 16843958; // 0x10104b6
-    field public static final int level = 16844032; // 0x1010500
+    field public static final int level = 16844033; // 0x1010501
     field public static final int lineSpacingExtra = 16843287; // 0x1010217
     field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
     field public static final int lines = 16843092; // 0x1010154
@@ -833,7 +833,7 @@
     field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
     field public static final int matchOrder = 16843855; // 0x101044f
     field public static final int max = 16843062; // 0x1010136
-    field public static final int maxButtonHeight = 16844029; // 0x10104fd
+    field public static final int maxButtonHeight = 16844030; // 0x10104fe
     field public static final int maxDate = 16843584; // 0x1010340
     field public static final int maxEms = 16843095; // 0x1010157
     field public static final int maxHeight = 16843040; // 0x1010120
@@ -876,25 +876,26 @@
     field public static final int navigationMode = 16843471; // 0x10102cf
     field public static final int negativeButtonText = 16843254; // 0x10101f6
     field public static final int nestedScrollingEnabled = 16843830; // 0x1010436
-    field public static final int networkSecurityConfig = 16844071; // 0x1010527
+    field public static final int networkSecurityConfig = 16844074; // 0x101052a
     field public static final int nextFocusDown = 16842980; // 0x10100e4
     field public static final int nextFocusForward = 16843580; // 0x101033c
     field public static final int nextFocusLeft = 16842977; // 0x10100e1
     field public static final int nextFocusRight = 16842978; // 0x10100e2
     field public static final int nextFocusUp = 16842979; // 0x10100e3
+    field public static final int nfcAntennaPositionDrawable = 16844063; // 0x101051f
     field public static final int noHistory = 16843309; // 0x101022d
     field public static final int normalScreens = 16843397; // 0x1010285
     field public static final int notificationTimeout = 16843651; // 0x1010383
     field public static final int numColumns = 16843032; // 0x1010118
     field public static final int numStars = 16843076; // 0x1010144
-    field public static final int numberPickerStyle = 16844068; // 0x1010524
+    field public static final int numberPickerStyle = 16844071; // 0x1010527
     field public static final int numbersBackgroundColor = 16843938; // 0x10104a2
     field public static final int numbersInnerTextColor = 16844001; // 0x10104e1
     field public static final int numbersSelectorColor = 16843939; // 0x10104a3
     field public static final int numbersTextColor = 16843937; // 0x10104a1
     field public static final deprecated int numeric = 16843109; // 0x1010165
     field public static final int numericShortcut = 16843236; // 0x10101e4
-    field public static final int offset = 16844052; // 0x1010514
+    field public static final int offset = 16844053; // 0x1010515
     field public static final int onClick = 16843375; // 0x101026f
     field public static final int oneshot = 16843159; // 0x1010197
     field public static final int opacity = 16843550; // 0x101031e
@@ -941,13 +942,13 @@
     field public static final deprecated int phoneNumber = 16843111; // 0x1010167
     field public static final int pivotX = 16843189; // 0x10101b5
     field public static final int pivotY = 16843190; // 0x10101b6
-    field public static final int pointerIcon = 16844041; // 0x1010509
+    field public static final int pointerIcon = 16844042; // 0x101050a
     field public static final int popupAnimationStyle = 16843465; // 0x10102c9
     field public static final int popupBackground = 16843126; // 0x1010176
     field public static final int popupCharacters = 16843332; // 0x1010244
     field public static final int popupElevation = 16843916; // 0x101048c
-    field public static final int popupEnterTransition = 16844063; // 0x101051f
-    field public static final int popupExitTransition = 16844064; // 0x1010520
+    field public static final int popupEnterTransition = 16844065; // 0x1010521
+    field public static final int popupExitTransition = 16844066; // 0x1010522
     field public static final int popupKeyboard = 16843331; // 0x1010243
     field public static final int popupLayout = 16843323; // 0x101023b
     field public static final int popupMenuStyle = 16843520; // 0x1010300
@@ -956,7 +957,7 @@
     field public static final int port = 16842793; // 0x1010029
     field public static final int positiveButtonText = 16843253; // 0x10101f5
     field public static final int preferenceCategoryStyle = 16842892; // 0x101008c
-    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
+    field public static final int preferenceFragmentStyle = 16844039; // 0x1010507
     field public static final int preferenceInformationStyle = 16842893; // 0x101008d
     field public static final int preferenceLayoutChild = 16842900; // 0x1010094
     field public static final int preferenceScreenStyle = 16842891; // 0x101008b
@@ -1024,7 +1025,7 @@
     field public static final int resizeClip = 16843983; // 0x10104cf
     field public static final int resizeMode = 16843619; // 0x1010363
     field public static final int resizeable = 16843405; // 0x101028d
-    field public static final int resizeableActivity = 16844022; // 0x10104f6
+    field public static final int resizeableActivity = 16844023; // 0x10104f7
     field public static final int resource = 16842789; // 0x1010025
     field public static final int restoreAnyVersion = 16843450; // 0x10102ba
     field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d
@@ -1144,8 +1145,8 @@
     field public static final int startColor = 16843165; // 0x101019d
     field public static final int startDelay = 16843746; // 0x10103e2
     field public static final int startOffset = 16843198; // 0x10101be
-    field public static final int startX = 16844048; // 0x1010510
-    field public static final int startY = 16844049; // 0x1010511
+    field public static final int startX = 16844049; // 0x1010511
+    field public static final int startY = 16844050; // 0x1010512
     field public static final deprecated int startYear = 16843132; // 0x101017c
     field public static final int stateListAnimator = 16843848; // 0x1010448
     field public static final int stateNotNeeded = 16842774; // 0x1010016
@@ -1202,8 +1203,8 @@
     field public static final int summaryOn = 16843247; // 0x10101ef
     field public static final int supportsAssist = 16844016; // 0x10104f0
     field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
-    field public static final int supportsLocalInteraction = 16844047; // 0x101050f
-    field public static final int supportsPictureInPicture = 16844023; // 0x10104f7
+    field public static final int supportsLocalInteraction = 16844048; // 0x1010510
+    field public static final int supportsPictureInPicture = 16844024; // 0x10104f8
     field public static final int supportsRtl = 16843695; // 0x10103af
     field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
     field public static final int supportsUploading = 16843419; // 0x101029b
@@ -1252,7 +1253,7 @@
     field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
     field public static final int textAppearanceMedium = 16842817; // 0x1010041
     field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
-    field public static final int textAppearancePopupMenuHeader = 16844034; // 0x1010502
+    field public static final int textAppearancePopupMenuHeader = 16844035; // 0x1010503
     field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
     field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
     field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -1310,9 +1311,9 @@
     field public static final int thumbTint = 16843889; // 0x1010471
     field public static final int thumbTintMode = 16843890; // 0x1010472
     field public static final int thumbnail = 16843429; // 0x10102a5
-    field public static final int tickMark = 16844042; // 0x101050a
-    field public static final int tickMarkTint = 16844043; // 0x101050b
-    field public static final int tickMarkTintMode = 16844044; // 0x101050c
+    field public static final int tickMark = 16844043; // 0x101050b
+    field public static final int tickMarkTint = 16844044; // 0x101050c
+    field public static final int tickMarkTintMode = 16844045; // 0x101050d
     field public static final int tileMode = 16843265; // 0x1010201
     field public static final int tileModeX = 16843895; // 0x1010477
     field public static final int tileModeY = 16843896; // 0x1010478
@@ -1324,11 +1325,11 @@
     field public static final int tintMode = 16843771; // 0x10103fb
     field public static final int title = 16843233; // 0x10101e1
     field public static final int titleCondensed = 16843234; // 0x10101e2
-    field public static final int titleMargin = 16844024; // 0x10104f8
-    field public static final int titleMarginBottom = 16844028; // 0x10104fc
-    field public static final int titleMarginEnd = 16844026; // 0x10104fa
-    field public static final int titleMarginStart = 16844025; // 0x10104f9
-    field public static final int titleMarginTop = 16844027; // 0x10104fb
+    field public static final int titleMargin = 16844025; // 0x10104f9
+    field public static final int titleMarginBottom = 16844029; // 0x10104fd
+    field public static final int titleMarginEnd = 16844027; // 0x10104fb
+    field public static final int titleMarginStart = 16844026; // 0x10104fa
+    field public static final int titleMarginTop = 16844028; // 0x10104fc
     field public static final int titleTextAppearance = 16843822; // 0x101042e
     field public static final int titleTextColor = 16844003; // 0x10104e3
     field public static final int titleTextStyle = 16843512; // 0x10102f8
@@ -1367,7 +1368,7 @@
     field public static final int trimPathEnd = 16843785; // 0x1010409
     field public static final int trimPathOffset = 16843786; // 0x101040a
     field public static final int trimPathStart = 16843784; // 0x1010408
-    field public static final int tunerCount = 16844061; // 0x101051d
+    field public static final int tunerCount = 16844062; // 0x101051e
     field public static final int type = 16843169; // 0x10101a1
     field public static final int typeface = 16842902; // 0x1010096
     field public static final int uiOptions = 16843672; // 0x1010398
@@ -1375,7 +1376,7 @@
     field public static final deprecated int unfocusedMonthDateColor = 16843588; // 0x1010344
     field public static final int unselectedAlpha = 16843278; // 0x101020e
     field public static final int updatePeriodMillis = 16843344; // 0x1010250
-    field public static final int use32bitAbi = 16844053; // 0x1010515
+    field public static final int use32bitAbi = 16844054; // 0x1010516
     field public static final int useDefaultMargins = 16843641; // 0x1010379
     field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
     field public static final int useLevel = 16843167; // 0x101019f
@@ -1387,7 +1388,7 @@
     field public static final int valueType = 16843488; // 0x10102e0
     field public static final int variablePadding = 16843157; // 0x1010195
     field public static final int vendor = 16843751; // 0x10103e7
-    field public static final int version = 16844057; // 0x1010519
+    field public static final int version = 16844058; // 0x101051a
     field public static final int versionCode = 16843291; // 0x101021b
     field public static final int versionName = 16843292; // 0x101021c
     field public static final int verticalCorrection = 16843322; // 0x101023a
@@ -1431,7 +1432,7 @@
     field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
     field public static final int windowAnimationStyle = 16842926; // 0x10100ae
     field public static final int windowBackground = 16842836; // 0x1010054
-    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
+    field public static final int windowBackgroundFallback = 16844036; // 0x1010504
     field public static final int windowClipToOutline = 16843947; // 0x10104ab
     field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
     field public static final int windowContentOverlay = 16842841; // 0x1010059
diff --git a/api/removed.txt b/api/removed.txt
index 8119834..0ff2476 100644
--- a/api/removed.txt
+++ b/api/removed.txt
@@ -1,3 +1,17 @@
+package android {
+
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
+  public static final class R.styleable {
+    field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
+    field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
+  }
+
+}
+
 package android.app {
 
   public class Notification implements android.os.Parcelable {
@@ -454,6 +468,11 @@
 
 package com.android.internal {
 
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
   public static final class R.styleable {
     field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
     field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
diff --git a/api/system-current.txt b/api/system-current.txt
index 3a2f29b..0b6ac73 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -405,13 +405,13 @@
     field public static final int backgroundTint = 16843883; // 0x101046b
     field public static final int backgroundTintMode = 16843884; // 0x101046c
     field public static final int backupAgent = 16843391; // 0x101027f
-    field public static final int backupInForeground = 16844058; // 0x101051a
+    field public static final int backupInForeground = 16844059; // 0x101051b
     field public static final int banner = 16843762; // 0x10103f2
     field public static final int baseline = 16843548; // 0x101031c
     field public static final int baselineAlignBottom = 16843042; // 0x1010122
     field public static final int baselineAligned = 16843046; // 0x1010126
     field public static final int baselineAlignedChildIndex = 16843047; // 0x1010127
-    field public static final int bitmap = 16844054; // 0x1010516
+    field public static final int bitmap = 16844055; // 0x1010517
     field public static final int borderlessButtonStyle = 16843563; // 0x101032b
     field public static final int bottom = 16843184; // 0x10101b0
     field public static final int bottomBright = 16842957; // 0x10100cd
@@ -430,7 +430,7 @@
     field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
     field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
     field public static final int buttonBarStyle = 16843566; // 0x101032e
-    field public static final int buttonGravity = 16844030; // 0x10104fe
+    field public static final int buttonGravity = 16844031; // 0x10104ff
     field public static final int buttonStyle = 16842824; // 0x1010048
     field public static final int buttonStyleInset = 16842826; // 0x101004a
     field public static final int buttonStyleSmall = 16842825; // 0x1010049
@@ -441,9 +441,9 @@
     field public static final int calendarTextColor = 16843931; // 0x101049b
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
-    field public static final int canControlMagnification = 16844039; // 0x1010507
-    field public static final int canPerformGestures = 16844045; // 0x101050d
-    field public static final int canRecord = 16844060; // 0x101051c
+    field public static final int canControlMagnification = 16844040; // 0x1010508
+    field public static final int canPerformGestures = 16844046; // 0x101050e
+    field public static final int canRecord = 16844061; // 0x101051d
     field public static final int canRequestEnhancedWebAccessibility = 16843736; // 0x10103d8
     field public static final int canRequestFilterKeyEvents = 16843737; // 0x10103d9
     field public static final int canRequestTouchExplorationMode = 16843735; // 0x10103d7
@@ -483,7 +483,7 @@
     field public static final int codes = 16843330; // 0x1010242
     field public static final int collapseColumns = 16843083; // 0x101014b
     field public static final int collapseContentDescription = 16843984; // 0x10104d0
-    field public static final int collapseIcon = 16844031; // 0x10104ff
+    field public static final int collapseIcon = 16844032; // 0x1010500
     field public static final int color = 16843173; // 0x10101a5
     field public static final int colorAccent = 16843829; // 0x1010435
     field public static final int colorActivatedHighlight = 16843664; // 0x1010390
@@ -520,18 +520,18 @@
     field public static final int contentAuthority = 16843408; // 0x1010290
     field public static final int contentDescription = 16843379; // 0x1010273
     field public static final int contentInsetEnd = 16843860; // 0x1010454
-    field public static final int contentInsetEndWithActions = 16844067; // 0x1010523
+    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
     field public static final int contentInsetLeft = 16843861; // 0x1010455
     field public static final int contentInsetRight = 16843862; // 0x1010456
     field public static final int contentInsetStart = 16843859; // 0x1010453
-    field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
+    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
     field public static final int contextClickable = 16844007; // 0x10104e7
-    field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
+    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
     field public static final int controlX1 = 16843772; // 0x10103fc
     field public static final int controlX2 = 16843774; // 0x10103fe
     field public static final int controlY1 = 16843773; // 0x10103fd
     field public static final int controlY2 = 16843775; // 0x10103ff
-    field public static final int countDown = 16844059; // 0x101051b
+    field public static final int countDown = 16844060; // 0x101051c
     field public static final int country = 16843962; // 0x10104ba
     field public static final int cropToPadding = 16843043; // 0x1010123
     field public static final int cursorVisible = 16843090; // 0x1010152
@@ -549,7 +549,7 @@
     field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
     field public static final int debuggable = 16842767; // 0x101000f
     field public static final int defaultHeight = 16844021; // 0x10104f5
-    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
+    field public static final int defaultToDeviceProtectedStorage = 16844037; // 0x1010505
     field public static final int defaultValue = 16843245; // 0x10101ed
     field public static final int defaultWidth = 16844020; // 0x10104f4
     field public static final int delay = 16843212; // 0x10101cc
@@ -569,7 +569,7 @@
     field public static final int dialogTheme = 16843528; // 0x1010308
     field public static final int dialogTitle = 16843250; // 0x10101f2
     field public static final int digits = 16843110; // 0x1010166
-    field public static final int directBootAware = 16844037; // 0x1010505
+    field public static final int directBootAware = 16844038; // 0x1010506
     field public static final int direction = 16843217; // 0x10101d1
     field public static final deprecated int directionDescriptions = 16843681; // 0x10103a1
     field public static final int directionPriority = 16843218; // 0x10101d2
@@ -617,12 +617,12 @@
     field public static final int elevation = 16843840; // 0x1010440
     field public static final int ellipsize = 16842923; // 0x10100ab
     field public static final int ems = 16843096; // 0x1010158
-    field public static final int enableVrMode = 16844069; // 0x1010525
+    field public static final int enableVrMode = 16844072; // 0x1010528
     field public static final int enabled = 16842766; // 0x101000e
     field public static final int end = 16843996; // 0x10104dc
     field public static final int endColor = 16843166; // 0x101019e
-    field public static final int endX = 16844050; // 0x1010512
-    field public static final int endY = 16844051; // 0x1010513
+    field public static final int endX = 16844051; // 0x1010513
+    field public static final int endY = 16844052; // 0x1010514
     field public static final deprecated int endYear = 16843133; // 0x101017d
     field public static final int enterFadeDuration = 16843532; // 0x101030c
     field public static final int entries = 16842930; // 0x10100b2
@@ -642,7 +642,7 @@
     field public static final int expandableListViewStyle = 16842863; // 0x101006f
     field public static final int expandableListViewWhiteStyle = 16843446; // 0x10102b6
     field public static final int exported = 16842768; // 0x1010010
-    field public static final int externalService = 16844046; // 0x101050e
+    field public static final int externalService = 16844047; // 0x101050f
     field public static final int extraTension = 16843371; // 0x101026b
     field public static final int extractNativeLibs = 16844010; // 0x10104ea
     field public static final int factor = 16843219; // 0x10101d3
@@ -667,7 +667,7 @@
     field public static final int fillBefore = 16843196; // 0x10101bc
     field public static final int fillColor = 16843780; // 0x1010404
     field public static final int fillEnabled = 16843343; // 0x101024f
-    field public static final int fillType = 16844062; // 0x101051e
+    field public static final int fillType = 16844064; // 0x1010520
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
     field public static final int filterTouchesWhenObscured = 16843460; // 0x10102c4
@@ -683,7 +683,7 @@
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
-    field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
+    field public static final int forceHasOverlappingRendering = 16844068; // 0x1010524
     field public static final int foreground = 16843017; // 0x1010109
     field public static final int foregroundGravity = 16843264; // 0x1010200
     field public static final int foregroundTint = 16843885; // 0x101046d
@@ -760,8 +760,8 @@
     field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
     field public static final int horizontalSpacing = 16843028; // 0x1010114
     field public static final int host = 16842792; // 0x1010028
-    field public static final int hotSpotX = 16844055; // 0x1010517
-    field public static final int hotSpotY = 16844056; // 0x1010518
+    field public static final int hotSpotX = 16844056; // 0x1010518
+    field public static final int hotSpotY = 16844057; // 0x1010519
     field public static final int hyphenationFrequency = 16843998; // 0x10104de
     field public static final int icon = 16842754; // 0x1010002
     field public static final int iconPreview = 16843337; // 0x1010249
@@ -848,7 +848,7 @@
     field public static final int label = 16842753; // 0x1010001
     field public static final int labelFor = 16843718; // 0x10103c6
     field public static final int labelTextSize = 16843317; // 0x1010235
-    field public static final int languageTag = 16844040; // 0x1010508
+    field public static final int languageTag = 16844041; // 0x1010509
     field public static final int largeHeap = 16843610; // 0x101035a
     field public static final int largeScreens = 16843398; // 0x1010286
     field public static final int largestWidthLimitDp = 16843622; // 0x1010366
@@ -906,7 +906,7 @@
     field public static final int layout_y = 16843136; // 0x1010180
     field public static final int left = 16843181; // 0x10101ad
     field public static final int letterSpacing = 16843958; // 0x10104b6
-    field public static final int level = 16844032; // 0x1010500
+    field public static final int level = 16844033; // 0x1010501
     field public static final int lineSpacingExtra = 16843287; // 0x1010217
     field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
     field public static final int lines = 16843092; // 0x1010154
@@ -939,7 +939,7 @@
     field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
     field public static final int matchOrder = 16843855; // 0x101044f
     field public static final int max = 16843062; // 0x1010136
-    field public static final int maxButtonHeight = 16844029; // 0x10104fd
+    field public static final int maxButtonHeight = 16844030; // 0x10104fe
     field public static final int maxDate = 16843584; // 0x1010340
     field public static final int maxEms = 16843095; // 0x1010157
     field public static final int maxHeight = 16843040; // 0x1010120
@@ -982,25 +982,26 @@
     field public static final int navigationMode = 16843471; // 0x10102cf
     field public static final int negativeButtonText = 16843254; // 0x10101f6
     field public static final int nestedScrollingEnabled = 16843830; // 0x1010436
-    field public static final int networkSecurityConfig = 16844071; // 0x1010527
+    field public static final int networkSecurityConfig = 16844074; // 0x101052a
     field public static final int nextFocusDown = 16842980; // 0x10100e4
     field public static final int nextFocusForward = 16843580; // 0x101033c
     field public static final int nextFocusLeft = 16842977; // 0x10100e1
     field public static final int nextFocusRight = 16842978; // 0x10100e2
     field public static final int nextFocusUp = 16842979; // 0x10100e3
+    field public static final int nfcAntennaPositionDrawable = 16844063; // 0x101051f
     field public static final int noHistory = 16843309; // 0x101022d
     field public static final int normalScreens = 16843397; // 0x1010285
     field public static final int notificationTimeout = 16843651; // 0x1010383
     field public static final int numColumns = 16843032; // 0x1010118
     field public static final int numStars = 16843076; // 0x1010144
-    field public static final int numberPickerStyle = 16844068; // 0x1010524
+    field public static final int numberPickerStyle = 16844071; // 0x1010527
     field public static final int numbersBackgroundColor = 16843938; // 0x10104a2
     field public static final int numbersInnerTextColor = 16844001; // 0x10104e1
     field public static final int numbersSelectorColor = 16843939; // 0x10104a3
     field public static final int numbersTextColor = 16843937; // 0x10104a1
     field public static final deprecated int numeric = 16843109; // 0x1010165
     field public static final int numericShortcut = 16843236; // 0x10101e4
-    field public static final int offset = 16844052; // 0x1010514
+    field public static final int offset = 16844053; // 0x1010515
     field public static final int onClick = 16843375; // 0x101026f
     field public static final int oneshot = 16843159; // 0x1010197
     field public static final int opacity = 16843550; // 0x101031e
@@ -1047,13 +1048,13 @@
     field public static final deprecated int phoneNumber = 16843111; // 0x1010167
     field public static final int pivotX = 16843189; // 0x10101b5
     field public static final int pivotY = 16843190; // 0x10101b6
-    field public static final int pointerIcon = 16844041; // 0x1010509
+    field public static final int pointerIcon = 16844042; // 0x101050a
     field public static final int popupAnimationStyle = 16843465; // 0x10102c9
     field public static final int popupBackground = 16843126; // 0x1010176
     field public static final int popupCharacters = 16843332; // 0x1010244
     field public static final int popupElevation = 16843916; // 0x101048c
-    field public static final int popupEnterTransition = 16844063; // 0x101051f
-    field public static final int popupExitTransition = 16844064; // 0x1010520
+    field public static final int popupEnterTransition = 16844065; // 0x1010521
+    field public static final int popupExitTransition = 16844066; // 0x1010522
     field public static final int popupKeyboard = 16843331; // 0x1010243
     field public static final int popupLayout = 16843323; // 0x101023b
     field public static final int popupMenuStyle = 16843520; // 0x1010300
@@ -1062,7 +1063,7 @@
     field public static final int port = 16842793; // 0x1010029
     field public static final int positiveButtonText = 16843253; // 0x10101f5
     field public static final int preferenceCategoryStyle = 16842892; // 0x101008c
-    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
+    field public static final int preferenceFragmentStyle = 16844039; // 0x1010507
     field public static final int preferenceInformationStyle = 16842893; // 0x101008d
     field public static final int preferenceLayoutChild = 16842900; // 0x1010094
     field public static final int preferenceScreenStyle = 16842891; // 0x101008b
@@ -1130,7 +1131,7 @@
     field public static final int resizeClip = 16843983; // 0x10104cf
     field public static final int resizeMode = 16843619; // 0x1010363
     field public static final int resizeable = 16843405; // 0x101028d
-    field public static final int resizeableActivity = 16844022; // 0x10104f6
+    field public static final int resizeableActivity = 16844023; // 0x10104f7
     field public static final int resource = 16842789; // 0x1010025
     field public static final int restoreAnyVersion = 16843450; // 0x10102ba
     field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d
@@ -1254,8 +1255,8 @@
     field public static final int startColor = 16843165; // 0x101019d
     field public static final int startDelay = 16843746; // 0x10103e2
     field public static final int startOffset = 16843198; // 0x10101be
-    field public static final int startX = 16844048; // 0x1010510
-    field public static final int startY = 16844049; // 0x1010511
+    field public static final int startX = 16844049; // 0x1010511
+    field public static final int startY = 16844050; // 0x1010512
     field public static final deprecated int startYear = 16843132; // 0x101017c
     field public static final int stateListAnimator = 16843848; // 0x1010448
     field public static final int stateNotNeeded = 16842774; // 0x1010016
@@ -1312,8 +1313,8 @@
     field public static final int summaryOn = 16843247; // 0x10101ef
     field public static final int supportsAssist = 16844016; // 0x10104f0
     field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
-    field public static final int supportsLocalInteraction = 16844047; // 0x101050f
-    field public static final int supportsPictureInPicture = 16844023; // 0x10104f7
+    field public static final int supportsLocalInteraction = 16844048; // 0x1010510
+    field public static final int supportsPictureInPicture = 16844024; // 0x10104f8
     field public static final int supportsRtl = 16843695; // 0x10103af
     field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
     field public static final int supportsUploading = 16843419; // 0x101029b
@@ -1362,7 +1363,7 @@
     field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
     field public static final int textAppearanceMedium = 16842817; // 0x1010041
     field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
-    field public static final int textAppearancePopupMenuHeader = 16844034; // 0x1010502
+    field public static final int textAppearancePopupMenuHeader = 16844035; // 0x1010503
     field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
     field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
     field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -1420,9 +1421,9 @@
     field public static final int thumbTint = 16843889; // 0x1010471
     field public static final int thumbTintMode = 16843890; // 0x1010472
     field public static final int thumbnail = 16843429; // 0x10102a5
-    field public static final int tickMark = 16844042; // 0x101050a
-    field public static final int tickMarkTint = 16844043; // 0x101050b
-    field public static final int tickMarkTintMode = 16844044; // 0x101050c
+    field public static final int tickMark = 16844043; // 0x101050b
+    field public static final int tickMarkTint = 16844044; // 0x101050c
+    field public static final int tickMarkTintMode = 16844045; // 0x101050d
     field public static final int tileMode = 16843265; // 0x1010201
     field public static final int tileModeX = 16843895; // 0x1010477
     field public static final int tileModeY = 16843896; // 0x1010478
@@ -1434,11 +1435,11 @@
     field public static final int tintMode = 16843771; // 0x10103fb
     field public static final int title = 16843233; // 0x10101e1
     field public static final int titleCondensed = 16843234; // 0x10101e2
-    field public static final int titleMargin = 16844024; // 0x10104f8
-    field public static final int titleMarginBottom = 16844028; // 0x10104fc
-    field public static final int titleMarginEnd = 16844026; // 0x10104fa
-    field public static final int titleMarginStart = 16844025; // 0x10104f9
-    field public static final int titleMarginTop = 16844027; // 0x10104fb
+    field public static final int titleMargin = 16844025; // 0x10104f9
+    field public static final int titleMarginBottom = 16844029; // 0x10104fd
+    field public static final int titleMarginEnd = 16844027; // 0x10104fb
+    field public static final int titleMarginStart = 16844026; // 0x10104fa
+    field public static final int titleMarginTop = 16844028; // 0x10104fc
     field public static final int titleTextAppearance = 16843822; // 0x101042e
     field public static final int titleTextColor = 16844003; // 0x10104e3
     field public static final int titleTextStyle = 16843512; // 0x10102f8
@@ -1477,7 +1478,7 @@
     field public static final int trimPathEnd = 16843785; // 0x1010409
     field public static final int trimPathOffset = 16843786; // 0x101040a
     field public static final int trimPathStart = 16843784; // 0x1010408
-    field public static final int tunerCount = 16844061; // 0x101051d
+    field public static final int tunerCount = 16844062; // 0x101051e
     field public static final int type = 16843169; // 0x10101a1
     field public static final int typeface = 16842902; // 0x1010096
     field public static final int uiOptions = 16843672; // 0x1010398
@@ -1485,7 +1486,7 @@
     field public static final deprecated int unfocusedMonthDateColor = 16843588; // 0x1010344
     field public static final int unselectedAlpha = 16843278; // 0x101020e
     field public static final int updatePeriodMillis = 16843344; // 0x1010250
-    field public static final int use32bitAbi = 16844053; // 0x1010515
+    field public static final int use32bitAbi = 16844054; // 0x1010516
     field public static final int useDefaultMargins = 16843641; // 0x1010379
     field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
     field public static final int useLevel = 16843167; // 0x101019f
@@ -1497,7 +1498,7 @@
     field public static final int valueType = 16843488; // 0x10102e0
     field public static final int variablePadding = 16843157; // 0x1010195
     field public static final int vendor = 16843751; // 0x10103e7
-    field public static final int version = 16844057; // 0x1010519
+    field public static final int version = 16844058; // 0x101051a
     field public static final int versionCode = 16843291; // 0x101021b
     field public static final int versionName = 16843292; // 0x101021c
     field public static final int verticalCorrection = 16843322; // 0x101023a
@@ -1541,7 +1542,7 @@
     field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
     field public static final int windowAnimationStyle = 16842926; // 0x10100ae
     field public static final int windowBackground = 16842836; // 0x1010054
-    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
+    field public static final int windowBackgroundFallback = 16844036; // 0x1010504
     field public static final int windowClipToOutline = 16843947; // 0x10104ab
     field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
     field public static final int windowContentOverlay = 16842841; // 0x1010059
diff --git a/api/system-removed.txt b/api/system-removed.txt
index 7f18d6a..715312f 100644
--- a/api/system-removed.txt
+++ b/api/system-removed.txt
@@ -1,3 +1,17 @@
+package android {
+
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
+  public static final class R.styleable {
+    field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
+    field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
+  }
+
+}
+
 package android.app {
 
   public class Notification implements android.os.Parcelable {
@@ -452,6 +466,11 @@
 
 package com.android.internal {
 
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
   public static final class R.styleable {
     field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
     field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
diff --git a/api/test-current.txt b/api/test-current.txt
index 8425e90..d277fd7 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -299,13 +299,13 @@
     field public static final int backgroundTint = 16843883; // 0x101046b
     field public static final int backgroundTintMode = 16843884; // 0x101046c
     field public static final int backupAgent = 16843391; // 0x101027f
-    field public static final int backupInForeground = 16844058; // 0x101051a
+    field public static final int backupInForeground = 16844059; // 0x101051b
     field public static final int banner = 16843762; // 0x10103f2
     field public static final int baseline = 16843548; // 0x101031c
     field public static final int baselineAlignBottom = 16843042; // 0x1010122
     field public static final int baselineAligned = 16843046; // 0x1010126
     field public static final int baselineAlignedChildIndex = 16843047; // 0x1010127
-    field public static final int bitmap = 16844054; // 0x1010516
+    field public static final int bitmap = 16844055; // 0x1010517
     field public static final int borderlessButtonStyle = 16843563; // 0x101032b
     field public static final int bottom = 16843184; // 0x10101b0
     field public static final int bottomBright = 16842957; // 0x10100cd
@@ -324,7 +324,7 @@
     field public static final int buttonBarNeutralButtonStyle = 16843914; // 0x101048a
     field public static final int buttonBarPositiveButtonStyle = 16843913; // 0x1010489
     field public static final int buttonBarStyle = 16843566; // 0x101032e
-    field public static final int buttonGravity = 16844030; // 0x10104fe
+    field public static final int buttonGravity = 16844031; // 0x10104ff
     field public static final int buttonStyle = 16842824; // 0x1010048
     field public static final int buttonStyleInset = 16842826; // 0x101004a
     field public static final int buttonStyleSmall = 16842825; // 0x1010049
@@ -335,9 +335,9 @@
     field public static final int calendarTextColor = 16843931; // 0x101049b
     field public static final int calendarViewShown = 16843596; // 0x101034c
     field public static final int calendarViewStyle = 16843613; // 0x101035d
-    field public static final int canControlMagnification = 16844039; // 0x1010507
-    field public static final int canPerformGestures = 16844045; // 0x101050d
-    field public static final int canRecord = 16844060; // 0x101051c
+    field public static final int canControlMagnification = 16844040; // 0x1010508
+    field public static final int canPerformGestures = 16844046; // 0x101050e
+    field public static final int canRecord = 16844061; // 0x101051d
     field public static final int canRequestEnhancedWebAccessibility = 16843736; // 0x10103d8
     field public static final int canRequestFilterKeyEvents = 16843737; // 0x10103d9
     field public static final int canRequestTouchExplorationMode = 16843735; // 0x10103d7
@@ -377,7 +377,7 @@
     field public static final int codes = 16843330; // 0x1010242
     field public static final int collapseColumns = 16843083; // 0x101014b
     field public static final int collapseContentDescription = 16843984; // 0x10104d0
-    field public static final int collapseIcon = 16844031; // 0x10104ff
+    field public static final int collapseIcon = 16844032; // 0x1010500
     field public static final int color = 16843173; // 0x10101a5
     field public static final int colorAccent = 16843829; // 0x1010435
     field public static final int colorActivatedHighlight = 16843664; // 0x1010390
@@ -414,18 +414,18 @@
     field public static final int contentAuthority = 16843408; // 0x1010290
     field public static final int contentDescription = 16843379; // 0x1010273
     field public static final int contentInsetEnd = 16843860; // 0x1010454
-    field public static final int contentInsetEndWithActions = 16844067; // 0x1010523
+    field public static final int contentInsetEndWithActions = 16844070; // 0x1010526
     field public static final int contentInsetLeft = 16843861; // 0x1010455
     field public static final int contentInsetRight = 16843862; // 0x1010456
     field public static final int contentInsetStart = 16843859; // 0x1010453
-    field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
+    field public static final int contentInsetStartWithNavigation = 16844069; // 0x1010525
     field public static final int contextClickable = 16844007; // 0x10104e7
-    field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
+    field public static final int contextPopupMenuStyle = 16844034; // 0x1010502
     field public static final int controlX1 = 16843772; // 0x10103fc
     field public static final int controlX2 = 16843774; // 0x10103fe
     field public static final int controlY1 = 16843773; // 0x10103fd
     field public static final int controlY2 = 16843775; // 0x10103ff
-    field public static final int countDown = 16844059; // 0x101051b
+    field public static final int countDown = 16844060; // 0x101051c
     field public static final int country = 16843962; // 0x10104ba
     field public static final int cropToPadding = 16843043; // 0x1010123
     field public static final int cursorVisible = 16843090; // 0x1010152
@@ -443,7 +443,7 @@
     field public static final deprecated int dayOfWeekTextAppearance = 16843925; // 0x1010495
     field public static final int debuggable = 16842767; // 0x101000f
     field public static final int defaultHeight = 16844021; // 0x10104f5
-    field public static final int defaultToDeviceProtectedStorage = 16844036; // 0x1010504
+    field public static final int defaultToDeviceProtectedStorage = 16844037; // 0x1010505
     field public static final int defaultValue = 16843245; // 0x10101ed
     field public static final int defaultWidth = 16844020; // 0x10104f4
     field public static final int delay = 16843212; // 0x10101cc
@@ -463,7 +463,7 @@
     field public static final int dialogTheme = 16843528; // 0x1010308
     field public static final int dialogTitle = 16843250; // 0x10101f2
     field public static final int digits = 16843110; // 0x1010166
-    field public static final int directBootAware = 16844037; // 0x1010505
+    field public static final int directBootAware = 16844038; // 0x1010506
     field public static final int direction = 16843217; // 0x10101d1
     field public static final deprecated int directionDescriptions = 16843681; // 0x10103a1
     field public static final int directionPriority = 16843218; // 0x10101d2
@@ -511,12 +511,12 @@
     field public static final int elevation = 16843840; // 0x1010440
     field public static final int ellipsize = 16842923; // 0x10100ab
     field public static final int ems = 16843096; // 0x1010158
-    field public static final int enableVrMode = 16844069; // 0x1010525
+    field public static final int enableVrMode = 16844072; // 0x1010528
     field public static final int enabled = 16842766; // 0x101000e
     field public static final int end = 16843996; // 0x10104dc
     field public static final int endColor = 16843166; // 0x101019e
-    field public static final int endX = 16844050; // 0x1010512
-    field public static final int endY = 16844051; // 0x1010513
+    field public static final int endX = 16844051; // 0x1010513
+    field public static final int endY = 16844052; // 0x1010514
     field public static final deprecated int endYear = 16843133; // 0x101017d
     field public static final int enterFadeDuration = 16843532; // 0x101030c
     field public static final int entries = 16842930; // 0x10100b2
@@ -536,7 +536,7 @@
     field public static final int expandableListViewStyle = 16842863; // 0x101006f
     field public static final int expandableListViewWhiteStyle = 16843446; // 0x10102b6
     field public static final int exported = 16842768; // 0x1010010
-    field public static final int externalService = 16844046; // 0x101050e
+    field public static final int externalService = 16844047; // 0x101050f
     field public static final int extraTension = 16843371; // 0x101026b
     field public static final int extractNativeLibs = 16844010; // 0x10104ea
     field public static final int factor = 16843219; // 0x10101d3
@@ -561,7 +561,7 @@
     field public static final int fillBefore = 16843196; // 0x10101bc
     field public static final int fillColor = 16843780; // 0x1010404
     field public static final int fillEnabled = 16843343; // 0x101024f
-    field public static final int fillType = 16844062; // 0x101051e
+    field public static final int fillType = 16844064; // 0x1010520
     field public static final int fillViewport = 16843130; // 0x101017a
     field public static final int filter = 16843035; // 0x101011b
     field public static final int filterTouchesWhenObscured = 16843460; // 0x10102c4
@@ -577,7 +577,7 @@
     field public static final int fontFamily = 16843692; // 0x10103ac
     field public static final int fontFeatureSettings = 16843959; // 0x10104b7
     field public static final int footerDividersEnabled = 16843311; // 0x101022f
-    field public static final int forceHasOverlappingRendering = 16844065; // 0x1010521
+    field public static final int forceHasOverlappingRendering = 16844068; // 0x1010524
     field public static final int foreground = 16843017; // 0x1010109
     field public static final int foregroundGravity = 16843264; // 0x1010200
     field public static final int foregroundTint = 16843885; // 0x101046d
@@ -654,8 +654,8 @@
     field public static final int horizontalScrollViewStyle = 16843603; // 0x1010353
     field public static final int horizontalSpacing = 16843028; // 0x1010114
     field public static final int host = 16842792; // 0x1010028
-    field public static final int hotSpotX = 16844055; // 0x1010517
-    field public static final int hotSpotY = 16844056; // 0x1010518
+    field public static final int hotSpotX = 16844056; // 0x1010518
+    field public static final int hotSpotY = 16844057; // 0x1010519
     field public static final int hyphenationFrequency = 16843998; // 0x10104de
     field public static final int icon = 16842754; // 0x1010002
     field public static final int iconPreview = 16843337; // 0x1010249
@@ -742,7 +742,7 @@
     field public static final int label = 16842753; // 0x1010001
     field public static final int labelFor = 16843718; // 0x10103c6
     field public static final int labelTextSize = 16843317; // 0x1010235
-    field public static final int languageTag = 16844040; // 0x1010508
+    field public static final int languageTag = 16844041; // 0x1010509
     field public static final int largeHeap = 16843610; // 0x101035a
     field public static final int largeScreens = 16843398; // 0x1010286
     field public static final int largestWidthLimitDp = 16843622; // 0x1010366
@@ -800,7 +800,7 @@
     field public static final int layout_y = 16843136; // 0x1010180
     field public static final int left = 16843181; // 0x10101ad
     field public static final int letterSpacing = 16843958; // 0x10104b6
-    field public static final int level = 16844032; // 0x1010500
+    field public static final int level = 16844033; // 0x1010501
     field public static final int lineSpacingExtra = 16843287; // 0x1010217
     field public static final int lineSpacingMultiplier = 16843288; // 0x1010218
     field public static final int lines = 16843092; // 0x1010154
@@ -833,7 +833,7 @@
     field public static final int marqueeRepeatLimit = 16843293; // 0x101021d
     field public static final int matchOrder = 16843855; // 0x101044f
     field public static final int max = 16843062; // 0x1010136
-    field public static final int maxButtonHeight = 16844029; // 0x10104fd
+    field public static final int maxButtonHeight = 16844030; // 0x10104fe
     field public static final int maxDate = 16843584; // 0x1010340
     field public static final int maxEms = 16843095; // 0x1010157
     field public static final int maxHeight = 16843040; // 0x1010120
@@ -876,25 +876,26 @@
     field public static final int navigationMode = 16843471; // 0x10102cf
     field public static final int negativeButtonText = 16843254; // 0x10101f6
     field public static final int nestedScrollingEnabled = 16843830; // 0x1010436
-    field public static final int networkSecurityConfig = 16844071; // 0x1010527
+    field public static final int networkSecurityConfig = 16844074; // 0x101052a
     field public static final int nextFocusDown = 16842980; // 0x10100e4
     field public static final int nextFocusForward = 16843580; // 0x101033c
     field public static final int nextFocusLeft = 16842977; // 0x10100e1
     field public static final int nextFocusRight = 16842978; // 0x10100e2
     field public static final int nextFocusUp = 16842979; // 0x10100e3
+    field public static final int nfcAntennaPositionDrawable = 16844063; // 0x101051f
     field public static final int noHistory = 16843309; // 0x101022d
     field public static final int normalScreens = 16843397; // 0x1010285
     field public static final int notificationTimeout = 16843651; // 0x1010383
     field public static final int numColumns = 16843032; // 0x1010118
     field public static final int numStars = 16843076; // 0x1010144
-    field public static final int numberPickerStyle = 16844068; // 0x1010524
+    field public static final int numberPickerStyle = 16844071; // 0x1010527
     field public static final int numbersBackgroundColor = 16843938; // 0x10104a2
     field public static final int numbersInnerTextColor = 16844001; // 0x10104e1
     field public static final int numbersSelectorColor = 16843939; // 0x10104a3
     field public static final int numbersTextColor = 16843937; // 0x10104a1
     field public static final deprecated int numeric = 16843109; // 0x1010165
     field public static final int numericShortcut = 16843236; // 0x10101e4
-    field public static final int offset = 16844052; // 0x1010514
+    field public static final int offset = 16844053; // 0x1010515
     field public static final int onClick = 16843375; // 0x101026f
     field public static final int oneshot = 16843159; // 0x1010197
     field public static final int opacity = 16843550; // 0x101031e
@@ -941,13 +942,13 @@
     field public static final deprecated int phoneNumber = 16843111; // 0x1010167
     field public static final int pivotX = 16843189; // 0x10101b5
     field public static final int pivotY = 16843190; // 0x10101b6
-    field public static final int pointerIcon = 16844041; // 0x1010509
+    field public static final int pointerIcon = 16844042; // 0x101050a
     field public static final int popupAnimationStyle = 16843465; // 0x10102c9
     field public static final int popupBackground = 16843126; // 0x1010176
     field public static final int popupCharacters = 16843332; // 0x1010244
     field public static final int popupElevation = 16843916; // 0x101048c
-    field public static final int popupEnterTransition = 16844063; // 0x101051f
-    field public static final int popupExitTransition = 16844064; // 0x1010520
+    field public static final int popupEnterTransition = 16844065; // 0x1010521
+    field public static final int popupExitTransition = 16844066; // 0x1010522
     field public static final int popupKeyboard = 16843331; // 0x1010243
     field public static final int popupLayout = 16843323; // 0x101023b
     field public static final int popupMenuStyle = 16843520; // 0x1010300
@@ -956,7 +957,7 @@
     field public static final int port = 16842793; // 0x1010029
     field public static final int positiveButtonText = 16843253; // 0x10101f5
     field public static final int preferenceCategoryStyle = 16842892; // 0x101008c
-    field public static final int preferenceFragmentStyle = 16844038; // 0x1010506
+    field public static final int preferenceFragmentStyle = 16844039; // 0x1010507
     field public static final int preferenceInformationStyle = 16842893; // 0x101008d
     field public static final int preferenceLayoutChild = 16842900; // 0x1010094
     field public static final int preferenceScreenStyle = 16842891; // 0x101008b
@@ -1024,7 +1025,7 @@
     field public static final int resizeClip = 16843983; // 0x10104cf
     field public static final int resizeMode = 16843619; // 0x1010363
     field public static final int resizeable = 16843405; // 0x101028d
-    field public static final int resizeableActivity = 16844022; // 0x10104f6
+    field public static final int resizeableActivity = 16844023; // 0x10104f7
     field public static final int resource = 16842789; // 0x1010025
     field public static final int restoreAnyVersion = 16843450; // 0x10102ba
     field public static final deprecated int restoreNeedsApplication = 16843421; // 0x101029d
@@ -1144,8 +1145,8 @@
     field public static final int startColor = 16843165; // 0x101019d
     field public static final int startDelay = 16843746; // 0x10103e2
     field public static final int startOffset = 16843198; // 0x10101be
-    field public static final int startX = 16844048; // 0x1010510
-    field public static final int startY = 16844049; // 0x1010511
+    field public static final int startX = 16844049; // 0x1010511
+    field public static final int startY = 16844050; // 0x1010512
     field public static final deprecated int startYear = 16843132; // 0x101017c
     field public static final int stateListAnimator = 16843848; // 0x1010448
     field public static final int stateNotNeeded = 16842774; // 0x1010016
@@ -1202,8 +1203,8 @@
     field public static final int summaryOn = 16843247; // 0x10101ef
     field public static final int supportsAssist = 16844016; // 0x10104f0
     field public static final int supportsLaunchVoiceAssistFromKeyguard = 16844017; // 0x10104f1
-    field public static final int supportsLocalInteraction = 16844047; // 0x101050f
-    field public static final int supportsPictureInPicture = 16844023; // 0x10104f7
+    field public static final int supportsLocalInteraction = 16844048; // 0x1010510
+    field public static final int supportsPictureInPicture = 16844024; // 0x10104f8
     field public static final int supportsRtl = 16843695; // 0x10103af
     field public static final int supportsSwitchingToNextInputMethod = 16843755; // 0x10103eb
     field public static final int supportsUploading = 16843419; // 0x101029b
@@ -1252,7 +1253,7 @@
     field public static final int textAppearanceListItemSmall = 16843679; // 0x101039f
     field public static final int textAppearanceMedium = 16842817; // 0x1010041
     field public static final int textAppearanceMediumInverse = 16842820; // 0x1010044
-    field public static final int textAppearancePopupMenuHeader = 16844034; // 0x1010502
+    field public static final int textAppearancePopupMenuHeader = 16844035; // 0x1010503
     field public static final int textAppearanceSearchResultSubtitle = 16843424; // 0x10102a0
     field public static final int textAppearanceSearchResultTitle = 16843425; // 0x10102a1
     field public static final int textAppearanceSmall = 16842818; // 0x1010042
@@ -1310,9 +1311,9 @@
     field public static final int thumbTint = 16843889; // 0x1010471
     field public static final int thumbTintMode = 16843890; // 0x1010472
     field public static final int thumbnail = 16843429; // 0x10102a5
-    field public static final int tickMark = 16844042; // 0x101050a
-    field public static final int tickMarkTint = 16844043; // 0x101050b
-    field public static final int tickMarkTintMode = 16844044; // 0x101050c
+    field public static final int tickMark = 16844043; // 0x101050b
+    field public static final int tickMarkTint = 16844044; // 0x101050c
+    field public static final int tickMarkTintMode = 16844045; // 0x101050d
     field public static final int tileMode = 16843265; // 0x1010201
     field public static final int tileModeX = 16843895; // 0x1010477
     field public static final int tileModeY = 16843896; // 0x1010478
@@ -1324,11 +1325,11 @@
     field public static final int tintMode = 16843771; // 0x10103fb
     field public static final int title = 16843233; // 0x10101e1
     field public static final int titleCondensed = 16843234; // 0x10101e2
-    field public static final int titleMargin = 16844024; // 0x10104f8
-    field public static final int titleMarginBottom = 16844028; // 0x10104fc
-    field public static final int titleMarginEnd = 16844026; // 0x10104fa
-    field public static final int titleMarginStart = 16844025; // 0x10104f9
-    field public static final int titleMarginTop = 16844027; // 0x10104fb
+    field public static final int titleMargin = 16844025; // 0x10104f9
+    field public static final int titleMarginBottom = 16844029; // 0x10104fd
+    field public static final int titleMarginEnd = 16844027; // 0x10104fb
+    field public static final int titleMarginStart = 16844026; // 0x10104fa
+    field public static final int titleMarginTop = 16844028; // 0x10104fc
     field public static final int titleTextAppearance = 16843822; // 0x101042e
     field public static final int titleTextColor = 16844003; // 0x10104e3
     field public static final int titleTextStyle = 16843512; // 0x10102f8
@@ -1367,7 +1368,7 @@
     field public static final int trimPathEnd = 16843785; // 0x1010409
     field public static final int trimPathOffset = 16843786; // 0x101040a
     field public static final int trimPathStart = 16843784; // 0x1010408
-    field public static final int tunerCount = 16844061; // 0x101051d
+    field public static final int tunerCount = 16844062; // 0x101051e
     field public static final int type = 16843169; // 0x10101a1
     field public static final int typeface = 16842902; // 0x1010096
     field public static final int uiOptions = 16843672; // 0x1010398
@@ -1375,7 +1376,7 @@
     field public static final deprecated int unfocusedMonthDateColor = 16843588; // 0x1010344
     field public static final int unselectedAlpha = 16843278; // 0x101020e
     field public static final int updatePeriodMillis = 16843344; // 0x1010250
-    field public static final int use32bitAbi = 16844053; // 0x1010515
+    field public static final int use32bitAbi = 16844054; // 0x1010516
     field public static final int useDefaultMargins = 16843641; // 0x1010379
     field public static final int useIntrinsicSizeAsMinimum = 16843536; // 0x1010310
     field public static final int useLevel = 16843167; // 0x101019f
@@ -1387,7 +1388,7 @@
     field public static final int valueType = 16843488; // 0x10102e0
     field public static final int variablePadding = 16843157; // 0x1010195
     field public static final int vendor = 16843751; // 0x10103e7
-    field public static final int version = 16844057; // 0x1010519
+    field public static final int version = 16844058; // 0x101051a
     field public static final int versionCode = 16843291; // 0x101021b
     field public static final int versionName = 16843292; // 0x101021c
     field public static final int verticalCorrection = 16843322; // 0x101023a
@@ -1431,7 +1432,7 @@
     field public static final int windowAllowReturnTransitionOverlap = 16843835; // 0x101043b
     field public static final int windowAnimationStyle = 16842926; // 0x10100ae
     field public static final int windowBackground = 16842836; // 0x1010054
-    field public static final int windowBackgroundFallback = 16844035; // 0x1010503
+    field public static final int windowBackgroundFallback = 16844036; // 0x1010504
     field public static final int windowClipToOutline = 16843947; // 0x10104ab
     field public static final int windowCloseOnTouchOutside = 16843611; // 0x101035b
     field public static final int windowContentOverlay = 16842841; // 0x1010059
diff --git a/api/test-removed.txt b/api/test-removed.txt
index 8119834..0ff2476 100644
--- a/api/test-removed.txt
+++ b/api/test-removed.txt
@@ -1,3 +1,17 @@
+package android {
+
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
+  public static final class R.styleable {
+    field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
+    field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
+  }
+
+}
+
 package android.app {
 
   public class Notification implements android.os.Parcelable {
@@ -454,6 +468,11 @@
 
 package com.android.internal {
 
+  public static final class R.attr {
+    field public static final int minimalHeight = 16844067; // 0x1010523
+    field public static final int minimalWidth = 16844022; // 0x10104f6
+  }
+
   public static final class R.styleable {
     field public static final int AndroidManifestLayout_minimalHeight = 6; // 0x6
     field public static final int AndroidManifestLayout_minimalWidth = 5; // 0x5
diff --git a/core/java/android/animation/ObjectAnimator.java b/core/java/android/animation/ObjectAnimator.java
index 1d10860..5c4b979 100644
--- a/core/java/android/animation/ObjectAnimator.java
+++ b/core/java/android/animation/ObjectAnimator.java
@@ -227,10 +227,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between int values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated. This object should
      * have a public method on it called <code>setName()</code>, where <code>name</code> is
@@ -274,10 +275,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between int values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated.
      * @param property The property being animated.
@@ -383,10 +385,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between color values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated. This object should
      * have a public method on it called <code>setName()</code>, where <code>name</code> is
@@ -403,10 +406,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between color values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated.
      * @param property The property being animated.
@@ -422,10 +426,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between float values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated. This object should
      * have a public method on it called <code>setName()</code>, where <code>name</code> is
@@ -469,10 +474,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between float values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * @param target The object whose property is to be animated.
      * @param property The property being animated.
@@ -580,10 +586,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between Object values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * <p><strong>Note:</strong> The values are stored as references to the original
      * objects, which means that changes to those objects after this method is called will
@@ -635,10 +642,11 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between Object values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation).
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
      *
      * <p><strong>Note:</strong> The values are stored as references to the original
      * objects, which means that changes to those objects after this method is called will
@@ -665,12 +673,13 @@
 
     /**
      * Constructs and returns an ObjectAnimator that animates between Object values. A single
-     * value implies that that value is the one being animated to. Two values imply starting
-     * and ending values. More than two values imply a starting value, values to animate through
-     * along the way, and an ending value (these values will be distributed evenly across
-     * the duration of the animation). This variant supplies a <code>TypeConverter</code> to
-     * convert from the animated values to the type of the property. If only one value is
-     * supplied, the <code>TypeConverter</code> must be a
+     * value implies that that value is the one being animated to, in which case the start value
+     * will be derived from the property being animated and the target object when {@link #start()}
+     * is called for the first time. Two values imply starting and ending values. More than two
+     * values imply a starting value, values to animate through along the way, and an ending value
+     * (these values will be distributed evenly across the duration of the animation).
+     * This variant supplies a <code>TypeConverter</code> to convert from the animated values to the
+     * type of the property. If only one value is supplied, the <code>TypeConverter</code> must be a
      * {@link android.animation.BidirectionalTypeConverter} to retrieve the current value.
      *
      * <p><strong>Note:</strong> The values are stored as references to the original
diff --git a/core/java/android/app/ActivityManagerInternal.java b/core/java/android/app/ActivityManagerInternal.java
index 4b8d9ee..3a70a4c 100644
--- a/core/java/android/app/ActivityManagerInternal.java
+++ b/core/java/android/app/ActivityManagerInternal.java
@@ -18,6 +18,7 @@
 
 import android.annotation.NonNull;
 import android.content.ComponentName;
+import android.content.IIntentSender;
 import android.os.IBinder;
 import android.service.voice.IVoiceInteractionSession;
 
@@ -144,4 +145,10 @@
      * Kill foreground apps from the specified user.
      */
     public abstract void killForegroundAppsForUser(int userHandle);
+
+    /**
+     *  Sets how long a {@link PendingIntent} can be temporarily whitelist to by bypass restrictions
+     *  such as Power Save mode.
+     */
+    public abstract void setPendingIntentWhitelistDuration(IIntentSender target, long duration);
 }
diff --git a/core/java/android/app/ActivityManagerNative.java b/core/java/android/app/ActivityManagerNative.java
index cd9a05b..f12c284 100644
--- a/core/java/android/app/ActivityManagerNative.java
+++ b/core/java/android/app/ActivityManagerNative.java
@@ -6966,8 +6966,8 @@
         reply.recycle();
     }
 
-    public void notifyLockedProfile(@UserIdInt int userId) throws RemoteException
-    {
+    @Override
+    public void notifyLockedProfile(@UserIdInt int userId) throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
         data.writeInterfaceToken(IActivityManager.descriptor);
@@ -6978,6 +6978,7 @@
         reply.recycle();
     }
 
+    @Override
     public void startConfirmDeviceCredentialIntent(Intent intent) throws RemoteException {
         Parcel data = Parcel.obtain();
         Parcel reply = Parcel.obtain();
@@ -6989,6 +6990,7 @@
         reply.recycle();
     }
 
+    @Override
     public int sendIntentSender(IIntentSender target, int code, Intent intent, String resolvedType,
             IIntentReceiver finishedReceiver, String requiredPermission, Bundle options)
             throws RemoteException {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 0cc44e7..e108dd6 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -4323,18 +4323,23 @@
                 // experience
                 bigTextText = mBuilder.processLegacyText(text);
             }
-            contentView.setTextViewText(R.id.big_text, bigTextText);
-            contentView.setViewVisibility(R.id.big_text,
-                    TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE);
-            contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines());
-            contentView.setBoolean(R.id.big_text, "setHasImage", mBuilder.mN.mLargeIcon != null);
+            applyBigTextContentView(mBuilder, contentView, bigTextText);
 
             return contentView;
         }
 
-        private int calculateMaxLines() {
+        static void applyBigTextContentView(Builder builder,
+                RemoteViews contentView, CharSequence bigTextText) {
+            contentView.setTextViewText(R.id.big_text, bigTextText);
+            contentView.setViewVisibility(R.id.big_text,
+                    TextUtils.isEmpty(bigTextText) ? View.GONE : View.VISIBLE);
+            contentView.setInt(R.id.big_text, "setMaxLines", calculateMaxLines(builder));
+            contentView.setBoolean(R.id.big_text, "setHasImage", builder.mN.mLargeIcon != null);
+        }
+
+        private static int calculateMaxLines(Builder builder) {
             int lineCount = MAX_LINES;
-            boolean hasActions = mBuilder.mActions.size() > 0;
+            boolean hasActions = builder.mActions.size() > 0;
             if (hasActions) {
                 lineCount -= LINES_CONSUMED_BY_ACTIONS;
             }
@@ -4532,6 +4537,16 @@
                     : mConversationTitle;
             boolean hasTitle = !TextUtils.isEmpty(title);
 
+            if (!hasTitle && mMessages.size() == 1) {
+                CharSequence sender = mMessages.get(0).mSender;
+                CharSequence text = mMessages.get(0).mText;
+                RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
+                        mBuilder.getBigTextLayoutResource(),
+                        false /* progress */, sender, null /* text */);
+                BigTextStyle.applyBigTextContentView(mBuilder, contentView, text);
+                return contentView;
+            }
+
             RemoteViews contentView = mBuilder.applyStandardTemplateWithActions(
                     mBuilder.getMessagingLayoutResource(),
                     false /* hasProgress */,
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index b758868..108350a 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -285,6 +285,12 @@
     public static final int BIND_ADJUST_WITH_ACTIVITY = 0x0080;
 
     /**
+     * @hide Flag for {@link #bindService}: allows application hosting service to manage whitelists
+     * such as temporary allowing a {@code PendingIntent} to bypass Power Save mode.
+     */
+    public static final int BIND_ALLOW_WHITELIST_MANAGEMENT = 0x01000000;
+
+    /**
      * @hide Flag for {@link #bindService}: Like {@link #BIND_FOREGROUND_SERVICE},
      * but only applies while the device is awake.
      */
diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java
index c285acb..ce7a124 100644
--- a/core/java/android/os/PowerManager.java
+++ b/core/java/android/os/PowerManager.java
@@ -1021,9 +1021,19 @@
     }
 
     /**
-     * Returns True if the device supports Sustained Performance Mode.
-     * Applications Should check if the device supports this mode, before
-     * using {@link android.view.Window#setSustainedPerformanceMode}.
+     * This function checks if the device has implemented Sustained Performance
+     * Mode. This needs to be checked only once and is constant for a particular
+     * device/release.
+     *
+     * Sustained Performance Mode is intended to provide a consistent level of
+     * performance for prolonged amount of time.
+     *
+     * Applications should check if the device supports this mode, before using
+     * {@link android.view.Window#setSustainedPerformanceMode}.
+     *
+     * @return Returns True if the device supports it, false otherwise.
+     *
+     * @see android.view.Window#setSustainedPerformanceMode
      */
     public boolean isSustainedPerformanceModeSupported() {
         return mContext.getResources().getBoolean(
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 0bc514e..f867fb0 100755
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -60,8 +60,8 @@
 import android.util.ArrayMap;
 import android.util.ArraySet;
 import android.util.Log;
-
 import android.util.MemoryIntArray;
+
 import com.android.internal.annotations.GuardedBy;
 import com.android.internal.util.ArrayUtils;
 import com.android.internal.widget.ILockSettings;
@@ -7950,6 +7950,7 @@
          * idle_factor                      (float)
          * min_time_to_alarm                (long)
          * max_temp_app_whitelist_duration  (long)
+         * notification_whitelist_duration  (long)
          * </pre>
          *
          * <p>
diff --git a/core/java/android/view/inputmethod/InputMethodManagerInternal.java b/core/java/android/view/inputmethod/InputMethodManagerInternal.java
index ce9908c..77df4e3 100644
--- a/core/java/android/view/inputmethod/InputMethodManagerInternal.java
+++ b/core/java/android/view/inputmethod/InputMethodManagerInternal.java
@@ -32,4 +32,9 @@
      * Called by the window manager to let the input method manager rotate the input method.
      */
     void switchInputMethod(boolean forwardDirection);
+
+    /**
+     * Hides the current input method, if visible.
+     */
+    void hideCurrentInputMethod();
 }
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java
index 3711b94..5cbd284 100644
--- a/core/java/android/widget/TextView.java
+++ b/core/java/android/widget/TextView.java
@@ -6857,11 +6857,11 @@
                         .setLineSpacing(mSpacingAdd, mSpacingMult)
                         .setIncludePad(mIncludePad)
                         .setBreakStrategy(mBreakStrategy)
-                        .setHyphenationFrequency(mHyphenationFrequency)
-                        .setMaxLines(mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE);
+                        .setHyphenationFrequency(mHyphenationFrequency);
                 if (shouldEllipsize) {
                     builder.setEllipsize(mEllipsize)
-                            .setEllipsizedWidth(ellipsisWidth);
+                            .setEllipsizedWidth(ellipsisWidth)
+                            .setMaxLines(mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE);
                 }
                 mHintLayout = builder.build();
             }
@@ -6948,12 +6948,11 @@
                     .setLineSpacing(mSpacingAdd, mSpacingMult)
                     .setIncludePad(mIncludePad)
                     .setBreakStrategy(mBreakStrategy)
-                    .setHyphenationFrequency(mHyphenationFrequency)
-                    .setMaxLines(mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE);
+                    .setHyphenationFrequency(mHyphenationFrequency);
             if (shouldEllipsize) {
                 builder.setEllipsize(effectiveEllipsize)
-                        .setEllipsizedWidth(ellipsisWidth);
-
+                        .setEllipsizedWidth(ellipsisWidth)
+                        .setMaxLines(mMaxMode == LINES ? mMaximum : Integer.MAX_VALUE);
             }
             // TODO: explore always setting maxLines
             result = builder.build();
@@ -6983,19 +6982,14 @@
         return false;
     }
 
-    private static int desired(Layout layout, int maxLines) {
+    private static int desired(Layout layout) {
         int n = layout.getLineCount();
         CharSequence text = layout.getText();
         float max = 0;
 
-        // if maxLines is set, and the text length is greater that the length of the text in the
-        // layout, it means that there is a cut-off and we cannot use it.
-        if (maxLines != -1 && text.length() > layout.getLineEnd(n - 1)) {
-            return -1;
-        }
-
         // if any line was wrapped, we can't use it.
         // but it's ok for the last line not to have a newline
+
         for (int i = 0; i < n - 1; i++) {
             if (text.charAt(layout.getLineEnd(i) - 1) != '\n')
                 return -1;
@@ -7068,7 +7062,7 @@
             width = widthSize;
         } else {
             if (mLayout != null && mEllipsize == null) {
-                des = desired(mLayout, getMaxLines());
+                des = desired(mLayout);
             }
 
             if (des < 0) {
@@ -7100,7 +7094,7 @@
                 int hintWidth;
 
                 if (mHintLayout != null && mEllipsize == null) {
-                    hintDes = desired(mHintLayout, getMaxLines());
+                    hintDes = desired(mHintLayout);
                 }
 
                 if (hintDes < 0) {
diff --git a/core/java/com/android/internal/os/BatteryStatsImpl.java b/core/java/com/android/internal/os/BatteryStatsImpl.java
index 93dc625..8b02352 100644
--- a/core/java/com/android/internal/os/BatteryStatsImpl.java
+++ b/core/java/com/android/internal/os/BatteryStatsImpl.java
@@ -8153,14 +8153,17 @@
     }
 
     private void resetAllStatsLocked() {
+        final long uptimeMillis = mClocks.uptimeMillis();
+        final long elapsedRealtimeMillis = mClocks.elapsedRealtime();
         mStartCount = 0;
-        initTimes(mClocks.uptimeMillis() * 1000, mClocks.elapsedRealtime() * 1000);
+        initTimes(uptimeMillis * 1000, elapsedRealtimeMillis * 1000);
         mScreenOnTimer.reset(false);
         for (int i=0; i<NUM_SCREEN_BRIGHTNESS_BINS; i++) {
             mScreenBrightnessTimer[i].reset(false);
         }
         mInteractiveTimer.reset(false);
         mPowerSaveModeEnabledTimer.reset(false);
+        mLastIdleTimeStart = elapsedRealtimeMillis;
         mLongestLightIdleTime = 0;
         mLongestFullIdleTime = 0;
         mDeviceIdleModeLightTimer.reset(false);
diff --git a/core/jni/android_graphics_drawable_VectorDrawable.cpp b/core/jni/android_graphics_drawable_VectorDrawable.cpp
index 9e69f79..045f127 100644
--- a/core/jni/android_graphics_drawable_VectorDrawable.cpp
+++ b/core/jni/android_graphics_drawable_VectorDrawable.cpp
@@ -36,6 +36,13 @@
     return reinterpret_cast<jlong>(tree);
 }
 
+static jlong createTreeFromCopy(JNIEnv*, jobject, jlong treePtr, jlong groupPtr) {
+    VectorDrawable::Group* rootGroup = reinterpret_cast<VectorDrawable::Group*>(groupPtr);
+    VectorDrawable::Tree* treeToCopy = reinterpret_cast<VectorDrawable::Tree*>(treePtr);
+    VectorDrawable::Tree* tree = new VectorDrawable::Tree(treeToCopy, rootGroup);
+    return reinterpret_cast<jlong>(tree);
+}
+
 static jlong createEmptyFullPath(JNIEnv*, jobject) {
     VectorDrawable::FullPath* newPath = new VectorDrawable::FullPath();
     return reinterpret_cast<jlong>(newPath);
@@ -344,6 +351,7 @@
 
 static const JNINativeMethod gMethods[] = {
         {"nCreateTree", "!(J)J", (void*)createTree},
+        {"nCreateTreeFromCopy", "!(JJ)J", (void*)createTreeFromCopy},
         {"nSetRendererViewportSize", "!(JFF)V", (void*)setTreeViewportSize},
         {"nSetRootAlpha", "!(JF)Z", (void*)setRootAlpha},
         {"nGetRootAlpha", "!(J)F", (void*)getRootAlpha},
diff --git a/core/res/res/layout/app_error_dialog.xml b/core/res/res/layout/app_error_dialog.xml
index 7147ea2..9a5bbd4 100644
--- a/core/res/res/layout/app_error_dialog.xml
+++ b/core/res/res/layout/app_error_dialog.xml
@@ -35,11 +35,11 @@
     />
 
     <Button
-            android:id="@+id/aerr_reset"
+            android:id="@+id/aerr_close"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
-            android:text="@string/aerr_reset"
-            android:drawableStart="@drawable/ic_refresh"
+            android:text="@string/aerr_close"
+            android:drawableStart="@drawable/ic_close"
             style="@style/aerr_list_item"
     />
 
@@ -53,15 +53,6 @@
     />
 
     <Button
-            android:id="@+id/aerr_close"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/aerr_close"
-            android:drawableStart="@drawable/ic_close"
-            style="@style/aerr_list_item"
-    />
-
-    <Button
             android:id="@+id/aerr_mute"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
diff --git a/core/res/res/layout/notification_template_header.xml b/core/res/res/layout/notification_template_header.xml
index d16dcc6..38ea92a 100644
--- a/core/res/res/layout/notification_template_header.xml
+++ b/core/res/res/layout/notification_template_header.xml
@@ -96,6 +96,7 @@
         android:layout_height="wrap_content"
         android:paddingTop="1dp"
         android:visibility="gone"
+        android:contentDescription="@string/expand_button_content_description"
         />
     <ImageView android:id="@+id/profile_badge"
         android:layout_width="@dimen/notification_badge_size"
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index b61d6cf..d12e34c 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -593,6 +593,9 @@
              the appearance matches the branding of the app requesting the fingerprint scan.-->
         <attr name="fingerprintAuthDrawable" format="reference" />
 
+	<!-- Asset that should be used to show users the position of the NFC antenna on the device. -->
+	<attr name="nfcAntennaPositionDrawable" format="reference" />
+
         <!-- ============ -->
         <!-- Panel styles -->
         <!-- ============ -->
@@ -4591,6 +4594,10 @@
             screens with limited space for text. -->
             <enum name="full" value="2" />
         </attr>
+        <!-- Placeholder for a deleted attribute. This should be removed before M release. -->
+        <attr name="__removeBeforeMRelease_leftIndents" format="reference" />
+        <!-- Placeholder for a deleted attribute. This should be removed before M release. -->
+        <attr name="__removeBeforeMRelease_rightIndents" format="reference" />
     </declare-styleable>
     <declare-styleable name="TextViewAppearance">
         <!-- Base text color, typeface, size, and style. -->
diff --git a/core/res/res/values/public.xml b/core/res/res/values/public.xml
index 6797799..fee2469 100644
--- a/core/res/res/values/public.xml
+++ b/core/res/res/values/public.xml
@@ -2595,13 +2595,13 @@
     <public type="attr" name="accessibilityTraversalAfter" id="0x010104d2" />
     <public type="attr" name="dialogPreferredPadding" id="0x010104d3" />
     <public type="attr" name="searchHintIcon" id="0x010104d4" />
-    <public type="attr" name="revisionCode" id="0x010104d5" />
-    <public type="attr" name="drawableTint" id="0x010104d6" />
-    <public type="attr" name="drawableTintMode" id="0x010104d7" />
-    <public type="attr" name="fraction" id="0x010104d8" />
+    <public type="attr" name="revisionCode" />
+    <public type="attr" name="drawableTint" />
+    <public type="attr" name="drawableTintMode" />
+    <public type="attr" name="fraction" />
 
-    <public type="style" name="Theme.DeviceDefault.Dialog.Alert" id="0x010302d1" />
-    <public type="style" name="Theme.DeviceDefault.Light.Dialog.Alert" id="0x010302d2" />
+    <public type="style" name="Theme.DeviceDefault.Dialog.Alert" />
+    <public type="style" name="Theme.DeviceDefault.Light.Dialog.Alert" />
 
   <!-- ===============================================================
        Resources added in version M of the platform
@@ -2653,79 +2653,85 @@
     <public type="id" name="accessibilityActionScrollRight" id="0x0102003b" />
     <public type="id" name="accessibilityActionContextClick" id="0x0102003c" />
 
-    <public type="string" name="fingerprint_icon_content_description" id="0x01040018" />
+    <public type="string" name="fingerprint_icon_content_description" />
 
   <!-- ===============================================================
        Resources added in version N of the platform
        =============================================================== -->
     <eat-comment />
 
-    <public type="attr" name="listMenuViewStyle" id="0x010104f2" />
-    <public type="attr" name="subMenuArrow" id="0x010104f3" />
-    <public type="attr" name="defaultWidth" id="0x010104f4" />
-    <public type="attr" name="defaultHeight" id="0x010104f5" />
-    <public type="attr" name="resizeableActivity" id="0x010104f6" />
-    <public type="attr" name="supportsPictureInPicture" id="0x010104f7" />
-    <public type="attr" name="titleMargin" id="0x010104f8" />
-    <public type="attr" name="titleMarginStart" id="0x010104f9" />
-    <public type="attr" name="titleMarginEnd" id="0x010104fa" />
-    <public type="attr" name="titleMarginTop" id="0x010104fb" />
-    <public type="attr" name="titleMarginBottom" id="0x010104fc" />
-    <public type="attr" name="maxButtonHeight" id="0x010104fd" />
-    <public type="attr" name="buttonGravity" id="0x010104fe" />
-    <public type="attr" name="collapseIcon" id="0x010104ff" />
-    <public type="attr" name="level" id="0x01010500" />
-    <public type="attr" name="contextPopupMenuStyle" id="0x01010501" />
-    <public type="attr" name="textAppearancePopupMenuHeader" id="0x01010502" />
-    <public type="attr" name="windowBackgroundFallback" id="0x01010503" />
-    <public type="attr" name="defaultToDeviceProtectedStorage" id="0x01010504" />
-    <public type="attr" name="directBootAware" id="0x01010505" />
-    <public type="attr" name="preferenceFragmentStyle" id="0x01010506" />
-    <public type="attr" name="canControlMagnification" id="0x01010507" />
-    <public type="attr" name="languageTag" id="0x01010508" />
-    <public type="attr" name="pointerIcon" id="0x01010509" />
-    <public type="attr" name="tickMark" id="0x0101050a" />
-    <public type="attr" name="tickMarkTint" id="0x0101050b" />
-    <public type="attr" name="tickMarkTintMode" id="0x0101050c" />
-    <public type="attr" name="canPerformGestures" id="0x0101050d" />
-    <public type="attr" name="externalService" id="0x0101050e" />
-    <public type="attr" name="supportsLocalInteraction" id="0x0101050f" />
-    <public type="attr" name="startX" id="0x01010510" />
-    <public type="attr" name="startY" id="0x01010511" />
-    <public type="attr" name="endX" id="0x01010512" />
-    <public type="attr" name="endY" id="0x01010513" />
-    <public type="attr" name="offset" id="0x01010514" />
-    <public type="attr" name="use32bitAbi" id="0x01010515" />
-    <public type="attr" name="bitmap" id="0x01010516" />
-    <public type="attr" name="hotSpotX" id="0x01010517" />
-    <public type="attr" name="hotSpotY" id="0x01010518" />
-    <public type="attr" name="version" id="0x01010519" />
-    <public type="attr" name="backupInForeground" id="0x0101051a" />
-    <public type="attr" name="countDown" id="0x0101051b" />
-    <public type="attr" name="canRecord" id="0x0101051c" />
-    <public type="attr" name="tunerCount" id="0x0101051d" />
-    <public type="attr" name="fillType" id="0x0101051e" />
-    <public type="attr" name="popupEnterTransition" id="0x0101051f" />
-    <public type="attr" name="popupExitTransition" id="0x01010520" />
-    <public type="attr" name="forceHasOverlappingRendering" id="0x01010521" />
-    <public type="attr" name="contentInsetStartWithNavigation" id="0x01010522" />
-    <public type="attr" name="contentInsetEndWithActions" id="0x01010523" />
-    <public type="attr" name="numberPickerStyle" id="0x01010524" />
-    <public type="attr" name="enableVrMode" id="0x01010525" />
-    <public type="attr" name="hash" id="0x01010526" />
-    <public type="attr" name="networkSecurityConfig" id="0x01010527" />
+    <public type="attr" name="listMenuViewStyle" />
+    <public type="attr" name="subMenuArrow" />
+    <public type="attr" name="defaultWidth" />
+    <public type="attr" name="defaultHeight" />
+    <!-- @removed -->
+    <public type="attr" name="minimalWidth" />
+    <public type="attr" name="resizeableActivity" />
+    <public type="attr" name="supportsPictureInPicture" />
+    <public type="attr" name="titleMargin" />
+    <public type="attr" name="titleMarginStart" />
+    <public type="attr" name="titleMarginEnd" />
+    <public type="attr" name="titleMarginTop" />
+    <public type="attr" name="titleMarginBottom" />
+    <public type="attr" name="maxButtonHeight" />
+    <public type="attr" name="buttonGravity" />
+    <public type="attr" name="collapseIcon" />
+    <public type="attr" name="level" />
+    <public type="attr" name="contextPopupMenuStyle" />
+    <public type="attr" name="textAppearancePopupMenuHeader" />
+    <public type="attr" name="windowBackgroundFallback" />
+    <public type="attr" name="defaultToDeviceProtectedStorage" />
+    <public type="attr" name="directBootAware" />
+    <public type="attr" name="preferenceFragmentStyle" />
+    <public type="attr" name="canControlMagnification" />
+    <public type="attr" name="languageTag" />
+    <public type="attr" name="pointerIcon" />
+    <public type="attr" name="tickMark" />
+    <public type="attr" name="tickMarkTint" />
+    <public type="attr" name="tickMarkTintMode" />
+    <public type="attr" name="canPerformGestures" />
+    <public type="attr" name="externalService" />
+    <public type="attr" name="supportsLocalInteraction" />
+    <public type="attr" name="startX" />
+    <public type="attr" name="startY" />
+    <public type="attr" name="endX" />
+    <public type="attr" name="endY" />
+    <public type="attr" name="offset" />
+    <public type="attr" name="use32bitAbi" />
+    <public type="attr" name="bitmap" />
+    <public type="attr" name="hotSpotX" />
+    <public type="attr" name="hotSpotY" />
+    <public type="attr" name="version" />
+    <public type="attr" name="backupInForeground" />
+    <public type="attr" name="countDown" />
+    <public type="attr" name="canRecord" />
+    <public type="attr" name="tunerCount" />
+    <public type="attr" name="nfcAntennaPositionDrawable" />
+    <public type="attr" name="fillType" />
+    <public type="attr" name="popupEnterTransition" />
+    <public type="attr" name="popupExitTransition" />
+    <!-- @removed -->
+    <public type="attr" name="minimalHeight" />
+    <public type="attr" name="forceHasOverlappingRendering" />
+    <public type="attr" name="contentInsetStartWithNavigation" />
+    <public type="attr" name="contentInsetEndWithActions" />
+    <public type="attr" name="numberPickerStyle" />
+    <public type="attr" name="enableVrMode" />
+    <public type="attr" name="hash" />
+    <public type="attr" name="networkSecurityConfig" />
 
-    <public type="style" name="Theme.Material.Light.DialogWhenLarge.DarkActionBar" id="0x010302d8" />
-    <public type="style" name="Widget.Material.SeekBar.Discrete" id="0x010302d9" />
-    <public type="style" name="Widget.Material.CompoundButton.Switch" id="0x010302da" />
-    <public type="style" name="Widget.Material.Light.CompoundButton.Switch" id="0x010302db" />
-    <public type="style" name="Widget.Material.NumberPicker" id="0x010302dc" />
-    <public type="style" name="Widget.Material.Light.NumberPicker" id="0x010302dd" />
-    <public type="style" name="TextAppearance.Material.Widget.Button.Colored" id="0x010302de" />
-    <public type="style" name="TextAppearance.Material.Widget.Button.Borderless.Colored" id="0x010302df" />
+    <public type="style" name="Theme.Material.Light.DialogWhenLarge.DarkActionBar" />
+    <public type="style" name="Widget.Material.SeekBar.Discrete" />
+    <public type="style" name="Widget.Material.CompoundButton.Switch" />
+    <public type="style" name="Widget.Material.Light.CompoundButton.Switch" />
+    <public type="style" name="Widget.Material.NumberPicker" />
+    <public type="style" name="Widget.Material.Light.NumberPicker" />
+    <public type="style" name="TextAppearance.Material.Widget.Button.Colored" />
+    <public type="style" name="TextAppearance.Material.Widget.Button.Borderless.Colored" />
 
-    <public type="id" name="accessibilityActionSetProgress" id="0x0102003d" />
-    <public type="id" name="icon_frame" id="0x0102003e" />
-    <public type="id" name="list_container" id="0x0102003f" />
-    <public type="id" name="switch_widget" id="0x01020040" />
+    <public type="id" name="accessibilityActionSetProgress" />
+    <public type="id" name="icon_frame" />
+    <public type="id" name="list_container" />
+    <public type="id" name="switch_widget" />
+
 </resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index e30fd1a..3a28822 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -2725,9 +2725,7 @@
     <!-- Text of the alert that is displayed when a process has crashed repeatedly. -->
     <string name="aerr_process_repeated"><xliff:g id="process">%1$s</xliff:g> keeps stopping</string>
     <!-- Button that restarts a crashed application -->
-    <string name="aerr_restart">Restart app</string>
-    <!-- Button that clears cache and restarts a crashed application -->
-    <string name="aerr_reset">Reset and restart app</string>
+    <string name="aerr_restart">Open app again</string>
     <!-- Button that sends feedback about a crashed application -->
     <string name="aerr_report">Send feedback</string>
     <!-- Button that closes a crashed application -->
@@ -4261,6 +4259,12 @@
     <!-- Content description of the work profile icon in the notification. -->
     <string name="notification_work_profile_content_description">Work profile</string>
 
+    <!-- Content description of the expand button icon in the notification.-->
+    <string name="expand_button_content_description">Expand button</string>
+
+    <!-- Accessibility action description on the expand button. -->
+    <string name="expand_action_accessibility">Click to expand</string>
+
     <!-- User visible name for USB MIDI Peripheral port -->
     <string name="usb_midi_peripheral_name">Android USB Peripheral Port</string>
     <!-- Manufacturer name for USB MIDI Peripheral port -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 737daed..9ab42a9 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2445,7 +2445,6 @@
   <java-symbol type="id" name="work_widget_badge_icon" />
 
   <java-symbol type="id" name="aerr_report" />
-  <java-symbol type="id" name="aerr_reset" />
   <java-symbol type="id" name="aerr_restart" />
   <java-symbol type="id" name="aerr_close" />
   <java-symbol type="id" name="aerr_mute" />
diff --git a/docs/html/_redirects.yaml b/docs/html/_redirects.yaml
index 9e9343e..2464e9e 100644
--- a/docs/html/_redirects.yaml
+++ b/docs/html/_redirects.yaml
@@ -50,25 +50,25 @@
 - from: /tools/sdk/installing.html
   to: /studio/index.html
 - from: /tools/eclipse/installing-adt.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /sdk/requirements.html
   to: /studio/index.html
 - from: /sdk/installing/next.html
   to: /training/basics/firstapp/index.html
 - from: /sdk/installing/installing-adt.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/projects/projects-eclipse.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/building/building-eclipse.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/building/building-cmdline-ant.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/testing/testing_eclipse.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/debugging/debugging-projects.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/publishing/app-signing-eclipse.html
-  to: /studio/tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 - from: /tools/testing/testing_ui.html
   to: /training/testing/ui-testing/index.html
 - from: /tools/testing/activity_test.html
@@ -99,10 +99,6 @@
   to: /training/testing/ui-testing/index.html
 - from: /guide/market/
   to: /google/play/
-- from: /guide/google/gcm/client-javadoc/...
-  to: /reference/com/google/android/gms/gcm/package-summary.html
-- from: /guide/google/gcm/server-javadoc/...
-  to: /reference/com/google/android/gms/gcm/package-summary.html
 - from: /guide/google/play/services.html
   to: https://developers.google.com/android/guides/overview
 - from: /guide/google/
@@ -771,10 +767,6 @@
   to: https://developers.google.com/android/guides/api-client
 - from: /google/auth/http-auth.html
   to: https://developers.google.com/android/guides/http-auth
-- from: /reference/gms-packages.html
-  to: https://developers.google.com/android/reference/packages
-- from: /reference/com/google/android/gms/
-  to: https://developers.google.com/android/reference/com/google/android/gms/
 - from: /preview/features/runtime-permissions.html
   to: /training/permissions/index.html
 - from: /preview/features/app-linking.html
@@ -865,11 +857,18 @@
 - from: /tools/testing-support-library/...
   to: /topic/libraries/testing-support-library/...
 
-# GCM redirects
+# GMS and GCM reference redirects
+- from: /reference/gms-packages.html
+  to: https://developers.google.com/android/reference/packages
+- from: /guide/google/gcm/client-javadoc/...
+  to: https://developers.google.com/android/reference/com/google/android/gms/gcm/package-summary
+- from: /guide/google/gcm/server-javadoc/...
+  to: https://developers.google.com/android/reference/com/google/android/gms/gcm/package-summary
+- from: /reference/com/google/android/gcm/...
+  to: https://developers.google.com/android/reference/com/google/android/gms/gcm/package-summary
 - from: /reference/com/google/...
   to: https://developers.google.com/android/reference/com/google/...
 
-
 # Files moved during the /studio restructure
 - from: /sdk/index.html
   to: /studio/index.html
@@ -1147,6 +1146,8 @@
   to: /studio/profile/ddms.html
 - from: /tools/revisions/index.html
   to: /studio/releases/index.html
+- from: /tools/help/adt.html
+  to: /studio/tools/sdk/eclipse-adt.html
 
 # Just incase something was missed, go to intro page
 - from: /tools/...
diff --git a/docs/html/about/dashboards/index.jd b/docs/html/about/dashboards/index.jd
index f4a03db..fff2608 100644
--- a/docs/html/about/dashboards/index.jd
+++ b/docs/html/about/dashboards/index.jd
@@ -63,19 +63,10 @@
 <br/>Any versions with less than 0.1% distribution are not shown.</em>
 </p>
 
-<p class="note"><strong>Note:</strong> This data is gathered from the new Google Play
-Store app, which supports Android 2.2 and above, so devices running older versions are not included.
-However, in August, 2013, versions older than Android 2.2 accounted for about 1% of devices that
-<em>checked in</em> to Google servers (not those that actually visited Google Play Store).
-</p>
-
-
-
 
 
 <h2 id="Screens">Screen Sizes and Densities</h2>
 
-
 <p>This section provides data about the relative number of devices that have a particular
 screen configuration, defined by a combination of screen size and density. To simplify the way that
 you design your user interfaces for different screen configurations, Android divides the range of
diff --git a/docs/html/ndk/guides/audio/opensl-prog-notes.jd b/docs/html/ndk/guides/audio/opensl-prog-notes.jd
index 3263145..e70aa08 100644
--- a/docs/html/ndk/guides/audio/opensl-prog-notes.jd
+++ b/docs/html/ndk/guides/audio/opensl-prog-notes.jd
@@ -61,8 +61,8 @@
  create array and can be added
 later after the object is created. The Android implementation provides
  a convenience feature to
-avoid this complexity; see the
- <a href="#dynamic-interfaces">Dynamic interfaces at object creation</a> section above.
+avoid this complexity, which is described in
+ <a href="{@docRoot}ndk/guides/audio/opensl-for-android.html#dynamic-interfaces">Dynamic interfaces at object creation</a>.
 </p>
 
 <p>
diff --git a/docs/html/samples/index.jd b/docs/html/samples/index.jd
index 76ea573..5885086 100644
--- a/docs/html/samples/index.jd
+++ b/docs/html/samples/index.jd
@@ -35,9 +35,8 @@
   from GitHub as a new project.
 </p>
 
-<p>For more information about importing samples, see
-<a href="{@docRoot}tools/studio/index.html#git-samples">Easy access to Android code samples on
-GitHub</a>.</p>
+<p>To view the Android code samples that you can import, see the 
+<a class="external-link" href="https://github.com/googlesamples/">Google Samples page</a> on GitHub.</p>
 
 <h2>Download Samples</h2>
 
diff --git a/docs/html/training/sync-adapters/running-sync-adapter.jd b/docs/html/training/sync-adapters/running-sync-adapter.jd
index 033450f..a640aa6 100644
--- a/docs/html/training/sync-adapters/running-sync-adapter.jd
+++ b/docs/html/training/sync-adapters/running-sync-adapter.jd
@@ -240,6 +240,7 @@
              * Ask the framework to run your sync adapter.
              * To maintain backward compatibility, assume that
              * changeUri is null.
+             */
             ContentResolver.requestSync(ACCOUNT, AUTHORITY, null);
         }
         ...
diff --git a/docs/html/wear/preview/features/ui-nav-actions.jd b/docs/html/wear/preview/features/ui-nav-actions.jd
index f5e2fc4..1ba275f 100644
--- a/docs/html/wear/preview/features/ui-nav-actions.jd
+++ b/docs/html/wear/preview/features/ui-nav-actions.jd
@@ -76,6 +76,7 @@
 &lt;android.support.wearable.view.drawer.WearableDrawerLayout
     android:id="@+id/drawer_layout"
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     tools:deviceIds="wear">
diff --git a/graphics/java/android/graphics/drawable/VectorDrawable.java b/graphics/java/android/graphics/drawable/VectorDrawable.java
index dd33e98..f5592fa 100644
--- a/graphics/java/android/graphics/drawable/VectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/VectorDrawable.java
@@ -804,7 +804,7 @@
                 mTintMode = copy.mTintMode;
                 mAutoMirrored = copy.mAutoMirrored;
                 mRootGroup = new VGroup(copy.mRootGroup, mVGTargetsMap);
-                createNativeTree(mRootGroup);
+                createNativeTreeFromCopy(copy, mRootGroup);
 
                 mBaseWidth = copy.mBaseWidth;
                 mBaseHeight = copy.mBaseHeight;
@@ -826,6 +826,16 @@
             VMRuntime.getRuntime().registerNativeAllocation(NATIVE_ALLOCATION_SIZE);
         }
 
+        // Create a new native tree with the given root group, and copy the properties from the
+        // given VectorDrawableState's native tree.
+        private void createNativeTreeFromCopy(VectorDrawableState copy, VGroup rootGroup) {
+            mNativeTree = new VirtualRefBasePtr(nCreateTreeFromCopy(
+                    copy.mNativeTree.get(), rootGroup.mNativePtr));
+            // Register tree size
+            VMRuntime.getRuntime().registerNativeAllocation(NATIVE_ALLOCATION_SIZE);
+        }
+
+
         void onTreeConstructionFinished() {
             mRootGroup.setTree(mNativeTree);
             mAllocationOfAllNodes = mRootGroup.getNativeSize();
@@ -1777,6 +1787,7 @@
     }
 
     private static native long nCreateTree(long rootGroupPtr);
+    private static native long nCreateTreeFromCopy(long treeToCopy, long rootGroupPtr);
     private static native void nSetRendererViewportSize(long rendererPtr, float viewportWidth,
             float viewportHeight);
     private static native boolean nSetRootAlpha(long rendererPtr, float alpha);
diff --git a/libs/hwui/VectorDrawable.cpp b/libs/hwui/VectorDrawable.cpp
index f0348e4..2b79941 100644
--- a/libs/hwui/VectorDrawable.cpp
+++ b/libs/hwui/VectorDrawable.cpp
@@ -530,7 +530,7 @@
     if (prop->getRootAlpha() == 1.0f && prop->getColorFilter() == nullptr) {
         return nullptr;
     } else {
-        outPaint->setColorFilter(mStagingProperties.getColorFilter());
+        outPaint->setColorFilter(prop->getColorFilter());
         outPaint->setFilterQuality(kLow_SkFilterQuality);
         outPaint->setAlpha(prop->getRootAlpha() * 255);
         return outPaint;
diff --git a/libs/hwui/VectorDrawable.h b/libs/hwui/VectorDrawable.h
index b33f26c..a5d1d4b 100644
--- a/libs/hwui/VectorDrawable.h
+++ b/libs/hwui/VectorDrawable.h
@@ -542,6 +542,12 @@
     Tree(Group* rootNode) : mRootNode(rootNode) {
         mRootNode->setPropertyChangedListener(&mPropertyChangedListener);
     }
+
+    // Copy properties from the tree and use the give node as the root node
+    Tree(const Tree* copy, Group* rootNode) : Tree(rootNode) {
+        mStagingProperties.syncAnimatableProperties(*copy->stagingProperties());
+        mStagingProperties.syncNonAnimatableProperties(*copy->stagingProperties());
+    }
     // Draws the VD onto a bitmap cache, then the bitmap cache will be rendered onto the input
     // canvas. Returns the number of pixels needed for the bitmap cache.
     int draw(Canvas* outCanvas, SkColorFilter* colorFilter,
@@ -666,7 +672,7 @@
     };
     void onPropertyChanged(TreeProperties* prop);
     TreeProperties* mutateStagingProperties() { return &mStagingProperties; }
-    const TreeProperties* stagingProperties() { return &mStagingProperties; }
+    const TreeProperties* stagingProperties() const { return &mStagingProperties; }
     PushStagingFunctor* getFunctor() { return &mFunctor;}
 
     // This should only be called from animations on RT
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/Camera2SurfaceViewTestCase.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/Camera2SurfaceViewTestCase.java
index 423c3b0..a8b782e8 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/Camera2SurfaceViewTestCase.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/Camera2SurfaceViewTestCase.java
@@ -37,6 +37,7 @@
 import android.hardware.camera2.CameraMetadata;
 import android.hardware.camera2.CaptureRequest;
 import android.hardware.camera2.CaptureResult;
+import android.hardware.camera2.params.StreamConfigurationMap;
 import android.media.ImageReader;
 import android.graphics.SurfaceTexture;
 import android.os.Bundle;
@@ -127,6 +128,7 @@
     protected List<Size> mOrderedRAW10Sizes; // In descending order.
     protected List<Size> mOrderedYUV420888Sizes; // In descending order.
     protected HashMap<Size, Long> mMinPreviewFrameDurationMap;
+    protected boolean mSupportRAW10;
 
     protected WindowManager mWindowManager;
 
@@ -603,16 +605,21 @@
         mCamera = CameraTestUtils.openCamera(
                 mCameraManager, cameraId, mCameraListener, mHandler);
         mCollector.setCameraId(cameraId);
-        mStaticInfo = new StaticMetadata(mCameraManager.getCameraCharacteristics(cameraId),
-                CheckLevel.ASSERT, /*collector*/null);
+        CameraCharacteristics properties = mCameraManager.getCameraCharacteristics(cameraId);
+        mStaticInfo = new StaticMetadata(properties, CheckLevel.ASSERT, /*collector*/null);
+        StreamConfigurationMap configMap =
+                properties.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
+        mSupportRAW10 = configMap.isOutputSupportedFor(ImageFormat.RAW10);
         if (mStaticInfo.isColorOutputSupported()) {
             mOrderedPreviewSizes = getSupportedPreviewSizes(cameraId, mCameraManager,
                     getPreviewSizeBound(mWindowManager, PREVIEW_SIZE_BOUND));
             mOrderedVideoSizes = getSupportedVideoSizes(
                     cameraId, mCameraManager, PREVIEW_SIZE_BOUND);
             mOrderedStillSizes = getSupportedStillSizes(cameraId, mCameraManager, null);
-            mOrderedRAW10Sizes = getSortedSizesForFormat(
-                    cameraId, mCameraManager, ImageFormat.RAW10, null);
+            if (mSupportRAW10) {
+                mOrderedRAW10Sizes = getSortedSizesForFormat(
+                        cameraId, mCameraManager, ImageFormat.RAW10, null);
+            }
             mOrderedYUV420888Sizes = getSortedSizesForFormat(
                     cameraId, mCameraManager, ImageFormat.YUV_420_888, null);
             // Use ImageFormat.YUV_420_888 for now. TODO: need figure out what's format for preview
@@ -636,6 +643,7 @@
             mOrderedPreviewSizes = null;
             mOrderedVideoSizes = null;
             mOrderedStillSizes = null;
+            mSupportRAW10 = false;
         }
     }
 
diff --git a/packages/SystemUI/res/anim/tv_pip_controls_text_focus_gain_animation.xml b/packages/SystemUI/res/anim/tv_pip_controls_focus_gain_animation.xml
similarity index 100%
rename from packages/SystemUI/res/anim/tv_pip_controls_text_focus_gain_animation.xml
rename to packages/SystemUI/res/anim/tv_pip_controls_focus_gain_animation.xml
diff --git a/packages/SystemUI/res/anim/tv_pip_controls_text_focus_lose_animation.xml b/packages/SystemUI/res/anim/tv_pip_controls_focus_loss_animation.xml
similarity index 100%
rename from packages/SystemUI/res/anim/tv_pip_controls_text_focus_lose_animation.xml
rename to packages/SystemUI/res/anim/tv_pip_controls_focus_loss_animation.xml
diff --git a/packages/SystemUI/res/anim/tv_pip_controls_in_recents_focus_lose_animation.xml b/packages/SystemUI/res/anim/tv_pip_controls_in_recents_focus_loss_animation.xml
similarity index 100%
rename from packages/SystemUI/res/anim/tv_pip_controls_in_recents_focus_lose_animation.xml
rename to packages/SystemUI/res/anim/tv_pip_controls_in_recents_focus_loss_animation.xml
diff --git a/packages/SystemUI/res/layout-television/recents_on_tv.xml b/packages/SystemUI/res/layout-television/recents_on_tv.xml
index 82b9f8c..2b78bee 100644
--- a/packages/SystemUI/res/layout-television/recents_on_tv.xml
+++ b/packages/SystemUI/res/layout-television/recents_on_tv.xml
@@ -21,6 +21,7 @@
     android:clipChildren="false"
     android:clipToPadding="false"
     android:background="@drawable/recents_tv_background_gradient">
+
     <com.android.systemui.recents.tv.views.TaskStackHorizontalGridView
         android:id="@+id/task_list"
         android:layout_width="wrap_content"
@@ -32,13 +33,13 @@
         android:focusable="true"
         android:layoutDirection="rtl" />
 
-    <!-- Placeholder view to give focus to the PIP menus. -->
+    <!-- Placeholder view to give focus to the PIP menus in talkback mode -->
     <View
         android:id="@+id/pip"
         android:layout_width="1dp"
         android:layout_height="1dp"
         android:focusable="true"
-        android:visibility="visible" />
+        android:visibility="gone" />
 
     <!-- Placeholder to dismiss during talkback. -->
     <ImageView
diff --git a/packages/SystemUI/res/layout/qs_detail.xml b/packages/SystemUI/res/layout/qs_detail.xml
index 32839d8..63390e2 100644
--- a/packages/SystemUI/res/layout/qs_detail.xml
+++ b/packages/SystemUI/res/layout/qs_detail.xml
@@ -44,7 +44,7 @@
         android:layout_height="wrap_content"
         />
 
-    <ScrollView
+    <com.android.systemui.qs.NonInterceptingScrollView
         android:layout_width="match_parent"
         android:layout_height="0dp"
         android:layout_weight="1">
@@ -52,7 +52,7 @@
             android:id="@android:id/content"
             android:layout_width="match_parent"
             android:layout_height="wrap_content" />
-    </ScrollView>
+    </com.android.systemui.qs.NonInterceptingScrollView>
 
     <include layout="@layout/qs_detail_buttons" />
 
diff --git a/packages/SystemUI/res/layout/tv_pip_control_button.xml b/packages/SystemUI/res/layout/tv_pip_control_button.xml
index f18a5da..096dda8 100644
--- a/packages/SystemUI/res/layout/tv_pip_control_button.xml
+++ b/packages/SystemUI/res/layout/tv_pip_control_button.xml
@@ -23,15 +23,25 @@
     <ImageView android:id="@+id/button"
         android:layout_width="34dp"
         android:layout_height="34dp"
-        android:padding="5dp"
+        android:layout_alignParentTop="true"
+        android:layout_centerHorizontal="true"
         android:focusable="true"
-        android:src="@drawable/ic_fullscreen_white_24dp"
-        android:background="@drawable/tv_pip_button_focused"
-        android:layerType="software" />
+        android:src="@drawable/tv_pip_button_focused"
+        android:importantForAccessibility="yes" />
+
+    <ImageView android:id="@+id/icon"
+        android:layout_width="34dp"
+        android:layout_height="34dp"
+        android:layout_alignParentTop="true"
+        android:layout_centerHorizontal="true"
+        android:padding="5dp"
+        android:importantForAccessibility="no" />
 
     <TextView android:id="@+id/desc"
         android:layout_width="100dp"
         android:layout_height="wrap_content"
+        android:layout_below="@id/icon"
+        android:layout_centerHorizontal="true"
         android:layout_marginTop="3dp"
         android:gravity="center"
         android:text="@string/pip_fullscreen"
diff --git a/packages/SystemUI/res/layout/tv_pip_recents_overlay.xml b/packages/SystemUI/res/layout/tv_pip_recents_overlay.xml
index 557bbe6..f157fd5 100644
--- a/packages/SystemUI/res/layout/tv_pip_recents_overlay.xml
+++ b/packages/SystemUI/res/layout/tv_pip_recents_overlay.xml
@@ -15,7 +15,7 @@
 -->
 <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
+    android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:gravity="top|center_horizontal"
     android:orientation="vertical">
@@ -33,7 +33,8 @@
             android:layout_height="32dp"
             android:translationY="-46dp"
             android:layout_gravity="top|center_horizontal"
-            android:background="@drawable/tv_pip_recents_overlay_scrim" />
+            android:background="@drawable/tv_pip_recents_overlay_scrim"
+            android:alpha="0" />
         <com.android.systemui.tv.pip.PipControlsView
             android:id="@+id/pip_control_contents"
             android:layout_width="wrap_content"
@@ -42,6 +43,8 @@
             android:layout_gravity="top|center_horizontal" />
     </com.android.systemui.tv.pip.PipRecentsControlsView>
 
+    <!-- Placeholder view to handle focus change between Recents row and PIP controls
+        in talkback mode -->
     <View
         android:id="@+id/recents"
         android:layout_width="1dp"
diff --git a/packages/SystemUI/src/com/android/systemui/qs/NonInterceptingScrollView.java b/packages/SystemUI/src/com/android/systemui/qs/NonInterceptingScrollView.java
new file mode 100644
index 0000000..15e1c96
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/NonInterceptingScrollView.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+package com.android.systemui.qs;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.MotionEvent;
+import android.widget.ScrollView;
+
+/**
+ * ScrollView that disallows intercepting for touches that can cause scrolling.
+ */
+public class NonInterceptingScrollView extends ScrollView {
+
+    private float mInitialY;
+
+    public NonInterceptingScrollView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent ev) {
+        int action = ev.getActionMasked();
+        switch (action) {
+            case MotionEvent.ACTION_DOWN:
+                mInitialY = ev.getY();
+                break;
+            case MotionEvent.ACTION_UP:
+            case MotionEvent.ACTION_CANCEL:
+                requestDisallowInterceptTouchEvent(false);
+                break;
+            default:
+                if (canScrollVertically(ev.getY() > mInitialY ? -1 : 1)) {
+                    requestDisallowInterceptTouchEvent(true);
+                }
+                break;
+        }
+        return super.onTouchEvent(ev);
+    }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
index f05aa3c..feacaa0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSTileBaseView.java
@@ -154,9 +154,9 @@
             event.setClassName(mAccessibilityClass);
             if (Switch.class.getName().equals(mAccessibilityClass)) {
                 String label = getResources()
-                        .getString(mTileState ? R.string.switch_bar_on : R.string.switch_bar_off);
+                        .getString(!mTileState ? R.string.switch_bar_on : R.string.switch_bar_off);
                 event.setContentDescription(label);
-                event.setChecked(mTileState);
+                event.setChecked(!mTileState);
             }
         }
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
index cfc6c52..b20f46f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsImpl.java
@@ -372,7 +372,7 @@
             if (stack.getTaskCount() > 0) {
                 // Only preload the icon (but not the thumbnail since it may not have been taken for
                 // the pausing activity)
-                preloadIcon(runningTask);
+                preloadIcon(runningTask.id);
 
                 // At this point, we don't know anything about the stack state.  So only calculate
                 // the dimensions of the thumbnail that we need for the transition into Recents, but
@@ -664,10 +664,10 @@
     /**
      * Preloads the icon of a task.
      */
-    private void preloadIcon(ActivityManager.RunningTaskInfo task) {
+    private void preloadIcon(int runningTaskId) {
         // Ensure that we load the running task's icon
         RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
-        launchOpts.runningTaskId = task.id;
+        launchOpts.runningTaskId = runningTaskId;
         launchOpts.loadThumbnails = false;
         launchOpts.onlyLoadForCache = true;
         Recents.getTaskLoader().loadTasks(mContext, sInstanceLoadPlan, launchOpts);
@@ -699,7 +699,7 @@
     private ActivityOptions getThumbnailTransitionActivityOptions(
             ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView,
                     Rect windowOverrideRect) {
-        if (runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
+        if (runningTask != null && runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
             ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
             ArrayList<Task> tasks = stackView.getStack().getStackTasks();
             TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
@@ -810,6 +810,10 @@
         RecentsTaskLoader loader = Recents.getTaskLoader();
         RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
 
+        int runningTaskId = !mLaunchedWhileDocking && (runningTask != null)
+                ? runningTask.id
+                : -1;
+
         // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
         // should always preload the tasks now. If we are dragging in recents, reload them as
         // the stacks might have changed.
@@ -818,7 +822,7 @@
             sInstanceLoadPlan = loader.createLoadPlan(mContext);
         }
         if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
-            loader.preloadTasks(sInstanceLoadPlan, runningTask.id, !isHomeStackVisible);
+            loader.preloadTasks(sInstanceLoadPlan, runningTaskId, !isHomeStackVisible);
         }
 
         TaskStack stack = sInstanceLoadPlan.getTaskStack();
@@ -830,12 +834,12 @@
         launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking;
         launchState.launchedViaDockGesture = mLaunchedWhileDocking;
         launchState.launchedViaDragGesture = mDraggingInRecents;
-        launchState.launchedToTaskId = (runningTask != null) ? runningTask.id : -1;
+        launchState.launchedToTaskId = runningTaskId;
         launchState.launchedWithAltTab = mTriggeredFromAltTab;
 
         // Preload the icon (this will be a null-op if we have preloaded the icon already in
         // preloadRecents())
-        preloadIcon(runningTask);
+        preloadIcon(runningTaskId);
 
         // Update the header bar if necessary
         Rect windowOverrideRect = getWindowRectOverride(growTarget);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
index 1a55958..ecb12d3 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/RecentsTvActivity.java
@@ -81,6 +81,7 @@
     private long mLastTabKeyEventTime;
     private boolean mIgnoreAltTabRelease;
     private boolean mLaunchedFromHome;
+    private boolean mTalkBackEnabled;
 
     private RecentsTvView mRecentsView;
     private View mPipView;
@@ -133,15 +134,22 @@
 
                 @Override
                 public void onRecentsFocused() {
-                    mRecentsView.requestFocus();
-                    mRecentsView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
+                    if (mTalkBackEnabled) {
+                        mTaskStackHorizontalGridView.requestFocus();
+                        mTaskStackHorizontalGridView.sendAccessibilityEvent(
+                                AccessibilityEvent.TYPE_VIEW_FOCUSED);
+                    }
+                    mTaskStackHorizontalGridView.startFocusGainAnimation();
                 }
             };
+
     private final View.OnFocusChangeListener mPipViewFocusChangeListener =
             new View.OnFocusChangeListener() {
                 @Override
                 public void onFocusChange(View v, boolean hasFocus) {
-                    handlePipViewFocusChange(hasFocus);
+                    if (hasFocus) {
+                        requestPipControlsFocus();
+                    }
                 }
             };
 
@@ -194,17 +202,18 @@
         loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
         loader.loadTasks(this, plan, loadOpts);
 
-
-        mRecentsView.setTaskStack(stack);
         List stackTasks = stack.getStackTasks();
         Collections.reverse(stackTasks);
         if (mTaskStackViewAdapter == null) {
             mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
             mTaskStackHorizontalGridView = mRecentsView
                     .setTaskStackViewAdapter(mTaskStackViewAdapter);
+            mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(
+                    getApplicationContext(), mTaskStackHorizontalGridView);
         } else {
             mTaskStackViewAdapter.setNewStackTasks(stackTasks);
         }
+        mRecentsView.init(stack);
 
         if (launchState.launchedToTaskId != -1) {
             ArrayList<Task> tasks = stack.getStackTasks();
@@ -305,6 +314,7 @@
                 View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
 
         mPipView = findViewById(R.id.pip);
+        mPipView.setOnFocusChangeListener(mPipViewFocusChangeListener);
         // Place mPipView at the PIP bounds for fine tuned focus handling.
         Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
         LayoutParams lp = (LayoutParams) mPipView.getLayoutParams();
@@ -342,7 +352,6 @@
         if(mLaunchedFromHome) {
             mHomeRecentsEnterExitAnimationHolder.startEnterAnimation(mPipManager.isPipShown());
         }
-        mTaskStackViewAdapter.setResetAddedCards(true);
         EventBus.getDefault().send(new EnterRecentsWindowAnimationCompletedEvent());
     }
 
@@ -353,19 +362,6 @@
         // Update the recent tasks
         updateRecentsTasks();
 
-        mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(
-                getApplicationContext(), mTaskStackHorizontalGridView);
-        if(mTaskStackHorizontalGridView != null &&
-                mTaskStackHorizontalGridView.getChildCount() > 0) {
-            if(mLaunchedFromHome) {
-                mHomeRecentsEnterExitAnimationHolder.setEnterFromHomeStartingAnimationValues();
-            } else {
-                mHomeRecentsEnterExitAnimationHolder.setEnterFromAppStartingAnimationValues();
-            }
-        } else {
-            mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
-        }
-
         // If this is a new instance from a configuration change, then we have to manually trigger
         // the enter animation state, or if recents was relaunched by AM, without going through
         // the normal mechanisms
@@ -387,9 +383,11 @@
         } else {
             mTaskStackHorizontalGridView.setSelectedPosition(0);
         }
+        mRecentsView.getViewTreeObserver().addOnPreDrawListener(this);
 
         View dismissPlaceholder = findViewById(R.id.dismiss_placeholder);
-        if (ssp.isTouchExplorationEnabled()) {
+        mTalkBackEnabled = ssp.isTouchExplorationEnabled();
+        if (mTalkBackEnabled) {
             dismissPlaceholder.setAccessibilityTraversalBefore(R.id.task_list);
             dismissPlaceholder.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
             mTaskStackHorizontalGridView.setAccessibilityTraversalAfter(R.id.dismiss_placeholder);
@@ -408,14 +406,29 @@
                 }
             });
         }
-        updatePipUI();
+
+        // Initialize PIP UI
+        if (mPipManager.isPipShown()) {
+            if (mTalkBackEnabled) {
+                // If talkback is on, use the mPipView to handle focus changes
+                // between recents row and PIP controls.
+                mPipView.setVisibility(View.VISIBLE);
+            } else {
+                mPipView.setVisibility(View.GONE);
+            }
+            // When PIP view has focus, recents overlay view will takes the focus
+            // as if it's the part of the Recents UI.
+            mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
+        } else {
+            mPipView.setVisibility(View.GONE);
+            mPipRecentsOverlayManager.removePipRecentsOverlayView();
+        }
     }
 
     @Override
     public void onPause() {
         super.onPause();
         mPipRecentsOverlayManager.onRecentsPaused();
-        mTaskStackViewAdapter.setResetAddedCards(false);
     }
 
     @Override
@@ -534,6 +547,7 @@
     public final void onBusEvent(AllTaskViewsDismissedEvent event) {
         if (mPipManager.isPipShown()) {
             mRecentsView.showEmptyView();
+            mPipRecentsOverlayManager.requestFocus(false);
         } else {
             dismissRecentsToHome(false);
         }
@@ -547,10 +561,14 @@
     @Override
     public boolean onPreDraw() {
         mRecentsView.getViewTreeObserver().removeOnPreDrawListener(this);
-        if(mLaunchedFromHome) {
-            mHomeRecentsEnterExitAnimationHolder.setEnterFromHomeStartingAnimationValues();
+        // Sets the initial values for enter animation.
+        // Animation will be started in {@link #onEnterAnimationComplete()}
+        if (mLaunchedFromHome) {
+            mHomeRecentsEnterExitAnimationHolder
+                    .setEnterFromHomeStartingAnimationValues(mPipManager.isPipShown());
         } else {
-            mHomeRecentsEnterExitAnimationHolder.setEnterFromAppStartingAnimationValues();
+            mHomeRecentsEnterExitAnimationHolder
+                    .setEnterFromAppStartingAnimationValues(mPipManager.isPipShown());
         }
         // We post to make sure that this information is delivered after this traversals is
         // finished.
@@ -564,35 +582,25 @@
     }
 
     private void updatePipUI() {
-        if (mPipManager.isPipShown()) {
-            mPipView.setVisibility(View.VISIBLE);
-            mPipView.setOnFocusChangeListener(mPipViewFocusChangeListener);
-            if (mPipView.hasFocus()) {
-                // This can happen only if the activity is resumed. Ask for reset.
-                handlePipViewFocusChange(true);
-            } else {
-                mPipView.requestFocus();
-            }
-        } else {
-            mPipView.setVisibility(View.GONE);
+        if (!mPipManager.isPipShown()) {
             mPipRecentsOverlayManager.removePipRecentsOverlayView();
+            mTaskStackHorizontalGridView.startFocusLossAnimation();
+        } else {
+            Log.w(TAG, "An activity entered PIP mode while Recents is shown");
         }
     }
 
     /**
-     * Handles the PIP view's focus change.
+     * Requests the focus to the PIP controls.
      * This starts the relevant recents row animation
      * and give focus to the recents overlay if needed.
      */
-    private void handlePipViewFocusChange(boolean hasFocus) {
-        mRecentsView.startRecentsRowFocusAnimation(!hasFocus);
-        if (hasFocus) {
-            // When PIP view has focus, recents overlay view will takes the focus
-            // as if it's the part of the Recents UI.
-            mPipRecentsOverlayManager.requestFocus(
-                    mTaskStackViewAdapter.getItemCount() > 0);
-        } else {
-            mPipRecentsOverlayManager.clearFocus();
+    public void requestPipControlsFocus() {
+        if (!mPipManager.isPipShown()) {
+            return;
         }
+
+        mTaskStackHorizontalGridView.startFocusLossAnimation();
+        mPipRecentsOverlayManager.requestFocus(mTaskStackViewAdapter.getItemCount() > 0);
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java
index 92718a3..9faaa4b 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/HomeRecentsEnterExitAnimationHolder.java
@@ -74,19 +74,35 @@
         }
     }
 
-    public void setEnterFromHomeStartingAnimationValues() {
+    /**
+     * Sets the initial values Recents enter animation
+     * when Recents is started from the Launcher.
+     */
+    public void setEnterFromHomeStartingAnimationValues(boolean isPipShown) {
         for(int i = 0; i < mGridView.getChildCount(); i++) {
             TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
             view.setTranslationX(0);
             view.setAlpha(0.0f);
+            view.getInfoFieldView().setAlpha(isPipShown ? 0 : 1f);
+            if (isPipShown && view.hasFocus()) {
+                view.getViewFocusAnimator().changeSize(false);
+            }
         }
     }
 
-    public void setEnterFromAppStartingAnimationValues() {
+    /**
+     * Sets the initial values Recents enter animation
+     * when Recents is started from an app.
+     */
+    public void setEnterFromAppStartingAnimationValues(boolean isPipShown) {
         for(int i = 0; i < mGridView.getChildCount(); i++) {
             TaskCardView view = (TaskCardView) mGridView.getChildAt(i);
             view.setTranslationX(0);
-            view.setAlpha(1.0f);
+            view.setAlpha(isPipShown ? mDimAlpha : 1f);
+            view.getInfoFieldView().setAlpha(isPipShown ? 0 : 1f);
+            if (isPipShown && view.hasFocus()) {
+                view.getViewFocusAnimator().changeSize(false);
+            }
         }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
index 45c1537..8a4cf399 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/RecentsRowFocusAnimationHolder.java
@@ -29,11 +29,11 @@
  * Recents row's focus animation with PIP controls.
  */
 public class RecentsRowFocusAnimationHolder {
-    private View mView;
-    private View mTitleView;
+    private final View mView;
+    private final View mTitleView;
 
     private AnimatorSet mFocusGainAnimatorSet;
-    private AnimatorSet mFocusLoseAnimatorSet;
+    private AnimatorSet mFocusLossAnimatorSet;
 
     public RecentsRowFocusAnimationHolder(View view, View titleView) {
         mView = view;
@@ -50,28 +50,45 @@
         mFocusGainAnimatorSet.setDuration(duration);
         mFocusGainAnimatorSet.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
 
-        mFocusLoseAnimatorSet = new AnimatorSet();
-        mFocusLoseAnimatorSet.playTogether(
+        mFocusLossAnimatorSet = new AnimatorSet();
+        mFocusLossAnimatorSet.playTogether(
                 // Animation doesn't start from the current value (1f) sometimes,
                 // so specify the desired initial value here.
                 ObjectAnimator.ofFloat(mView, "alpha", 1f, dimAlpha),
                 ObjectAnimator.ofFloat(mTitleView, "alpha", 0f));
-        mFocusLoseAnimatorSet.setDuration(duration);
-        mFocusLoseAnimatorSet.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
+        mFocusLossAnimatorSet.setDuration(duration);
+        mFocusLossAnimatorSet.setInterpolator(Interpolators.FAST_OUT_SLOW_IN);
     }
 
     /**
-     * Returns the Recents row's focus change animation.
+     * Starts the Recents row's focus gain animation.
      */
-    public Animator getFocusChangeAnimator(boolean hasFocus) {
-        return hasFocus ? mFocusGainAnimatorSet : mFocusLoseAnimatorSet;
+    public void startFocusGainAnimation() {
+        cancelAnimator(mFocusLossAnimatorSet);
+        mFocusGainAnimatorSet.start();
     }
 
     /**
-     * Resets the views to the initial state immediately.
+     * Starts the Recents row's focus loss animation.
+     */
+    public void startFocusLossAnimation() {
+        cancelAnimator(mFocusGainAnimatorSet);
+        mFocusLossAnimatorSet.start();
+    }
+
+    /**
+     * Resets the views immediately and ends the animations.
      */
     public void reset() {
+        cancelAnimator(mFocusLossAnimatorSet);
+        cancelAnimator(mFocusGainAnimatorSet);
         mView.setAlpha(1f);
         mTitleView.setAlpha(1f);
     }
+
+    private static void cancelAnimator(Animator animator) {
+        if (animator.isStarted()) {
+            animator.cancel();
+        }
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/ViewFocusAnimator.java b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/ViewFocusAnimator.java
index 8218599..72fd7a4 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/animations/ViewFocusAnimator.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/animations/ViewFocusAnimator.java
@@ -89,7 +89,7 @@
         });
     }
 
-    public void setFocusProgress(float level) {
+    private void setFocusProgress(float level) {
         mFocusProgress = level;
 
         float scale = mUnselectedScale + (level * mSelectedScaleDelta);
@@ -107,33 +107,19 @@
         mTargetView.getDismissIconView().setZ(z);
     }
 
-    public float getFocusProgress() {
-        return mFocusProgress;
-    }
-
-    public void animateFocus(boolean focused) {
+    private void animateFocus(boolean focused) {
         if (mFocusAnimation.isStarted()) {
             mFocusAnimation.cancel();
         }
 
         float target = focused ? 1.0f : 0.0f;
 
-        if (getFocusProgress() != target) {
-            mFocusAnimation.setFloatValues(getFocusProgress(), target);
+        if (mFocusProgress != target) {
+            mFocusAnimation.setFloatValues(mFocusProgress, target);
             mFocusAnimation.start();
         }
     }
 
-    public void setFocusImmediate(boolean focused) {
-        if (mFocusAnimation.isStarted()) {
-            mFocusAnimation.cancel();
-        }
-
-        float target = focused ? 1.0f : 0.0f;
-
-        setFocusProgress(target);
-    }
-
     @Override
     public void onFocusChange(View v, boolean hasFocus) {
         if (v != mTargetView) {
@@ -142,21 +128,27 @@
         changeSize(hasFocus);
     }
 
-    protected void changeSize(boolean hasFocus) {
+    /**
+     * Changes the size of the {@link TaskCardView} to show its focused state.
+     */
+    public void changeSize(boolean hasFocus) {
         ViewGroup.LayoutParams lp = mTargetView.getLayoutParams();
         int width = lp.width;
         int height = lp.height;
 
         if (width < 0 && height < 0) {
             mTargetView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
-            height = mTargetView.getMeasuredHeight();
         }
 
         if (mTargetView.isAttachedToWindow() && mTargetView.hasWindowFocus() &&
                 mTargetView.getVisibility() == View.VISIBLE) {
             animateFocus(hasFocus);
         } else {
-            setFocusImmediate(hasFocus);
+            // Set focus immediately.
+            if (mFocusAnimation.isStarted()) {
+                mFocusAnimation.cancel();
+            }
+            setFocusProgress(hasFocus ? 1.0f : 0.0f);
         }
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
index 06b2441..318b7f9 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/RecentsTvView.java
@@ -59,7 +59,7 @@
     private boolean mAwaitingFirstLayout = true;
     private Rect mSystemInsets = new Rect();
     private RecentsTvTransitionHelper mTransitionHelper;
-    private Handler mHandler;
+    private final Handler mHandler = new Handler();
     private OnScrollListener mScrollListener;
     public RecentsTvView(Context context) {
         this(context, null);
@@ -81,9 +81,7 @@
         LayoutInflater inflater = LayoutInflater.from(context);
         mEmptyView = inflater.inflate(R.layout.recents_tv_empty, this, false);
         addView(mEmptyView);
-        mEmptyViewFocusAnimationHolder = new RecentsRowFocusAnimationHolder(mEmptyView, null);
 
-        mHandler = new Handler();
         mTransitionHelper = new RecentsTvTransitionHelper(mContext, mHandler);
     }
 
@@ -91,20 +89,18 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
         mDismissPlaceholder = findViewById(R.id.dismiss_placeholder);
+        mTaskStackHorizontalView = (TaskStackHorizontalGridView) findViewById(R.id.task_list);
     }
 
-    public void setTaskStack(TaskStack stack) {
+    /**
+     * Initialize the view.
+     */
+    public void init(TaskStack stack) {
         RecentsConfiguration config = Recents.getConfiguration();
         RecentsActivityLaunchState launchState = config.getLaunchState();
         mStack = stack;
 
-        if (mTaskStackHorizontalView != null) {
-            mTaskStackHorizontalView.reset();
-            mTaskStackHorizontalView.setStack(stack);
-        } else {
-            mTaskStackHorizontalView = (TaskStackHorizontalGridView) findViewById(R.id.task_list);
-            mTaskStackHorizontalView.setStack(stack);
-        }
+        mTaskStackHorizontalView.init(stack);
 
         if (stack.getStackTaskCount() > 0) {
             hideEmptyView();
@@ -112,6 +108,7 @@
             showEmptyView();
         }
 
+        // Layout with the new stack
         requestLayout();
     }
 
@@ -189,17 +186,6 @@
     }
 
     /**
-     * Starts the focus change animation.
-     */
-    public void startRecentsRowFocusAnimation(boolean hasFocus) {
-        if (mEmptyView.getVisibility() == View.VISIBLE) {
-            mEmptyViewFocusAnimationHolder.getFocusChangeAnimator(hasFocus).start();
-        } else {
-            mTaskStackHorizontalView.startRecentsRowFocusAnimation(hasFocus);
-        }
-    }
-
-    /**
      * Hides the task stack and shows the empty view.
      */
     public void showEmptyView() {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
index 758f93a..72a589f 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskCardView.java
@@ -40,16 +40,18 @@
 import com.android.systemui.R;
 import com.android.systemui.recents.Recents;
 import com.android.systemui.recents.misc.SystemServicesProxy;
+import com.android.systemui.recents.model.Task;
+import com.android.systemui.recents.tv.RecentsTvActivity;
 import com.android.systemui.recents.tv.animations.DismissAnimationsHolder;
 import com.android.systemui.recents.tv.animations.RecentsRowFocusAnimationHolder;
 import com.android.systemui.recents.tv.animations.ViewFocusAnimator;
-import com.android.systemui.recents.model.Task;
 
 public class TaskCardView extends LinearLayout {
 
     private static final String TAG = "TaskCardView";
     private View mThumbnailView;
     private View mDismissIconView;
+    private View mInfoFieldView;
     private TextView mTitleTextView;
     private ImageView mBadgeView;
     private Task mTask;
@@ -79,14 +81,14 @@
     protected void onFinishInflate() {
         super.onFinishInflate();
         mThumbnailView = findViewById(R.id.card_view_thumbnail);
+        mInfoFieldView = findViewById(R.id.card_info_field);
         mTitleTextView = (TextView) findViewById(R.id.card_title_text);
         mBadgeView = (ImageView) findViewById(R.id.card_extra_badge);
         mDismissIconView = findViewById(R.id.dismiss_icon);
         mDismissAnimationsHolder = new DismissAnimationsHolder(this);
-        View title = findViewById(R.id.card_info_field);
         mCornerRadius = getResources().getDimensionPixelSize(
                 R.dimen.recents_task_view_rounded_corners_radius);
-        mRecentsRowFocusAnimationHolder = new RecentsRowFocusAnimationHolder(this, title);
+        mRecentsRowFocusAnimationHolder = new RecentsRowFocusAnimationHolder(this, mInfoFieldView);
         SystemServicesProxy ssp = Recents.getSystemServices();
         if (!ssp.isTouchExplorationEnabled()) {
             mDismissIconView.setVisibility(VISIBLE);
@@ -102,6 +104,9 @@
         mBadgeView.setImageDrawable(task.icon);
         setThumbnailView();
         setContentDescription(task.titleDescription);
+        mDismissState = false;
+        mDismissAnimationsHolder.reset();
+        mRecentsRowFocusAnimationHolder.reset();
     }
 
     public Task getTask() {
@@ -196,40 +201,37 @@
     }
 
     @Override
-    public boolean onKeyDown(int keyCode, KeyEvent event) {
-        switch (keyCode) {
+    public boolean dispatchKeyEvent(KeyEvent event) {
+        // Override dispatchKeyEvent() instead of onKeyDown() to prevent warning from ViewRootImpl.
+        switch (event.getKeyCode()) {
             case KeyEvent.KEYCODE_DPAD_DOWN : {
-                if (!isInDismissState()) {
+                if (!isInDismissState() && event.getAction() == KeyEvent.ACTION_DOWN) {
                     setDismissState(true);
                     return true;
                 }
                 break;
             }
             case KeyEvent.KEYCODE_DPAD_UP : {
-                if (isInDismissState()) {
-                    setDismissState(false);
-                    return true;
+                if (event.getAction() == KeyEvent.ACTION_DOWN) {
+                    if (isInDismissState()) {
+                        setDismissState(false);
+                    } else {
+                        ((RecentsTvActivity) getContext()).requestPipControlsFocus();
+                    }
                 }
-                break;
+                return true;
             }
 
-            //Eat right and left key presses when we are in dismiss state
-            case KeyEvent.KEYCODE_DPAD_LEFT : {
-                if (isInDismissState()) {
-                    return true;
-                }
-                break;
-            }
+            // Eat right and left key presses when we are in dismiss state
+            case KeyEvent.KEYCODE_DPAD_LEFT :
             case KeyEvent.KEYCODE_DPAD_RIGHT : {
                 if (isInDismissState()) {
                     return true;
                 }
                 break;
             }
-            default:
-                break;
         }
-        return super.onKeyDown(keyCode, event);
+        return super.dispatchKeyEvent(event);
     }
 
     private void setDismissState(boolean dismissState) {
@@ -252,22 +254,14 @@
         mDismissAnimationsHolder.startDismissAnimation(listener);
     }
 
+    public ViewFocusAnimator getViewFocusAnimator() {
+        return mViewFocusAnimator;
+    }
+
     public RecentsRowFocusAnimationHolder getRecentsRowFocusAnimationHolder() {
         return mRecentsRowFocusAnimationHolder;
     }
 
-    @Override
-    protected void onDetachedFromWindow() {
-        super.onDetachedFromWindow();
-        setDismissState(false);
-    }
-
-    public void reset() {
-        mDismissState = false;
-        mRecentsRowFocusAnimationHolder.reset();
-        mDismissAnimationsHolder.reset();
-    }
-
     private void setThumbnailView() {
         ImageView screenshotView = (ImageView) findViewById(R.id.card_view_banner_icon);
         PackageManager pm = getContext().getPackageManager();
@@ -332,6 +326,10 @@
         return mThumbnailView;
     }
 
+    public View getInfoFieldView() {
+        return mInfoFieldView;
+    }
+
     public View getDismissIconView() {
         return mDismissIconView;
     }
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalGridView.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalGridView.java
index 3fb339e..f9b8700 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalGridView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalGridView.java
@@ -18,8 +18,6 @@
 import android.animation.Animator;
 import android.animation.AnimatorSet;
 import android.content.Context;
-import android.os.Handler;
-import android.os.Message;
 import android.support.v17.leanback.widget.HorizontalGridView;
 import android.util.AttributeSet;
 import android.view.View;
@@ -39,14 +37,6 @@
 public class TaskStackHorizontalGridView extends HorizontalGridView implements TaskStackCallbacks {
     private static final int ANIMATION_DELAY_MS = 50;
     private static final int MSG_START_RECENT_ROW_FOCUS_ANIMATION = 100;
-    private final Handler mHandler = new Handler() {
-        @Override
-        public void handleMessage(Message msg) {
-            if (msg.what == MSG_START_RECENT_ROW_FOCUS_ANIMATION) {
-                startRecentsRowFocusAnimation(msg.arg1 == 1);
-            }
-        }
-    };
     private TaskStack mStack;
     private Task mFocusedTask;
     private AnimatorSet mRecentsRowFocusAnimation;
@@ -74,38 +64,15 @@
     }
 
     /**
-     * Resets this view for reuse.
-     */
-    public void reset() {
-        for (int i = 0; i < getChildCount(); i++) {
-            ((TaskCardView) getChildAt(i)).getRecentsRowFocusAnimationHolder().reset();
-        }
-        if (mRecentsRowFocusAnimation != null && mRecentsRowFocusAnimation.isStarted()) {
-            mRecentsRowFocusAnimation.cancel();
-        }
-        mHandler.removeCallbacksAndMessages(null);
-        requestLayout();
-    }
-
-    /**
-     * @param task - Task to reset
-     */
-    private void resetFocusedTask(Task task) {
-        mFocusedTask = null;
-    }
-
-    /**
-     * Sets the task stack.
+     * Initializes the grid view.
      * @param stack
      */
-    public void setStack(TaskStack stack) {
-        //Set new stack
+    public void init(TaskStack stack) {
+        // Set new stack
         mStack = stack;
         if (mStack != null) {
             mStack.setCallbacks(this);
         }
-        //Layout with new stack
-        requestLayout();
     }
 
     /**
@@ -126,13 +93,6 @@
     }
 
     /**
-     * @return - The focused task card view.
-     */
-    public TaskCardView getFocusedTaskCardView() {
-        return ((TaskCardView)findFocus());
-    }
-
-    /**
      * @param task
      * @return Child view for given task
      */
@@ -146,32 +106,31 @@
         return null;
     }
 
+
     /**
-     * Starts the focus change animation.
+     * Starts the Recents row's focus gain animation.
      */
-    public void startRecentsRowFocusAnimation(final boolean hasFocus) {
-        if (getChildCount() == 0) {
-            // Animation request may happen before view is attached.
-            // Post again with small dealy so animation can be run again later.
-            if (getAdapter().getItemCount() > 0) {
-                mHandler.sendMessageDelayed(mHandler.obtainMessage(
-                        MSG_START_RECENT_ROW_FOCUS_ANIMATION, hasFocus ? 1 : 0),
-                        ANIMATION_DELAY_MS);
+    public void startFocusGainAnimation() {
+        for (int i = 0; i < getChildCount(); i++) {
+            TaskCardView v = (TaskCardView) getChildAt(i);
+            if (v.hasFocus()) {
+                v.getViewFocusAnimator().changeSize(true);
             }
-            return;
+            v.getRecentsRowFocusAnimationHolder().startFocusGainAnimation();
         }
-        if (mRecentsRowFocusAnimation != null && mRecentsRowFocusAnimation.isStarted()) {
-            mRecentsRowFocusAnimation.cancel();
+    }
+
+    /**
+     * Starts the Recents row's focus loss animation.
+     */
+    public void startFocusLossAnimation() {
+        for (int i = 0; i < getChildCount(); i++) {
+            TaskCardView v = (TaskCardView) getChildAt(i);
+            if (v.hasFocus()) {
+                v.getViewFocusAnimator().changeSize(false);
+            }
+            v.getRecentsRowFocusAnimationHolder().startFocusLossAnimation();
         }
-        Animator animator = ((TaskCardView) getChildAt(0)).getRecentsRowFocusAnimationHolder()
-                .getFocusChangeAnimator(hasFocus);
-        mRecentsRowFocusAnimation = new AnimatorSet();
-        AnimatorSet.Builder builder = mRecentsRowFocusAnimation.play(animator);
-        for (int i = 1; i < getChildCount(); i++) {
-            builder.with(((TaskCardView) getChildAt(i)).getRecentsRowFocusAnimationHolder()
-                    .getFocusChangeAnimator(hasFocus));
-        }
-        mRecentsRowFocusAnimation.start();
     }
 
     @Override
@@ -185,7 +144,7 @@
             AnimationProps animation, boolean fromDockGesture) {
         ((TaskStackHorizontalViewAdapter) getAdapter()).removeTask(removedTask);
         if (mFocusedTask == removedTask) {
-            resetFocusedTask(removedTask);
+            mFocusedTask = null;
         }
         // If there are no remaining tasks, then just close recents
         if (mStack.getStackTaskCount() == 0) {
diff --git a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
index b6b86b4..236d077 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/tv/views/TaskStackHorizontalViewAdapter.java
@@ -43,17 +43,13 @@
     private static final String TAG = "TaskStackViewAdapter";
     private List<Task> mTaskList;
     private TaskStackHorizontalGridView mGridView;
-    private boolean mResetAddedCards;
 
     public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
         private TaskCardView mTaskCardView;
         private Task mTask;
-        private boolean mShouldReset;
         public ViewHolder(View v) {
             super(v);
-            if(v instanceof TaskCardView) {
-                mTaskCardView = (TaskCardView) v;
-            }
+            mTaskCardView = (TaskCardView) v;
         }
 
         public void init(Task task) {
@@ -90,7 +86,6 @@
                 public void onAnimationEnd(Animator animation) {
                     removeTask(task);
                     EventBus.getDefault().send(new DeleteTaskDataEvent(task));
-                    mShouldReset = true;
                 }
 
                 @Override
@@ -131,23 +126,6 @@
     }
 
     @Override
-    public void onViewAttachedToWindow(ViewHolder holder) {
-        if (mResetAddedCards) {
-            holder.mTaskCardView.reset();
-        }
-    }
-
-    @Override
-    public void onViewDetachedFromWindow(ViewHolder holder) {
-        // We only want to reset on view detach if this is the last task being dismissed.
-        // This is so that we do not reset when shifting to apps etc, as it is not needed.
-        if (holder.mShouldReset) {
-            holder.mTaskCardView.reset();
-            holder.mShouldReset = false;
-        }
-    }
-
-    @Override
     public int getItemCount() {
         return mTaskList.size();
     }
@@ -178,8 +156,4 @@
         mTaskList.add(position, task);
         notifyItemInserted(position);
     }
-
-    public void setResetAddedCards(boolean reset) {
-        mResetAddedCards = reset;
-    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
index e89c136..a0bae20 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/Divider.java
@@ -39,6 +39,7 @@
 public class Divider extends SystemUI {
     private DividerWindowManager mWindowManager;
     private DividerView mView;
+    private final DividerState mDividerState = new DividerState();
     private DockDividerVisibilityListener mDockDividerVisibilityListener;
     private boolean mVisible = false;
     private boolean mMinimized = false;
@@ -76,7 +77,7 @@
         final int width = landscape ? size : MATCH_PARENT;
         final int height = landscape ? MATCH_PARENT : size;
         mWindowManager.add(mView, width, height);
-        mView.setWindowManager(mWindowManager);
+        mView.injectDependencies(mWindowManager, mDividerState);
     }
 
     private void removeDivider() {
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java
new file mode 100644
index 0000000..353a974
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerState.java
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2016 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
+ */
+
+package com.android.systemui.stackdivider;
+
+/**
+ * Class to hold state of divider that needs to persist across configuration changes.
+ */
+public class DividerState {
+    public boolean animateAfterRecentsDrawn;
+    public boolean growAfterRecentsDrawn;
+}
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
index f728aa4..d09587b 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/DividerView.java
@@ -30,12 +30,12 @@
 import android.graphics.Region.Op;
 import android.hardware.display.DisplayManager;
 import android.os.Bundle;
+import android.os.Handler;
 import android.util.AttributeSet;
 import android.view.Display;
 import android.view.DisplayInfo;
 import android.view.GestureDetector;
 import android.view.GestureDetector.SimpleOnGestureListener;
-import android.view.HapticFeedbackConstants;
 import android.view.MotionEvent;
 import android.view.PointerIcon;
 import android.view.VelocityTracker;
@@ -141,8 +141,6 @@
     private DividerSnapAlgorithm mSnapAlgorithm;
     private final Rect mStableInsets = new Rect();
 
-    private boolean mAnimateAfterRecentsDrawn;
-    private boolean mGrowAfterRecentsDrawn;
     private boolean mGrowRecents;
     private ValueAnimator mCurrentAnimator;
     private boolean mEntranceAnimationRunning;
@@ -151,6 +149,8 @@
     private GestureDetector mGestureDetector;
     private boolean mDockedStackMinimized;
     private boolean mAdjustedForIme;
+    private DividerState mState;
+    private final Handler mHandler = new Handler();
 
     private final AccessibilityDelegate mHandleDelegate = new AccessibilityDelegate() {
         @Override
@@ -335,8 +335,9 @@
         }
     }
 
-    public void setWindowManager(DividerWindowManager windowManager) {
+    public void injectDependencies(DividerWindowManager windowManager, DividerState dividerState) {
         mWindowManager = windowManager;
+        mState = dividerState;
     }
 
     public WindowManagerProxy getWindowManagerProxy() {
@@ -558,7 +559,7 @@
                 if (endDelay == 0 || mCancelled) {
                     endAction.run();
                 } else {
-                    postDelayed(endAction, endDelay);
+                    mHandler.postDelayed(endAction, endDelay);
                 }
             }
         });
@@ -1048,15 +1049,15 @@
     public final void onBusEvent(RecentsActivityStartingEvent recentsActivityStartingEvent) {
         if (mGrowRecents && getWindowManagerProxy().getDockSide() == WindowManager.DOCKED_TOP
                 && getCurrentPosition() == getSnapAlgorithm().getLastSplitTarget().position) {
-            mGrowAfterRecentsDrawn = true;
+            mState.growAfterRecentsDrawn = true;
             startDragging(false /* animate */, false /* touching */);
         }
     }
 
     public final void onBusEvent(DockedTopTaskEvent event) {
         if (event.dragMode == NavigationBarGestureHelper.DRAG_MODE_NONE) {
-            mGrowAfterRecentsDrawn = false;
-            mAnimateAfterRecentsDrawn = true;
+            mState.growAfterRecentsDrawn = false;
+            mState.animateAfterRecentsDrawn = true;
             startDragging(false /* animate */, false /* touching */);
         }
         updateDockSide();
@@ -1068,11 +1069,11 @@
     }
 
     public final void onBusEvent(RecentsDrawnEvent drawnEvent) {
-        if (mAnimateAfterRecentsDrawn) {
-            mAnimateAfterRecentsDrawn = false;
+        if (mState.animateAfterRecentsDrawn) {
+            mState.animateAfterRecentsDrawn = false;
             updateDockSide();
 
-            post(() -> {
+            mHandler.post(() -> {
                 // Delay switching resizing mode because this might cause jank in recents animation
                 // that's longer than this animation.
                 stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(),
@@ -1080,8 +1081,8 @@
                         200 /* endDelay */);
             });
         }
-        if (mGrowAfterRecentsDrawn) {
-            mGrowAfterRecentsDrawn = false;
+        if (mState.growAfterRecentsDrawn) {
+            mState.growAfterRecentsDrawn = false;
             updateDockSide();
             EventBus.getDefault().send(new RecentsGrowingEvent());
             stopDragging(getCurrentPosition(), mSnapAlgorithm.getMiddleTarget(), 336,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
index 63933d4..91889d3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java
@@ -1887,10 +1887,13 @@
                 public boolean onDismiss() {
                     if (mHeadsUpManager != null && mHeadsUpManager.isHeadsUp(notificationKey)) {
                         // Release the HUN notification to the shade.
+
+                        if (isPanelFullyCollapsed()) {
+                            HeadsUpManager.setIsClickedNotification(row, true);
+                        }
                         //
                         // In most cases, when FLAG_AUTO_CANCEL is set, the notification will
                         // become canceled shortly by NoMan, but we can't assume that.
-                        HeadsUpManager.setIsClickedNotification(row, true);
                         mHeadsUpManager.releaseImmediately(notificationKey);
                     }
                     StatusBarNotification parentToCancel = null;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index 6f6b02d..6e9e830 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -1486,11 +1486,26 @@
         updateBackground();
     }
 
+    public int getPositionOfChild(ExpandableNotificationRow childRow) {
+        if (mIsSummaryWithChildren) {
+            return mChildrenContainer.getPositionInLinearLayout(childRow);
+        }
+        return 0;
+    }
+
     public void setExpansionLogger(ExpansionLogger logger, String key) {
         mLogger = logger;
         mLoggingKey = key;
     }
 
+    public void onExpandedByGesture(boolean userExpanded) {
+        int event = MetricsEvent.ACTION_NOTIFICATION_GESTURE_EXPANDER;
+        if (mGroupManager.isSummaryOfGroup(getStatusBarNotification())) {
+            event = MetricsEvent.ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER;
+        }
+        MetricsLogger.action(mContext, event, userExpanded);
+    }
+
     @Override
     public float getIncreasedPaddingAmount() {
         if (mIsSummaryWithChildren) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index f3c666f..d6c02e4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -360,7 +360,9 @@
 
     private void setVisible(final boolean isVisible) {
         if (isVisible) {
-
+            // This call can happen multiple times, but removing only removes a single one.
+            // We therefore need to remove the old one.
+            getViewTreeObserver().removeOnPreDrawListener(mEnableAnimationPredrawListener);
             // We only animate if we are drawn at least once, otherwise the view might animate when
             // it's shown the first time
             getViewTreeObserver().addOnPreDrawListener(mEnableAnimationPredrawListener);
@@ -401,12 +403,17 @@
             return mContext.getResources().getDimensionPixelSize(
                         com.android.internal.R.dimen.notification_action_list_height);
         }
+        int hint;
         if (mHeadsUpChild != null) {
-            return mHeadsUpChild.getHeight();
+            hint = mHeadsUpChild.getHeight();
         } else {
-            return mContractedChild.getHeight() + mContext.getResources().getDimensionPixelSize(
-                com.android.internal.R.dimen.notification_action_list_height);
+            hint = mContractedChild.getHeight() + mContext.getResources().getDimensionPixelSize(
+                    com.android.internal.R.dimen.notification_action_list_height);
         }
+        if (mExpandedChild != null) {
+            hint = Math.min(hint, mExpandedChild.getHeight());
+        }
+        return hint;
     }
 
     private void updateContentTransformation() {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index bc33b30..cdfdad4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -18,6 +18,7 @@
 
 import android.app.Notification;
 import android.content.Context;
+import android.content.pm.ApplicationInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.graphics.Canvas;
@@ -25,6 +26,7 @@
 import android.graphics.Rect;
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.Icon;
+import android.os.Parcelable;
 import android.os.UserHandle;
 import android.text.TextUtils;
 import android.util.AttributeSet;
@@ -325,8 +327,20 @@
 
 
     public static String contentDescForNotification(Context c, Notification n) {
-        Notification.Builder builder = Notification.Builder.recoverBuilder(c, n);
-        String appName = builder.loadHeaderAppName();
+        String appName = "";
+        try {
+            Notification.Builder builder = Notification.Builder.recoverBuilder(c, n);
+            appName = builder.loadHeaderAppName();
+        } catch (RuntimeException e) {
+            Log.e(TAG, "Unable to recover builder", e);
+            // Trying to get the app name from the app info instead.
+            Parcelable appInfo = n.extras.getParcelable(
+                    Notification.EXTRA_BUILDER_APPLICATION_INFO);
+            if (appInfo instanceof ApplicationInfo) {
+                appName = String.valueOf(((ApplicationInfo) appInfo).loadLabel(
+                        c.getPackageManager()));
+            }
+        }
 
         CharSequence title = n.extras.getCharSequence(Notification.EXTRA_TITLE);
         CharSequence ticker = n.tickerText;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java
index b66e9f3..8463e06 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/HeaderTransformState.java
@@ -109,9 +109,6 @@
     @Override
     public void recycle() {
         super.recycle();
-        if (mWorkProfileState != null) {
-            mWorkProfileState.recycle();
-        }
         sInstancePool.release(this);
     }
 
@@ -120,6 +117,10 @@
         super.reset();
         mExpandButton = null;
         mWorkProfileState = null;
+        if (mWorkProfileState != null) {
+            mWorkProfileState.recycle();
+            mWorkProfileState = null;
+        }
     }
 
     public void setVisible(boolean visible) {
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 31fa3bf..d9a8a3f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
@@ -3020,7 +3020,7 @@
         if ((mSystemUiVisibility & STATUS_OR_NAV_TRANSIENT) != 0  // a transient bar is revealed
                 && event.getAction() == MotionEvent.ACTION_OUTSIDE // touch outside the source bar
                 && event.getX() == 0 && event.getY() == 0  // a touch outside both bars
-                ) {
+                && !mRemoteInputController.isRemoteInputActive()) { // not due to typing in IME
             userAutohide();
         }
     }
@@ -4339,6 +4339,8 @@
 
     // ---------------------- DragDownHelper.OnDragDownListener ------------------------------------
 
+
+    /* Only ever called as a consequence of a lockscreen expansion gesture. */
     @Override
     public boolean onDraggedDown(View startingChild, int dragLengthY) {
         if (hasActiveNotifications()) {
@@ -4349,6 +4351,10 @@
 
             // We have notifications, go to locked shade.
             goToLockedShade(startingChild);
+            if (startingChild instanceof ExpandableNotificationRow) {
+                ExpandableNotificationRow row = (ExpandableNotificationRow) startingChild;
+                row.onExpandedByGesture(true /* drag down is always an open */);
+            }
             return true;
         } else {
 
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
index 2f522f0..40ff051 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/RemoteInputView.java
@@ -47,6 +47,7 @@
 import com.android.internal.logging.MetricsLogger;
 import com.android.internal.logging.MetricsProto;
 import com.android.systemui.R;
+import com.android.systemui.statusbar.ExpandableView;
 import com.android.systemui.statusbar.NotificationData;
 import com.android.systemui.statusbar.RemoteInputController;
 import com.android.systemui.statusbar.stack.ScrollContainer;
@@ -284,11 +285,17 @@
 
     private void findScrollContainer() {
         if (mScrollContainer == null) {
+            mScrollContainerChild = null;
             ViewParent p = this;
             while (p != null) {
+                if (mScrollContainerChild == null && p instanceof ExpandableView) {
+                    mScrollContainerChild = (View) p;
+                }
                 if (p.getParent() instanceof ScrollContainer) {
                     mScrollContainer = (ScrollContainer) p.getParent();
-                    mScrollContainerChild = (View) p;
+                    if (mScrollContainerChild == null) {
+                        mScrollContainerChild = (View) p;
+                    }
                     break;
                 }
                 p = p.getParent();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
index cb0b848..a0f1bc2 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationChildrenContainer.java
@@ -677,6 +677,10 @@
         mHeaderUtil = new NotificationHeaderUtil(mNotificationParent);
     }
 
+    public ExpandableNotificationRow getNotificationParent() {
+        return mNotificationParent;
+    }
+
     public NotificationHeaderView getHeaderView() {
         return mNotificationHeader;
     }
@@ -854,4 +858,23 @@
             child.setRemoved();
         }
     }
+
+    public int getPositionInLinearLayout(View childInGroup) {
+        int position = mNotificationHeaderMargin + mNotificatonTopPadding;
+
+        for (int i = 0; i < mChildren.size(); i++) {
+            ExpandableNotificationRow child = mChildren.get(i);
+            boolean notGone = child.getVisibility() != View.GONE;
+            if (notGone) {
+                position += mDividerHeight;
+            }
+            if (child == childInGroup) {
+                return position;
+            }
+            if (notGone) {
+                position += child.getIntrinsicHeight();
+            }
+        }
+        return 0;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
index 19f4074..b58538d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/NotificationStackScrollLayout.java
@@ -610,9 +610,13 @@
             ExpandableView expandableView = (ExpandableView) mForcedScroll;
             int positionInLinearLayout = getPositionInLinearLayout(expandableView);
             int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
+            int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();
 
             targetScroll = Math.max(0, Math.min(targetScroll, getScrollRange()));
-            if (mOwnScrollY < targetScroll || positionInLinearLayout < mOwnScrollY) {
+
+            // Only apply the scroll if we're scrolling the view upwards, or the view is so far up
+            // that it is not visible anymore.
+            if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
                 mOwnScrollY = targetScroll;
             }
         }
@@ -959,11 +963,13 @@
                 && (mIsExpanded || !((ExpandableNotificationRow) v).isPinned());
     }
 
+    /* Only ever called as a consequence of an expansion gesture in the shade. */
     @Override
     public void setUserExpandedChild(View v, boolean userExpanded) {
         if (v instanceof ExpandableNotificationRow) {
-            ((ExpandableNotificationRow) v).setUserExpanded(userExpanded,
-                    true /* allowChildrenExpansion */);
+            ExpandableNotificationRow row = (ExpandableNotificationRow) v;
+            row.setUserExpanded(userExpanded, true /* allowChildrenExpansion */);
+            row.onExpandedByGesture(userExpanded);
         }
     }
 
@@ -1032,9 +1038,13 @@
     @Override
     public boolean scrollTo(View v) {
         ExpandableView expandableView = (ExpandableView) v;
-        int targetScroll = targetScrollForView(expandableView, getPositionInLinearLayout(v));
+        int positionInLinearLayout = getPositionInLinearLayout(v);
+        int targetScroll = targetScrollForView(expandableView, positionInLinearLayout);
+        int outOfViewScroll = positionInLinearLayout + expandableView.getIntrinsicHeight();
 
-        if (mOwnScrollY < targetScroll) {
+        // Only apply the scroll if we're scrolling the view upwards, or the view is so far up
+        // that it is not visible anymore.
+        if (mOwnScrollY < targetScroll || outOfViewScroll < mOwnScrollY) {
             mScroller.startScroll(mScrollX, mOwnScrollY, 0, targetScroll - mOwnScrollY);
             mDontReportNextOverScroll = true;
             postInvalidateOnAnimation();
@@ -1062,6 +1072,10 @@
             // animating away. To work around that we'll wait until things have settled.
             removeCallbacks(mReclamp);
             postDelayed(mReclamp, 50);
+        } else if (mForcedScroll != null) {
+            // The scroll was requested before we got the actual inset - in case we need
+            // to scroll up some more do so now.
+            scrollTo(mForcedScroll);
         }
         return insets;
     }
@@ -2361,7 +2375,15 @@
         return view.getHeight();
     }
 
-    private int getPositionInLinearLayout(View requestedChild) {
+    private int getPositionInLinearLayout(View requestedView) {
+        ExpandableNotificationRow childInGroup = null;
+        ExpandableNotificationRow requestedRow = null;
+        if (isChildInGroup(requestedView)) {
+            // We're asking for a child in a group. Calculate the position of the parent first,
+            // then within the parent.
+            childInGroup = (ExpandableNotificationRow) requestedView;
+            requestedView = requestedRow = childInGroup.getNotificationParent();
+        }
         int position = 0;
         float previousIncreasedAmount = 0.0f;
         for (int i = 0; i < getChildCount(); i++) {
@@ -2377,7 +2399,10 @@
                 }
                 previousIncreasedAmount = increasedPaddingAmount;
             }
-            if (child == requestedChild) {
+            if (child == requestedView) {
+                if (requestedRow != null) {
+                    position += requestedRow.getPositionOfChild(childInGroup);
+                }
                 return position;
             }
             if (notGone) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
index d6c5506..8f0cd8e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/stack/StackScrollState.java
@@ -26,9 +26,8 @@
 import com.android.systemui.statusbar.ExpandableNotificationRow;
 import com.android.systemui.statusbar.ExpandableView;
 
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
+import java.util.WeakHashMap;
 
 /**
  * A state of a {@link com.android.systemui.statusbar.stack.NotificationStackScrollLayout} which
@@ -39,12 +38,12 @@
     private static final String CHILD_NOT_FOUND_TAG = "StackScrollStateNoSuchChild";
 
     private final ViewGroup mHostView;
-    private Map<ExpandableView, StackViewState> mStateMap;
+    private WeakHashMap<ExpandableView, StackViewState> mStateMap;
     private final int mClearAllTopPadding;
 
     public StackScrollState(ViewGroup hostView) {
         mHostView = hostView;
-        mStateMap = new HashMap<ExpandableView, StackViewState>();
+        mStateMap = new WeakHashMap<>();
         mClearAllTopPadding = hostView.getContext().getResources().getDimensionPixelSize(
                 R.dimen.clear_all_padding_top);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlButtonView.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlButtonView.java
index bcf2f67..80c593c 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlButtonView.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlButtonView.java
@@ -21,12 +21,11 @@
 import android.content.Context;
 import android.content.res.TypedArray;
 import android.util.AttributeSet;
-import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View.OnFocusChangeListener;
 import android.view.View;
 import android.widget.ImageView;
-import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
 import android.widget.TextView;
 
 import com.android.systemui.R;
@@ -34,31 +33,28 @@
 /**
  * A view containing PIP controls including fullscreen, close, and media controls.
  */
-public class PipControlButtonView extends LinearLayout {
+public class PipControlButtonView extends RelativeLayout {
     private OnFocusChangeListener mFocusChangeListener;
-    private ImageView mButtonImageView;
+    private ImageView mIconImageView;
+    ImageView mButtonImageView;
     private TextView mDescriptionTextView;
-    private Animator mFocusGainAnimator;
-    private Animator mFocusLoseAnimator;
+    private Animator mTextFocusGainAnimator;
+    private Animator mButtonFocusGainAnimator;
+    private Animator mTextFocusLossAnimator;
+    private Animator mButtonFocusLossAnimator;
 
     private final OnFocusChangeListener mInternalFocusChangeListener =
             new OnFocusChangeListener() {
                 @Override
                 public void onFocusChange(View v, boolean hasFocus) {
                     if (hasFocus) {
-                        if (mFocusLoseAnimator.isStarted()) {
-                            mFocusLoseAnimator.cancel();
-                        }
-                        mFocusGainAnimator.start();
+                        startFocusGainAnimation();
                     } else {
-                        if (mFocusGainAnimator.isStarted()) {
-                            mFocusGainAnimator.cancel();
-                        }
-                        mFocusLoseAnimator.start();
+                        startFocusLossAnimation();
                     }
 
                     if (mFocusChangeListener != null) {
-                        mFocusChangeListener.onFocusChange(v, hasFocus);
+                        mFocusChangeListener.onFocusChange(PipControlButtonView.this, hasFocus);
                     }
                 }
             };
@@ -82,9 +78,7 @@
                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
         inflater.inflate(R.layout.tv_pip_control_button, this);
 
-        setOrientation(LinearLayout.VERTICAL);
-        setGravity(Gravity.CENTER);
-
+        mIconImageView = (ImageView) findViewById(R.id.icon);
         mButtonImageView = (ImageView) findViewById(R.id.button);
         mDescriptionTextView = (TextView) findViewById(R.id.desc);
 
@@ -103,12 +97,19 @@
         super.onFinishInflate();
         mButtonImageView.setOnFocusChangeListener(mInternalFocusChangeListener);
 
-        mFocusGainAnimator = AnimatorInflater.loadAnimator(getContext(),
-                R.anim.tv_pip_controls_text_focus_gain_animation);
-        mFocusGainAnimator.setTarget(mDescriptionTextView);
-        mFocusLoseAnimator = AnimatorInflater.loadAnimator(getContext(),
-                R.anim.tv_pip_controls_text_focus_lose_animation);
-        mFocusLoseAnimator.setTarget(mDescriptionTextView);
+        mTextFocusGainAnimator = AnimatorInflater.loadAnimator(getContext(),
+                R.anim.tv_pip_controls_focus_gain_animation);
+        mTextFocusGainAnimator.setTarget(mDescriptionTextView);
+        mButtonFocusGainAnimator = AnimatorInflater.loadAnimator(getContext(),
+                R.anim.tv_pip_controls_focus_gain_animation);
+        mButtonFocusGainAnimator.setTarget(mButtonImageView);
+
+        mTextFocusLossAnimator = AnimatorInflater.loadAnimator(getContext(),
+                R.anim.tv_pip_controls_focus_loss_animation);
+        mTextFocusLossAnimator.setTarget(mDescriptionTextView);
+        mButtonFocusLossAnimator = AnimatorInflater.loadAnimator(getContext(),
+                R.anim.tv_pip_controls_focus_loss_animation);
+        mButtonFocusLossAnimator.setTarget(mButtonImageView);
     }
 
     @Override
@@ -125,7 +126,7 @@
      * Sets the drawable for the button with the given resource id.
      */
     public void setImageResource(int resId) {
-        mButtonImageView.setImageResource(resId);
+        mIconImageView.setImageResource(resId);
     }
 
     /**
@@ -136,8 +137,51 @@
         mDescriptionTextView.setText(resId);
     }
 
-    @Override
-    public boolean isFocused() {
-        return mButtonImageView.isFocused();
+    private static void cancelAnimator(Animator animator) {
+        if (animator.isStarted()) {
+            animator.cancel();
+        }
+    }
+
+    /**
+     * Starts the focus gain animation.
+     */
+    public void startFocusGainAnimation() {
+        cancelAnimator(mButtonFocusLossAnimator);
+        cancelAnimator(mTextFocusLossAnimator);
+        mTextFocusGainAnimator.start();
+        if (mButtonImageView.getAlpha() < 1f) {
+            // If we had faded out the ripple drawable, run our manual focus change animation.
+            // See the comment at {@link #startFocusLossAnimation()} for the reason of manual
+            // animator.
+            mButtonFocusGainAnimator.start();
+        }
+    }
+
+    /**
+     * Starts the focus loss animation.
+     */
+    public void startFocusLossAnimation() {
+        cancelAnimator(mButtonFocusGainAnimator);
+        cancelAnimator(mTextFocusGainAnimator);
+        mTextFocusLossAnimator.start();
+        if (mButtonImageView.hasFocus()) {
+            // Button uses ripple that has the default animation for the focus changes.
+            // Howevever, it doesn't expose the API to fade out while it is focused,
+            // so we should manually run the fade out animation when PIP controls row loses focus.
+            mButtonFocusLossAnimator.start();
+        }
+    }
+
+    /**
+     * Resets to initial state.
+     */
+    public void reset() {
+        cancelAnimator(mButtonFocusGainAnimator);
+        cancelAnimator(mTextFocusGainAnimator);
+        cancelAnimator(mButtonFocusLossAnimator);
+        cancelAnimator(mTextFocusLossAnimator);
+        mButtonImageView.setAlpha(1f);
+        mDescriptionTextView.setAlpha(mButtonImageView.hasFocus() ? 1f : 0f);
     }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlsView.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlsView.java
index 5614bf9..71740ce 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlsView.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipControlsView.java
@@ -61,8 +61,7 @@
     private PipControlButtonView mCloseButtonView;
     private PipControlButtonView mPlayPauseButtonView;
 
-    private boolean mHasFocus;
-    private OnFocusChangeListener mOnChildFocusChangeListener;
+    private PipControlButtonView mFocusedChild;
 
     private MediaController.Callback mMediaControllerCallback = new MediaController.Callback() {
         @Override
@@ -80,8 +79,12 @@
 
     private final OnFocusChangeListener mFocusChangeListener = new OnFocusChangeListener() {
         @Override
-        public void onFocusChange(View v, boolean hasFocus) {
-            onChildViewFocusChanged();
+        public void onFocusChange(View view, boolean hasFocus) {
+            if (hasFocus) {
+                mFocusedChild = (PipControlButtonView) view;
+            } else if (mFocusedChild == view) {
+                mFocusedChild = null;
+            }
         }
     };
 
@@ -200,23 +203,13 @@
     }
 
     /**
-     * Sets a listener to be invoked when {@link android.view.View.hasFocus()} is changed.
+     * Resets to initial state.
      */
-    public void setOnChildFocusChangeListener(OnFocusChangeListener listener) {
-        mOnChildFocusChangeListener = listener;
-    }
-
-    private void onChildViewFocusChanged() {
-        // At this moment, hasFocus() returns true although there's no focused child.
-        boolean hasFocus = (mFullButtonView != null && mFullButtonView.isFocused())
-                || (mPlayPauseButtonView != null && mPlayPauseButtonView.isFocused())
-                || (mCloseButtonView != null && mCloseButtonView.isFocused());
-        if (mHasFocus != hasFocus) {
-            mHasFocus = hasFocus;
-            if (mOnChildFocusChangeListener != null) {
-                mOnChildFocusChangeListener.onFocusChange(getFocusedChild(), mHasFocus);
-            }
-        }
+    public void reset() {
+        mFullButtonView.reset();
+        mCloseButtonView.reset();
+        mPlayPauseButtonView.reset();
+        mFullButtonView.requestFocus();
     }
 
     /**
@@ -225,4 +218,11 @@
     public void setListener(Listener listener) {
         mListener = listener;
     }
+
+    /**
+     * Returns the focused control button view to animate focused button.
+     */
+    PipControlButtonView getFocusedButton() {
+        return mFocusedChild;
+    }
 }
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
index 476598d..30622d2 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipManager.java
@@ -126,7 +126,6 @@
     private int mSuspendPipResizingReason;
 
     private Context mContext;
-    private SystemServicesProxy mSystemServiceProxy;
     private PipRecentsOverlayManager mPipRecentsOverlayManager;
     private IActivityManager mActivityManager;
     private MediaSessionManager mMediaSessionManager;
@@ -213,8 +212,7 @@
         mPipBounds = mDefaultPipBounds;
 
         mActivityManager = ActivityManagerNative.getDefault();
-        mSystemServiceProxy = SystemServicesProxy.getInstance(context);
-        mSystemServiceProxy.registerTaskStackListener(mTaskStackListener);
+        SystemServicesProxy.getInstance(context).registerTaskStackListener(mTaskStackListener);
         IntentFilter intentFilter = new IntentFilter();
         intentFilter.addAction(Intent.ACTION_MEDIA_RESOURCE_GRANTED);
         mContext.registerReceiver(mBroadcastReceiver, intentFilter);
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsControlsView.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsControlsView.java
index df44dc1..ffe96af 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsControlsView.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsControlsView.java
@@ -48,12 +48,12 @@
         abstract void onBackPressed();
     }
 
-    final PipManager mPipManager = PipManager.getInstance();
+    private final PipManager mPipManager = PipManager.getInstance();
     private Listener mListener;
     private PipControlsView mPipControlsView;
     private View mScrim;
     private Animator mFocusGainAnimator;
-    private AnimatorSet mFocusLoseAnimatorSet;
+    private AnimatorSet mFocusLossAnimatorSet;
 
     public PipRecentsControlsView(Context context) {
         this(context, null, 0, 0);
@@ -80,12 +80,12 @@
         mScrim = findViewById(R.id.scrim);
 
         mFocusGainAnimator = loadAnimator(mPipControlsView,
-                      R.anim.tv_pip_controls_in_recents_focus_gain_animation);
+                R.anim.tv_pip_controls_in_recents_focus_gain_animation);
 
-        mFocusLoseAnimatorSet = new AnimatorSet();
-        mFocusLoseAnimatorSet.playSequentially(
+        mFocusLossAnimatorSet = new AnimatorSet();
+        mFocusLossAnimatorSet.playSequentially(
                 loadAnimator(mPipControlsView,
-                        R.anim.tv_pip_controls_in_recents_focus_lose_animation),
+                        R.anim.tv_pip_controls_in_recents_focus_loss_animation),
                 loadAnimator(mScrim, R.anim.tv_pip_controls_in_recents_scrim_fade_in_animation));
 
         Rect pipBounds = mPipManager.getRecentsFocusedPipBounds();
@@ -99,21 +99,29 @@
     }
 
     /**
-     * Starts focus gaining animation.
+     * Starts focus gain animation.
      */
     public void startFocusGainAnimation() {
         // Hides the scrim view as soon as possible, before the PIP resize animation starts.
         // If we don't, PIP will be moved down a bit and a gap between the scrim and PIP will be
         // shown at the bottom of the PIP.
         mScrim.setAlpha(0);
-        startAnimator(mFocusGainAnimator, mFocusLoseAnimatorSet);
+        PipControlButtonView focus = mPipControlsView.getFocusedButton();
+        if (focus != null) {
+            focus.startFocusGainAnimation();
+        }
+        startAnimator(mFocusGainAnimator, mFocusLossAnimatorSet);
     }
 
     /**
-     * Starts focus losing animation.
+     * Starts focus loss animation.
      */
-    public void startFocusLoseAnimation() {
-        startAnimator(mFocusLoseAnimatorSet, mFocusGainAnimator);
+    public void startFocusLossAnimation() {
+        PipControlButtonView focus = mPipControlsView.getFocusedButton();
+        if (focus != null) {
+            focus.startFocusLossAnimation();
+        }
+        startAnimator(mFocusLossAnimatorSet, mFocusGainAnimator);
     }
 
     /**
@@ -121,14 +129,14 @@
      */
     public void reset() {
         cancelAnimator(mFocusGainAnimator);
-        cancelAnimator(mFocusLoseAnimatorSet);
+        cancelAnimator(mFocusLossAnimatorSet);
 
         // Reset to initial state (i.e. end of focused)
-        requestFocus();
+        mScrim.setAlpha(0);
         mPipControlsView.setTranslationY(0);
         mPipControlsView.setScaleX(1);
         mPipControlsView.setScaleY(1);
-        mScrim.setAlpha(0);
+        mPipControlsView.reset();
     }
 
     private static void startAnimator(Animator animator, Animator previousAnimator) {
@@ -153,13 +161,20 @@
 
     @Override
     public boolean dispatchKeyEvent(KeyEvent event) {
-        if (!event.isCanceled()
-                && event.getKeyCode() == KeyEvent.KEYCODE_BACK
-                && event.getAction() == KeyEvent.ACTION_UP) {
-            if (mPipControlsView.mListener != null) {
-                ((PipRecentsControlsView.Listener) mPipControlsView.mListener).onBackPressed();
+        if (!event.isCanceled()) {
+            if (event.getKeyCode() == KeyEvent.KEYCODE_BACK
+                    && event.getAction() == KeyEvent.ACTION_UP) {
+                if (mPipControlsView.mListener != null) {
+                    ((PipRecentsControlsView.Listener) mPipControlsView.mListener).onBackPressed();
+                }
+                return true;
+            } else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_DOWN) {
+                if (event.getAction() == KeyEvent.ACTION_DOWN) {
+                    mPipManager.getPipRecentsOverlayManager().clearFocus();
+                }
+                // Consume the down event always to prevent warning logs from ViewRootImpl.
+                return true;
             }
-            return true;
         }
         return super.dispatchKeyEvent(event);
     }
diff --git a/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsOverlayManager.java b/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsOverlayManager.java
index 6e4a593..895b8a2 100644
--- a/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsOverlayManager.java
+++ b/packages/SystemUI/src/com/android/systemui/tv/pip/PipRecentsOverlayManager.java
@@ -18,15 +18,20 @@
 
 import android.content.Context;
 import android.graphics.PixelFormat;
+import android.graphics.Rect;
 import android.util.Log;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.accessibility.AccessibilityEvent;
-import android.view.WindowManager.LayoutParams;
 import android.view.WindowManager;
+import android.view.WindowManager.LayoutParams;
+import android.view.accessibility.AccessibilityEvent;
 
 import com.android.systemui.R;
+import com.android.systemui.recents.misc.SystemServicesProxy;
 
+import static android.view.Gravity.CENTER_HORIZONTAL;
+import static android.view.Gravity.TOP;
+import static android.view.View.MeasureSpec.UNSPECIFIED;
 import static com.android.systemui.tv.pip.PipManager.STATE_PIP_OVERLAY;
 import static com.android.systemui.tv.pip.PipManager.STATE_PIP_RECENTS;
 import static com.android.systemui.tv.pip.PipManager.STATE_PIP_RECENTS_FOCUSED;
@@ -42,13 +47,16 @@
 
     private final PipManager mPipManager = PipManager.getInstance();
     private final WindowManager mWindowManager;
+    private final SystemServicesProxy mSystemServicesProxy;
     private View mOverlayView;
     private PipRecentsControlsView mPipControlsView;
     private View mRecentsView;
+    private boolean mTalkBackEnabled;
 
-    private final LayoutParams mPipRecentsControlsViewLayoutParams;
-    private final LayoutParams mPipRecentsControlsViewFocusedLayoutParams;
+    private LayoutParams mPipRecentsControlsViewLayoutParams;
+    private LayoutParams mPipRecentsControlsViewFocusedLayoutParams;
 
+    private boolean mHasFocusableInRecents;
     private boolean mIsPipRecentsOverlayShown;
     private boolean mIsRecentsShown;
     private boolean mIsPipFocusedInRecent;
@@ -72,18 +80,7 @@
 
     PipRecentsOverlayManager(Context context) {
         mWindowManager = (WindowManager) context.getSystemService(WindowManager.class);
-
-        mPipRecentsControlsViewLayoutParams = new WindowManager.LayoutParams(
-                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
-                LayoutParams.TYPE_SYSTEM_DIALOG,
-                LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE,
-                PixelFormat.TRANSLUCENT);
-        mPipRecentsControlsViewFocusedLayoutParams = new WindowManager.LayoutParams(
-                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
-                LayoutParams.TYPE_SYSTEM_DIALOG,
-                0,
-                PixelFormat.TRANSLUCENT);
-
+        mSystemServicesProxy = SystemServicesProxy.getInstance(context);
         initViews(context);
     }
 
@@ -101,6 +98,20 @@
                 }
             }
         });
+
+        mOverlayView.measure(UNSPECIFIED, UNSPECIFIED);
+        mPipRecentsControlsViewLayoutParams = new WindowManager.LayoutParams(
+                mOverlayView.getMeasuredWidth(), mOverlayView.getMeasuredHeight(),
+                LayoutParams.TYPE_SYSTEM_DIALOG,
+                LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_NOT_TOUCHABLE,
+                PixelFormat.TRANSLUCENT);
+        mPipRecentsControlsViewLayoutParams.gravity = TOP | CENTER_HORIZONTAL;
+        mPipRecentsControlsViewFocusedLayoutParams = new WindowManager.LayoutParams(
+                mOverlayView.getMeasuredWidth(), mOverlayView.getMeasuredHeight(),
+                LayoutParams.TYPE_SYSTEM_DIALOG,
+                0,
+                PixelFormat.TRANSLUCENT);
+        mPipRecentsControlsViewFocusedLayoutParams.gravity = TOP | CENTER_HORIZONTAL;
     }
 
     /**
@@ -111,9 +122,10 @@
         if (mIsPipRecentsOverlayShown) {
             return;
         }
+        mTalkBackEnabled = mSystemServicesProxy.isTouchExplorationEnabled();
+        mRecentsView.setVisibility(mTalkBackEnabled ? View.VISIBLE : View.GONE);
         mIsPipRecentsOverlayShown = true;
         mIsPipFocusedInRecent = true;
-        mPipControlsView.reset();
         mWindowManager.addView(mOverlayView, mPipRecentsControlsViewFocusedLayoutParams);
     }
 
@@ -126,50 +138,46 @@
             return;
         }
         mWindowManager.removeView(mOverlayView);
+        // Resets the controls view when its removed.
+        // If not, changing focus in reset will be show animation when Recents is resumed.
+        mPipControlsView.reset();
         mIsPipRecentsOverlayShown = false;
     }
 
     /**
      * Request focus to the PIP Recents overlay.
-     * Called when the PIP view in {@link com.android.systemui.recents.tv.RecentsTvActivity}
-     * is focused.
      * This should be called only by {@link com.android.systemui.recents.tv.RecentsTvActivity}.
-     * @param allowRecentsFocusable {@code true} if Recents can have focus. (i.e. Has a recent task)
+     * @param hasFocusableInRecents {@code true} if Recents can have focus. (i.e. Has a recent task)
      */
-    public void requestFocus(boolean allowRecentsFocusable) {
-        mRecentsView.setVisibility(allowRecentsFocusable ? View.VISIBLE : View.GONE);
+    public void requestFocus(boolean hasFocusableInRecents) {
+        mHasFocusableInRecents = hasFocusableInRecents;
         if (!mIsPipRecentsOverlayShown || !mIsRecentsShown || mIsPipFocusedInRecent
                 || !mPipManager.isPipShown()) {
             return;
         }
         mIsPipFocusedInRecent = true;
-        mPipManager.resizePinnedStack(STATE_PIP_RECENTS_FOCUSED);
-
-        mWindowManager.updateViewLayout(mOverlayView, mPipRecentsControlsViewFocusedLayoutParams);
-        mPipControlsView.requestFocus();
-        mPipControlsView.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED);
         mPipControlsView.startFocusGainAnimation();
+        mWindowManager.updateViewLayout(mOverlayView, mPipRecentsControlsViewFocusedLayoutParams);
+        mPipManager.resizePinnedStack(STATE_PIP_RECENTS_FOCUSED);
+        if (mTalkBackEnabled) {
+            mPipControlsView.requestFocus();
+            mPipControlsView.sendAccessibilityEvent(
+                    AccessibilityEvent.TYPE_VIEW_FOCUSED);
+        }
     }
 
     /**
      * Request focus to the PIP Recents overlay.
-     * Called when the PIP view in {@link com.android.systemui.recents.tv.RecentsTvActivity}
-     * is focused.
-     * This should be called only by {@link com.android.systemui.recents.tv.RecentsTvActivity}.
      */
     public void clearFocus() {
         if (!mIsPipRecentsOverlayShown || !mIsRecentsShown || !mIsPipFocusedInRecent
-                || !mPipManager.isPipShown()) {
+                || !mPipManager.isPipShown() || !mHasFocusableInRecents) {
             return;
         }
-        if (!mRecentsView.hasFocus()) {
-            // Let mRecentsView's focus listener handle clearFocus().
-            mRecentsView.requestFocus();
-        }
         mIsPipFocusedInRecent = false;
-        mPipManager.resizePinnedStack(STATE_PIP_RECENTS);
+        mPipControlsView.startFocusLossAnimation();
         mWindowManager.updateViewLayout(mOverlayView, mPipRecentsControlsViewLayoutParams);
-        mPipControlsView.startFocusLoseAnimation();
+        mPipManager.resizePinnedStack(STATE_PIP_RECENTS);
         if (mCallback != null) {
             mCallback.onRecentsFocused();
         }
diff --git a/proto/src/metrics_constants.proto b/proto/src/metrics_constants.proto
index f8cdf9b..a1487e3 100644
--- a/proto/src/metrics_constants.proto
+++ b/proto/src/metrics_constants.proto
@@ -2212,6 +2212,12 @@
     // Notification group expansion state toggled by the expand affordance.
     ACTION_NOTIFICATION_GROUP_EXPANDER = 408;
 
+    // Notification expansion state toggled by the expand gesture.
+    ACTION_NOTIFICATION_GESTURE_EXPANDER = 409;
+
+    // Notification group expansion state toggled by the expand gesture.
+    ACTION_NOTIFICATION_GROUP_GESTURE_EXPANDER = 410;
+
     // Add new aosp constants above this line.
     // END OF AOSP CONSTANTS
   }
diff --git a/services/core/java/com/android/server/DeviceIdleController.java b/services/core/java/com/android/server/DeviceIdleController.java
index 69960c7..bb966f7 100644
--- a/services/core/java/com/android/server/DeviceIdleController.java
+++ b/services/core/java/com/android/server/DeviceIdleController.java
@@ -542,6 +542,8 @@
                 "mms_temp_app_whitelist_duration";
         private static final String KEY_SMS_TEMP_APP_WHITELIST_DURATION =
                 "sms_temp_app_whitelist_duration";
+        private static final String KEY_NOTIFICATION_WHITELIST_DURATION =
+                "notification_whitelist_duration";
 
         /**
          * This is the time, after becoming inactive, that we go in to the first
@@ -752,6 +754,14 @@
          */
         public long SMS_TEMP_APP_WHITELIST_DURATION;
 
+        /**
+         * Amount of time we would like to whitelist an app that is handling a
+         * {@link android.app.PendingIntent} triggered by a {@link android.app.Notification}.
+         * @see Settings.Global#DEVICE_IDLE_CONSTANTS
+         * @see #KEY_NOTIFICATION_WHITELIST_DURATION
+         */
+        public long NOTIFICATION_WHITELIST_DURATION;
+
         private final ContentResolver mResolver;
         private final boolean mHasWatch;
         private final KeyValueListParser mParser = new KeyValueListParser(',');
@@ -842,6 +852,8 @@
                         KEY_MMS_TEMP_APP_WHITELIST_DURATION, 60 * 1000L);
                 SMS_TEMP_APP_WHITELIST_DURATION = mParser.getLong(
                         KEY_SMS_TEMP_APP_WHITELIST_DURATION, 20 * 1000L);
+                NOTIFICATION_WHITELIST_DURATION = mParser.getLong(
+                        KEY_NOTIFICATION_WHITELIST_DURATION, 30 * 1000L);
             }
         }
 
@@ -945,6 +957,10 @@
             pw.print("    "); pw.print(KEY_SMS_TEMP_APP_WHITELIST_DURATION); pw.print("=");
             TimeUtils.formatDuration(SMS_TEMP_APP_WHITELIST_DURATION, pw);
             pw.println();
+
+            pw.print("    "); pw.print(KEY_NOTIFICATION_WHITELIST_DURATION); pw.print("=");
+            TimeUtils.formatDuration(NOTIFICATION_WHITELIST_DURATION, pw);
+            pw.println();
         }
     }
 
@@ -1252,6 +1268,10 @@
             addPowerSaveTempWhitelistAppDirectInternal(0, appId, duration, sync, reason);
         }
 
+        public long getNotificationWhitelistDuration() {
+            return mConstants.NOTIFICATION_WHITELIST_DURATION;
+        }
+
         public void setNetworkPolicyTempWhitelistCallback(Runnable callback) {
             setNetworkPolicyTempWhitelistCallbackInternal(callback);
         }
@@ -1632,7 +1652,7 @@
             }
             entry.first.value = timeNow + duration;
             if (DEBUG) {
-                Slog.d(TAG, "Adding AppId " + appId + " to temp whitelist");
+                Slog.d(TAG, "Adding AppId " + appId + " to temp whitelist. New entry: " + newEntry);
             }
             if (newEntry) {
                 // No pending timeout for the app id, post a delayed message
@@ -1665,12 +1685,18 @@
     }
 
     private void postTempActiveTimeoutMessage(int uid, long delay) {
+        if (DEBUG) {
+            Slog.d(TAG, "postTempActiveTimeoutMessage: uid=" + uid + ", delay=" + delay);
+        }
         mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_TEMP_APP_WHITELIST_TIMEOUT, uid, 0),
                 delay);
     }
 
     void checkTempAppWhitelistTimeout(int uid) {
         final long timeNow = SystemClock.elapsedRealtime();
+        if (DEBUG) {
+            Slog.d(TAG, "checkTempAppWhitelistTimeout: uid=" + uid + ", timeNow=" + timeNow);
+        }
         synchronized (this) {
             Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.get(uid);
             if (entry == null) {
@@ -1694,6 +1720,9 @@
                 }
             } else {
                 // Need more time
+                if (DEBUG) {
+                    Slog.d(TAG, "Time to remove UID " + uid + ": " + entry.first.value);
+                }
                 postTempActiveTimeoutMessage(uid, entry.first.value - timeNow);
             }
         }
@@ -2514,6 +2543,8 @@
         pw.println("    Print currently whitelisted apps.");
         pw.println("  whitelist [package ...]");
         pw.println("    Add (prefix with +) or remove (prefix with -) packages.");
+        pw.println("  tempwhitelist");
+        pw.println("    Print packages that are temporarily whitelisted.");
         pw.println("  tempwhitelist [-u] [package ..]");
         pw.println("    Temporarily place packages in whitelist for 10 seconds.");
     }
@@ -2817,8 +2848,7 @@
                     pw.println("Failed: " + re);
                 }
             } else {
-                pw.println("At least one package name must be specified");
-                return -1;
+                dumpTempWhitelistSchedule(pw, false);
             }
         } else {
             return shell.handleDefaultCommands(cmd);
@@ -2943,20 +2973,8 @@
                     pw.println();
                 }
             }
-            size = mTempWhitelistAppIdEndTimes.size();
-            if (size > 0) {
-                pw.println("  Temp whitelist schedule:");
-                final long timeNow = SystemClock.elapsedRealtime();
-                for (int i = 0; i < size; i++) {
-                    pw.print("    UID=");
-                    pw.print(mTempWhitelistAppIdEndTimes.keyAt(i));
-                    pw.print(": ");
-                    Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.valueAt(i);
-                    TimeUtils.formatDuration(entry.first.value, timeNow, pw);
-                    pw.print(" - ");
-                    pw.println(entry.second);
-                }
-            }
+            dumpTempWhitelistSchedule(pw, true);
+
             size = mTempWhitelistAppIdArray != null ? mTempWhitelistAppIdArray.length : 0;
             if (size > 0) {
                 pw.println("  Temp whitelist app ids:");
@@ -2968,7 +2986,7 @@
             }
 
             pw.print("  mLightEnabled="); pw.print(mLightEnabled);
-            pw.print(" mDeepEnabled="); pw.println(mDeepEnabled);
+            pw.print("  mDeepEnabled="); pw.println(mDeepEnabled);
             pw.print("  mForceIdle="); pw.println(mForceIdle);
             pw.print("  mMotionSensor="); pw.println(mMotionSensor);
             pw.print("  mCurDisplay="); pw.println(mCurDisplay);
@@ -3040,4 +3058,26 @@
             }
         }
     }
-}
+
+    void dumpTempWhitelistSchedule(PrintWriter pw, boolean printTitle) {
+        final int size = mTempWhitelistAppIdEndTimes.size();
+        if (size > 0) {
+            String prefix = "";
+            if (printTitle) {
+                pw.println("  Temp whitelist schedule:");
+                prefix = "    ";
+            }
+            final long timeNow = SystemClock.elapsedRealtime();
+            for (int i = 0; i < size; i++) {
+                pw.print(prefix);
+                pw.print("UID=");
+                pw.print(mTempWhitelistAppIdEndTimes.keyAt(i));
+                pw.print(": ");
+                Pair<MutableLong, String> entry = mTempWhitelistAppIdEndTimes.valueAt(i);
+                TimeUtils.formatDuration(entry.first.value, timeNow, pw);
+                pw.print(" - ");
+                pw.println(entry.second);
+            }
+        }
+    }
+ }
diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java
index 727bf5c..5d8fe7c 100644
--- a/services/core/java/com/android/server/InputMethodManagerService.java
+++ b/services/core/java/com/android/server/InputMethodManagerService.java
@@ -159,6 +159,7 @@
     static final int MSG_BIND_INPUT = 1010;
     static final int MSG_SHOW_SOFT_INPUT = 1020;
     static final int MSG_HIDE_SOFT_INPUT = 1030;
+    static final int MSG_HIDE_CURRENT_INPUT_METHOD = 1035;
     static final int MSG_ATTACH_TOKEN = 1040;
     static final int MSG_CREATE_SESSION = 1050;
 
@@ -2846,6 +2847,11 @@
                 }
                 args.recycle();
                 return true;
+            case MSG_HIDE_CURRENT_INPUT_METHOD:
+                synchronized (mMethodMap) {
+                    hideCurrentInputLocked(0, null);
+                }
+                return true;
             case MSG_ATTACH_TOKEN:
                 args = (SomeArgs)msg.obj;
                 try {
@@ -3880,6 +3886,12 @@
             mHandler.sendMessage(mHandler.obtainMessage(MSG_SWITCH_IME,
                     forwardDirection ? 1 : 0, 0));
         }
+
+        @Override
+        public void hideCurrentInputMethod() {
+            mHandler.removeMessages(MSG_HIDE_CURRENT_INPUT_METHOD);
+            mHandler.sendEmptyMessage(MSG_HIDE_CURRENT_INPUT_METHOD);
+        }
     }
 
     private static String imeWindowStatusToString(final int imeWindowVis) {
diff --git a/services/core/java/com/android/server/NetworkScoreService.java b/services/core/java/com/android/server/NetworkScoreService.java
index 2a78f90..3745e0b 100644
--- a/services/core/java/com/android/server/NetworkScoreService.java
+++ b/services/core/java/com/android/server/NetworkScoreService.java
@@ -17,12 +17,10 @@
 package com.android.server;
 
 import android.Manifest.permission;
-import android.content.BroadcastReceiver;
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
 import android.content.Intent;
-import android.content.IntentFilter;
 import android.content.ServiceConnection;
 import android.content.pm.PackageManager;
 import android.net.INetworkScoreCache;
@@ -33,7 +31,6 @@
 import android.net.ScoredNetwork;
 import android.os.Binder;
 import android.os.IBinder;
-import android.os.PatternMatcher;
 import android.os.RemoteException;
 import android.os.UserHandle;
 import android.provider.Settings;
@@ -42,6 +39,7 @@
 
 import com.android.internal.R;
 import com.android.internal.annotations.GuardedBy;
+import com.android.internal.content.PackageMonitor;
 
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
@@ -62,39 +60,75 @@
 
     private final Context mContext;
     private final Map<Integer, INetworkScoreCache> mScoreCaches;
-    /** Lock used to update mReceiver when scorer package changes occur. */
-    private final Object mReceiverLock = new Object[0];
+    /** Lock used to update mPackageMonitor when scorer package changes occur. */
+    private final Object mPackageMonitorLock = new Object[0];
 
-    /** Clears scores when the active scorer package is no longer valid. */
-    @GuardedBy("mReceiverLock")
-    private ScorerChangedReceiver mReceiver;
+    @GuardedBy("mPackageMonitorLock")
+    private NetworkScorerPackageMonitor mPackageMonitor;
     private ScoringServiceConnection mServiceConnection;
 
-    private class ScorerChangedReceiver extends BroadcastReceiver {
+    /**
+     * Clears scores when the active scorer package is no longer valid and
+     * manages the service connection.
+     */
+    private class NetworkScorerPackageMonitor extends PackageMonitor {
         final String mRegisteredPackage;
 
-        ScorerChangedReceiver(String packageName) {
-            mRegisteredPackage = packageName;
+        private NetworkScorerPackageMonitor(String mRegisteredPackage) {
+            this.mRegisteredPackage = mRegisteredPackage;
         }
 
         @Override
-        public void onReceive(Context context, Intent intent) {
-            String action = intent.getAction();
-            if (Intent.ACTION_PACKAGE_CHANGED.equals(action)
-                    || Intent.ACTION_PACKAGE_REPLACED.equals(action)
-                    || Intent.ACTION_PACKAGE_FULLY_REMOVED.equals(action)) {
-                NetworkScorerAppData activeScorer =
+        public void onPackageAdded(String packageName, int uid) {
+            evaluateBinding(packageName, true /* forceUnbind */);
+        }
+
+        @Override
+        public void onPackageRemoved(String packageName, int uid) {
+            evaluateBinding(packageName, true /* forceUnbind */);
+        }
+
+        @Override
+        public void onPackageModified(String packageName) {
+            evaluateBinding(packageName, false /* forceUnbind */);
+        }
+
+        @Override
+        public boolean onHandleForceStop(Intent intent, String[] packages, int uid, boolean doit) {
+            if (doit) { // "doit" means the force stop happened instead of just being queried for.
+                for (String packageName : packages) {
+                    evaluateBinding(packageName, true /* forceUnbind */);
+                }
+            }
+            return super.onHandleForceStop(intent, packages, uid, doit);
+        }
+
+        @Override
+        public void onPackageUpdateFinished(String packageName, int uid) {
+            evaluateBinding(packageName, true /* forceUnbind */);
+        }
+
+        private void evaluateBinding(String scorerPackageName, boolean forceUnbind) {
+            if (mRegisteredPackage.equals(scorerPackageName)) {
+                if (DBG) {
+                    Log.d(TAG, "Evaluating binding for: " + scorerPackageName
+                            + ", forceUnbind=" + forceUnbind);
+                }
+                final NetworkScorerAppData activeScorer =
                         NetworkScorerAppManager.getActiveScorer(mContext);
                 if (activeScorer == null) {
-                    // Package change has invalidated a scorer.
+                    // Package change has invalidated a scorer, this will also unbind any service
+                    // connection.
                     Log.i(TAG, "Package " + mRegisteredPackage +
                             " is no longer valid, disabling scoring.");
                     setScorerInternal(null);
                 } else if (activeScorer.mScoringServiceClassName == null) {
                     // The scoring service is not available, make sure it's unbound.
                     unbindFromScoringServiceIfNeeded();
-                } else {
-                    // The scoring service may have changed or been added.
+                } else { // The scoring service changed in some way.
+                    if (forceUnbind) {
+                        unbindFromScoringServiceIfNeeded();
+                    }
                     bindToScoringServiceIfNeeded(activeScorer);
                 }
             }
@@ -121,7 +155,7 @@
             Settings.Global.putInt(cr, Settings.Global.NETWORK_SCORING_PROVISIONED, 1);
         }
 
-        registerPackageReceiverIfNeeded();
+        registerPackageMonitorIfNeeded();
     }
 
     /** Called when the system is ready for us to start third-party code. */
@@ -130,33 +164,29 @@
         bindToScoringServiceIfNeeded();
     }
 
-    private void registerPackageReceiverIfNeeded() {
-        if (DBG) Log.d(TAG, "registerPackageReceiverIfNeeded");
+    private void registerPackageMonitorIfNeeded() {
+        if (DBG) Log.d(TAG, "registerPackageMonitorIfNeeded");
         NetworkScorerAppData scorer = NetworkScorerAppManager.getActiveScorer(mContext);
-        synchronized (mReceiverLock) {
-            // Unregister the receiver if the current scorer has changed since last registration.
-            if (mReceiver != null) {
-                if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                    Log.v(TAG, "Unregistering receiver for " + mReceiver.mRegisteredPackage);
+        synchronized (mPackageMonitorLock) {
+            // Unregister the current monitor if needed.
+            if (mPackageMonitor != null) {
+                if (DBG) {
+                    Log.d(TAG, "Unregistering package monitor for "
+                            + mPackageMonitor.mRegisteredPackage);
                 }
-                mContext.unregisterReceiver(mReceiver);
-                mReceiver = null;
+                mPackageMonitor.unregister();
+                mPackageMonitor = null;
             }
 
-            // Register receiver if a scorer is active.
+            // Create and register the monitor if a scorer is active.
             if (scorer != null) {
-                IntentFilter filter = new IntentFilter();
-                filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
-                filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
-                filter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
-                filter.addDataScheme("package");
-                filter.addDataSchemeSpecificPart(scorer.mPackageName,
-                        PatternMatcher.PATTERN_LITERAL);
-                mReceiver = new ScorerChangedReceiver(scorer.mPackageName);
+                mPackageMonitor = new NetworkScorerPackageMonitor(scorer.mPackageName);
                 // TODO: Need to update when we support per-user scorers. http://b/23422763
-                mContext.registerReceiverAsUser(mReceiver, UserHandle.SYSTEM, filter, null, null);
-                if (Log.isLoggable(TAG, Log.VERBOSE)) {
-                    Log.v(TAG, "Registered receiver for " + scorer.mPackageName);
+                mPackageMonitor.register(mContext, null /* thread */, UserHandle.SYSTEM,
+                        false /* externalStorage */);
+                if (DBG) {
+                    Log.d(TAG, "Registered package monitor for "
+                            + mPackageMonitor.mRegisteredPackage);
                 }
             }
         }
@@ -299,7 +329,7 @@
             // will be made to bind to the new scorer.
             bindToScoringServiceIfNeeded();
             if (result) { // new scorer successfully set
-                registerPackageReceiverIfNeeded();
+                registerPackageMonitorIfNeeded();
 
                 Intent intent = new Intent(NetworkScoreManager.ACTION_SCORER_CHANGED);
                 if (prevScorer != null) { // Directly notify the old scorer.
@@ -391,20 +421,24 @@
     private static class ScoringServiceConnection implements ServiceConnection {
         private final ComponentName mComponentName;
         private boolean mBound = false;
+        private boolean mConnected = false;
 
         ScoringServiceConnection(ComponentName componentName) {
             mComponentName = componentName;
         }
 
         void connect(Context context) {
-            disconnect(context);
-            Intent service = new Intent();
-            service.setComponent(mComponentName);
-            mBound = context.bindServiceAsUser(service, this,
-                    Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
-                    UserHandle.SYSTEM);
             if (!mBound) {
-                Log.w(TAG, "Bind call failed for " + service);
+                Intent service = new Intent();
+                service.setComponent(mComponentName);
+                mBound = context.bindServiceAsUser(service, this,
+                        Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
+                        UserHandle.SYSTEM);
+                if (!mBound) {
+                    Log.w(TAG, "Bind call failed for " + service);
+                } else {
+                    if (DBG) Log.d(TAG, "ScoringServiceConnection bound.");
+                }
             }
         }
 
@@ -413,6 +447,7 @@
                 if (mBound) {
                     mBound = false;
                     context.unbindService(this);
+                    if (DBG) Log.d(TAG, "ScoringServiceConnection unbound.");
                 }
             } catch (RuntimeException e) {
                 Log.e(TAG, "Unbind failed.", e);
@@ -422,15 +457,20 @@
         @Override
         public void onServiceConnected(ComponentName name, IBinder service) {
             if (DBG) Log.d(TAG, "ScoringServiceConnection: " + name.flattenToString());
+            mConnected = true;
         }
 
         @Override
         public void onServiceDisconnected(ComponentName name) {
-            if (DBG) Log.d(TAG, "ScoringServiceConnection, disconnected: " + name.flattenToString());
+            if (DBG) {
+                Log.d(TAG, "ScoringServiceConnection, disconnected: " + name.flattenToString());
+            }
+            mConnected = false;
         }
 
         public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
-            writer.println("ScoringServiceConnection: " + mComponentName + ", bound: " + mBound);
+            writer.println("ScoringServiceConnection: " + mComponentName + ", bound: " + mBound
+                    + ", connected: " + mConnected);
         }
     }
 }
diff --git a/services/core/java/com/android/server/am/ActiveServices.java b/services/core/java/com/android/server/am/ActiveServices.java
index c24123a..6a8c8b0 100755
--- a/services/core/java/com/android/server/am/ActiveServices.java
+++ b/services/core/java/com/android/server/am/ActiveServices.java
@@ -831,8 +831,9 @@
 
         int clientLabel = 0;
         PendingIntent clientIntent = null;
+        final boolean isCallerSystem = callerApp.info.uid == Process.SYSTEM_UID;
 
-        if (callerApp.info.uid == Process.SYSTEM_UID) {
+        if (isCallerSystem) {
             // Hacky kind of thing -- allow system stuff to tell us
             // what they are, so we can report this elsewhere for
             // others to know why certain services are running.
@@ -854,6 +855,12 @@
                     "BIND_TREAT_LIKE_ACTIVITY");
         }
 
+        if ((flags & Context.BIND_ALLOW_WHITELIST_MANAGEMENT) != 0 && !isCallerSystem) {
+            throw new SecurityException(
+                    "Non-system caller " + caller + " (pid=" + Binder.getCallingPid()
+                    + ") set BIND_ALLOW_WHITELIST_MANAGEMENT when binding service " + service);
+        }
+
         final boolean callerFg = callerApp.setSchedGroup != ProcessList.SCHED_GROUP_BACKGROUND;
         final boolean isBindExternal = (flags & Context.BIND_EXTERNAL_SERVICE) != 0;
 
@@ -1124,6 +1131,11 @@
                 }
 
                 if (r.binding.service.app != null) {
+                    if (r.binding.service.app.whitelistManager) {
+                        // Must reset flag here because on computeOomAdjLocked() the service
+                        // connection will be gone...
+                        r.binding.service.app.whitelistManager = false;
+                    }
                     // This could have made the service less important.
                     if ((r.flags&Context.BIND_TREAT_LIKE_ACTIVITY) != 0) {
                         r.binding.service.app.treatLikeActivity = true;
diff --git a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
index f2bf4f9..43bb5ee 100644
--- a/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
+++ b/services/core/java/com/android/server/am/ActivityManagerDebugConfig.java
@@ -90,6 +90,7 @@
     static final boolean DEBUG_VISIBLE_BEHIND = DEBUG_ALL_ACTIVITIES || false;
     static final boolean DEBUG_USAGE_STATS = DEBUG_ALL || false;
     static final boolean DEBUG_PERMISSIONS_REVIEW = DEBUG_ALL || false;
+    static final boolean DEBUG_WHITELISTS = DEBUG_ALL || false;
 
     static final String POSTFIX_ADD_REMOVE = (APPEND_CATEGORY_NAME) ? "_AddRemove" : "";
     static final String POSTFIX_APP = (APPEND_CATEGORY_NAME) ? "_App" : "";
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index eb4391e..ec54116 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -266,6 +266,7 @@
 import static android.app.ActivityManager.StackId.LAST_STATIC_STACK_ID;
 import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
 import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
+import static android.content.pm.PackageManager.FEATURE_LEANBACK_ONLY;
 import static android.content.pm.PackageManager.FEATURE_PICTURE_IN_PICTURE;
 import static android.content.pm.PackageManager.GET_PROVIDERS;
 import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
@@ -320,6 +321,7 @@
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_USAGE_STATS;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_VISIBILITY;
 import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_VISIBLE_BEHIND;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_WHITELISTS;
 import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_BACKUP;
 import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_BROADCAST;
 import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_CLEANUP;
@@ -1344,6 +1346,7 @@
     boolean mSupportsMultiWindow;
     boolean mSupportsFreeformWindowManagement;
     boolean mSupportsPictureInPicture;
+    boolean mSupportsLeanbackOnly;
     Rect mDefaultPinnedStackBounds;
     IActivityController mController = null;
     boolean mControllerIsAMonkey = false;
@@ -7133,6 +7136,41 @@
         }
     }
 
+    /**
+     * Whitelists {@code targetUid} to temporarily bypass Power Save mode.
+     *
+     * <p>{@code callerUid} must be allowed to request such whitelist by calling
+     * {@link #addTempPowerSaveWhitelistGrantorUid(int)}.
+     */
+    void tempWhitelistAppForPowerSave(int callerPid, int callerUid, int targetUid, long duration) {
+        if (DEBUG_WHITELISTS) {
+            Slog.d(TAG, "tempWhitelistAppForPowerSave(" + callerPid + ", " + callerUid + ", "
+                    + targetUid + ", " + duration + ")");
+        }
+        synchronized (mPidsSelfLocked) {
+            final ProcessRecord pr = mPidsSelfLocked.get(callerPid);
+            if (pr == null) {
+                Slog.w(TAG, "tempWhitelistAppForPowerSave() no ProcessRecord for pid " + callerPid);
+                return;
+            }
+            if (!pr.whitelistManager) {
+                if (DEBUG_WHITELISTS) {
+                    Slog.d(TAG, "tempWhitelistAppForPowerSave() for target " + targetUid + ": pid "
+                            + callerPid + " is not allowed");
+                }
+                return;
+            }
+        }
+
+        final long token = Binder.clearCallingIdentity();
+        try {
+            mLocalDeviceIdleController.addPowerSaveTempWhitelistAppDirect(targetUid, duration,
+                    true, "pe from uid:" + callerUid);
+        } finally {
+            Binder.restoreCallingIdentity(token);
+        }
+    }
+
     @Override
     public void cancelIntentSender(IIntentSender sender) {
         if (!(sender instanceof PendingIntentRecord)) {
@@ -12813,6 +12851,9 @@
         final boolean forceRtl = Settings.Global.getInt(resolver, DEVELOPMENT_FORCE_RTL, 0) != 0;
         final boolean forceResizable = Settings.Global.getInt(
                 resolver, DEVELOPMENT_FORCE_RESIZABLE_ACTIVITIES, 0) != 0;
+        final boolean supportsLeanbackOnly =
+                mContext.getPackageManager().hasSystemFeature(FEATURE_LEANBACK_ONLY);
+
         // Transfer any global setting for forcing RTL layout, into a System Property
         SystemProperties.set(DEVELOPMENT_FORCE_RTL, forceRtl ? "1":"0");
 
@@ -12828,6 +12869,7 @@
             mWaitForDebugger = mOrigWaitForDebugger = waitForDebugger;
             mAlwaysFinishActivities = alwaysFinishActivities;
             mLenientBackgroundCheck = lenientBackgroundCheck;
+            mSupportsLeanbackOnly = supportsLeanbackOnly;
             mForceResizableActivities = forceResizable;
             mWindowManager.setForceResizableTasks(mForceResizableActivities);
             if (supportsMultiWindow || forceResizable) {
@@ -19017,6 +19059,9 @@
                     }
                 }
             }
+
+            app.whitelistManager = false;
+
             for (int conni = s.connections.size()-1;
                     conni >= 0 && (adj > ProcessList.FOREGROUND_APP_ADJ
                             || schedGroup == ProcessList.SCHED_GROUP_BACKGROUND
@@ -19035,6 +19080,10 @@
                         // Binding to ourself is not interesting.
                         continue;
                     }
+                    if ((cr.flags & Context.BIND_ALLOW_WHITELIST_MANAGEMENT) != 0) {
+                        app.whitelistManager = true;
+                    }
+
                     if ((cr.flags&Context.BIND_WAIVE_PRIORITY) == 0) {
                         ProcessRecord client = cr.binding.client;
                         int clientAdj = computeOomAdjLocked(client, cachedAdj,
@@ -21306,6 +21355,15 @@
                 }
             }
         }
+
+        @Override
+        public void setPendingIntentWhitelistDuration(IIntentSender target, long duration) {
+            if (!(target instanceof PendingIntentRecord)) {
+                Slog.w(TAG, "markAsSentFromNotification(): not a PendingIntentRecord: " + target);
+                return;
+            }
+            ((PendingIntentRecord) target).setWhitelistDuration(duration);
+        }
     }
 
     private final class SleepTokenImpl extends SleepToken {
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 8b637e0..ba044cc4 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1832,9 +1832,9 @@
         boolean isVisible =
                 !behindFullscreenActivity || r.mLaunchTaskBehind || activityVisibleBehind;
 
-        if (isVisible && r.isRecentsActivity()) {
-            // Recents activity can only be visible if the home stack is the focused stack or we are
-            // in split-screen mode.
+        if (mService.mSupportsLeanbackOnly && isVisible && r.isRecentsActivity()) {
+            // On devices that support leanback only (Android TV), Recents activity can only be
+            // visible if the home stack is the focused stack or we are in split-screen mode.
             isVisible = mStackSupervisor.getStack(DOCKED_STACK_ID) != null
                     || mStackSupervisor.isFocusedStack(this);
         }
diff --git a/services/core/java/com/android/server/am/AppErrorDialog.java b/services/core/java/com/android/server/am/AppErrorDialog.java
index ddfab4d..e37feb2 100644
--- a/services/core/java/com/android/server/am/AppErrorDialog.java
+++ b/services/core/java/com/android/server/am/AppErrorDialog.java
@@ -18,13 +18,17 @@
 
 import android.app.ActivityManagerInternal;
 import android.app.ActivityOptions;
+import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
 import android.content.pm.IPackageDataObserver;
 import android.content.pm.PackageManager;
 import android.content.res.Resources;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Message;
+import android.provider.Settings;
 import android.text.BidiFormatter;
 import android.util.Slog;
 import android.view.LayoutInflater;
@@ -43,6 +47,7 @@
     private final AppErrorResult mResult;
     private final ProcessRecord mProc;
     private final boolean mRepeating;
+    private final boolean mForeground;
 
     private CharSequence mName;
 
@@ -54,9 +59,9 @@
     static final int FORCE_QUIT = 1;
     static final int FORCE_QUIT_AND_REPORT = 2;
     static final int RESTART = 3;
-    static final int RESET = 4;
     static final int MUTE = 5;
     static final int TIMEOUT = 6;
+    static final int CANCEL = 7;
 
     // 5-minute timeout, then we automatically dismiss the crash dialog
     static final long DISMISS_TIMEOUT = 1000 * 60 * 5;
@@ -69,6 +74,7 @@
         mProc = data.proc;
         mResult = data.result;
         mRepeating = data.repeating;
+        mForeground = data.task != null;
         BidiFormatter bidi = BidiFormatter.getInstance();
 
         if ((mProc.pkgList.size() == 1) &&
@@ -86,7 +92,8 @@
                     bidi.unicodeWrap(mName.toString())));
         }
 
-        setCancelable(false);
+        setCancelable(true);
+        setCancelMessage(mHandler.obtainMessage(CANCEL));
 
         WindowManager.LayoutParams attrs = getWindow().getAttributes();
         attrs.setTitle("Application Error: " + mProc.info.processName);
@@ -111,25 +118,41 @@
         LayoutInflater.from(context).inflate(
                 com.android.internal.R.layout.app_error_dialog, frame, true);
 
+        boolean hasRestart = !mRepeating && mForeground;
+        final boolean hasReceiver = mProc.errorReportReceiver != null;
+
         final TextView restart = (TextView) findViewById(com.android.internal.R.id.aerr_restart);
         restart.setOnClickListener(this);
-        restart.setVisibility(!mRepeating ? View.VISIBLE : View.GONE);
-        final TextView reset = (TextView) findViewById(com.android.internal.R.id.aerr_reset);
-        reset.setOnClickListener(this);
-        reset.setVisibility(mRepeating ? View.VISIBLE : View.GONE);
+        restart.setVisibility(hasRestart ? View.VISIBLE : View.GONE);
         final TextView report = (TextView) findViewById(com.android.internal.R.id.aerr_report);
         report.setOnClickListener(this);
-        final boolean hasReceiver = mProc.errorReportReceiver != null;
         report.setVisibility(hasReceiver ? View.VISIBLE : View.GONE);
         final TextView close = (TextView) findViewById(com.android.internal.R.id.aerr_close);
+        close.setVisibility(!hasRestart ? View.VISIBLE : View.GONE);
         close.setOnClickListener(this);
+
+        boolean showMute = !IS_USER_BUILD && Settings.Global.getInt(context.getContentResolver(),
+                Settings.Global.DEVELOPMENT_SETTINGS_ENABLED, 0) != 0;
         final TextView mute = (TextView) findViewById(com.android.internal.R.id.aerr_mute);
         mute.setOnClickListener(this);
-        mute.setVisibility(!IS_USER_BUILD ? View.VISIBLE : View.GONE);
+        mute.setVisibility(showMute ? View.VISIBLE : View.GONE);
 
         findViewById(com.android.internal.R.id.customPanel).setVisibility(View.VISIBLE);
     }
 
+    @Override
+    public void onStart() {
+        super.onStart();
+        getContext().registerReceiver(mReceiver,
+                new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
+    }
+
+    @Override
+    protected void onStop() {
+        super.onStop();
+        getContext().unregisterReceiver(mReceiver);
+    }
+
     private final Handler mHandler = new Handler() {
         public void handleMessage(Message msg) {
             final int result = msg.what;
@@ -163,9 +186,6 @@
             case com.android.internal.R.id.aerr_restart:
                 mHandler.obtainMessage(RESTART).sendToTarget();
                 break;
-            case com.android.internal.R.id.aerr_reset:
-                mHandler.obtainMessage(RESET).sendToTarget();
-                break;
             case com.android.internal.R.id.aerr_report:
                 mHandler.obtainMessage(FORCE_QUIT_AND_REPORT).sendToTarget();
                 break;
@@ -180,6 +200,15 @@
         }
     }
 
+    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (Intent.ACTION_CLOSE_SYSTEM_DIALOGS.equals(intent.getAction())) {
+                cancel();
+            }
+        }
+    };
+
     static class Data {
         AppErrorResult result;
         TaskRecord task;
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java
index 3ed9969..49106f4 100644
--- a/services/core/java/com/android/server/am/AppErrors.java
+++ b/services/core/java/com/android/server/am/AppErrors.java
@@ -370,38 +370,9 @@
 
         Intent appErrorIntent = null;
         MetricsLogger.action(mContext, MetricsProto.MetricsEvent.ACTION_APP_CRASH, res);
-        if (res == AppErrorDialog.TIMEOUT) {
+        if (res == AppErrorDialog.TIMEOUT || res == AppErrorDialog.CANCEL) {
             res = AppErrorDialog.FORCE_QUIT;
         }
-        if (res == AppErrorDialog.RESET) {
-            String[] packageList = r.getPackageList();
-            if (packageList != null) {
-                PackageManager pm = mContext.getPackageManager();
-                final Semaphore s = new Semaphore(0);
-                for (int i = 0; i < packageList.length; i++) {
-                    if (i < packageList.length - 1) {
-                        pm.deleteApplicationCacheFiles(packageList[i], null);
-                    } else {
-                        pm.deleteApplicationCacheFiles(packageList[i],
-                                new IPackageDataObserver.Stub() {
-                                    @Override
-                                    public void onRemoveCompleted(String packageName,
-                                                                  boolean succeeded) {
-                                        s.release();
-                                    }
-                                });
-
-                        // Wait until cache has been cleared before we restart.
-                        try {
-                            s.acquire();
-                        } catch (InterruptedException e) {
-                        }
-                    }
-                }
-            }
-            // If there was nothing to reset, just restart;
-            res = AppErrorDialog.RESTART;
-        }
         synchronized (mService) {
             if (res == AppErrorDialog.MUTE) {
                 stopReportingCrashesLocked(r);
diff --git a/services/core/java/com/android/server/am/PendingIntentRecord.java b/services/core/java/com/android/server/am/PendingIntentRecord.java
index 1f8d26b..c1ff4dd 100644
--- a/services/core/java/com/android/server/am/PendingIntentRecord.java
+++ b/services/core/java/com/android/server/am/PendingIntentRecord.java
@@ -47,6 +47,7 @@
     final WeakReference<PendingIntentRecord> ref;
     boolean sent = false;
     boolean canceled = false;
+    private long whitelistDuration = 0;
 
     String stringName;
     String lastTagPrefix;
@@ -66,9 +67,9 @@
         final int flags;
         final int hashCode;
         final int userId;
-        
+
         private static final int ODD_PRIME_NUMBER = 37;
-        
+
         Key(int _t, String _p, ActivityRecord _a, String _w,
                 int _r, Intent[] _i, String[] _it, int _f, Bundle _o, int _userId) {
             type = _t;
@@ -106,7 +107,7 @@
             //Slog.i(ActivityManagerService.TAG, this + " hashCode=0x"
             //        + Integer.toHexString(hashCode));
         }
-        
+
         public boolean equals(Object otherObj) {
             if (otherObj == null) {
                 return false;
@@ -198,6 +199,11 @@
         ref = new WeakReference<PendingIntentRecord>(this);
     }
 
+    void setWhitelistDuration(long duration) {
+        this.whitelistDuration = duration;
+        this.stringName = null;
+    }
+
     public void send(int code, Intent intent, String resolvedType, IIntentReceiver finishedReceiver,
             String requiredPermission, Bundle options) {
         sendInner(code, intent, resolvedType, finishedReceiver,
@@ -216,6 +222,14 @@
         if (intent != null) intent.setDefusable(true);
         if (options != null) options.setDefusable(true);
 
+        if (whitelistDuration > 0 && !canceled) {
+            // Must call before acquiring the lock. It's possible the method return before sending
+            // the intent due to some validations inside the lock, in which case the UID shouldn't
+            // be whitelisted, but since the whitelist is temporary, that would be ok.
+            owner.tempWhitelistAppForPowerSave(Binder.getCallingPid(), Binder.getCallingUid(), uid,
+                    whitelistDuration);
+        }
+
         synchronized (owner) {
             final ActivityContainer activityContainer = (ActivityContainer)container;
             if (activityContainer != null && activityContainer.mParentActivity != null &&
@@ -361,7 +375,7 @@
             }
         }
     }
-    
+
     void dump(PrintWriter pw, String prefix) {
         pw.print(prefix); pw.print("uid="); pw.print(uid);
                 pw.print(" packageName="); pw.print(key.packageName);
@@ -383,6 +397,7 @@
             pw.print(prefix); pw.print("sent="); pw.print(sent);
                     pw.print(" canceled="); pw.println(canceled);
         }
+        pw.print(prefix); pw.println("whitelistDuration="); pw.println(whitelistDuration);
     }
 
     public String toString() {
@@ -396,6 +411,9 @@
         sb.append(key.packageName);
         sb.append(' ');
         sb.append(key.typeName());
+        if (whitelistDuration > 0) {
+            sb.append( " (whitelistDuration: ").append(whitelistDuration).append("ms)");
+        }
         sb.append('}');
         return stringName = sb.toString();
     }
diff --git a/services/core/java/com/android/server/am/ProcessRecord.java b/services/core/java/com/android/server/am/ProcessRecord.java
index da18f32..691fd2a 100644
--- a/services/core/java/com/android/server/am/ProcessRecord.java
+++ b/services/core/java/com/android/server/am/ProcessRecord.java
@@ -194,6 +194,8 @@
 
     // Process is currently hosting a backup agent for backup or restore
     public boolean inFullBackup;
+    // App is allowed to manage whitelists such as temporary Power Save mode whitelist.
+    boolean whitelistManager;
 
     void dump(PrintWriter pw, String prefix) {
         final long now = SystemClock.uptimeMillis();
@@ -376,6 +378,9 @@
                     }
                     pw.println();
         }
+        if (whitelistManager) {
+            pw.print(prefix); pw.print("whitelistManager="); pw.println(whitelistManager);
+        }
         if (activities.size() > 0) {
             pw.print(prefix); pw.println("Activities:");
             for (int i=0; i<activities.size(); i++) {
diff --git a/services/core/java/com/android/server/job/JobSchedulerService.java b/services/core/java/com/android/server/job/JobSchedulerService.java
index 491ee18..1b8eccb 100644
--- a/services/core/java/com/android/server/job/JobSchedulerService.java
+++ b/services/core/java/com/android/server/job/JobSchedulerService.java
@@ -16,6 +16,9 @@
 
 package com.android.server.job;
 
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
+import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER;
+
 import java.io.FileDescriptor;
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -41,6 +44,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.ServiceInfo;
 import android.content.pm.PackageManager.NameNotFoundException;
+import android.net.Uri;
 import android.os.BatteryStats;
 import android.os.Binder;
 import android.os.Handler;
@@ -217,7 +221,41 @@
             if (DEBUG) {
                 Slog.d(TAG, "Receieved: " + intent.getAction());
             }
-            if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
+            if (Intent.ACTION_PACKAGE_CHANGED.equals(intent.getAction())) {
+                // Purge the app's jobs if the whole package was just disabled.  When this is
+                // the case the component name will be a bare package name.
+                final String pkgName = getPackageName(intent);
+                final int pkgUid = intent.getIntExtra(Intent.EXTRA_UID, -1);
+                if (pkgName != null && pkgUid != -1) {
+                    final String[] changedComponents = intent.getStringArrayExtra(
+                            Intent.EXTRA_CHANGED_COMPONENT_NAME_LIST);
+                    if (changedComponents != null) {
+                        for (String component : changedComponents) {
+                            if (component.equals(pkgName)) {
+                                if (DEBUG) {
+                                    Slog.d(TAG, "Package state change: " + pkgName);
+                                }
+                                try {
+                                    final int userId = UserHandle.getUserId(pkgUid);
+                                    IPackageManager pm = AppGlobals.getPackageManager();
+                                    final int state = pm.getApplicationEnabledSetting(pkgName, userId);
+                                    if (state == COMPONENT_ENABLED_STATE_DISABLED
+                                            || state ==  COMPONENT_ENABLED_STATE_DISABLED_USER) {
+                                        if (DEBUG) {
+                                            Slog.d(TAG, "Removing jobs for package " + pkgName
+                                                    + " in user " + userId);
+                                        }
+                                        cancelJobsForUid(pkgUid, true);
+                                    }
+                                } catch (RemoteException e) { /* cannot happen */ }
+                                break;
+                            }
+                        }
+                    }
+                } else {
+                    Slog.w(TAG, "PACKAGE_CHANGED for " + pkgName + " / uid " + pkgUid);
+                }
+            } else if (Intent.ACTION_PACKAGE_REMOVED.equals(intent.getAction())) {
                 // If this is an outright uninstall rather than the first half of an
                 // app update sequence, cancel the jobs associated with the app.
                 if (!intent.getBooleanExtra(Intent.EXTRA_REPLACING, false)) {
@@ -237,6 +275,12 @@
         }
     };
 
+    private String getPackageName(Intent intent) {
+        Uri uri = intent.getData();
+        String pkg = uri != null ? uri.getSchemeSpecificPart() : null;
+        return pkg;
+    }
+
     final private IUidObserver mUidObserver = new IUidObserver.Stub() {
         @Override public void onUidStateChanged(int uid, int procState) throws RemoteException {
             updateUidState(uid, procState);
@@ -520,7 +564,9 @@
     public void onBootPhase(int phase) {
         if (PHASE_SYSTEM_SERVICES_READY == phase) {
             // Register br for package removals and user removals.
-            final IntentFilter filter = new IntentFilter(Intent.ACTION_PACKAGE_REMOVED);
+            final IntentFilter filter = new IntentFilter();
+            filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
+            filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
             filter.addDataScheme("package");
             getContext().registerReceiverAsUser(
                     mBroadcastReceiver, UserHandle.ALL, filter, null, null);
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 53c5a6d..dc85dd7 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -16,6 +16,10 @@
 
 package com.android.server.notification;
 
+import static android.content.Context.BIND_ALLOW_WHITELIST_MANAGEMENT;
+import static android.content.Context.BIND_AUTO_CREATE;
+import static android.content.Context.BIND_FOREGROUND_SERVICE;
+
 import android.annotation.NonNull;
 import android.app.ActivityManager;
 import android.app.PendingIntent;
@@ -43,7 +47,6 @@
 import android.os.UserManager;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.util.ArrayMap;
 import android.util.ArraySet;
 import android.util.Log;
 import android.util.Slog;
@@ -56,7 +59,6 @@
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
 
@@ -681,7 +683,7 @@
             };
             if (!mContext.bindServiceAsUser(intent,
                 serviceConnection,
-                Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE,
+                BIND_AUTO_CREATE | BIND_FOREGROUND_SERVICE | BIND_ALLOW_WHITELIST_MANAGEMENT,
                 new UserHandle(userid))) {
                 mServicesBinding.remove(servicesBindingTag);
                 Slog.w(TAG, "Unable to bind " + getCaption() + " service: " + intent);
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index cf4669d..b5a8bf3 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -40,11 +40,13 @@
 import static android.service.notification.NotificationListenerService.TRIM_LIGHT;
 import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_DEFAULT;
 import static android.service.notification.NotificationListenerService.Ranking.IMPORTANCE_NONE;
+
 import static org.xmlpull.v1.XmlPullParser.END_DOCUMENT;
 
 import android.Manifest;
 import android.annotation.Nullable;
 import android.app.ActivityManager;
+import android.app.ActivityManagerInternal;
 import android.app.ActivityManagerNative;
 import android.app.AppGlobals;
 import android.app.AppOpsManager;
@@ -56,6 +58,7 @@
 import android.app.NotificationManager;
 import android.app.NotificationManager.Policy;
 import android.app.PendingIntent;
+import android.app.RemoteInput;
 import android.app.StatusBarManager;
 import android.app.backup.BackupManager;
 import android.app.usage.UsageEvents;
@@ -64,6 +67,7 @@
 import android.content.ComponentName;
 import android.content.ContentResolver;
 import android.content.Context;
+import android.content.IIntentSender;
 import android.content.Intent;
 import android.content.IntentFilter;
 import android.content.pm.ApplicationInfo;
@@ -90,6 +94,7 @@
 import android.os.IInterface;
 import android.os.Looper;
 import android.os.Message;
+import android.os.Parcelable;
 import android.os.Process;
 import android.os.RemoteException;
 import android.os.SystemClock;
@@ -127,6 +132,7 @@
 import com.android.internal.statusbar.NotificationVisibility;
 import com.android.internal.util.FastXmlSerializer;
 import com.android.internal.util.Preconditions;
+import com.android.server.DeviceIdleController;
 import com.android.server.EventLogTags;
 import com.android.server.LocalServices;
 import com.android.server.SystemService;
@@ -2542,6 +2548,8 @@
                     + " id=" + id + " notification=" + notification);
         }
 
+        markAsSentFromNotification(notification);
+
         // Sanitize inputs
         notification.priority = clamp(notification.priority, Notification.PRIORITY_MIN,
                 Notification.PRIORITY_MAX);
@@ -2556,6 +2564,63 @@
         idOut[0] = id;
     }
 
+    private static void markAsSentFromNotification(Notification notification) {
+        final ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class);
+        final long duration = LocalServices.getService(DeviceIdleController.LocalService.class)
+                .getNotificationWhitelistDuration();
+
+        int size = 0;
+        if (notification.contentIntent != null) {
+            am.setPendingIntentWhitelistDuration(notification.contentIntent.getTarget(), duration);
+        }
+        if (notification.deleteIntent != null) {
+            am.setPendingIntentWhitelistDuration(notification.deleteIntent.getTarget(), duration);
+        }
+        if (notification.fullScreenIntent != null) {
+            am.setPendingIntentWhitelistDuration(notification.fullScreenIntent.getTarget(),
+                    duration);
+        }
+        if (notification.actions != null) {
+            for (Notification.Action action: notification.actions) {
+                am.setPendingIntentWhitelistDuration(action.actionIntent.getTarget(), duration);
+                setPendingIntentWhitelistDuration(am, duration, action.getExtras());
+                final RemoteInput[] remoteInputs = action.getRemoteInputs();
+                if (remoteInputs != null) {
+                    for (RemoteInput remoteInput : remoteInputs) {
+                        setPendingIntentWhitelistDuration(am, duration, remoteInput.getExtras());
+                    }
+                }
+            }
+        }
+    }
+
+    private static void setPendingIntentWhitelistDuration(ActivityManagerInternal am, long duration,
+            Bundle extras) {
+        for (String key : extras.keySet()) {
+            setPendingIntentWhitelistDuration(am, duration, extras.getParcelable(key));
+            final Parcelable[] parcelableArray = extras.getParcelableArray(key);
+            if (parcelableArray != null) {
+                for (Parcelable parcelable: parcelableArray) {
+                    setPendingIntentWhitelistDuration(am, duration, parcelable);
+                }
+            }
+            final ArrayList<Parcelable> parcelableList = extras.getParcelableArrayList(key);
+            if (parcelableList != null) {
+                for (Parcelable parcelable: parcelableList) {
+                    setPendingIntentWhitelistDuration(am, duration, parcelable);
+                }
+            }
+        }
+    }
+
+    private static void setPendingIntentWhitelistDuration(ActivityManagerInternal am, long duration,
+            Parcelable parcelable) {
+        if (parcelable instanceof PendingIntent) {
+            am.setPendingIntentWhitelistDuration(((PendingIntent) parcelable).getTarget(),
+                    duration);
+        }
+    }
+
     private class EnqueueNotificationRunnable implements Runnable {
         private final NotificationRecord r;
         private final int userId;
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index 0cafb93..66bb24d 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -4360,6 +4360,11 @@
             pf.bottom = df.bottom = of.bottom = mUnrestrictedScreenTop + mUnrestrictedScreenHeight;
             // ...with content insets above the nav bar
             cf.bottom = vf.bottom = mStableBottom;
+            if (mStatusBar != null && mFocusedWindow == mStatusBar && canReceiveInput(mStatusBar)) {
+                // The status bar forces the navigation bar while it's visible. Make sure the IME
+                // avoids the navigation bar in that case.
+                pf.right = df.right = of.right = cf.right = vf.right = mStableRight;
+            }
             // IM dock windows always go to the bottom of the screen.
             attrs.gravity = Gravity.BOTTOM;
             mDockLayer = win.getSurfaceLayer();
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 1b31d07c..e73649d 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -45,9 +45,11 @@
 import android.view.animation.AnimationUtils;
 import android.view.animation.Interpolator;
 import android.view.animation.PathInterpolator;
+import android.view.inputmethod.InputMethodManagerInternal;
 
 import com.android.internal.policy.DividerSnapAlgorithm;
 import com.android.internal.policy.DockedDividerUtils;
+import com.android.server.LocalServices;
 import com.android.server.wm.DimLayer.DimLayerUser;
 import com.android.server.wm.WindowManagerService.H;
 
@@ -131,6 +133,7 @@
     private float mLastAnimationProgress;
     private float mLastDividerProgress;
     private final DividerSnapAlgorithm[] mSnapAlgorithmForRotation = new DividerSnapAlgorithm[4];
+    private boolean mImeHideRequested;
 
     DockedStackDividerController(WindowManagerService service, DisplayContent displayContent) {
         mService = service;
@@ -375,11 +378,39 @@
             }
         }
         mDockedStackListeners.finishBroadcast();
-        if (!exists) {
+        if (exists) {
+            InputMethodManagerInternal inputMethodManagerInternal =
+                    LocalServices.getService(InputMethodManagerInternal.class);
+            if (inputMethodManagerInternal != null) {
+
+                // Hide the current IME to avoid problems with animations from IME adjustment when
+                // attaching the docked stack.
+                inputMethodManagerInternal.hideCurrentInputMethod();
+                mImeHideRequested = true;
+            }
+        } else {
             setMinimizedDockedStack(false);
         }
     }
 
+    /**
+     * Resets the state that IME hide has been requested. See {@link #isImeHideRequested}.
+     */
+    void resetImeHideRequested() {
+        mImeHideRequested = false;
+    }
+
+    /**
+     * The docked stack divider controller makes sure the IME gets hidden when attaching the docked
+     * stack, to avoid animation problems. This flag indicates whether the request to hide the IME
+     * has been sent in an asynchronous manner, and the IME should be treated as hidden already.
+     *
+     * @return whether IME hide request has been sent
+     */
+    boolean isImeHideRequested() {
+        return mImeHideRequested;
+    }
+
     void notifyDockedStackMinimizedChanged(boolean minimizedDock, long animDuration) {
         mService.mH.removeMessages(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED);
         mService.mH.obtainMessage(NOTIFY_DOCKED_STACK_MINIMIZED_CHANGED,
@@ -606,7 +637,12 @@
     private void setMinimizedDockedStack(boolean minimized) {
         final TaskStack stack = mDisplayContent.getDockedStackVisibleForUserLocked();
         notifyDockedStackMinimizedChanged(minimized, 0);
-        setMinimizeAmount(stack, minimized ? 1f : 0f);
+        if (stack == null) {
+            return;
+        }
+        if (stack.setAdjustedForMinimizedDock(minimized ? 1f : 0f)) {
+            mService.mWindowPlacerLocked.performSurfacePlacement();
+        }
     }
 
     private boolean isAnimationMaximizing() {
@@ -690,8 +726,11 @@
         float t = Math.min(1f, (float) (now - mAnimationStartTime) / mAnimationDuration);
         t = (isAnimationMaximizing() ? TOUCH_RESPONSE_INTERPOLATOR : mMinimizedDockInterpolator)
                 .getInterpolation(t);
-        setMinimizeAmount(stack, getMinimizeAmount(stack, t));
-
+        if (stack != null) {
+            if (stack.setAdjustedForMinimizedDock(getMinimizeAmount(stack, t))) {
+                mService.mWindowPlacerLocked.performSurfacePlacement();
+            }
+        }
         if (t >= 1.0f) {
             mAnimatingForMinimizedDockedStack = false;
             return false;
@@ -700,42 +739,6 @@
         }
     }
 
-    void setMinimizeAmount(TaskStack dockedStack, float minimizeAmount) {
-        final ArrayList<TaskStack> stacks = mDisplayContent.getStacks();
-
-        // If the docked stack is not visible, clear the complementary stack on all stacks.
-        if (dockedStack == null) {
-            for (int i = stacks.size() - 1; i >= 0; --i) {
-                final TaskStack stack = stacks.get(i);
-                stack.resetAdjustedForComplementDock();
-            }
-            return;
-        }
-
-        // Otherwise if the docked stack minimize amount has changed, update the adjusted bounds
-        // on the other stack that's currently visible, so that the stack's getDimBounds()
-        // occupies what's left by the docked stack. This is needed so that stuff like wallpaper
-        // gets cropped properly to the area left by the dock.
-        if (dockedStack.setAdjustedForMinimizedDock(minimizeAmount)) {
-            final boolean adjusted =
-                    dockedStack.isVisibleForUserLocked() && minimizeAmount != 0.0f;
-            dockedStack.getDimBounds(mTmpRect2);
-            int dockSide = dockedStack.getDockSide();
-            for (int i = stacks.size() - 1; i >= 0; --i) {
-                final TaskStack stack = stacks.get(i);
-                if (stack == dockedStack) {
-                    continue;
-                }
-                if (stack.isVisibleLocked() && adjusted) {
-                    stack.setAdjustedForComplementDock(mTmpRect2, dockSide);
-                } else {
-                    stack.resetAdjustedForComplementDock();
-                }
-            }
-            mService.mWindowPlacerLocked.performSurfacePlacement();
-        }
-    }
-
     private float getInterpolatedAnimationValue(float t) {
         return t * mAnimationTarget + (1 - t) * mAnimationStart;
     }
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 114d9be..8be5b19 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -123,7 +123,6 @@
     private float mAdjustImeAmount;
     private float mAdjustDividerAmount;
     private final int mDockedStackMinimizeThickness;
-    private boolean mAdjustedForForComplementDock;
 
     // If this is true, we are in the bounds animating mode.
     // The task will be down or upscaled to perfectly fit the
@@ -243,9 +242,7 @@
                 insetBounds = mFullyAdjustedImeBounds;
             }
         }
-        if (!mAdjustedForForComplementDock) {
-            alignTasksToAdjustedBounds(adjusted ? mAdjustedBounds : mBounds, insetBounds);
-        }
+        alignTasksToAdjustedBounds(adjusted ? mAdjustedBounds : mBounds, insetBounds);
         mDisplayContent.layoutNeeded = true;
     }
 
@@ -864,7 +861,6 @@
         mImeWin = imeWin;
         mImeGoingAway = false;
         if (!mAdjustedForIme || forceUpdate) {
-            mAdjustedForForComplementDock = false;
             mAdjustedForIme = true;
             mAdjustImeAmount = 0f;
             mAdjustDividerAmount = 0f;
@@ -927,12 +923,10 @@
      * @return Whether the amount has changed and a layout is needed.
      */
     boolean setAdjustedForMinimizedDock(float minimizeAmount) {
-        mAdjustedForForComplementDock = false;
-
         if (minimizeAmount != mMinimizeAmount) {
             mMinimizeAmount = minimizeAmount;
             updateAdjustedBounds();
-            return true;
+            return isVisibleForUserLocked();
         } else {
             return false;
         }
@@ -942,33 +936,6 @@
         return mMinimizeAmount != 0f;
     }
 
-    void setAdjustedForComplementDock(Rect dockBounds, int dockSide) {
-        if (mMinimizeAmount != 0f || mAdjustedForIme) {
-            return;
-        }
-        mTmpAdjustedBounds.set(mBounds);
-        if (dockSide == DOCKED_TOP) {
-            mTmpAdjustedBounds.top = dockBounds.bottom;
-        } else if (dockSide == DOCKED_LEFT) {
-            mTmpAdjustedBounds.left = dockBounds.right;
-        } else if (dockSide == DOCKED_RIGHT) {
-            mTmpAdjustedBounds.right = dockBounds.left;
-        } else {
-            Slog.w(TAG_WM, "setAdjustedForComplementDock: invalid dock side " + dockSide);
-            return;
-        }
-        mAdjustedForForComplementDock = true;
-        setAdjustedBounds(mTmpAdjustedBounds);
-    }
-
-    void resetAdjustedForComplementDock() {
-        if (mAdjustedForForComplementDock) {
-            mAdjustedForForComplementDock = false;
-            mTmpAdjustedBounds.setEmpty();
-            setAdjustedBounds(mTmpAdjustedBounds);
-        }
-    }
-
     /**
      * Puts all visible tasks that are adjusted for IME into resizing mode and adds the windows
      * to the list of to be drawn windows the service is waiting for.
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 695ed36..3f4c1d5 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3569,6 +3569,8 @@
         final ArrayList<Task> tasks = displayContent.getTasks();
         final boolean inMultiWindow = isStackVisibleLocked(DOCKED_STACK_ID)
                 || isStackVisibleLocked(FREEFORM_WORKSPACE_STACK_ID);
+        final boolean dockMinimized =
+                getDefaultDisplayContentLocked().mDividerControllerLocked.isMinimizedDock();
         for (int taskNdx = tasks.size() - 1; taskNdx >= 0; --taskNdx) {
             AppTokenList tokens = tasks.get(taskNdx).mAppTokens;
             final int firstToken = tokens.size() - 1;
@@ -3603,8 +3605,10 @@
                     continue;
                 }
 
-                // No app except the home app may specify the screen orientation in multi-window.
-                if (inMultiWindow && !atoken.mTask.isHomeTask()) {
+                // No app except the home app may specify the screen orientation in multi-window,
+                // and only if the docked stack is minimized to avoid weirdness when home task
+                // temporarily gets moved to the front.
+                if (inMultiWindow && (!atoken.mTask.isHomeTask() || !dockMinimized)) {
                     continue;
                 }
 
@@ -7596,7 +7600,8 @@
 
     void adjustForImeIfNeeded(final DisplayContent displayContent) {
         final WindowState imeWin = mInputMethodWindow;
-        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw();
+        final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw()
+                && !displayContent.mDividerControllerLocked.isImeHideRequested();
         final boolean dockVisible = isStackVisibleLocked(DOCKED_STACK_ID);
         final TaskStack imeTargetStack = getImeFocusStackLocked();
         final int imeDockSide = (dockVisible && imeTargetStack != null) ?
diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java
index 9dae0f2..37d6faf5 100644
--- a/services/core/java/com/android/server/wm/WindowStateAnimator.java
+++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java
@@ -23,7 +23,6 @@
 import static android.view.WindowManager.LayoutParams.FLAG_SCALED;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
 import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
-import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
 import static com.android.server.wm.AppWindowAnimator.sDummyAnimation;
 import static com.android.server.wm.DragResizeMode.DRAG_RESIZE_MODE_FREEFORM;
 import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ADD_REMOVE;
@@ -1328,33 +1327,6 @@
             return;
         }
 
-        // We crop wallpaper windows to the stack bounds of their current target to avoid them
-        // showing behind transparent windows in other stacks in split-screen mode.
-        if (w.getBaseType() == TYPE_WALLPAPER) {
-            final WindowState wallpaperTarget = mWallpaperControllerLocked.getWallpaperTarget();
-            if (wallpaperTarget != null) {
-                final Task task = wallpaperTarget.getTask();
-                final WindowStateAnimator winAnimator = wallpaperTarget.mWinAnimator;
-                // We can only crop the wallpaper using final crop with stack bounds if the target
-                // is not animating, or if it's animating with clip mode STACK_CLIP_AFTER_ANIM.
-                // If it's animating with mode STACK_CLIP_NONE, we shouldn't crop either the task
-                // itself or the wallpaper. If it's animating with STACK_CLIP_BEFORE_ANIM, the crop
-                // is before the transform on the task itself.
-                final boolean useFinalCropOnWallpaper = !winAnimator.isAnimationSet()
-                        || winAnimator.resolveStackClip() == STACK_CLIP_AFTER_ANIM;
-                if (task != null && !task.isFullscreen()
-                        && task.cropWindowsToStackBounds()
-                        && useFinalCropOnWallpaper){
-                    final TaskStack stack = task.mStack;
-                    if (stack != null && !stack.isFullscreen()) {
-                        stack.getDimBounds(mTmpStackBounds);
-                        finalClipRect.set(mTmpStackBounds);
-                    }
-                }
-            }
-            return;
-        }
-
         final Task task = w.getTask();
         if (task == null || !task.cropWindowsToStackBounds()) {
             return;
@@ -1487,7 +1459,7 @@
             // We need to ensure for each surface, that we disable transformation matrix
             // scaling in the same transaction which we resize the surface in.
             // As we are in SCALING_MODE_SCALE_TO_WINDOW, SurfaceFlinger will
-            // then take over the scaling until the new buffer arrives, and things
+            // then take over the scaling until the new buffer arrives, and things 
             // will be seamless.
             mForceScaleUntilResize = true;
         } else {
@@ -1773,6 +1745,10 @@
                 mWin.mAppToken.onFirstWindowDrawn(mWin, this);
             }
 
+            if (mWin.mAttrs.type == TYPE_INPUT_METHOD) {
+                mWin.mDisplayContent.mDividerControllerLocked.resetImeHideRequested();
+            }
+
             return true;
         }
         return false;
diff --git a/services/net/java/android/net/apf/ApfFilter.java b/services/net/java/android/net/apf/ApfFilter.java
index 538e8f8..485f2f5 100644
--- a/services/net/java/android/net/apf/ApfFilter.java
+++ b/services/net/java/android/net/apf/ApfFilter.java
@@ -597,12 +597,13 @@
     private void generateIPv4FilterLocked(ApfGenerator gen) throws IllegalInstructionException {
         // Here's a basic summary of what the IPv4 filter program does:
         //
-        // if it's multicast and we're dropping multicast:
-        //   drop
-        // if it's not broadcast:
-        //   pass
-        // if it's not DHCP destined to our MAC:
-        //   drop
+        // if filtering multicast (i.e. multicast lock not held):
+        //   if it's multicast:
+        //     drop
+        //   if it's not broadcast:
+        //     pass
+        //   if it's not DHCP destined to our MAC:
+        //     drop
         // pass
 
         if (mMulticastFilter) {
@@ -610,27 +611,27 @@
             gen.addLoad8(Register.R0, IPV4_DEST_ADDR_OFFSET);
             gen.addAnd(0xf0);
             gen.addJumpIfR0Equals(0xe0, gen.DROP_LABEL);
-        }
 
-        // Drop all broadcasts besides DHCP addressed to us
-        // If not a broadcast packet, pass
-        gen.addLoadImmediate(Register.R0, ETH_DEST_ADDR_OFFSET);
-        gen.addJumpIfBytesNotEqual(Register.R0, ETH_BROADCAST_MAC_ADDRESS, gen.PASS_LABEL);
-        // If not UDP, drop
-        gen.addLoad8(Register.R0, IPV4_PROTOCOL_OFFSET);
-        gen.addJumpIfR0NotEquals(IPPROTO_UDP, gen.DROP_LABEL);
-        // If fragment, drop. This matches the BPF filter installed by the DHCP client.
-        gen.addLoad16(Register.R0, IPV4_FRAGMENT_OFFSET_OFFSET);
-        gen.addJumpIfR0AnyBitsSet(IPV4_FRAGMENT_OFFSET_MASK, gen.DROP_LABEL);
-        // If not to DHCP client port, drop
-        gen.addLoadFromMemory(Register.R1, gen.IPV4_HEADER_SIZE_MEMORY_SLOT);
-        gen.addLoad16Indexed(Register.R0, UDP_DESTINATION_PORT_OFFSET);
-        gen.addJumpIfR0NotEquals(DHCP_CLIENT_PORT, gen.DROP_LABEL);
-        // If not DHCP to our MAC address, drop
-        gen.addLoadImmediate(Register.R0, DHCP_CLIENT_MAC_OFFSET);
-        // NOTE: Relies on R1 containing IPv4 header offset.
-        gen.addAddR1();
-        gen.addJumpIfBytesNotEqual(Register.R0, mHardwareAddress, gen.DROP_LABEL);
+            // Drop all broadcasts besides DHCP addressed to us
+            // If not a broadcast packet, pass
+            gen.addLoadImmediate(Register.R0, ETH_DEST_ADDR_OFFSET);
+            gen.addJumpIfBytesNotEqual(Register.R0, ETH_BROADCAST_MAC_ADDRESS, gen.PASS_LABEL);
+            // If not UDP, drop
+            gen.addLoad8(Register.R0, IPV4_PROTOCOL_OFFSET);
+            gen.addJumpIfR0NotEquals(IPPROTO_UDP, gen.DROP_LABEL);
+            // If fragment, drop. This matches the BPF filter installed by the DHCP client.
+            gen.addLoad16(Register.R0, IPV4_FRAGMENT_OFFSET_OFFSET);
+            gen.addJumpIfR0AnyBitsSet(IPV4_FRAGMENT_OFFSET_MASK, gen.DROP_LABEL);
+            // If not to DHCP client port, drop
+            gen.addLoadFromMemory(Register.R1, gen.IPV4_HEADER_SIZE_MEMORY_SLOT);
+            gen.addLoad16Indexed(Register.R0, UDP_DESTINATION_PORT_OFFSET);
+            gen.addJumpIfR0NotEquals(DHCP_CLIENT_PORT, gen.DROP_LABEL);
+            // If not DHCP to our MAC address, drop
+            gen.addLoadImmediate(Register.R0, DHCP_CLIENT_MAC_OFFSET);
+            // NOTE: Relies on R1 containing IPv4 header offset.
+            gen.addAddR1();
+            gen.addJumpIfBytesNotEqual(Register.R0, mHardwareAddress, gen.DROP_LABEL);
+        }
 
         // Otherwise, pass
         gen.addJump(gen.PASS_LABEL);
diff --git a/services/net/java/android/net/dhcp/DhcpClient.java b/services/net/java/android/net/dhcp/DhcpClient.java
index 99b10c3..96c852b 100644
--- a/services/net/java/android/net/dhcp/DhcpClient.java
+++ b/services/net/java/android/net/dhcp/DhcpClient.java
@@ -84,7 +84,7 @@
 public class DhcpClient extends StateMachine {
 
     private static final String TAG = "DhcpClient";
-    private static final boolean DBG = false;
+    private static final boolean DBG = true;
     private static final boolean STATE_DBG = false;
     private static final boolean MSG_DBG = false;
     private static final boolean PACKET_DBG = false;
diff --git a/services/tests/servicestests/src/android/net/apf/ApfTest.java b/services/tests/servicestests/src/android/net/apf/ApfTest.java
index 9e04d23..fae82ca 100644
--- a/services/tests/servicestests/src/android/net/apf/ApfTest.java
+++ b/services/tests/servicestests/src/android/net/apf/ApfTest.java
@@ -663,7 +663,7 @@
     @LargeTest
     public void testApfFilterIPv4() throws Exception {
         MockIpManagerCallback ipManagerCallback = new MockIpManagerCallback();
-        ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, false /* multicastFilter */);
+        ApfFilter apfFilter = new TestApfFilter(ipManagerCallback, true /* multicastFilter */);
         byte[] program = ipManagerCallback.getApfProgram();
 
         // Verify empty packet of 100 zero bytes is passed
@@ -726,46 +726,57 @@
         byte[] program = ipManagerCallback.getApfProgram();
 
         // Construct IPv4 and IPv6 multicast packets.
-        ByteBuffer v4packet = ByteBuffer.wrap(new byte[100]);
-        v4packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
-        v4packet.position(IPV4_DEST_ADDR_OFFSET);
-        v4packet.put(new byte[]{(byte)224,0,0,1});
+        ByteBuffer mcastv4packet = ByteBuffer.wrap(new byte[100]);
+        mcastv4packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
+        mcastv4packet.position(IPV4_DEST_ADDR_OFFSET);
+        mcastv4packet.put(new byte[]{(byte)224,0,0,1});
 
-        ByteBuffer v6packet = ByteBuffer.wrap(new byte[100]);
-        v6packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IPV6);
-        v6packet.put(IPV6_NEXT_HEADER_OFFSET, (byte)IPPROTO_UDP);
-        v6packet.position(IPV6_DEST_ADDR_OFFSET);
-        v6packet.put(new byte[]{(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb});
+        ByteBuffer mcastv6packet = ByteBuffer.wrap(new byte[100]);
+        mcastv6packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IPV6);
+        mcastv6packet.put(IPV6_NEXT_HEADER_OFFSET, (byte)IPPROTO_UDP);
+        mcastv6packet.position(IPV6_DEST_ADDR_OFFSET);
+        mcastv6packet.put(new byte[]{(byte)0xff,2,0,0,0,0,0,0,0,0,0,0,0,0,0,(byte)0xfb});
+
+        // Construct IPv4 broadcast packet.
+        ByteBuffer bcastv4packet = ByteBuffer.wrap(new byte[100]);
+        bcastv4packet.put(ETH_BROADCAST_MAC_ADDRESS);
+        bcastv4packet.putShort(ETH_ETHERTYPE_OFFSET, (short)ETH_P_IP);
+        bcastv4packet.position(IPV4_DEST_ADDR_OFFSET);
+        bcastv4packet.put(new byte[]{(byte)192,(byte)0,(byte)2,(byte)63});
 
         // Verify initially disabled multicast filter is off
-        assertPass(program, v4packet.array(), 0);
-        assertPass(program, v6packet.array(), 0);
+        assertPass(program, bcastv4packet.array(), 0);
+        assertPass(program, mcastv4packet.array(), 0);
+        assertPass(program, mcastv6packet.array(), 0);
 
         // Turn on multicast filter and verify it works
         ipManagerCallback.resetApfProgramWait();
         apfFilter.setMulticastFilter(true);
         program = ipManagerCallback.getApfProgram();
-        assertDrop(program, v4packet.array(), 0);
-        assertDrop(program, v6packet.array(), 0);
+        assertDrop(program, bcastv4packet.array(), 0);
+        assertDrop(program, mcastv4packet.array(), 0);
+        assertDrop(program, mcastv6packet.array(), 0);
 
         // Turn off multicast filter and verify it's off
         ipManagerCallback.resetApfProgramWait();
         apfFilter.setMulticastFilter(false);
         program = ipManagerCallback.getApfProgram();
-        assertPass(program, v4packet.array(), 0);
-        assertPass(program, v6packet.array(), 0);
+        assertPass(program, bcastv4packet.array(), 0);
+        assertPass(program, mcastv4packet.array(), 0);
+        assertPass(program, mcastv6packet.array(), 0);
 
         // Verify it can be initialized to on
         ipManagerCallback.resetApfProgramWait();
         apfFilter.shutdown();
         apfFilter = new TestApfFilter(ipManagerCallback, true /* multicastFilter */);
         program = ipManagerCallback.getApfProgram();
-        assertDrop(program, v4packet.array(), 0);
-        assertDrop(program, v6packet.array(), 0);
+        assertDrop(program, bcastv4packet.array(), 0);
+        assertDrop(program, mcastv4packet.array(), 0);
+        assertDrop(program, mcastv6packet.array(), 0);
 
         // Verify that ICMPv6 multicast is not dropped.
-        v6packet.put(IPV6_NEXT_HEADER_OFFSET, (byte)IPPROTO_ICMPV6);
-        assertPass(program, v6packet.array(), 0);
+        mcastv6packet.put(IPV6_NEXT_HEADER_OFFSET, (byte)IPPROTO_ICMPV6);
+        assertPass(program, mcastv6packet.array(), 0);
 
         apfFilter.shutdown();
     }